enhance indent
This commit is contained in:
parent
c481f00618
commit
c415e4ed64
|
@ -30,11 +30,10 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"units:s" => { name => 'units', default => 'absolute' },
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'units:s' => { name => 'units', default => 'absolute' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -82,9 +81,12 @@ sub run {
|
|||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $value,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Connections: %d%s", $result->{$oid_fwNumCom}, $extra));
|
||||
$self->{output}->perfdata_add(label => "connections", unit => 'con',
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Connections: %d%s", $result->{$oid_fwNumCom}, $extra)
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => "connections", unit => 'con',
|
||||
value => $result->{$oid_fwNumCom},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', %total_options),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', %total_options),
|
||||
|
|
|
@ -30,10 +30,9 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning', },
|
||||
'critical:s' => { name => 'critical', },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -90,7 +89,6 @@ sub run {
|
|||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0, max => 100);
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"label:s" => { name => 'label' },
|
||||
"command:s" => { name => 'command' },
|
||||
"args:s" => { name => 'args' },
|
||||
"shell" => { name => 'shell' },
|
||||
$options{options}->add_options(arguments => {
|
||||
'label:s' => { name => 'label' },
|
||||
'command:s' => { name => 'command' },
|
||||
'args:s' => { name => 'args' },
|
||||
'shell' => { name => 'shell' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -124,19 +124,21 @@ sub update_command {
|
|||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
||||
|
||||
# snmpset -On -c test -v 2c localhost \
|
||||
# '.1.3.6.1.4.1.8072.1.3.2.2.1.21.4.104.102.101.102' = 4 \
|
||||
# '.1.3.6.1.4.1.8072.1.3.2.2.1.2.4.104.102.101.102' = /bin/echo \
|
||||
# '.1.3.6.1.4.1.8072.1.3.2.2.1.3.4.104.102.101.102' = 'myplop'
|
||||
#
|
||||
|
||||
my $instance = $self->get_instance();
|
||||
$self->{snmp}->load(oids => [$oid_nsExtendArgs, $oid_nsExtendStatus,
|
||||
$oid_nsExtendCommand, $oid_nsExtendStorage, $oid_nsExtendExecType],
|
||||
$self->{snmp}->load(
|
||||
oids => [
|
||||
$oid_nsExtendArgs, $oid_nsExtendStatus,
|
||||
$oid_nsExtendCommand, $oid_nsExtendStorage, $oid_nsExtendExecType
|
||||
],
|
||||
instances => [$instance],
|
||||
instance_regexp => '^(.+)$');
|
||||
instance_regexp => '^(.+)$'
|
||||
);
|
||||
my $result = $self->{snmp}->get_leef();
|
||||
|
||||
if (!defined($result->{$oid_nsExtendCommand . '.' . $instance})) {
|
||||
|
@ -145,11 +147,18 @@ sub run {
|
|||
$self->update_command(result => $result, instance => $instance);
|
||||
}
|
||||
|
||||
$result = $self->{snmp}->get_leef(oids => [$oid_nsExtendOutputFull . '.' . $instance,
|
||||
$oid_nsExtendResult . '.' . $instance], nothing_quit => 1);
|
||||
$result = $self->{snmp}->get_leef(
|
||||
oids => [
|
||||
$oid_nsExtendOutputFull . '.' . $instance,
|
||||
$oid_nsExtendResult . '.' . $instance
|
||||
],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => $self->{output}->get_litteral_status(status => $result->{$oid_nsExtendResult . '.' . $instance}),
|
||||
short_msg => $result->{$oid_nsExtendOutputFull . '.' . $instance});
|
||||
$self->{output}->output_add(
|
||||
severity => $self->{output}->get_litteral_status(status => $result->{$oid_nsExtendResult . '.' . $instance}),
|
||||
short_msg => $result->{$oid_nsExtendOutputFull . '.' . $instance}
|
||||
);
|
||||
$self->{output}->display(force_ignore_perfdata => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
|
|
@ -50,9 +50,8 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_load_components => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"sensor-scale" => { name => 'sensor_scale' },
|
||||
$options{options}->add_options(arguments => {
|
||||
'sensor-scale' => { name => 'sensor_scale' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -207,9 +206,15 @@ sub check {
|
|||
}
|
||||
|
||||
$self->{components}->{sensor}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("sensor '%s' status is '%s' [instance = %s, value = %s]",
|
||||
$name, $result->{entPhySensorOperStatus}, $result->{entPhySensorType} . '.' . $instance,
|
||||
defined($result->{entPhySensorValue}) ? $result->{entPhySensorValue} : '-'));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"sensor '%s' status is '%s' [instance = %s, value = %s]",
|
||||
$name,
|
||||
$result->{entPhySensorOperStatus},
|
||||
$result->{entPhySensorType} . '.' . $instance,
|
||||
defined($result->{entPhySensorValue}) ? $result->{entPhySensorValue} : '-'
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'sensor', section => 'sensor.' . $result->{entPhySensorType}, value => $result->{entPhySensorOperStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
|
@ -221,13 +226,23 @@ sub check {
|
|||
my $component = 'sensor.' . $result->{entPhySensorType};
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $component, instance => $instance, value => $result->{entPhySensorValue});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Sensor '%s/%s' is %s %s", $name, $instance, $result->{entPhySensorValue}, $perfdata_unit{$result->{entPhySensorType}}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf(
|
||||
"Sensor '%s/%s' is %s %s",
|
||||
$name,
|
||||
$instance,
|
||||
$result->{entPhySensorValue},
|
||||
$perfdata_unit{$result->{entPhySensorType}}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(label => $component . '_' . $name, unit => $perfdata_unit{$result->{entPhySensorType}},
|
||||
$self->{output}->perfdata_add(
|
||||
label => $component . '_' . $name, unit => $perfdata_unit{$result->{entPhySensorType}},
|
||||
value => $result->{entPhySensorValue},
|
||||
warning => $warn,
|
||||
critical => $crit);
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,8 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -107,12 +106,14 @@ sub manage_selection {
|
|||
|
||||
$self->{isdn} = {};
|
||||
$self->{bearer} = { active => 0, total => 0 };
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $oid_isdnBearerOperStatus },
|
||||
{ oid => $oid_isdnSignalingIfIndex },
|
||||
{ oid => $oid_isdnSignalingStatsEntry },
|
||||
],
|
||||
nothing_quit => 1);
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
# Get interface name
|
||||
foreach my $oid (keys %{$snmp_result->{$oid_isdnSignalingIfIndex}}) {
|
||||
|
@ -132,8 +133,11 @@ sub manage_selection {
|
|||
}
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_isdnSignalingStatsEntry}, instance => $instance);
|
||||
$self->{isdn}->{$instance} = { in => $result->{isdnSigStatsInCalls}, out => $result->{isdnSigStatsOutCalls},
|
||||
display => $display };
|
||||
$self->{isdn}->{$instance} = {
|
||||
in => $result->{isdnSigStatsInCalls},
|
||||
out => $result->{isdnSigStatsOutCalls},
|
||||
display => $display
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $oid (keys %{$snmp_result->{$oid_isdnBearerOperStatus}}) {
|
||||
|
|
|
@ -54,19 +54,21 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
"service:s@" => { name => 'service', },
|
||||
"application:s@" => { name => 'application', },
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'service:s@' => { name => 'service' },
|
||||
'application:s@' => { name => 'application' },
|
||||
});
|
||||
|
||||
@{$self->{connections}} = ();
|
||||
$self->{services} = { total => { filter => '.*?#.*?#.*?#.*?#.*?#(?!(listen))', builtin => 1, number => 0, msg => 'Total connections: %d' } };
|
||||
$self->{applications} = {};
|
||||
$self->{states} = { closed => 0, listen => 0, synSent => 0, synReceived => 0,
|
||||
$self->{states} = {
|
||||
closed => 0, listen => 0, synSent => 0, synReceived => 0,
|
||||
established => 0, finWait1 => 0, finWait2 => 0, closeWait => 0,
|
||||
lastAck => 0, closing => 0, timeWait => 0 };
|
||||
lastAck => 0, closing => 0, timeWait => 0
|
||||
};
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -92,10 +94,12 @@ sub get_from_rfc4022 {
|
|||
|
||||
my $oid_tcpConnectionState = '.1.3.6.1.2.1.6.19.1.7';
|
||||
my $oid_tcpListenerProcess = '.1.3.6.1.2.1.6.20.1.4';
|
||||
my $results = $self->{snmp}->get_multiple_table(oids => [
|
||||
my $results = $self->{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $oid_tcpConnectionState },
|
||||
{ oid => $oid_tcpListenerProcess },
|
||||
]);
|
||||
]
|
||||
);
|
||||
return 0 if (scalar(keys %{$results->{$oid_tcpConnectionState}}) + scalar(keys %{$results->{$oid_tcpListenerProcess}}) == 0);
|
||||
|
||||
# Listener
|
||||
|
@ -175,14 +179,17 @@ sub check_services {
|
|||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{services}->{$tag} = { filter => ((defined($ipv) && $ipv ne '') ? $ipv : '.*?') . '#' .
|
||||
$self->{services}->{$tag} = {
|
||||
filter =>
|
||||
((defined($ipv) && $ipv ne '') ? $ipv : '.*?') . '#' .
|
||||
((defined($filter_ip_src) && $filter_ip_src ne '') ? $filter_ip_src : '.*?') . '#' .
|
||||
((defined($port_src) && $port_src ne '') ? $port_src : '.*?') . '#' .
|
||||
((defined($filter_ip_dst) && $filter_ip_dst ne '') ? $filter_ip_dst : '.*?') . '#' .
|
||||
((defined($port_dst) && $port_dst ne '') ? $port_dst : '.*?') . '#' .
|
||||
((defined($state) && $state ne '') ? lc($state) : '(?!(listen))')
|
||||
,
|
||||
builtin => 0, number => 0 };
|
||||
((defined($state) && $state ne '') ? lc($state) : '(?!(listen))'),
|
||||
builtin => 0,
|
||||
number => 0
|
||||
};
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-service-' . $tag, value => $warn)) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $warn . "' for service '$tag'.");
|
||||
$self->{output}->option_exit();
|
||||
|
@ -209,9 +216,7 @@ sub check_applications {
|
|||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{applications}->{$tag} = {
|
||||
services => {},
|
||||
};
|
||||
$self->{applications}->{$tag} = { services => {} };
|
||||
foreach my $service (split /\|/, $services) {
|
||||
if (!defined($self->{services}->{$service})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Service '" . $service . "' is not defined.");
|
||||
|
@ -241,20 +246,29 @@ sub test_services {
|
|||
}
|
||||
}
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $self->{services}->{$tag}->{number},
|
||||
threshold => [ { label => 'critical-service-' . $tag, 'exit_litteral' => 'critical' }, { label => 'warning-service-' . $tag, exit_litteral => 'warning' } ]);
|
||||
my ($perf_label, $msg) = ('service_' . $tag, "Service '$tag' connections: %d");
|
||||
my $exit_code = $self->{perfdata}->threshold_check(
|
||||
value => $self->{services}->{$tag}->{number},
|
||||
threshold => [ { label => 'critical-service-' . $tag, exit_litteral => 'critical' }, { label => 'warning-service-' . $tag, exit_litteral => 'warning' } ]
|
||||
);
|
||||
|
||||
my $msg = "Service '$tag' connections: %d";
|
||||
if ($self->{services}->{$tag}->{builtin} == 1) {
|
||||
($perf_label, $msg) = ($tag, $self->{services}->{$tag}->{msg});
|
||||
$msg = $self->{services}->{$tag}->{msg};
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf($msg, $self->{services}->{$tag}->{number}));
|
||||
$self->{output}->perfdata_add(label => $perf_label,
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf($msg, $self->{services}->{$tag}->{number})
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'service',
|
||||
nlabel => 'service.connections.tcp.count',
|
||||
instances => $tag,
|
||||
value => $self->{services}->{$tag}->{number},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-service-' . $tag),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-service-' . $tag),
|
||||
min => 0);
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,15 +282,23 @@ sub test_applications {
|
|||
$number += $self->{services}->{$_}->{number};
|
||||
}
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $number,
|
||||
threshold => [ { label => 'critical-app-' . $tag, 'exit_litteral' => 'critical' }, { label => 'warning-app-' . $tag, exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("Applicatin '%s' connections: %d", $tag, $number));
|
||||
$self->{output}->perfdata_add(label => 'app_' . $tag,
|
||||
my $exit_code = $self->{perfdata}->threshold_check(
|
||||
value => $number,
|
||||
threshold => [ { label => 'critical-app-' . $tag, exit_litteral => 'critical' }, { label => 'warning-app-' . $tag, exit_litteral => 'warning' } ]
|
||||
);
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf("Applicatin '%s' connections: %d", $tag, $number)
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'app',
|
||||
nlabel => 'application.connections.tcp.count',
|
||||
instances => $tag,
|
||||
value => $number,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-app-' . $tag),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-app-' . $tag),
|
||||
min => 0);
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,9 +327,12 @@ sub run {
|
|||
$self->test_applications();
|
||||
|
||||
foreach (keys %{$self->{states}}) {
|
||||
$self->{output}->perfdata_add(label => 'con_' . $_,
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'con_' . $_,
|
||||
nlabel => 'connections.tcp.' . lc($_) . '.count',
|
||||
value => $self->{states}->{$_},
|
||||
min => 0);
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
|
|
|
@ -125,15 +125,21 @@ sub run {
|
|||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => floor($value / $unitdiv->{$self->{option_results}->{unit}}),
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->perfdata_add(label => 'uptime', unit => $self->{option_results}->{unit},
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'uptime', unit => $self->{option_results}->{unit},
|
||||
value => floor($value / $unitdiv->{$self->{option_results}->{unit}}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
min => 0
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("System uptime is: %s",
|
||||
centreon::plugins::misc::change_seconds(value => $value, start => 'd')));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf(
|
||||
'System uptime is: %s',
|
||||
centreon::plugins::misc::change_seconds(value => $value, start => 'd')
|
||||
)
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
|
|
@ -80,10 +80,9 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{adminState} eq "up" and %{operState} ne %{operStateLast}' },
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{adminState} eq "up" and %{operState} ne %{operStateLast}' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -110,8 +109,11 @@ sub manage_selection {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{vrrp} = {};
|
||||
my $snmp_result = $options{snmp}->get_table(oid => $oid_vrrpOperEntry, end => $mapping->{vrrpOperMasterIpAddr}->{oid},
|
||||
nothing_quit => 1);
|
||||
my $snmp_result = $options{snmp}->get_table(
|
||||
oid => $oid_vrrpOperEntry,
|
||||
end => $mapping->{vrrpOperMasterIpAddr}->{oid},
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{vrrpOperState}->{oid}\.(.*)$/);
|
||||
|
|
Loading…
Reference in New Issue