]> jspc29.x-matter.uni-frankfurt.de Git - hadesicinga.git/commitdiff
New script for getting hard disk status + temperature checks. Sergey.
authorhadaq <hadaq>
Wed, 12 May 2010 15:36:52 +0000 (15:36 +0000)
committerhadaq <hadaq>
Wed, 12 May 2010 15:36:52 +0000 (15:36 +0000)
plugins/my_check_proc_disk_status.pl [new file with mode: 0755]

diff --git a/plugins/my_check_proc_disk_status.pl b/plugins/my_check_proc_disk_status.pl
new file mode 100755 (executable)
index 0000000..308bc15
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/perl -w
+# ----------------------------------------------------------------------------
+# File Name:            my_check_proc_status.pl
+# Author:               Sergey Yurevich
+# Date:                 16/01/2007
+# Version:              0.1
+# Description:          script checks the status of the process (alive/dead)
+# ----------------------------------------------------------------------------
+
+use strict;
+use warnings;
+use IO::Socket;
+use lib '/usr/local/icinga/libexec/';
+use utils qw($TIMEOUT %ERRORS &print_revision &support);
+
+@ARGV == 5 or die "usage: my_check_proc_status.pl host_ip host_port proc_name\n"; 
+
+my ($remote_host, $remote_port, $proc_name, $temp_warn, $temp_crit) = @ARGV;
+
+#my $remote_host = 'lxhadesdaq.gsi.de';
+#my $remote_port = '60006';
+my $protocol    = 'tcp';
+my $state;
+my $answer = "";
+
+my $socket = IO::Socket::INET->new(PeerAddr => $remote_host,
+                                  PeerPort => $remote_port,
+                                  Proto    => $protocol,
+                                  Type     => SOCK_STREAM)
+     or $answer = "CRITICAL - no response from $proc_name at $remote_host:$remote_port";
+
+if($answer){
+    $state = $ERRORS{'CRITICAL'};
+}
+else{
+    $answer = <$socket>;
+
+    close($socket);
+
+    if($answer =~ /OK/){
+       $state = $ERRORS{'OK'};
+
+       #- Check disk temperatures
+       my @anser_list = split(/,/, $answer);
+       foreach my $line (@anser_list){
+           if( $line =~ /temp:\s+\/dev\/\w{3}\s+(\d+)/ ){
+               if($1 > $temp_warn && $1 < $temp_crit){
+                   $state = $ERRORS{'WARNING'};
+               }
+               elsif($1 > $temp_crit){
+                   $state = $ERRORS{'CRITICAL'};
+               }
+           }
+       }
+    }
+    elsif($answer =~ /WARNING/){
+       $state = $ERRORS{'WARNING'};
+    }
+    elsif($answer =~ /CRITICAL/){
+       $state = $ERRORS{'CRITICAL'};
+    }
+    elsif($answer){
+       $state = $ERRORS{'UNKNOWN'};
+    }
+}
+
+if($state == $ERRORS{'OK'}){
+    print "$answer\n";
+}
+elsif($state == $ERRORS{'WARNING'}){
+    print "$answer\n";
+}
+elsif($state == $ERRORS{'CRITICAL'}){
+    print "$answer\n";
+}
+elsif($state == $ERRORS{'UNKNOWN'}){
+    print "UNKNOWN - $answer\n";
+}
+
+exit $state;
+
+
+
+