LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   munin sensors plugin (http://www.linuxquestions.org/questions/linux-software-2/munin-sensors-plugin-452171/)

asgozzi 06-06-2006 02:23 PM

munin sensors plugin
 
hi.

I recently installed the munin software (munin.projects.linpro.no) to monitor workstations and servers in my LAN.
from the servers I am able to get all the infos I need (cpu, ram, inodes, etc..) but with the hot italian summer approaching I would like to monitor the workstation's sensors too.

the problem is I can't configure properly the munin-node plugin in order to send the munin server data like CPU temperature, fans speeds and voltages.
I read at least twice all the documents on the official munin website but I still can't figure out if the plugin code has to be edited or if I need to set special environment variables.

the plugin requires lm-sensors and the the i2c modules and I have both:
Quote:

osmosis:/etc# sensors
it87-isa-0290
Adapter: ISA adapter
VCore 1: +1.54 V (min = +1.42 V, max = +1.57 V)
VCore 2: +2.50 V (min = +2.40 V, max = +2.61 V)
+3.3V: +0.00 V (min = +3.14 V, max = +3.47 V) ALARM
+5V: +0.00 V (min = +4.76 V, max = +5.24 V) ALARM
+12V: +0.00 V (min = +11.39 V, max = +12.61 V) ALARM
-12V: -27.36 V (min = -12.63 V, max = -11.41 V) ALARM
-5V: -13.64 V (min = -5.26 V, max = -4.77 V) ALARM
Stdby: +4.44 V (min = +4.76 V, max = +5.24 V) ALARM
VBat: +3.31 V
fan1: 1577 RPM (min = 0 RPM, div = 8)
fan2: 5273 RPM (min = 3013 RPM, div = 8)
CPU Temp: +48C (low = +15C, high = +45C) sensor = diode
followind the official documentation I tried running manually the plugin with the following arguments:

Quote:

osmosis:/etc/munin/plugins# ./sensors autoconf
yes
Quote:

osmosis:/etc/munin/plugins# ./sensors suggest
fan
volt
temp
I also tried 'conf' but that gives no output at all.

I'm sorry for the (maybe) dumb question but I really don't know where to look :confused:


this is the plugin code:
Code:

#!/usr/bin/perl -w
# -*- perl -*-
# Wildcard plugin to monitor sensors.
#
# Requirements:
#        - i2c and lm_sensors modules installed and loaded
#        - sensors program installed and in path
#
# Note:
#        - Sensor names are read from the output of the sensors program.
#          Change them in /etc/sensors.conf if you don't like them.
#
# Parameters supported:
#
#        config
#        autoconf
#        suggest
#
# Configurable variables
#
#        sensors          - Override default program
#        ignore_temp<n>    - Temperature <n> will not be plotted
#        ignore_fan<n>    - Fan <n> will not be plotted
#        ignore_volt<n>    - Voltage <n> will not be plotted
#        fan_warn_percent  - Percentage over mininum for warning
#        volt_warn_percent - Percentage over mininum/under maximum for warning
#                            Narrow the voltage bracket by this.
#
# $Log$
# Revision 1.10  2004/12/15 15:40:12  jimmyo
# Fixed typo in graph_category.
#
# Revision 1.9  2004/11/23 17:08:25  ilmari
# Fixed linux/sensors_ plugin to report warning and critical values for temperatures and voltages if sensors reports them.
#
# Revision 1.3.2.3  2004/08/18 17:27:15  jimmyo
# Made linux/sensors_volt work with negative voltages (Deb#256734).
#
# Revision 1.3.2.2  2004/08/18 17:20:29  jimmyo
# linux/sensors_temp now understand temp lines without hyst or max settings (Deb#256380).
#
# Revision 1.3.2.1  2004/08/18 17:01:01  jimmyo
# Force LANG/LC_ALL=C in linux/sensors_ and generic/hddtemp2, to remove problems in parsing of sensors output (SF#972749, SF#972748, Deb#255312)
#
# Revision 1.3  2004/04/28 21:46:41  jimmyo
# Sensors-* patch from SF#906868.
#
# Revision 1.2  2004/04/27 21:55:43  jimmyo
# Patched temp-part of linux-pugin sensors_* with better regexp (Deb#245289).
#
# Revision 1.1  2004/02/05 16:47:02  jimmyo
# Added new wildcard plugin linux/sensors_ that replaces the i2c plugins (SF#890952).
#
#
#
# Magic markers:
#%# family=manual
#%# capabilities=autoconf suggest

use strict;

$ENV{'LANG'} = "C"; # Force parseable output from sensors.
$ENV{'LC_ALL'} = "C"; # Force parseable output from sensors.
my $SENSORS = $ENV{'sensors'} || 'sensors';
my %config = (
              fan => {
                        regex => qr/^(\S[^:]*)\s*:\s+\+?(\d+) RPM.*?(\d+) RPM/m,
                        title => 'Fans',
                        vtitle => 'RPM',
                        print_threshold => \&fan_threshold,
                        graph_args => '--base 1000 -l 0'
                      },
              temp => {
                        regex => qr/^(\S[^:]*)\s*:\s+\+?(\d+(?:\.\d+)?)[ ]C(?:\s+\((?:high|limit)\s*=\s*\+?(\d+(?:\.\d+)?)[ ]C,\s*hyst(?:eresis)?\s*=\s*\+?(\d+(?:\.\d+)?)[ ]C\))?/m,
                        title => 'Temperatures',
                        vtitle => 'Celsius',
                        print_threshold => \&temp_threshold,
                        graph_args => '--base 1000 -l 0'
                      },
              volt => {
                        regex => qr/^(\S[^:]*)\s*:\s+\+?(-?\d+(?:\.\d+)?) V(?:\s+\(min\s*=\s*\+?(-?\d+(?:\.\d+)?) V,\s*max\s*=\s*\+?(-?\d+(?:\.\d+)?) V\))/m,
                        title => 'Voltages',
                        vtitle => 'Volt',
                        print_threshold => \&volt_threshold,
                        graph_args => '--base 1000 --logarithmic'
                      },
            );

if ( exists $ARGV[0] and $ARGV[0] eq 'autoconf' ) {
  # Now see if "sensors" can run
  my $text = `$SENSORS`;
  if ($?) {
    if ($? == -1) {
      print "no (program $SENSORS not found)\n";
    } else {
      print "no (program $SENSORS died)\n";
    }
    exit 1;
  }

  unless ($text =~ /[ ]C/) {
    print "no (no temperature readings)\n";
    exit 1;
  }

  print "yes\n";
  exit 0;
}

if ($ARGV[0] and $ARGV[0] eq 'suggest') {
  my $text = `$SENSORS`;
  foreach my $func (keys %config) {
    print $func, "\n" if $text =~ $config{$func}->{regex};
  }
  exit;
}

$0 =~ /sensors_(.+)*$/;
my $func = $1;
exit 2 unless defined $func;

if (exists $ARGV[0] eq 'config' ) {
  print "graph_title $config{$func}->{title}\n";
  print "graph_vtitle $config{$func}->{vtitle}\n";
  print "graph_args $config{$func}->{graph_args}\n";
  print "graph_category sensors\n";
  my $text = `$SENSORS`;
  my $sensor = 1;
  while ($text =~ /$config{$func}->{regex}/g) {
    my ($label, undef, $max, $min) = ($1, $2, $3, $4);
    print "$func$sensor.label $label\n";
    $config{$func}->{print_threshold}->($func.$sensor, $3, $4);
    print "$func$sensor.graph no\n" if exists $ENV{"ignore_$func$sensor"};
    $sensor++;
  }
  exit 0;
}

my $text = `$SENSORS`;
my $sensor = 1;
while ($text =~ /$config{$func}->{regex}/g) {
  print "$func$sensor.value $2\n";
  $sensor++;
}


# vim:syntax=perl


cosmicharade 03-27-2009 04:32 AM

did you work it out
 
I have the same problem! argh...

hasienda 05-30-2009 07:43 AM

Some hints
 
Quote:

Originally Posted by asgozzi (Post 2280177)
hi.
I recently installed the munin software (munin.projects.linpro.no) to monitor workstations and servers in my LAN. [snip]

Well, I was there some days ago, when setting up a system for myself. There are some questions left for me too, but at least I think I got behind the point, from where you were asking below. So expect an answer from a not much wiser colleague :-)
Quote:

