1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Plugin-Gallery: Get better 2nd level headings

sensors, weather, snmp
This commit is contained in:
dipohl 2017-02-24 17:30:35 +01:00
parent 37d658526b
commit 95de964ec9
24 changed files with 10 additions and 10 deletions

View file

@ -1,168 +0,0 @@
#!/usr/bin/env python
# coding=iso-8859-1
"""
=head1 NAME
esxi__sensors - Munin plugin to monitor hardware sensors in a VMware ESXi
installation.
=head1 APPLICABLE SYSTEMS
VMware ESX and ESXi systems. Might work with other systems that use CIM and
CIM_NumericSensors, probably with changes to the namespace.
The host on which the plugin is run must have the pywbem Python library
installed.
=head1 CONFIGURATION
The remote host name is taken from the plugin name as the SNMP plugins are;
to monitor host 192.168.1.15, symlink the plugin to esxi_192.168.1.15_sensors .
The username and password for accessing the ESXi system must be set in a config
file:
[esxi_192.168.1.15_*]
env.user monitor
env.pass passw0rd
To create an account just for monitoring the ESXi, add a user to the host,
make it a member of the 'root' group, and give it the 'No access' role.
That will allow the account to connect via WBEM, but not via any of the
management tools.
In the event that not all sensor types are desired, the plugin can be limited
to a subset of the types available:
env.sensors 2 3 5
Check the sensor_data dictionary at the top of the script to see what sensor
types are available.
=head1 INTERPRETATION
This is a multigraph plugin that will generate separate graphs for each type
of sensor. The names of the sensors are taken from the ESXi host.
If the host provides error thresholds for the sensor readings, those will be
passed along to munin.
=head1 VERSION
1.0
=head1 AUTHOR
Phil Gold <phil_g@pobox.com>
=head1 LICENSE
To the extent possible under law, the author(s) have dedicated all copyright and
related and neighboring rights to this software to the public domain worldwide
under a CC0 waiver. This software is distributed without any warranty.
http://creativecommons.org/publicdomain/zero/1.0/
=cut
"""
import os, sys
import re, string
import pywbem
NS = 'root/cimv2'
sensor_data = {
2 : {'prefix':'temp', 'title':'Temperatures', 'unit':'°C'},
3 : {'prefix':'volt', 'title':'Voltages', 'unit':'Volts'},
4 : {'prefix':'amp', 'title':'Current', 'unit':'Amps'},
5 : {'prefix':'fan', 'title':'Fans', 'unit':'RPM'}
}
def munin_id(instance):
return sensor_data[instance['SensorType']]['prefix'] + \
re.sub('[^a-zA-Z0-9]', '_', instance['DeviceId'])
def inst_val(instance, field):
return instance[field] * 10 ** instance['UnitModifier']
def munin_warning(instance):
if not instance['EnabledThresholds']:
return ':'
result = ''
if 0 in instance['EnabledThresholds']:
result += str(inst_val(instance, 'LowerThresholdNonCritical'))
result += ':'
if 1 in instance['EnabledThresholds']:
result += str(inst_val(instance, 'UpperThresholdNonCritical'))
return result
def munin_critical(instance):
if not instance['EnabledThresholds']:
return ':'
result = ''
if 2 in instance['EnabledThresholds']:
result += str(inst_val(instance, 'LowerThresholdCritical'))
elif 4 in instance['EnabledThresholds']:
result += str(inst_val(instance, 'LowerThresholdFatal'))
result += ':'
if 3 in instance['EnabledThresholds']:
result += str(inst_val(instance, 'UpperThresholdCritical'))
elif 5 in instance['EnabledThresholds']:
result += str(inst_val(instance, 'UpperThresholdFatal'))
return result
def print_sensors(sensor_type, instances, config):
print 'multigraph esxi_' + sensor_data[sensor_type]['prefix'] + 's'
if config:
print "graph_title ESXi " + sensor_data[sensor_type]['title']
print "graph_args --base 1000 -l 0"
print "graph_vlabel " + sensor_data[sensor_type]['unit']
print "graph_category sensors"
for i in instances:
if i['SensorType'] == sensor_type:
print '{0}.label {1}'.format(munin_id(i), i['Caption'])
print '{0}.max {1}'.format(munin_id(i), inst_val(i, 'MaxReadable'))
print '{0}.min {1}'.format(munin_id(i), inst_val(i, 'MinReadable'))
if munin_warning(i) != ':':
print '{0}.warning {1}'.format(munin_id(i), munin_warning(i))
if munin_critical(i) != ':':
print '{0}.critical {1}'.format(munin_id(i), munin_critical(i))
print ''
return
for i in instances:
if i['SensorType'] == sensor_type:
print '{0}.value {1}'.format(munin_id(i), inst_val(i, 'CurrentReading'))
print ''
plugin_name = list(os.path.split(sys.argv[0]))[1]
host = plugin_name[string.index(plugin_name, '_')+1:string.rindex(plugin_name, '_')]
if host == '':
sys.stderr.write("No hostname found.\n")
exit(1)
try:
username = os.environ['user']
password = os.environ['pass']
except KeyError:
sys.stderr.write("Username and password must be specified.\n")
exit(1)
try:
sensors = map(int, re.split(',? +', os.environ['sensors']))
except:
sensors = [2, 3, 4, 5]
config = len(sys.argv) > 1 and sys.argv[1] == 'config'
wbemclient = pywbem.WBEMConnection('https://' + host, (username, password), NS)
insts = sorted(wbemclient.EnumerateInstances('CIM_NumericSensor'))
print 'host_name ' + host
for sensor_type in sensors:
print_sensors(sensor_type, insts, config)

