mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 23:54:18 +02:00
add change output short format
This commit is contained in:
parent
92df62781c
commit
82267156d0
@ -40,6 +40,7 @@ sub new {
|
|||||||
"filter-perfdata:s" => { name => 'filter_perfdata' },
|
"filter-perfdata:s" => { name => 'filter_perfdata' },
|
||||||
"change-perfdata:s@" => { name => 'change_perfdata' },
|
"change-perfdata:s@" => { name => 'change_perfdata' },
|
||||||
"extend-perfdata:s@" => { name => 'extend_perfdata' },
|
"extend-perfdata:s@" => { name => 'extend_perfdata' },
|
||||||
|
"change-short-output:s@" => { name => 'change_short_output' },
|
||||||
"filter-uom:s" => { name => 'filter_uom' },
|
"filter-uom:s" => { name => 'filter_uom' },
|
||||||
"verbose" => { name => 'verbose' },
|
"verbose" => { name => 'verbose' },
|
||||||
"debug" => { name => 'debug' },
|
"debug" => { name => 'debug' },
|
||||||
@ -350,14 +351,8 @@ sub output_xml {
|
|||||||
print $self->{xml_output}->toString(1);
|
print $self->{xml_output}->toString(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub output_txt {
|
sub output_txt_short_display {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
my $force_ignore_perfdata = (defined($options{force_ignore_perfdata}) && $options{force_ignore_perfdata} == 1) ? 1 : 0;
|
|
||||||
my $force_long_output = (defined($options{force_long_output}) && $options{force_long_output} == 1) ? 1 : 0;
|
|
||||||
|
|
||||||
if (defined($self->{global_short_concat_outputs}->{UNQUALIFIED_YET})) {
|
|
||||||
$self->output_add(severity => uc($options{exit_litteral}), short_msg => $self->{global_short_concat_outputs}->{UNQUALIFIED_YET});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined($self->{global_short_concat_outputs}->{CRITICAL})) {
|
if (defined($self->{global_short_concat_outputs}->{CRITICAL})) {
|
||||||
print (($options{nolabel} == 0 ? 'CRITICAL: ' : '') . $self->{global_short_concat_outputs}->{CRITICAL} . " ");
|
print (($options{nolabel} == 0 ? 'CRITICAL: ' : '') . $self->{global_short_concat_outputs}->{CRITICAL} . " ");
|
||||||
@ -371,6 +366,44 @@ sub output_txt {
|
|||||||
if (uc($options{exit_litteral}) eq 'OK') {
|
if (uc($options{exit_litteral}) eq 'OK') {
|
||||||
print (($options{nolabel} == 0 ? 'OK: ' : '') . (defined($self->{global_short_concat_outputs}->{OK}) ? $self->{global_short_concat_outputs}->{OK} : '') . " ");
|
print (($options{nolabel} == 0 ? 'OK: ' : '') . (defined($self->{global_short_concat_outputs}->{OK}) ? $self->{global_short_concat_outputs}->{OK} : '') . " ");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub output_txt_short {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
if (!defined($self->{option_results}->{change_short_output})) {
|
||||||
|
$self->output_txt_short_display(%options);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $stdout = '';
|
||||||
|
{
|
||||||
|
local *STDOUT;
|
||||||
|
open STDOUT, '>', \$stdout;
|
||||||
|
$self->output_txt_short_display(%options);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (@{$self->{option_results}->{change_short_output}}) {
|
||||||
|
my ($pattern, $replace, $modifier) = split /~/;
|
||||||
|
next if (!defined($pattern));
|
||||||
|
$replace = '' if (!defined($replace));
|
||||||
|
$modifier = '' if (!defined($modifier));
|
||||||
|
eval "\$stdout =~ s{$pattern}{$replace}$modifier";
|
||||||
|
}
|
||||||
|
|
||||||
|
print $stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub output_txt {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
my $force_ignore_perfdata = (defined($options{force_ignore_perfdata}) && $options{force_ignore_perfdata} == 1) ? 1 : 0;
|
||||||
|
my $force_long_output = (defined($options{force_long_output}) && $options{force_long_output} == 1) ? 1 : 0;
|
||||||
|
|
||||||
|
if (defined($self->{global_short_concat_outputs}->{UNQUALIFIED_YET})) {
|
||||||
|
$self->output_add(severity => uc($options{exit_litteral}), short_msg => $self->{global_short_concat_outputs}->{UNQUALIFIED_YET});
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->output_txt_short(%options);
|
||||||
|
|
||||||
if ($force_ignore_perfdata == 1) {
|
if ($force_ignore_perfdata == 1) {
|
||||||
print "\n";
|
print "\n";
|
||||||
@ -1049,6 +1082,10 @@ Change traffic values in percent: --change-perfdata=traffic_in,,percent()
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
=item B<--change-short-output>
|
||||||
|
|
||||||
|
Change short output display. --change-short-output=pattern~replace~modifier
|
||||||
|
|
||||||
=item B<--range-perfdata>
|
=item B<--range-perfdata>
|
||||||
|
|
||||||
Change perfdata range thresholds display:
|
Change perfdata range thresholds display:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user