Originally Posted by asgozzi (Post 2280177)
the problem is I can't configure properly the munin-node plugin in order to send the munin server data like CPU temperature, fans speeds and voltages.

Don't confuse server and client tasks. The Munin server is pulling data from the node(s). A Munin node (client) will never contact the server on it's own, regardless of the server running at localhost or on another machine.
I guess, you're running both - server and node scripts - on the same machine. This is covered by the standard Munin configuration AFAIK from my install (Debian GNU/Linux package for lenny aka 5.0). A central Munin server collecting data from multiple machines seems not to hard to configure and requires some additional statements in the Munin server configuration file typically located at /etc/munin/munin.conf .
Quote:

Originally Posted by asgozzi (Post 2280177)
I read at least twice all the documents on the official munin website but I still can't figure out if the plugin code has to be edited or if I need to set special environment variables.

Well, I see a bunch of plug-in scripts in /usr/share/munin/plugins , but you need to link each script to /etc/munin/plugins like this
Code:

#> ls -al /etc/munin/plugins/
total 8
drwxr-xr-x 2 root root 4096 May 29 23:15 .
drwxr-xr-x 5 root root 4096 May 16 22:49 ..
lrwxrwxrwx 1 root root  34 May 25 00:24 apt-proxy -> /usr/share/munin/plugins/apt-proxy
lrwxrwxrwx 1 root root  32 May 24 22:53 bind95 -> /usr/share/munin/plugins/bind95_
lrwxrwxrwx 1 root root  28 May 16 22:49 cpu -> /usr/share/munin/plugins/cpu
lrwxrwxrwx 1 root root  27 May 16 22:49 df -> /usr/share/munin/plugins/df
[snip]

