Projet

Général

Profil

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

root / plugins / disk / megaraid-controller-information @ 64089240

Historique | Voir | Annoter | Télécharger (5,6 ko)

1
#!/usr/bin/perl -w
2
#
3
# Munin plugin for MegaRAID
4
# This plugin can graph:- Currently Drive Temperature and Error Count
5
#
6
#---------------------
7
# Examples
8
# Create a symbolic link to MegaRaid_<AdapterNumber>_<temp|error|other|predictive>
9
#       ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_0_temp
10
#           graph temperature on adapter 0
11
#
12
#       ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_0_error
13
#           graph media errors on adapter 0
14
#
15
#       ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_1_temp
16
#           graph temperature on adapter 1
17
#
18
#---------------------
19
# Log
20
# Revision 0.1  2011/04/16  idobson
21
# -First version only basic support of the MegaRaid controller
22
#
23
# Revision 0.2  2011/04/17 fkatzenb
24
# -Added bash statement to remove the log file created each time MegaCli64 is ran
25
# -Added a few comments and visual changes
26
#
27
# Revision 1.0 2011/04/17 fkatzenb
28
# -Revamped Code to symbolic link for sensor type and future growth
29
#
30
# Revision 1.1 2011/04/17 fkatzenb
31
# -Revised scalling
32
#
33
# Revision 1.2 2011/04/28 fkatzenb
34
# -Added support for graph_info support
35
# -Added warning & critical alerts support
36
# -Added data info
37
#
38
# Revision 2.0 2011/04/29 fkatzenb
39
# -Added remaining support for SMART Errors
40
#
41
# Revision 2.1 2011/04/29 fkatzenb
42
# -Added version information for in the graph description
43
#
44
#
45
#---------------------
46
#
47
# Add the following to your /etc/munin/plugin-conf.d/munin-node:
48
#
49
#       [MegaRaid_*]
50
#       user root
51
#
52
#---------------------
53
#
54
#
55
# Magic markers (optional - used by munin-config and installation scripts):
56
#
57
#%# family=auto
58
#%# capabilities=autoconf
59
#
60
my $DisplayVer=2.1;
61

    
62
use strict;
63
use warnings;
64

    
65
my $DevID=0; 		#Device Number found
66
my $DevData=0; 		#Device Data found
67

    
68
# Parse out Adapter number and parameter desired from file name and remove whitespace
69
my $Parameters=`basename $0 | sed 's/^MegaRaid_//g' | tr '_' '-'` ;
70
chomp $Parameters;
71
my ($Adapter,$Type)=split(/-/,$Parameters);
72

    
73
# Locate MegaCli64 application and remove whitespace
74
my $Command=`which MegaCli64 megacli | head -n 1`;
75
chomp $Command;
76

    
77
# Use this to define future parameters to monitor
78
my %config = (
79
  temp => {
80
    lookfor => 'Drive Temperature :',
81
    label => 'Temp',
82
    title => "MegaRAID Adapter $Adapter: Drive Temperatures",
83
    vlabel => 'Celsius',
84
    graph_args => '--base 1000 -l 0',
85
    warning => '55',
86
    critical => '65',
87
    info_tag => "Temperature (C)",
88
    description => "Internal Temperatures for drives on Adapter $Adapter."
89
  },
90
  error => {
91
    lookfor => 'Media Error Count: ',
92
    label => 'Media Err',
93
    title => "MegaRAID Adapter $Adapter: Media Errors (SMART)",
94
    vlabel => 'Number of Errors',
95
    graph_args => '--base 1000 -l 0',
96
    warning => '',
97
    critical => '',
98
    info_tag => "Media Errors (SMART)",
99
    description => "Number of SMART errors related to the drive's media on Adapter $Adapter."
100
  },
101
  other => {
102
    lookfor => 'Other Error Count: ',
103
    label => 'Other Err',
104
    title => "MegaRAID Adapter $Adapter: Others Errors (SMART)",
105
    vlabel => 'Number of Errors',
106
    graph_args => '--base 1000 -l 0',
107
    warning => '',
108
    critical => '',
109
    info_tag => "Other Errors (SMART)",
110
    description => "Number of SMART errors not related to the drive's media on Adapter $Adapter."
111
  },
112
  predictive => {
113
    lookfor => 'Predictive Failure Count: ',
114
    label => 'Predictive Err',
115
    title => "MegaRAID Adapter $Adapter: Predictive Errors (SMART)",
116
    vlabel => 'Number of Errors',
117
    graph_args => '--base 1000 -l 0',
118
    warning => '',
119
    critical => '',
120
    info_tag => "Predictive Errors (SMART)",
121
    description => "Number of SMART errors for each drive on Adapter $Adapter."
122
  }
123
);
124

    
125
#Auto config options
126
if ($ARGV[0] and $ARGV[0] eq "autoconf" ) {
127
   if (-e $Command ) {
128
      print "yes\n";
129
      } else {
130
      print "no\n";
131
     }
132
     exit 0;
133
}
134

    
135
#Read Output of MegaRaid command
136
$Command.=" -PDList -a".$Adapter;
137
my @Output=qx($Command);
138

    
139
#Munin Config Options
140
if ($ARGV[0] and $ARGV[0] eq "config"){
141
   print "graph_title $config{$Type}->{title}\n";
142
   print "graph_vlabel $config{$Type}->{vlabel}\n";
143
   print "graph_args $config{$Type}->{graph_args}\n";
144
   print "graph_scale yes\n";
145
   print "graph_category disk\n";
146
   print "graph_info $config{$Type}->{description} <br />Generated by MegaRaid_, Version $DisplayVer<br />\n";
147

    
148
   foreach my $Line (@Output) {
149
      $Line=~ s/\r//g;
150
      $Line=~ s/\n//g;
151

    
152
      #Find the device ID
153
      if ( $Line=~ m/Slot Number: /i ) {
154
         $DevID=$Line;
155
         $DevID=~ s/Slot Number: //;
156
         print "A".$Adapter."_D".$DevID."_$Type.label A$Adapter:D$DevID $config{$Type}->{label}\n";
157
         print "A".$Adapter."_D".$DevID."_$Type.info Adapter: $Adapter / Drive: $DevID - $config{$Type}->{info_tag}\n";
158
         if ($config{$Type}->{warning} ne '' ) {
159
            print "A".$Adapter."_D".$DevID."_$Type.warning $config{$Type}->{warning}\n";
160
            }
161
         if ($config{$Type}->{critical} ne '') {
162
            print "A".$Adapter."_D".$DevID."_$Type.critical $config{$Type}->{critical}\n";
163
            }
164
      }
165
   }
166
   exit 0;
167
}
168

    
169
#Actually dump the data
170
foreach my $Line (@Output) {
171
   $Line=~ s/\r//g;
172
   $Line=~ s/\n//g;
173

    
174
   #Find the device ID
175
   if ( $Line=~ m/Slot Number: /i ) { $DevID=$Line; $DevID=~ s/Slot Number: //; chomp $DevID; }
176

    
177
   #Find the data and print it out
178
   if ( $Line=~ m/$config{$Type}->{lookfor}/i ) {
179
      $DevData=$Line;
180
      $DevData=~s/$config{$Type}->{lookfor}//;
181
      $DevData=~s/C.*//;
182
      chomp $DevData;
183
      print "A".$Adapter."_D".$DevID."_$Type.value $DevData\n";
184
   }
185
}
186

    
187
#Remove log file created by running MegaCli
188
   unlink "MegaSAS.log";
189

    
190
exit 0;