View file

@ -1,200 +0,0 @@
#!/usr/bin/perl -w
# -*- cperl -*-
=head1 NAME
freeipmi - Multigraph-plugin to monitor sensors using FreeIPMI
=head1 CONFIGURATION
When used to monitor the local host, plugin config should define user root for direct ipmi access:
[freeipmi]
user root
=head2 ENVIRONMENT VARIABLES
When used to monitor a foreign host, this plugins use the variables
IPMI_USERNAME and IPMI_PASSWORD to log in on the remote system.
=head2 WILDCARD PLUGIN
When used for the local host, the plugin should be linked as
non-wildcard plugin, i.e., 'freeipmi', whereas when used to monitor a
foreign host it should be, e.g., 'freeipmi_192.168.0.253'.
=head1 DEPENDENCIES
The plugin requires FreeIPMI 1.1.5 or later to fetch the information.
Limits set on thresholds are available when using FreeIPMI 1.2.0 or
later.
=head1 AUTHOR
Diego Elio Pettenò <flameeyes@flameeyes.eu>.
With help and suggestions of:
Bart ten Brinke <info@retrosync.com>
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
use strict;
use Munin::Plugin;
$ENV{'LANG'} = "C"; # Force parsable output from sensors.
$ENV{'LC_ALL'} = "C"; # Force parsable output from sensors.
my $IPMISENSORS = $ENV{'ipmisensors'} || 'ipmi-sensors';
$0 =~ /freeipmi(?:_(.+))$/;
my $hostname = $1;
my $help_output = `$IPMISENSORS --help`;
$IPMISENSORS .= " --output-sensor-thresholds" if $help_output =~ /--output-sensor-thresholds/;
$IPMISENSORS .= " --quiet-cache --comma-separated-output --no-header-output --ignore-not-available-sensors --sensor-types=Temperature,Fan,Current,Voltage";
$IPMISENSORS .= " --hostname=$hostname" if defined($hostname);
$IPMISENSORS .= " --username=$ENV{IPMI_USERNAME}" if defined($ENV{IPMI_USERNAME});
$IPMISENSORS .= " --password=$ENV{IPMI_PASSWORD}" if defined($ENV{IPMI_PASSWORD});
my $output=`$IPMISENSORS 2>/dev/null`;
my $retval=$?;
if ( defined $ARGV[0] and $ARGV[0] eq 'autoconf' ) {
if ($retval >= 1) {
print "no (ipmi-sensors died)\n";
} elsif ($retval == -1) {
print "no (ipmi-sensors not found)\n";
} elsif ($output eq "\n") {
print "no (no compatible sensors)\n";
} else {
print "yes\n";
}
exit 0;
}
my %sensors = (
temp => {
inputs => [],
title => "Temperatures by IPMI",
vlabel => "Degrees Celsius",
graph_args => "--base 1000 -l 0",
},
fan => {
inputs => [],
title => "Fans speed by IPMI",
vlabel => "RPM",
graph_args => "--base 1000 -l 0",
},
power => {
inputs => [],
title => "Power by IPMI",
vlabel => "W",
graph_args => "--base 1000 -l 0",
},
current => {
inputs => [],
title => "Current by IPMI",
vlabel => "A",
graph_args => "--base 1000 -l 0",
},
voltage => {
inputs => [],
title => "Voltages by IPMI",
vlabel => "Volt",
graph_args => "--base 1000 --logarithmic",
},
);
my @data = split(/\n/, $output);
foreach my $line (@data) {
my @dataline = split(/,/, $line);
# skip values that are not useful
next if $dataline[3] eq "N/A";
my %sensor = (
graphid => "ipmi" . $dataline[0],
value => $dataline[3],
label => $dataline[1]
);
$sensor{lwarn} = (defined($dataline[7]) and $dataline[7] ne "N/A") ? $dataline[7] : '';
$sensor{hwarn} = (defined($dataline[8]) and $dataline[8] ne "N/A") ? $dataline[8] : '';
$sensor{lcrit} = (defined($dataline[6]) and $dataline[6] ne "N/A") ? $dataline[6] : '';
$sensor{hcrit} = (defined($dataline[9]) and $dataline[9] ne "N/A") ? $dataline[9] : '';
my $type;
if ( $dataline[2] eq "Temperature" ) {
$type = "temp";
} elsif ( $dataline[2] eq "Fan" ) {
$type = "fan"
} elsif ( $dataline[2] eq "Current" and $dataline[4] eq "W" ) {
$type = "power";
} elsif ( $dataline[2] eq "Current" and $dataline[4] eq "A" ) {
$type = "current";
} elsif ( $dataline[2] eq "Voltage" ) {
$type = "voltage";
}
push(@{$sensors{$type}->{inputs}}, \%sensor);
}
if ( defined $ARGV[0] and $ARGV[0] eq 'config' ) {
foreach my $type (keys %sensors) {
# don't print anything if no value is found
next if scalar(@{$sensors{$type}->{inputs}}) == 0;
print "host_name $hostname" if defined($hostname);
print <<END;
multigraph freeipmi_$type
graph_title $sensors{$type}->{title}
graph_vlabel $sensors{$type}->{vlabel}
graph_args $sensors{$type}->{graph_args}
graph_category sensors
END
foreach my $sensor (@{$sensors{$type}->{inputs}}) {
print "$sensor->{graphid}.label $sensor->{label}\n";
print "$sensor->{graphid}.warning $sensor->{lwarn}:$sensor->{hwarn}\n"
unless $sensor->{lwarn} eq '' and $sensor->{hwarn} eq '';
print "$sensor->{graphid}.critical $sensor->{lcrit}:$sensor->{hcrit}\n"
unless $sensor->{lcrit} eq '' and $sensor->{hcrit} eq '';
}
}
unless ( ($ENV{MUNIN_CAP_DIRTYCONFIG} || 0) == 1 ) {
exit 0;
}
}
foreach my $type (keys %sensors) {
# don't print anything if no value is found
next if scalar(@{$sensors{$type}->{inputs}}) == 0;
print "multigraph freeipmi_$type\n";
foreach my $sensor (@{$sensors{$type}->{inputs}}) {
print "$sensor->{graphid}.value $sensor->{value}\n";
}
}

