1
0

check_ups_input3 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/perl
  2. use strict;
  3. use Net::SNMP;
  4. exit if (!$ARGV[0]);
  5. my $hostip=$ARGV[0];
  6. my $TIMEOUT = 30;
  7. $SIG{ALRM} = sub { print "ERROR: No response\n"; exit 3; };
  8. alarm($TIMEOUT);
  9. my ($session, $error) = Net::SNMP->session(
  10. -hostname => shift || $hostip,
  11. -community => shift || 'public',
  12. -timeout => 5,
  13. -port => shift || 161
  14. );
  15. if (!defined($session)) {
  16. printf("ERROR: %s.\n", $error);
  17. exit 1;
  18. }
  19. my $inputac = '1.3.6.1.4.1.318.1.1.1.3.2.1.0';
  20. my $result = $session->get_request(
  21. -varbindlist => [$inputac]
  22. );
  23. my $perf_data = "input=0;210;200;0;280;";
  24. if (!defined($result)) {
  25. printf("ERROR: %s. |".$perf_data."\n", $session->error);
  26. $session->close;
  27. exit 2;
  28. }
  29. $perf_data = "input=%s;210;200;0;280;";
  30. if (($result->{$inputac} < 201) or $result->{$inputac} > 255) {
  31. printf("ERROR Input AC: %sV |".$perf_data."\n",$result->{$inputac},$result->{$inputac});
  32. $session->close;
  33. exit 2;
  34. }
  35. printf("OK Input AC %sV |".$perf_data."\n", $result->{$inputac},$result->{$inputac});
  36. $session->close;
  37. exit 0;