Plug-ins with a name ending in "_" are special. By running it like this
Code:

#> munin-run sensors_fan suggest
fan
volt
temp

It is telling you, that you may create the three different links
Code:

sensors_fan -> /usr/share/munin/plugins/sensors_
sensors_volt -> /usr/share/munin/plugins/sensors_
sensors_temp -> /usr/share/munin/plugins/sensors_

to make full use of it's capabilities.

Configuration hints reside inside each plug-in script. Just open it with your favorite editor. In the header you should find hints about options for that plug-in to be put into the central Munin plug-in configuration file /etc/munin/plugin-conf.d/munin-node . Editing the scripts is often not necessary, but you may customize them or even create your own as you like (if you're able to do so).
Quote:

Originally Posted by asgozzi (Post 2280177)
the plugin requires lm-sensors and the the i2c modules and I have both:


followind the official documentation I tried running manually the plugin with the following arguments: [snip]

You are looking for this:
Code:

#>  munin-run sensors_fan     
fan1.value 0
fan2.value 4891

Yes, it's that easy, if lm-sensors/libsensors4 is configured well in /etc/sensors3.conf (current) or /etc/sensors.conf (old location). That is a different thing, but your output of the "sensors" command seems ok.
Quote:

Originally Posted by asgozzi (Post 2280177)
I also tried 'conf' but that gives no output at all.

Expect to see nothing. You'll see more with a slightly different call:
Code:

#> munin-run sensors_fan config
graph_title Fans
graph_vtitle RPM
graph_args --base 1000 -l 0
graph_category sensors
fan1.label Case Fan
fan1.warning 1394:
fan1.critical 1328:
fan2.label CPU Fan
fan2.warning 4428:
fan2.critical 4218:

Quote:

Originally Posted by asgozzi (Post 2280177)
I'm sorry for the (maybe) dumb question but I really don't know where to look :confused:


this is the plugin code: [snip]

I know, in fact this is Debian/GNU Linux too, right? :-)

You have a WWW server at the same machine Munin is running on? If not, you'll have to install one, to get the graphs in /var/www/munin by directing you Browser of choice to <munin-server-ip>/munin .

Hope, that will give you something to continue.

gshergill 08-20-2012 04:39 AM

Munin - sensors_ and ipmi_
 
Hi,

I know this is 3 years after the last post... but hopefully there is a response =)

I've ran the command,

Code:

munin-run sensors_fan
Can't exec "sensors": No such file or directory at /etc/munin/plugins/sensors_fan line 282.
Use of uninitialized value $text in pattern match (m//) at /etc/munin/plugins/sensors_fan line 284.

I'm wondering if someone can send me their config for the file,

sensors_

or preferably for the file,

ipmi_

ipmi_ mostly works, but there are no graphics displayed on the web interface.

Thank you for your time.

Kind Regards,

gshergill

hasienda 08-21-2012 02:06 PM

Config? Not the problem
 
Quote:

Originally Posted by gshergill (Post 4758913)
Hi,

I know this is 3 years after the last post... but hopefully there is a response =)

I've ran the command,

Quote:

Code:

munin-run sensors_fan
Can't exec "sensors": No such file or directory at /etc/munin/plugins/sensors_fan line 282.
Use of uninitialized value $text in pattern match (m//) at /etc/munin/plugins/sensors_fan line 284.

I'm wondering if someone can send me their config for the file,
Most probably configuration is not the problem here. Don't you see: "No such file or directory ..."? Munin sensor scripts don't automatically install the required programs, that they rely upon.

I bet you're missing the appropriate programs. So install matching versions of 'lib-sensors<n>' and 'lm-sensors', preferably with your package manager, whatever flavor you use, and check again, please.

gshergill 08-22-2012 03:35 AM

Hi hasienda,

Perfect reply! Thank you.

The issue was that lm-sensors was missing, I didn't realise it was not installed as part of the package.

Applied your solution to the issue with "ipmi_", and it worked perfectly too (ipmitool in this case). Now comes the attempt to integrate all of this with Nagios XI...

Thanks a lot for the reply, really appreciated the help.

Kind Regards,

gshergill


All times are GMT -5. The time now is 08:29 PM.