View file

@ -1,72 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) Viktoras Pecia 2010(Based on 2006 Lars Strand "temperatures" code)
#
# Plugin to fetch humidity from weather.noaa.gov
#
# Parameters supported:
#
# config
# autoconf
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
use strict;
my @wcode = undef;
if (defined($ENV{wcode})) {
@wcode = split(' ', $ENV{wcode});
} else {
@wcode = ("EYSA","EYKA","EYPA","EYVI");
}
my $proxy = $ENV{proxy} || undef; # Example: "http://proxy.foo.bar:8080/"
my $ret = undef;
if (! eval "require LWP::UserAgent;")
{
$ret = "LWP::UserAgent not found";
}
if (defined $ARGV[0] and $ARGV[0] eq "autoconf") {
if (defined $ret) {
print "no ($ret)\n";
exit 1;
} else {
print "yes\n";
exit 0;
}
}
my $datasource = "http://weather.noaa.gov/pub/data/observations/metar/decoded/";
my $ua = LWP::UserAgent->new(timeout => 30);
$ua->agent('Munin');
# Use proxy, if defined.
if (defined($proxy)) {
$ua->proxy(['http'], $proxy);
}
if (defined $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title Humidity\n";
print "graph_args --base 1000 -l 0\n";
print "graph_category sensors\n";
print "graph_info This graph shows humidity fetched from weather.nooa.gov.\n";
print "graph_vlabel humidity in %\n";
for my $station (@wcode) {
my $url = "$datasource$station.TXT";
my $response = $ua->request(HTTP::Request->new('GET',$url));
# New York City, Central Park, NY, United States (KNYC) 40-47-00N 073-58-00W 48M
if ($response->content =~ /^((.*?),.*\)).*\n/) {
print "$station.label $2\n";
print "$station.info $1\n";
} else {
print "$station.label $station\n";
}
}
}
for my $station (@wcode) {
my $url = "$datasource$station.TXT";
my $response = $ua->request(HTTP::Request->new('GET',$url));
if ($response->content =~ /Relative Humidity:\s*(\d+)\%.*/) {
print "$station.value $1\n";
} else {
print "$station.value U\n";
}
}

View file

