Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / raid @ 55847bc8

Historique | Voir | Annoter | Télécharger (1,49 ko)

1
#!/usr/bin/perl -w
2
# 
3
# (c) 2007 Nathan Rutman nathan@clusterfs.com
4
#
5
# Plugin to monitor RAID status 
6
#
7
# Results are % of healthy drives in a raid device
8
#
9
#
10
#%# family=contrib
11
#%# capabilities=autoconf
12

    
13
if ($ARGV[0] and $ARGV[0] eq "autoconf")
14
{
15
    if (-r "/proc/mdstat" and `grep md /proc/mdstat`)
16
    {
17
	print "yes\n";
18
	exit 0;
19
    }
20
    else
21
    {
22
	print "no RAID devices\n";
23
	exit 1;
24
    }
25
}
26

    
27
if ( $ARGV[0] and $ARGV[0] eq "config" )
28
{
29
    print "graph_title RAID status\n";
30
    print "graph_category disk\n";
31
    print "graph_info This graph monitors RAID disk health.  Values are percentage of healthy drives in each raid group.  Degraded devices are marked Critical.\n";
32
    print "graph_args --base 1000 -l 0\n";
33
    print "graph_vlabel % healthy\n";
34
    print "graph_scale  no\n";
35
}
36

    
37
{
38
    local( $/, *MDSTAT ) ;
39
    open (MDSTAT, "/proc/mdstat") or exit 1;
40
    #open (MDSTAT, "/etc/munin/plugins/sample.failed") or exit 1;
41
    my $text = <MDSTAT>;
42
    close MDSTAT;
43

    
44
    while ($text =~ /(md\d)\s+:\s+active\s+(\w+)\s+(.*)\n.*\[(\d+)\/(\d+)]\s+\[(\w+)]/ )
45
    {
46
	my($dev,$type,$members,$nmem,$nact,$status) = ($1,$2,$3,$4,$5,$6);
47
	#print "item: $dev $type ($members) status=$status \n";
48
	if ( $ARGV[0] and $ARGV[0] eq "config" ) 
49
	{
50
	    print "$dev.label $dev\n";
51
	    print "$dev.info $type $members\n";
52
	    # 100: means less than 100
53
	    print "$dev.critical 100:\n";	
54
	} 
55
	else
56
	{
57
	    my $pct = 100 * $nact / $nmem; 
58
	    print "$dev.value $pct\n";
59
	}
60
	$text = $';
61
    } 
62
}
63

    
64
exit 0;
65

    
66
# vim:syntax=perl
67