Logoj0ke.net Open Build Service > Projects > server:monitoring > nagios-plugins-lsi > check_mpt
Sign Up | Log In

File check_mpt of Package nagios-plugins-lsi

 
1
#! /usr/bin/perl 
2
# $Id: check_mpt.pl,v 0.1 2006/05/16 15:17:49 Exp $
3
4
# check_mpt.pl Copyright (C) 2006 Claudio Messineo <claudio@zero.it>
5
#
6
#
7
#
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU General Public License
10
# as published by the Free Software Foundation; either version 2
11
# of the License, or (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty
15
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# you should have received a copy of the GNU General Public License
19
# along with this program (or with Nagios);  if not, write to the
20
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
# Boston, MA 02111-1307, USA
22
23
use strict;
24
use English;
25
use Getopt::Long;
26
use vars qw($PROGNAME);
27
use lib "/usr/local/nagios/libexec" ;
28
use utils qw (%ERRORS &print_revision &support);
29
30
sub print_help ();
31
sub print_usage ();
32
33
my ($opt_h, $opt_V, $opt_c);
34
my ($result, $message, $mpt_path, $num_raid, $enabled );
35
36
$PROGNAME="check_mpt";
37
$mpt_path="sudo /usr/sbin/mpt-status";
38
$num_raid=2;
39
$enabled=1;
40
41
Getopt::Long::Configure('bundling');
42
GetOptions(
43
    "V" => \$opt_V, "version"       => \$opt_V,
44
    "h" => \$opt_h, "help"      => \$opt_h,
45
    "c=n"   => \$opt_c, "num_raid=n"    => \$opt_c
46
    );
47
48
if ($opt_V) {
49
    print_revision($PROGNAME, '$Id: check_mpt.pl,v 0.1 2006/05/16 15:17:49 Exp $');
50
    exit $ERRORS{'OK'};
51
}
52
53
if ($opt_h) {
54
    print_help();
55
    exit $ERRORS{'OK'};
56
}
57
58
sub print_usage () {
59
    print "Usage:\n";
60
    print "  $PROGNAME <-c numraid>\n";
61
    print "  $PROGNAME [-h | --help]\n";
62
    print "  $PROGNAME [-V | --version]\n";
63
}
64
65
sub print_help () {
66
    print_revision($PROGNAME, '$Id: check_mpt.pl,v 0.1 2006/05/16 15:17:49 Exp $');
67
    print "Copyright (c) 2006 Claudio Messineo claudio\@__no__spam__zero.it (s/__no__spam__//)\n\n";
68
    print_usage();
69
    print "\n";
70
    support();
71
}
72
73
if($opt_c =~ /^([0-9]+)$/){
74
    $num_raid = $1;
75
}
76
77
78
if ( ! open( MPT_STAT, " $mpt_path | " ) ) {
79
           print "ERROR: could not open $mpt_path  \n";
80
           exit $ERRORS{'UNKNOWN'};
81
           }
82
else {
83
        while (<MPT_STAT>) {
84
            if ( $_ =~ m/ENABLED/ ) {
85
                $enabled--;
86
            }
87
            if ( $_ =~ m/ONLINE/ ) {
88
                $num_raid--;
89
            }
90
                        next;
91
                }
92
    if (($num_raid==0) and ($enabled==0)) {
93
        print "Mpt-status OK\n";
94
        exit $ERRORS{'OK'};
95
    }
96
    else {
97
        print "Mpt-status Alert\n";
98
        exit $ERRORS{'WARNING'};
99
    }
100
}
101