enhance encoding (#2531)
This commit is contained in:
parent
bc9cba7ec5
commit
1c1201292e
|
@ -148,7 +148,7 @@ sub reload_cache {
|
|||
my $trim_id = centreon::plugins::misc::trim($id->string_value);
|
||||
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
|
||||
my $trim_title = centreon::plugins::misc::trim($title->string_value);
|
||||
$datas->{"department_".$trim_id} = $self->{output}->to_utf8($trim_title);
|
||||
$datas->{"department_".$trim_id} = $self->{output}->decode($trim_title);
|
||||
}
|
||||
|
||||
$webcontent = $self->{http}->request(url_path => $url_original_path . "/Tickets/TicketPriority&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=");
|
||||
|
@ -159,7 +159,7 @@ sub reload_cache {
|
|||
my $trim_id = centreon::plugins::misc::trim($id->string_value);
|
||||
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
|
||||
my $trim_title = centreon::plugins::misc::trim($title->string_value);
|
||||
$datas->{"priority_".$trim_id} = $self->{output}->to_utf8($trim_title);
|
||||
$datas->{"priority_".$trim_id} = $self->{output}->decode($trim_title);
|
||||
}
|
||||
|
||||
$webcontent = $self->{http}->request(url_path => $url_original_path . "/Base/Staff&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=");
|
||||
|
@ -170,7 +170,7 @@ sub reload_cache {
|
|||
my $trim_id = centreon::plugins::misc::trim($id->string_value);
|
||||
my ($title) = $xp->find('./username', $actionNode)->get_nodelist;
|
||||
my $trim_title = centreon::plugins::misc::trim($title->string_value);
|
||||
$datas->{"staff_".$trim_id} = $self->{output}->to_utf8($trim_title);
|
||||
$datas->{"staff_".$trim_id} = $self->{output}->decode($trim_title);
|
||||
}
|
||||
|
||||
$webcontent = $self->{http}->request(url_path => $url_original_path . "/Tickets/TicketStatus&apikey=" . $self->{option_results}->{kayako_api_key} . "&salt=" . $salt . "&signature=" . $digest . "=");
|
||||
|
@ -181,7 +181,7 @@ sub reload_cache {
|
|||
my $trim_id = centreon::plugins::misc::trim($id->string_value);
|
||||
my ($title) = $xp->find('./title', $actionNode)->get_nodelist;
|
||||
my $trim_title = centreon::plugins::misc::trim($title->string_value);
|
||||
$datas->{"status_".$trim_id} = $self->{output}->to_utf8($trim_title);
|
||||
$datas->{"status_".$trim_id} = $self->{output}->decode($trim_title);
|
||||
}
|
||||
|
||||
$self->{statefile_cache}->write(data => $datas);
|
||||
|
|
|
@ -40,18 +40,18 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
||||
"department-id:s" => { name => 'department_id' },
|
||||
"staff-id:s" => { name => 'staff_id' },
|
||||
"status-id:s" => { name => 'status_id' },
|
||||
"priority-id:s" => { name => 'priority_id' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"start-date:s" => { name => 'start_date' },
|
||||
"end-date:s" => { name => 'end_date' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
||||
"department-id:s" => { name => 'department_id' },
|
||||
"staff-id:s" => { name => 'staff_id' },
|
||||
"status-id:s" => { name => 'status_id' },
|
||||
"priority-id:s" => { name => 'priority_id' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"start-date:s" => { name => 'start_date' },
|
||||
"end-date:s" => { name => 'end_date' }
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
return $self;
|
||||
|
@ -104,22 +104,22 @@ sub reload_cache {
|
|||
|
||||
$self->{sql}->query(query => "SELECT departmentid, title FROM swdepartments");
|
||||
while ((my $row = $self->{sql}->fetchrow_hashref())) {
|
||||
$datas->{"department_" . $row->{departmentid}} = $self->{output}->to_utf8($row->{title});
|
||||
$datas->{"department_" . $row->{departmentid}} = $self->{output}->decode($row->{title});
|
||||
}
|
||||
|
||||
$self->{sql}->query(query => "SELECT priorityid, title FROM swticketpriorities");
|
||||
while ((my $row = $self->{sql}->fetchrow_hashref())) {
|
||||
$datas->{"priority_" . $row->{priorityid}} = $self->{output}->to_utf8($row->{title});
|
||||
$datas->{"priority_" . $row->{priorityid}} = $self->{output}->decode($row->{title});
|
||||
}
|
||||
|
||||
$self->{sql}->query(query => "SELECT staffid, username FROM swstaff");
|
||||
while ((my $row = $self->{sql}->fetchrow_hashref())) {
|
||||
$datas->{"staff_" . $row->{staffid}} = $self->{output}->to_utf8($row->{username});
|
||||
$datas->{"staff_" . $row->{staffid}} = $self->{output}->decode($row->{username});
|
||||
}
|
||||
|
||||
$self->{sql}->query(query => "SELECT ticketstatusid, title FROM swticketstatus");
|
||||
while ((my $row = $self->{sql}->fetchrow_hashref())) {
|
||||
$datas->{"status_" . $row->{ticketstatusid}} = $self->{output}->to_utf8($row->{title});
|
||||
$datas->{"status_" . $row->{ticketstatusid}} = $self->{output}->decode($row->{title});
|
||||
}
|
||||
|
||||
$self->{statefile_cache}->write(data => $datas);
|
||||
|
|
|
@ -57,7 +57,7 @@ sub manage_selection {
|
|||
my ($num, $index) = ($1, $2);
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $num . '.' . $index);
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $index))));
|
||||
|
||||
$results->{$name} = {
|
||||
description => $result->{description}
|
||||
|
|
|
@ -71,7 +71,7 @@ sub check {
|
|||
while ($options{stdout} =~ /\[scenario=(.*?)\]\[result=(.*?)\]\[latency=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{scenario}, $self->{data}->{result}, $self->{data}->{latency}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
($self->{output}->decode($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$checked++;
|
||||
|
|
|
@ -68,7 +68,7 @@ sub check {
|
|||
while ($options{stdout} =~ /\[scenario=(.*?)\]\[result=(.*?)\]\[latency=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{scenario}, $self->{data}->{result}, $self->{data}->{latency}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
($self->{output}->decode($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$checked++;
|
||||
|
|
|
@ -77,7 +77,7 @@ sub check {
|
|||
while ($options{stdout} =~ /\[id=(.*?)\]\[type=(.*?)\]\[\[message=(.*?)\]\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{id}, $self->{data}->{type}, $self->{data}->{message}) =
|
||||
(centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2), $self->{output}->to_utf8($3));
|
||||
(centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2), $self->{output}->decode($3));
|
||||
|
||||
$checked++;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ sub check {
|
|||
while ($options{stdout} =~ /\[url=(.*?)\]\[scenario=(.*?)\]\[result=(.*?)\]\[latency=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{url}, $self->{data}->{scenario}, $self->{data}->{result}, $self->{data}->{latency}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), $self->{output}->to_utf8($2), centreon::plugins::misc::trim($3),
|
||||
($self->{output}->decode($1), $self->{output}->decode($2), centreon::plugins::misc::trim($3),
|
||||
centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
|
||||
|
||||
$checked++;
|
||||
|
|
|
@ -62,7 +62,7 @@ sub check {
|
|||
while ($options{stdout} =~ /\[server=(.*?)\]\[check=(.*?)\]\[result=(.*?)\]\[isvalid=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{server}, $self->{data}->{check}, $self->{data}->{result}, $self->{data}->{isvalid}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
($self->{output}->decode($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
|
||||
|
||||
$checked++;
|
||||
|
|
|
@ -64,7 +64,7 @@ sub check {
|
|||
while ($options{stdout} =~ /\[role=(.*?)\]\[requiredservicesrunning=(.*?)\]\[servicesrunning=(.*?)\]\[servicesnotrunning=(.*?)\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{role}, $self->{data}->{requiredservicesrunning}, $self->{data}->{servicesrunning}, $self->{data}->{servicesnotrunning}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
($self->{output}->decode($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$checked++;
|
||||
|
|
|
@ -55,10 +55,11 @@ sub new {
|
|||
'output-file:s' => { name => 'output_file' },
|
||||
'disco-format' => { name => 'disco_format' },
|
||||
'disco-show' => { name => 'disco_show' },
|
||||
'float-precision:s' => { name => 'float_precision', default => 8 }
|
||||
'float-precision:s' => { name => 'float_precision', default => 8 },
|
||||
'source-encoding:s' => { name => 'source_encoding' , default => 'UTF-8' }
|
||||
});
|
||||
|
||||
%{$self->{option_results}} = ();
|
||||
$self->{option_results} = {};
|
||||
|
||||
$self->{option_msg} = [];
|
||||
|
||||
|
@ -80,7 +81,7 @@ sub new {
|
|||
$self->{explode_perfdata_total} = 0;
|
||||
$self->{range_perfdata} = 0;
|
||||
$self->{global_status} = 0;
|
||||
$self->{encode_utf8_import} = 0;
|
||||
$self->{encode_import} = 0;
|
||||
$self->{perlqq} = 0;
|
||||
|
||||
$self->{disco_elements} = [];
|
||||
|
@ -137,6 +138,9 @@ sub check_options {
|
|||
|
||||
$self->load_perfdata_extend_args();
|
||||
$self->{option_results}->{use_new_perfdata} = 1 if (defined($self->{option_results}->{output_openmetrics}));
|
||||
|
||||
$self->{source_encoding} = (!defined($self->{option_results}->{source_encoding}) || $self->{option_results}->{source_encoding} eq '') ?
|
||||
'UTF-8' : $self->{option_results}->{source_encoding};
|
||||
}
|
||||
|
||||
sub add_option_msg {
|
||||
|
@ -794,24 +798,23 @@ sub display_disco_show {
|
|||
}
|
||||
}
|
||||
|
||||
sub to_utf8 {
|
||||
sub decode {
|
||||
my ($self, $value) = @_;
|
||||
|
||||
if ($self->{encode_utf8_import} == 0) {
|
||||
if ($self->{encode_import} == 0) {
|
||||
# Some Perl version dont have the following module (like Perl 5.6.x)
|
||||
if (centreon::plugins::misc::mymodule_load(
|
||||
no_quit => 1, module => 'Encode',
|
||||
error_msg => "Cannot load module 'Encode'.")
|
||||
) {
|
||||
print "Cannot load module 'Encode'\n";
|
||||
$self->exit(exit_litteral => 'unknown');
|
||||
}
|
||||
my $rv = centreon::plugins::misc::mymodule_load(
|
||||
no_quit => 1,
|
||||
module => 'Encode',
|
||||
error_msg => "Cannot load module 'Encode'."
|
||||
);
|
||||
return $value if ($rv);
|
||||
|
||||
$self->{encode_utf8_import} = 1;
|
||||
$self->{encode_import} = 1;
|
||||
eval '$self->{perlqq} = Encode::PERLQQ';
|
||||
}
|
||||
|
||||
return centreon::plugins::misc::trim(Encode::decode('UTF-8', $value, $self->{perlqq}));
|
||||
return centreon::plugins::misc::trim(Encode::decode($self->{source_encoding}, $value, $self->{perlqq}));
|
||||
}
|
||||
|
||||
sub parameter {
|
||||
|
@ -1453,6 +1456,10 @@ Display discovery values (if the mode manages it).
|
|||
|
||||
Set the float precision for thresholds (Default: 8).
|
||||
|
||||
=item B<--source-encoding>
|
||||
|
||||
Set encoding of monitoring sources (In some case. Default: 'UTF-8').
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<output>.
|
||||
|
|
|
@ -70,7 +70,7 @@ sub manage_selection {
|
|||
next;
|
||||
}
|
||||
|
||||
$result->{name} = $self->{output}->to_utf8($result->{name});
|
||||
$result->{name} = $self->{output}->decode($result->{name});
|
||||
$results->{$instance} = $result;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ sub manage_selection {
|
|||
|
||||
$self->{tags} = {};
|
||||
foreach (keys %$tags) {
|
||||
$tags->{$_} = $self->{output}->to_utf8($tags->{$_});
|
||||
$tags->{$_} = $self->{output}->decode($tags->{$_});
|
||||
if (defined($self->{option_results}->{filter_tag_index}) && $self->{option_results}->{filter_tag_index} ne '' &&
|
||||
$_ !~ /$self->{option_results}->{filter_tag_index}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $tags->{$_} . "': no matching 'org' filter.", debug => 1);
|
||||
|
|
|
@ -127,12 +127,12 @@ sub reload_cache_fcportname {
|
|||
my $if_index = $1;
|
||||
push @{$options{datas}->{all_ids}}, $if_index if ($store_index == 1);
|
||||
if ($options{result}->{ $self->{oids_label}->{ifname}->{oid} }->{$_} =~ /\d+\/(\d+)$/) {
|
||||
$options{datas}->{ $options{name} . '_' . $if_index } = $self->{output}->to_utf8(
|
||||
$options{datas}->{ $options{name} . '_' . $if_index } = $self->{output}->decode(
|
||||
$options{result}->{ $self->{oids_label}->{ $options{name} }->{oid} }->{ $self->{oids_label}->{ $options{name} }->{oid} . '.' . ($1 + 1) }
|
||||
);
|
||||
} else {
|
||||
# we use ifname if there is no fcportname
|
||||
$options{datas}->{ $options{name} . '_' . $if_index } = $self->{output}->to_utf8(
|
||||
$options{datas}->{ $options{name} . '_' . $if_index } = $self->{output}->decode(
|
||||
$options{result}->{ $self->{oids_label}->{ifname}->{oid} }->{$_}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ my %map_vs_type = (
|
|||
2 => 'loadbalancinggroup',
|
||||
3 => 'sslvpn',
|
||||
4 => 'contentswitching',
|
||||
5 => 'cacheredirection',
|
||||
5 => 'cacheredirection'
|
||||
);
|
||||
|
||||
sub new {
|
||||
|
@ -42,12 +42,12 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"name:s" => { name => 'name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'name:s' => { name => 'name' },
|
||||
'regexp' => { name => 'use_regexp' },
|
||||
'filter-type:s' => { name => 'filter_type' }
|
||||
});
|
||||
|
||||
$self->{vs_id_selected} = [];
|
||||
|
||||
return $self;
|
||||
|
@ -77,7 +77,7 @@ sub manage_selection {
|
|||
next;
|
||||
}
|
||||
|
||||
$name = $self->{output}->to_utf8($name);
|
||||
$name = $self->{output}->decode($name);
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $name eq $self->{option_results}->{name}) {
|
||||
push @{$self->{vs_id_selected}}, $instance;
|
||||
next;
|
||||
|
|
|
@ -33,7 +33,7 @@ sub set_counters {
|
|||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'vs', type => 3, cb_prefix_output => 'prefix_vs_output', cb_long_output => 'vs_long_output', indent_long_output => ' ', message_multiple => 'All virtual servers are ok',
|
||||
group => [
|
||||
{ name => 'ap', display_long => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access profiles are ok', type => 1, skipped_code => { -10 => 1 } },
|
||||
{ name => 'ap', display_long => 1, cb_prefix_output => 'prefix_ap_output', message_multiple => 'All access profiles are ok', type => 1, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
@ -43,56 +43,53 @@ sub set_counters {
|
|||
key_values => [ { name => 'apmAccessStatTotalSessions', diff => 1 } ],
|
||||
output_template => 'created sessions: %s',
|
||||
perfdatas => [
|
||||
{ value => 'apmAccessStatTotalSessions', template => '%s', min => 0 },
|
||||
],
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'sessions-active', nlabel => 'system.sessions.active.count', set => {
|
||||
key_values => [ { name => 'apmAccessStatCurrentActiveSessions' } ],
|
||||
output_template => 'active sessions: %s',
|
||||
perfdatas => [
|
||||
{ value => 'apmAccessStatCurrentActiveSessions', template => '%s', min => 0 },
|
||||
],
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'sessions-pending', nlabel => 'system.sessions.pending.count', set => {
|
||||
key_values => [ { name => 'apmAccessStatCurrentPendingSessions' } ],
|
||||
output_template => 'pending sessions: %s',
|
||||
perfdatas => [
|
||||
{ value => 'apmAccessStatCurrentPendingSessions', template => '%s', min => 0 },
|
||||
],
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{ap} = [
|
||||
{ label => 'ap-sessions-created', nlabel => 'acessprofile.sessions.created.count', set => {
|
||||
{ label => 'ap-sessions-created', nlabel => 'accessprofile.sessions.created.count', set => {
|
||||
key_values => [ { name => 'apmPaStatTotalSessions', diff => 1 } ],
|
||||
output_template => 'created sessions: %s',
|
||||
perfdatas => [
|
||||
{ value => 'apmPaStatTotalSessions', template => '%s',
|
||||
min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'ap-sessions-active', nlabel => 'acessprofile.sessions.active.count', set => {
|
||||
{ label => 'ap-sessions-active', nlabel => 'accessprofile.sessions.active.count', set => {
|
||||
key_values => [ { name => 'apmPaStatCurrentActiveSessions' } ],
|
||||
output_template => 'active sessions: %s',
|
||||
perfdatas => [
|
||||
{ value => 'apmPaStatCurrentActiveSessions', template => '%s',
|
||||
min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'ap-sessions-pending', nlabel => 'acessprofile.sessions.pending.count', set => {
|
||||
{ label => 'ap-sessions-pending', nlabel => 'accessprofile.sessions.pending.count', set => {
|
||||
key_values => [ { name => 'apmPaStatCurrentPendingSessions' } ],
|
||||
output_template => 'pending sessions: %s',
|
||||
perfdatas => [
|
||||
{ value => 'apmPaStatCurrentPendingSessions', template => '%s',
|
||||
min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -121,7 +118,7 @@ sub new {
|
|||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-vs:s' => { name => 'filter_vs' },
|
||||
'filter-ap:s' => { name => 'filter_ap' },
|
||||
'filter-ap:s' => { name => 'filter_ap' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -160,8 +157,8 @@ sub manage_selection {
|
|||
my $instance = $1;
|
||||
|
||||
my @indexes = split(/\./, $instance);
|
||||
my $ap_name = $self->{output}->to_utf8(join('', map(chr($_), splice(@indexes, 0, shift(@indexes)) )));
|
||||
my $vs_name = $self->{output}->to_utf8(join('', map(chr($_), splice(@indexes, 0, shift(@indexes)) )));
|
||||
my $ap_name = $self->{output}->decode(join('', map(chr($_), splice(@indexes, 0, shift(@indexes)) )));
|
||||
my $vs_name = $self->{output}->decode(join('', map(chr($_), splice(@indexes, 0, shift(@indexes)) )));
|
||||
|
||||
$result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_apmPaStatEntry}, instance => $instance);
|
||||
if (defined($self->{option_results}->{filter_vs}) && $self->{option_results}->{filter_vs} ne '' &&
|
||||
|
|
|
@ -31,7 +31,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'filter-name:s' => { name => 'filter_name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -48,14 +48,14 @@ sub manage_selection {
|
|||
my $map_pool_status = {
|
||||
0 => 'none', 1 => 'green',
|
||||
2 => 'yellow', 3 => 'red',
|
||||
4 => 'blue', 5 => 'gray',
|
||||
4 => 'blue', 5 => 'gray'
|
||||
};
|
||||
my $map_pool_enabled = {
|
||||
0 => 'none', 1 => 'enabled', 2 => 'disabled', 3 => 'disabledbyparent',
|
||||
0 => 'none', 1 => 'enabled', 2 => 'disabled', 3 => 'disabledbyparent'
|
||||
};
|
||||
my $mapping = {
|
||||
AvailState => { oid => '.1.3.6.1.4.1.3375.2.2.4.3.2.1.3', map => $map_pool_status },
|
||||
EnabledState => { oid => '.1.3.6.1.4.1.3375.2.2.4.3.2.1.4', map => $map_pool_enabled },
|
||||
EnabledState => { oid => '.1.3.6.1.4.1.3375.2.2.4.3.2.1.4', map => $map_pool_enabled }
|
||||
};
|
||||
my $oid_ltmNodeAddrStatusEntry = '.1.3.6.1.4.1.3375.2.2.4.3.2.1';
|
||||
|
||||
|
@ -71,7 +71,7 @@ sub manage_selection {
|
|||
my ($num, $index) = ($1, $2);
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $num . '.' . $index);
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $index))));
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
|
@ -81,7 +81,7 @@ sub manage_selection {
|
|||
|
||||
$results->{$name} = {
|
||||
status => $result->{AvailState},
|
||||
state => $result->{EnabledState},
|
||||
state => $result->{EnabledState}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'filter-name:s' => { name => 'filter_name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -73,7 +73,7 @@ sub manage_selection {
|
|||
my ($num, $index) = ($1, $2);
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $num . '.' . $index);
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $index))));
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
|
|
|
@ -91,7 +91,7 @@ sub manage_selection {
|
|||
my ($num, $index) = ($1, $2);
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $snmp_result->{$branch}, instance => $num . '.' . $index);
|
||||
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $index))));
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping virtual server '" . $name . "'.", debug => 1);
|
||||
|
|
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -47,7 +47,6 @@ sub set_counters {
|
|||
$self->{maps_counters}->{node} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'state' }, { name => 'status' }, { name => 'reason' },{ name => 'display' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
|
@ -142,7 +141,7 @@ sub manage_selection {
|
|||
my ($num, $index) = ($1, $2);
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $snmp_result->{$branch_name}, instance => $num . '.' . $index);
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $index))));
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
|
|
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng catalog_status_calc);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -33,7 +33,7 @@ sub custom_status_output {
|
|||
'status: %s [state: %s] [reason: %s]',
|
||||
$self->{result_values}->{status},
|
||||
$self->{result_values}->{state},
|
||||
$self->{result_values}->{reason},
|
||||
$self->{result_values}->{reason}
|
||||
);
|
||||
return $msg;
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ sub set_counters {
|
|||
label => 'status', type => 2, warning_default => '%{state} eq "enabled" and %{status} eq "yellow"', critical_default => '%{state} eq "enabled" and %{status} eq "red"',
|
||||
set => {
|
||||
key_values => [ { name => 'state' }, { name => 'status' }, { name => 'reason' },{ name => 'display' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
|
@ -118,18 +117,18 @@ my $mapping = {
|
|||
new => {
|
||||
AvailState => { oid => '.1.3.6.1.4.1.3375.2.2.5.5.2.1.2', map => $map_pool_status },
|
||||
EnabledState => { oid => '.1.3.6.1.4.1.3375.2.2.5.5.2.1.3', map => $map_pool_enabled },
|
||||
StatusReason => { oid => '.1.3.6.1.4.1.3375.2.2.5.5.2.1.5' },
|
||||
StatusReason => { oid => '.1.3.6.1.4.1.3375.2.2.5.5.2.1.5' }
|
||||
},
|
||||
old => {
|
||||
AvailState => { oid => '.1.3.6.1.4.1.3375.2.2.5.1.2.1.18', map => $map_pool_status },
|
||||
EnabledState => { oid => '.1.3.6.1.4.1.3375.2.2.5.1.2.1.19', map => $map_pool_enabled },
|
||||
StatusReason => { oid => '.1.3.6.1.4.1.3375.2.2.5.1.2.1.21' },
|
||||
StatusReason => { oid => '.1.3.6.1.4.1.3375.2.2.5.1.2.1.21' }
|
||||
},
|
||||
};
|
||||
my $mapping2 = {
|
||||
ltmPoolStatServerCurConns => { oid => '.1.3.6.1.4.1.3375.2.2.5.2.3.1.8' },
|
||||
ltmPoolActiveMemberCnt => { oid => '.1.3.6.1.4.1.3375.2.2.5.1.2.1.8' },
|
||||
ltmPoolMemberCnt => { oid => '.1.3.6.1.4.1.3375.2.2.5.1.2.1.23' },
|
||||
ltmPoolMemberCnt => { oid => '.1.3.6.1.4.1.3375.2.2.5.1.2.1.23' }
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -154,7 +153,7 @@ sub manage_selection {
|
|||
my ($num, $index) = ($1, $2);
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $snmp_result->{$branch_name}, instance => $num . '.' . $index);
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $index))));
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
|
|
|
@ -135,7 +135,7 @@ sub manage_selection {
|
|||
$oid =~ /^$oid_status->{$map}\.(.*?)\.(.*)$/;
|
||||
my ($num, $index) = ($1, $2);
|
||||
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $index))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $index))));
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter name.", debug => 1);
|
||||
|
|
|
@ -188,7 +188,7 @@ sub manage_selection {
|
|||
my $port_name = $2;
|
||||
my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_jnxVirtualChassisPortEntry}, instance => $chassis_id . '.' . $1 . '.' . $port_name);
|
||||
|
||||
$port_name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $port_name))));
|
||||
$port_name = $self->{output}->decode(join('', map(chr($_), split(/\./, $port_name))));
|
||||
$self->{member}->{$result->{jnxVirtualChassisMemberSerialnumber}}->{port}->{$port_name} = {
|
||||
display => $port_name,
|
||||
admin_status => $result2->{jnxVirtualChassisPortAdminStatus},
|
||||
|
|
|
@ -32,13 +32,13 @@ sub new {
|
|||
|
||||
$options{options}->add_options(arguments => {
|
||||
'oid-filter:s' => { name => 'oid_filter', default => 'ifname' },
|
||||
'oid-display:s' => { name => 'oid_display', default => 'ifname' },
|
||||
'oid-display:s' => { name => 'oid_display', default => 'ifname' }
|
||||
});
|
||||
|
||||
$self->{oids_label} = {
|
||||
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
|
||||
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
|
||||
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1',
|
||||
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1'
|
||||
};
|
||||
|
||||
return $self;
|
||||
|
@ -58,7 +58,7 @@ sub run {
|
|||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $self->{oids_label}->{'ifname'} }})) {
|
||||
next if ($key !~ /^$self->{oids_label}->{'ifname'}\.(.*)$/);
|
||||
$self->{datas}->{'ifname' . "_" . $1} = $self->{output}->to_utf8($interfaceTables->{$self->{oids_label}->{'ifname'} }->{$key});
|
||||
$self->{datas}->{'ifname' . "_" . $1} = $self->{output}->decode($interfaceTables->{$self->{oids_label}->{'ifname'} }->{$key});
|
||||
push @{$self->{datas}->{all_ids}}, $1;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ sub new {
|
|||
|
||||
$options{options}->add_options(arguments => {
|
||||
'oid-filter:s' => { name => 'oid_filter', default => 'ifname' },
|
||||
'oid-display:s' => { name => 'oid_display', default => 'ifname' },
|
||||
'oid-display:s' => { name => 'oid_display', default => 'ifname' }
|
||||
});
|
||||
|
||||
$self->{oids_label} = {
|
||||
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
|
||||
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
|
||||
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1',
|
||||
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1'
|
||||
};
|
||||
|
||||
return $self;
|
||||
|
@ -58,7 +58,7 @@ sub run {
|
|||
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $self->{oids_label}->{'ifname'} }})) {
|
||||
next if ($key !~ /^$self->{oids_label}->{'ifname'}\.(.*)$/);
|
||||
$self->{datas}->{'ifname' . "_" . $1} = $self->{output}->to_utf8($interfaceTables->{$self->{oids_label}->{'ifname'} }->{$key});
|
||||
$self->{datas}->{'ifname' . "_" . $1} = $self->{output}->decode($interfaceTables->{$self->{oids_label}->{'ifname'} }->{$key});
|
||||
push @{$self->{datas}->{all_ids}}, $1;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ sub manage_selection {
|
|||
next;
|
||||
}
|
||||
|
||||
$self->{result_names}->{$oid} = $self->{output}->to_utf8($self->{result_names}->{$oid});
|
||||
$self->{result_names}->{$oid} = $self->{output}->decode($self->{result_names}->{$oid});
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{name}) {
|
||||
push @{$self->{bca_id_selected}}, $instance;
|
||||
}
|
||||
|
@ -110,11 +110,15 @@ sub run {
|
|||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
$self->{snmp}->load(oids => [$oid_spvBCAStatus, $oid_spvBCAEURT, $oid_spvBCASRT,
|
||||
$oid_spvBCARTTClient, $oid_spvBCARTTServer,
|
||||
$oid_spvBCADTTClient, $oid_spvBCADTTServer,
|
||||
$oid_spvBCAThresholdWarning, $oid_spvBCAThresholdAlert],
|
||||
instances => $self->{bca_id_selected});
|
||||
$self->{snmp}->load(
|
||||
oids => [
|
||||
$oid_spvBCAStatus, $oid_spvBCAEURT, $oid_spvBCASRT,
|
||||
$oid_spvBCARTTClient, $oid_spvBCARTTServer,
|
||||
$oid_spvBCADTTClient, $oid_spvBCADTTServer,
|
||||
$oid_spvBCAThresholdWarning, $oid_spvBCAThresholdAlert
|
||||
],
|
||||
instances => $self->{bca_id_selected}
|
||||
);
|
||||
my $result = $self->{snmp}->get_leef();
|
||||
|
||||
if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp})) {
|
||||
|
@ -202,4 +206,4 @@ Allows to use regexp to filter filesystem name (with option --name).
|
|||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ sub manage_selection {
|
|||
next;
|
||||
}
|
||||
|
||||
$self->{result_names}->{$oid} = $self->{output}->to_utf8($self->{result_names}->{$oid});
|
||||
$self->{result_names}->{$oid} = $self->{output}->decode($self->{result_names}->{$oid});
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{bcn}) {
|
||||
push @{$self->{bcn_id_selected}}, $instance;
|
||||
}
|
||||
|
@ -181,4 +181,4 @@ Regexp dst to transform display value. (security risk!!!)
|
|||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ sub manage_selection {
|
|||
next;
|
||||
}
|
||||
|
||||
$self->{result_names}->{$oid} = $self->{output}->to_utf8($self->{result_names}->{$oid});
|
||||
$self->{result_names}->{$oid} = $self->{output}->decode($self->{result_names}->{$oid});
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{name}) {
|
||||
push @{$self->{bca_id_selected}}, $instance;
|
||||
next;
|
||||
|
@ -131,4 +131,4 @@ Allows to use regexp to filter bca name (with option --name).
|
|||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"bcn:s" => { name => 'bcn' },
|
||||
"name" => { name => 'use_name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"display-transform-src:s" => { name => 'display_transform_src' },
|
||||
"display-transform-dst:s" => { name => 'display_transform_dst' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'bcn:s' => { name => 'bcn' },
|
||||
'name' => { name => 'use_name' },
|
||||
'regexp' => { name => 'use_regexp' },
|
||||
'display-transform-src:s' => { name => 'display_transform_src' },
|
||||
'display-transform-dst:s' => { name => 'display_transform_dst' }
|
||||
});
|
||||
|
||||
$self->{bcn_id_selected} = [];
|
||||
|
||||
return $self;
|
||||
|
@ -72,7 +72,7 @@ sub manage_selection {
|
|||
next;
|
||||
}
|
||||
|
||||
$self->{result_names}->{$oid} = $self->{output}->to_utf8($self->{result_names}->{$oid});
|
||||
$self->{result_names}->{$oid} = $self->{output}->decode($self->{result_names}->{$oid});
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $self->{result_names}->{$oid} eq $self->{option_results}->{bcn}) {
|
||||
push @{$self->{bcn_id_selected}}, $instance;
|
||||
}
|
||||
|
@ -94,8 +94,10 @@ sub run {
|
|||
$self->{output}->output_add(long_msg => "'" . $name . "'");
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'List bcn:');
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List bcn:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
@ -126,8 +128,10 @@ sub disco_show {
|
|||
my $name = $self->{result_names}->{$oid_spvBCNName . '.' . $instance};
|
||||
$name = $self->get_display_value(value => $name);
|
||||
|
||||
$self->{output}->add_disco_entry(name => $name,
|
||||
bcnid => $instance);
|
||||
$self->{output}->add_disco_entry(
|
||||
name => $name,
|
||||
bcnid => $instance
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,4 +168,4 @@ Regexp dst to transform display value. (security risk!!!)
|
|||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ sub manage_selection {
|
|||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fwMountPointName}})) {
|
||||
$key =~ /\.([0-9]+)$/;
|
||||
my $instance = $1;
|
||||
my $filter_name = $self->{output}->to_utf8($self->{results}->{$oid_fwMountPointName}->{$key});
|
||||
my $filter_name = $self->{output}->decode($self->{results}->{$oid_fwMountPointName}->{$key});
|
||||
next if (!defined($filter_name));
|
||||
if (!defined($self->{option_results}->{storage})) {
|
||||
push @{$self->{storage_id_selected}}, $instance;
|
||||
|
|
|
@ -74,7 +74,7 @@ sub manage_selection {
|
|||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$mapping->{svSvcOperatingState}->{oid}\.(.*?)\.(.*)$/);
|
||||
my $instance = $1 . '.' . $2;
|
||||
my $svc_name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $2))));
|
||||
my $svc_name = $self->{output}->decode(join('', map(chr($_), split(/\./, $2))));
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
|
|
|
@ -86,11 +86,12 @@ sub run {
|
|||
severity => 'OK',
|
||||
short_msg => 'All service states are ok'
|
||||
);
|
||||
use Encode;
|
||||
foreach my $oid ($options{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($oid !~ /^$oid_svSvcOperatingState\.(\d+)\.(.*)$/);
|
||||
my $instance = $1 . '.' . $2;
|
||||
|
||||
my $svc_name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $2))));
|
||||
my $svc_name = $self->{output}->decode(join('', map(chr($_), split(/\./, $2))));
|
||||
my $svc_installed_state = $result->{$oid_svSvcInstalledState . '.' . $instance};
|
||||
my $svc_operating_state = $result->{$oid_svSvcOperatingState . '.' . $instance};
|
||||
for (my $i = 0; $i < scalar(@{$self->{option_results}->{service}}); $i++) {
|
||||
|
|
|
@ -71,14 +71,18 @@ sub run {
|
|||
|
||||
$self->manage_selection();
|
||||
foreach my $name (sort(keys %{$self->{result}})) {
|
||||
$self->{output}->output_add(long_msg => "'" . $name . "' [DisplayName = " . $self->{output}->to_utf8($self->{result}->{$name}->{DisplayName}) . '] [' .
|
||||
'StartMode = ' . $self->{result}->{$name}->{StartMode} . '] [' .
|
||||
'State = ' . $self->{result}->{$name}->{State} .
|
||||
']');
|
||||
$self->{output}->output_add(
|
||||
long_msg => "'" . $name . "' [DisplayName = " . $self->{output}->decode($self->{result}->{$name}->{DisplayName}) . '] [' .
|
||||
'StartMode = ' . $self->{result}->{$name}->{StartMode} . '] [' .
|
||||
'State = ' . $self->{result}->{$name}->{State} .
|
||||
']'
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'List services:');
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List services:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
@ -98,7 +102,7 @@ sub disco_show {
|
|||
foreach my $name (sort(keys %{$self->{result}})) {
|
||||
$self->{output}->add_disco_entry(
|
||||
name => $name,
|
||||
display_name => $self->{output}->to_utf8($self->{result}->{$name}->{DisplayName}),
|
||||
display_name => $self->{output}->decode($self->{result}->{$name}->{DisplayName}),
|
||||
start_mode => $self->{result}->{$name}->{StartMode},
|
||||
state => $self->{result}->{$name}->{State}
|
||||
);
|
||||
|
|
|
@ -268,8 +268,8 @@ sub reload_cache {
|
|||
foreach my $key (keys %$result) {
|
||||
next if ($key !~ /$oid_dskPath\.([0-9]+)$/);
|
||||
$datas->{disks}->{$1} = [
|
||||
$self->{output}->to_utf8($result->{$key}),
|
||||
$self->{output}->to_utf8($result->{$oid_dskDevice . '.' . $1})
|
||||
$self->{output}->decode($result->{$key}),
|
||||
$self->{output}->decode($result->{$oid_dskDevice . '.' . $1})
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -924,7 +924,7 @@ sub reload_cache_index_value {
|
|||
foreach (keys %{$options{result}->{ $self->{oids_label}->{$options{name}}->{oid} }}) {
|
||||
/^$self->{oids_label}->{$options{name}}->{oid}\.(.*)$/;
|
||||
push @{$options{datas}->{all_ids}}, $1 if ($store_index == 1);
|
||||
$options{datas}->{$options{name} . "_" . $1} = $self->{output}->to_utf8($options{result}->{ $self->{oids_label}->{$options{name}}->{oid} }->{$_});
|
||||
$options{datas}->{$options{name} . '_' . $1} = $self->{output}->decode($options{result}->{ $self->{oids_label}->{$options{name}}->{oid} }->{$_});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,19 +34,18 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"diskpath:s" => { name => 'diskpath' },
|
||||
"name" => { name => 'use_name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"regexp-isensitive" => { name => 'use_regexpi' },
|
||||
"display-transform-src:s" => { name => 'display_transform_src' },
|
||||
"display-transform-dst:s" => { name => 'display_transform_dst' },
|
||||
"skip-total-size-zero" => { name => 'skip_total_size_zero' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'diskpath:s' => { name => 'diskpath' },
|
||||
'name' => { name => 'use_name' },
|
||||
'regexp' => { name => 'use_regexp' },
|
||||
'regexp-isensitive' => { name => 'use_regexpi' },
|
||||
'display-transform-src:s' => { name => 'display_transform_src' },
|
||||
'display-transform-dst:s' => { name => 'display_transform_dst' },
|
||||
'skip-total-size-zero' => { name => 'skip_total_size_zero' }
|
||||
});
|
||||
|
||||
$self->{diskpath_id_selected} = [];
|
||||
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -113,7 +112,7 @@ sub manage_selection {
|
|||
my $total_diskpath = 0;
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /\.([0-9]+)$/);
|
||||
$self->{datas}->{'dskPath_' . $1} = $self->{output}->to_utf8($result->{$key});
|
||||
$self->{datas}->{'dskPath_' . $1} = $self->{output}->decode($result->{$key});
|
||||
$total_diskpath = $1;
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ sub manage_selection {
|
|||
$self->{datas}->{all_ids} = [];
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oids_label}->{$self->{option_results}->{oid_filter}} }})) {
|
||||
next if ($key !~ /^$self->{oids_label}->{$self->{option_results}->{oid_filter}}\.(.*)$/);
|
||||
$self->{datas}->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->to_utf8($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_filter}} }->{$key});
|
||||
$self->{datas}->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->decode($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_filter}} }->{$key});
|
||||
push @{$self->{datas}->{all_ids}}, $1;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ sub manage_selection {
|
|||
if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}) {
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oids_label}->{$self->{option_results}->{oid_display}} }})) {
|
||||
next if ($key !~ /^$self->{oids_label}->{$self->{option_results}->{oid_display}}\.(.*)$/);
|
||||
$self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_display}} }->{$key});
|
||||
$self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->decode($self->{results}->{$self->{oids_label}->{ $self->{option_results}->{oid_display}} }->{$key});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ sub get_extra_values_by_instance {
|
|||
foreach (keys %{$self->{results}->{ $self->{extra_oids}->{$name}->{oid} }}) {
|
||||
if (/^$self->{extra_oids}->{$name}->{oid}\.$matching/) {
|
||||
$extra_values->{$name} = '' if (!defined($extra_values->{$name}));
|
||||
$extra_values->{$name} .= $append . $self->{output}->to_utf8($self->{results}->{ $self->{extra_oids}->{$name}->{oid} }->{$_});
|
||||
$extra_values->{$name} .= $append . $self->{output}->decode($self->{results}->{ $self->{extra_oids}->{$name}->{oid} }->{$_});
|
||||
$append = ',';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,18 +77,17 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"storage:s" => { name => 'storage' },
|
||||
"name" => { name => 'use_name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"regexp-isensitive" => { name => 'use_regexpi' },
|
||||
"oid-filter:s" => { name => 'oid_filter', default => 'hrStorageDescr'},
|
||||
"oid-display:s" => { name => 'oid_display', default => 'hrStorageDescr'},
|
||||
"display-transform-src:s" => { name => 'display_transform_src' },
|
||||
"display-transform-dst:s" => { name => 'display_transform_dst' },
|
||||
"filter-storage-type:s" => { name => 'filter_storage_type', default => '^(hrStorageFixedDisk|hrStorageNetworkDisk|hrFSBerkeleyFFS)$' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'storage:s' => { name => 'storage' },
|
||||
'name' => { name => 'use_name' },
|
||||
'regexp' => { name => 'use_regexp' },
|
||||
'regexp-isensitive' => { name => 'use_regexpi' },
|
||||
'oid-filter:s' => { name => 'oid_filter', default => 'hrStorageDescr'},
|
||||
'oid-display:s' => { name => 'oid_display', default => 'hrStorageDescr'},
|
||||
'display-transform-src:s' => { name => 'display_transform_src' },
|
||||
'display-transform-dst:s' => { name => 'display_transform_dst' },
|
||||
'filter-storage-type:s' => { name => 'filter_storage_type', default => '^(hrStorageFixedDisk|hrStorageNetworkDisk|hrFSBerkeleyFFS)$' }
|
||||
});
|
||||
|
||||
$self->{storage_id_selected} = [];
|
||||
|
||||
|
@ -187,7 +186,7 @@ sub manage_selection {
|
|||
push @{$self->{datas}->{all_ids}}, $storage_index;
|
||||
}
|
||||
|
||||
$self->{datas}->{$$_[1] . "_" . $storage_index} = $self->{output}->to_utf8($result->{ $oids_hrStorageTable{$$_[1]} }->{$key});
|
||||
$self->{datas}->{$$_[1] . "_" . $storage_index} = $self->{output}->decode($result->{ $oids_hrStorageTable{$$_[1]} }->{$key});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +199,7 @@ sub manage_selection {
|
|||
$result = $self->{snmp}->get_table(oid => $oids_hrStorageTable{$self->{option_results}->{oid_display}});
|
||||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /\.([0-9]+)$/);
|
||||
$self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($result->{$key});
|
||||
$self->{datas}->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->decode($result->{$key});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -420,7 +420,7 @@ sub reload_cache {
|
|||
push @{$datas->{all_ids}}, $storage_index;
|
||||
}
|
||||
|
||||
$datas->{$$_[1] . "_" . $storage_index} = $self->{output}->to_utf8($result->{ $oids_hrStorageTable{$$_[1]} }->{$key});
|
||||
$datas->{$$_[1] . "_" . $storage_index} = $self->{output}->decode($result->{ $oids_hrStorageTable{$$_[1]} }->{$key});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ sub manage_selection {
|
|||
my $instance = $1;
|
||||
|
||||
$result = $options{snmp}->map_instance(mapping => $mapping_ha, results => $snmp_result->{$oid_haEntry}, instance => $instance);
|
||||
my $name = $self->{output}->to_utf8(join('', map(chr($_), split(/\./, $instance))));
|
||||
my $name = $self->{output}->decode(join('', map(chr($_), split(/\./, $instance))));
|
||||
if (defined($self->{option_results}->{filter_node}) && $self->{option_results}->{filter_node} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_node}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping node '" . $name . "'.", debug => 1);
|
||||
|
|
Loading…
Reference in New Issue