@ -1,92 +0,0 @@
#!/bin/bash
# Plugin to monitor harddrive temperatures connected to a MegaRAID controller
#
# Plugin must be ran as root so add these configuration in
# /etc/munin/plugin-conf.d/munin-node.
#
# [megacli*]
# user root
#
# -----------
# 2011-06-10 ver 1.0
# - initial version
# TODO
# - allow override of tool path via config
# 32-bit or 64-bit
if [[ $( uname -a | grep x86_64 ) ]]
then
MEGACLI='/opt/MegaRAID/MegaCli/MegaCli64'
else
MEGACLI='/opt/MegaRAID/MegaCli/MegaCli'
fi
if [[ ! -x $MEGACLI ]]
then
echo "FATAL ERROR: $MEGACLI not found or not executable!"
exit 1
fi
declare -a output
IFS=$'\n'
output=($($MEGACLI -PDList -aALL -NoLog | grep -E 'Inquiry Data:|Drive Temperature' | cut -f2 -d:))
unset IFS
# TODO
# - if array size is odd, there's a problem, exit?
output_size=${#output[*]}
if [ "$1" = "config" ]
then
echo 'graph_title MegaCli HDD temperature'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel temp in °C'
echo 'graph_category sensors'
i=0
while [[ $i -lt $output_size ]]
do
if [ $((i % 2)) -eq 0 ]
then
label=$( echo ${output[$i]} | perl -ne \
's/^\s*|\s*$//; print;' )
# TODO:
# - add other brands??
# remove brand name, just model and serial number
label_graph=$( echo ${output[$i]} | perl -ne \
's/SEAGATE|MAXTOR|WDC//i; s/^\s*|\s*$//; print;' )
echo $(echo $label | tr ' ' _).label $label_graph
fi
(( i++ ))
done
exit 0
fi
# print label and corresponding value
# - even -> label
# - odd -> value
i=0
while [[ $i -lt $output_size ]]
do
if [ $((i % 2)) -eq 0 ]
then
label=$( echo ${output[$i]} | perl -ne 's/^\s*|\s*$//; print;' )
echo -n $(echo $label | tr ' ' _).value
else
value=$( echo ${output[$i]} | cut -f1 -dC )
echo " $value"
fi
(( i++ ))
done

View file

@ -1,99 +0,0 @@
#!/usr/bin/perl -w
# Author: William Viker <william.viker@gmail.com>
# Version: 0.1
# Non-members may check out a read-only working copy anonymously over HTTP.
# $ svn checkout http://wfrogmunin.googlecode.com/svn/trunk/ wfrogmunin-read-only
# TODO:
# * Wait a couple of hours to see if this actually works.
# * Add proper data labels for the different values possible
# * more..
use strict;
use Data::Dumper;
# INSTRUCTIONS
#
# 1. Install wfrog, get it up running with your weather station
# 2. Locate your wfrog.csv file (wfrog creates after 10 mins)
# 3. cd /etc/munin/plugins/
# 4. ln -s /usr/share/munin/plugins/wfrog wfrog_temp
# 4. ln -s /usr/share/munin/plugins/wfrog wfrog_pressure
# 5. etc..
# 6. reload munin-node ;-)
# In case you need to change this.
my %CONFIG = (
'wfrogcsv' => '/var/lib/wfrog/wfrog.csv',
);
my $interesting;
if ($0 =~ m#wfrog_(\w+)#) {
$interesting = $1;
}
else {
print STDERR "Symlink the wfrog plugin file to wfrog_something, like wfrog_temperature, etc." . "\n";
exit 1;
}
if (defined $ARGV[0] && $ARGV[0] eq 'autoconf') {
print "yes\n";
exit 0;
}
open FILE, "<", $CONFIG{'wfrogcsv'};
my $header = <FILE>;
seek( FILE, -300, 2 );
my @line = readline FILE;
$header =~ s/[\r\n]//gs; # bah @ csv
$line[-1] =~ s/[\r\n]//gs; # --- " ---
my @Data = split /,/, $line[-1];
my @Keys = split /,/, $header;
my $GotKeyName;
my $GotKeyData;
my $cpos = 0;
for (@Keys) {
if ($_ eq $interesting) {
$GotKeyName = $_;
if (defined $Data[$cpos]) {
$GotKeyData = $Data[$cpos];
}
}
$cpos++;
}
unless (defined $GotKeyName) {
print STDERR "Could not find any data on '$interesting'. Does the file contain any data?\n";
exit 1;
}
my $graph_name = $GotKeyName;
$graph_name =~ s/[^a-z]//gi;
if (defined $ARGV[0] && $ARGV[0] eq 'config') {
print "graph_title WFrog $GotKeyName\n"
. "graph_args --base 1000 -l 0\n"
. "graph_vlabel Value\n"
. "graph_scale yes\n"
. "graph_category sensors\n"
# . "graph_printf %3.0lf\n"
. "$graph_name.label $GotKeyName\n"
. "$graph_name.draw AREASTACK\n";
exit 0;
}
print "$graph_name.value $GotKeyData\n";