« Munin HP plugin » : différence entre les versions

Aller à la navigation Aller à la recherche
3 365 octets ajoutés ,  16 décembre 2015
 
(7 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
* https://github.com/mhagander/munin-plugins
[[Category:serveur]]
[[Category:debian]]
[[Category:monitoring]]
 
* src : https://github.com/mhagander/munin-plugins


=hpacu HP Array Controllers=
=hpacu HP Array Controllers=
Ligne 234 : Ligne 238 :
if ( $ARGV[0] and $ARGV[0] eq "config") {
if ( $ARGV[0] and $ARGV[0] eq "config") {
   print "graph_title HP Fans\n";
   print "graph_title HP Fans\n";
   print "graph_category system\n";
   print "graph_category sensors\n";
   print "ok.label Fans OK\n";
   print "ok.label Fans OK\n";
   print "ok.type GAUGE\n";
   print "ok.type GAUGE\n";
Ligne 271 : Ligne 275 :


<pre>
<pre>
==
#!/usr/bin/env perl
#!/usr/bin/env perl
#
#
Ligne 335 : Ligne 338 :
if ( $ARGV[0] and $ARGV[0] eq "config") {
if ( $ARGV[0] and $ARGV[0] eq "config") {
   print "graph_title HP Power Supplies\n";
   print "graph_title HP Power Supplies\n";
   print "graph_category system\n";
   print "graph_category sensors\n";
   print "ok.label Power Supplies OK\n";
   print "ok.label Power Supplies OK\n";
   print "ok.type GAUGE\n";
   print "ok.type GAUGE\n";
Ligne 369 : Ligne 372 :
</pre>
</pre>


=l=
=hptemp=
 
diff from https://github.com/mhagander/munin-plugins:
<pre>
<    if (/^\s*(\d+)\s*Basic Sensor\s+(CPU \(\d+\)|Ambient|Processor Zone|Memory Board|System Board|Pwr\. Supply Bay|I\/O Zone|SCSI Backplane)\s+(\S+)\s+\d+F\/\s*(\d+)C\s+\d+F\/\s*(\d+)C/) {
---
>    if (/^\s*(\d+)\s*Basic Sensor\s+(CPU \(\d+\)|Processor Zone|I\/O Zone)\s+(\S+)\s+\d+F\/\s*(\d+)C\s+\d+F\/\s*(\d+)C/) {
</pre>
 
Cette regexp est susceptible d'évoluer ... en fonction des sensors de HP.
 
working plugin:
<pre>
#!/usr/bin/env perl
#
# hptemp - Munin plugin for HP server temperature
#
# Copyright (C) 2010 Magnus Hagander
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
=head1 NAME
 
hptemp - Munin plugin to monitor HP server temp
 
=head1 CONFIGURATION
 
The plugin needs to be able to execute /sbin/hplog, which requires
root permissions. The following configuration is needed:
 
  [hptemp]
  user=root
 
=head1 INTERPRETATION
 
The graphs will show the temperature measured at different locations
in the server.
 
=head1 MAGIC MARKERS
 
#%# family=contrib
 
=head1 AUTHOR
 
Magnus Hagander <magnus@hagander.net>
 
=head1 LICENSE
 
GPLv2
 
=cut
 
use strict;
use warnings;
 
use Munin::Plugin;
 
if ( $ARGV[0] and $ARGV[0] eq "autoconf") {
  print "no\n";
  exit(0);
}
 
my @sensors;
open(HPLOG, "/sbin/hplog -t |") || die "Could not run hplog\n";
while (<HPLOG>) {
  next if /^\s*$/;
  next if /^ID/;
  if (/^\s*(\d+)\s*Basic Sensor\s+(CPU \(\d+\)|Ambient|Processor Zone|Memory Board|System Board|Pwr\. Supply Bay|I\/O Zone|SCSI Backplane|Chassis)\s+(\S+)\s+\d+F\/\s*(\d+)C\s+\d+F\/\s*(\d+)C/) {
      push @sensors, {
'id' => $1,
'name' => $2,
'state' => $3,
'current' => $4,
'threshold' => $5
};
  }
  else {
      die "Could not parse line $_";
  }
}
close(HPLOG);
 
if ( $ARGV[0] and $ARGV[0] eq "config") {
  print "graph_title HP temperature\n";
  print "graph_category sensors\n";
  for my $sensor (@sensors) {
      print "s" . $sensor->{'id'} . ".label " . $sensor->{'name'} . "\n";
      print "s" . $sensor->{'id'} . ".type GAUGE\n";
      print "s" . $sensor->{'id'} . ".min 0\n";
      print "s" . $sensor->{'id'} . ".warning " . ($sensor->{'threshold'}-10) . "\n";
      print "s" . $sensor->{'id'} . ".critical " . $sensor->{'threshold'} . "\n";
  }
  print "degraded.label Temperature sensors not normal\n";
  print "degraded.type GAUGE\n";
  print "degraded.min 0\n";
  print "degraded.critical 1\n";
  exit(0);
}
 
my $notok = 0;
for my $sensor (@sensors) {
    print "s" . $sensor->{'id'} . ".value " . $sensor->{'current'} . "\n";
    $notok++ if ($sensor->{'state'} ne "Normal");
}
print "degraded.value $notok\n";
</pre>
4 231

modifications

Menu de navigation