From 8cf201fcb7e359fa2d170b453d55e5d028ac6629 Mon Sep 17 00:00:00 2001 From: hadaq Date: Wed, 12 May 2010 15:36:52 +0000 Subject: [PATCH] New script for getting hard disk status + temperature checks. Sergey. --- plugins/my_check_proc_disk_status.pl | 84 ++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 plugins/my_check_proc_disk_status.pl diff --git a/plugins/my_check_proc_disk_status.pl b/plugins/my_check_proc_disk_status.pl new file mode 100755 index 0000000..308bc15 --- /dev/null +++ b/plugins/my_check_proc_disk_status.pl @@ -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; + + + + -- 2.43.0