document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/perl
  2. # Script to monitor NetASQ UTM v9 internal temperature from Nagios  
  3. # 15/06/2013 Made by Securizame (www.securizame.com)
  4. # info@securizame.com
  5.  
  6. use Getopt::Std;
  7.  
  8. #USAGE $0 -H $donde -w $warntemp -c $crittemp
  9.  
  10. my $user=\'admin\';
  11. my $pass=\'la_password\';
  12. my $internal_ip=\'aaa.bbb.ccc.ddd\';
  13. my $temp;
  14.  
  15. getopts(\'H:w:c:\');
  16. my $host=$opt_H;
  17. my $warn=$opt_w;
  18. my $crit=$opt_c;
  19.  
  20. #Populate "/tmp/comando" file with "MONITOR STAT" command
  21. system ("sshpass -p $pass ssh $user\\@$host -o StrictHostKeyChecking=no \\"echo MONITOR STAT > /tmp/comando\\"");
  22.  
  23. #Remote MONITOR STAT execution
  24. system ("sshpass -p $pass ssh $user\\@$host -o StrictHostKeyChecking=no \\"nsrpc -c /tmp/comando $user:$pass\\@$internal_ip > /tmp/output\\"");
  25.  
  26. #Get output to local machine
  27. my $devuelve=`sshpass -p $pass ssh $user\\@$host -o StrictHostKeyChecking=no \\"cat /tmp/output\\"`;
  28.  
  29. #Delete remote tracks
  30. system ("sshpass -p $pass ssh $user\\@$host -o StrictHostKeyChecking=no \\"rm -rf /tmp/output /tmp/comando\\"");
  31.  
  32. #Extract temperature value from retrieved output
  33. my @cachos=split(/temperature\\=/,$devuelve);
  34. my @trozos=split(/\\n/,$cachos[1]);
  35.  
  36. $temp=$trozos[0];
  37.  
  38. if ($temp >= $crit)
  39. {
  40.         print ("CRITICAL, Temperature $temp\\n");
  41.         exit 2;
  42. }
  43. elsif ($temp >= $warn)
  44. {
  45.         print ("WARNING, Temperature $temp\\n");
  46.         exit 1;
  47. }
  48. else
  49. {
  50.        print ("OK, Temperature $temp\\n");
  51.        exit 0;
  52. }
');