#!/usr/bin/perl use strict; use Net::SNMP; exit if (!$ARGV[0]); my $TIMEOUT = 30; $SIG{ALRM} = sub { print "ERROR: No response\n"; exit 3; }; alarm($TIMEOUT); my $hostip=$ARGV[0]; my ($session, $error) = Net::SNMP->session( -hostname => shift || $hostip, -community => shift || 'public', -timeout => 5, -port => shift || 161 ); if (!defined($session)) { printf("ERROR: %s.\n", $error); exit 1; } my $inputac = '1.3.6.1.4.1.318.1.1.1.3.2.2.0'; my $result = $session->get_request( -varbindlist => [$inputac] ); my $perf_data = "input=0;210;200;0;280;"; if (!defined($result)) { printf("ERROR: %s. |".$perf_data."\n", $session->error); $session->close; exit 2; } $perf_data = "input=%s;210;200;0;280;"; if (($result->{$inputac} < 201) or $result->{$inputac} > 255) { printf("ERROR Input AC: %sV |".$perf_data."\n",$result->{$inputac},$result->{$inputac}); $session->close; exit 2; } printf("OK Input AC %sV |".$perf_data."\n", $result->{$inputac},$result->{$inputac}); $session->close; exit 0;