mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-24 22:25:02 +02:00
align data -> indompting
git-svn-id: http://svn.centreon.com/Plugins/Dev@2445 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
parent
65435306cf
commit
c30f7e7d00
@ -68,48 +68,44 @@ GetOptions
|
|||||||
|
|
||||||
if ($opt_V) {
|
if ($opt_V) {
|
||||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($opt_h) {
|
if ($opt_h) {
|
||||||
print_help();
|
print_help();
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$opt_H) {
|
if (!$opt_H) {
|
||||||
print_usage();
|
print_usage();
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
my $snmp = "1";
|
my $snmp = "1";
|
||||||
if ($opt_v && $opt_v =~ /^[0-9]$/) {
|
$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/);
|
||||||
$snmp = $opt_v;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($snmp eq "3") {
|
if ($snmp eq "3") {
|
||||||
if (!$opt_u) {
|
if (!$opt_u) {
|
||||||
print "Option -u (--username) is required for snmpV3\n";
|
print "Option -u (--username) is required for snmpV3\n";
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
if (!$opt_x && !$opt_k) {
|
if (!$opt_x && !$opt_k) {
|
||||||
print "Option -k (--key) or -x (--password) is required for snmpV3\n";
|
print "Option -k (--key) or -x (--password) is required for snmpV3\n";
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}elsif ($opt_x && $opt_k) {
|
} elsif ($opt_x && $opt_k) {
|
||||||
print "Only option -k (--key) or -x (--password) is needed for snmpV3\n";
|
print "Only option -k (--key) or -x (--password) is needed for snmpV3\n";
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$opt_C) {
|
$opt_C = "public" if (!$opt_C);
|
||||||
$opt_C = "public";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $process;
|
my $process;
|
||||||
if(!$opt_p) {
|
if(!$opt_p) {
|
||||||
print_usage();
|
print_usage();
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}elsif ($opt_p !~ /([-.A-Za-z0-9]+)/){
|
} elsif ($opt_p !~ /([-.A-Za-z0-9]+)/){
|
||||||
print_usage();
|
print_usage();
|
||||||
exit $ERRORS{'OK'};
|
exit $ERRORS{'OK'};
|
||||||
}
|
}
|
||||||
$process = $opt_p;
|
$process = $opt_p;
|
||||||
|
|
||||||
@ -123,23 +119,23 @@ my $OID_SW_RunStatus =$oreon{MIB2}{SW_RUNSTATUS};
|
|||||||
|
|
||||||
my ($session, $error);
|
my ($session, $error);
|
||||||
if ($snmp eq "1" || $snmp eq "2") {
|
if ($snmp eq "1" || $snmp eq "2") {
|
||||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||||
if (!defined($session)) {
|
if (!defined($session)) {
|
||||||
print("UNKNOWN: SNMP Session : $error\n");
|
print("UNKNOWN: SNMP Session : $error\n");
|
||||||
exit $ERRORS{'UNKNOWN'};
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
}elsif ($opt_k) {
|
} elsif ($opt_k) {
|
||||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||||
if (!defined($session)) {
|
if (!defined($session)) {
|
||||||
print("UNKNOWN: SNMP Session : $error\n");
|
print("UNKNOWN: SNMP Session : $error\n");
|
||||||
exit $ERRORS{'UNKNOWN'};
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
}elsif ($opt_x) {
|
} elsif ($opt_x) {
|
||||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_x);
|
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_x);
|
||||||
if (!defined($session)) {
|
if (!defined($session)) {
|
||||||
print("UNKNOWN: SNMP Session : $error\n");
|
print("UNKNOWN: SNMP Session : $error\n");
|
||||||
exit $ERRORS{'UNKNOWN'};
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $session->get_table(Baseoid => $OID_SW_RunName);
|
$result = $session->get_table(Baseoid => $OID_SW_RunName);
|
||||||
@ -154,16 +150,13 @@ foreach my $key (oid_lex_sort(keys %$result)) {
|
|||||||
my @oid_list = split (/\./,$key);
|
my @oid_list = split (/\./,$key);
|
||||||
$process_list{$$result{$key}} = pop (@oid_list) ;
|
$process_list{$$result{$key}} = pop (@oid_list) ;
|
||||||
if (defined($opt_p) && $opt_p ne ""){
|
if (defined($opt_p) && $opt_p ne ""){
|
||||||
if ($$result{$key} eq $opt_p){
|
$proc++ if ($$result{$key} eq $opt_p);
|
||||||
$proc++;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$proc++;
|
$proc++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($opt_n))
|
if (!($opt_n)) {
|
||||||
{
|
|
||||||
if ($process_list{$process}) {
|
if ($process_list{$process}) {
|
||||||
$result = $session->get_request(-varbindlist => [$OID_SW_RunStatus . "." . $process_list{$process}]);
|
$result = $session->get_request(-varbindlist => [$OID_SW_RunStatus . "." . $process_list{$process}]);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
@ -171,7 +164,7 @@ if (!($opt_n))
|
|||||||
$session->close;
|
$session->close;
|
||||||
exit $ERRORS{'UNKNOWN'};
|
exit $ERRORS{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
$proc_run = $result->{$OID_SW_RunStatus . "." . $process_list{$process} };
|
$proc_run = $result->{$OID_SW_RunStatus . "." . $process_list{$process} };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,4 +205,3 @@ sub print_help () {
|
|||||||
print_usage();
|
print_usage();
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user