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

Category Tree: Reduce number of categories

sphinx -> search
unicorn -> webserver
moved some plugins to other dirs to get better seconde level heading
This commit is contained in:
dipohl 2017-02-23 02:22:08 +01:00
parent 444c7939de
commit e08a6448ce
20 changed files with 11 additions and 11 deletions

View file

@ -1,70 +0,0 @@
#!/bin/sh
#
# Plugin to graph battery capacity.
#
# Parameters:
#
# acpi - Override path to acpi program
#
#
# $Log$
# Revision 1.1 2007/03/14 19:52:10 anarcat
# ACPI-Battery plugin, framework copied from acpi plugin
#
#
# Expected content of /proc/acpi/battery/BAT0/info:
# present: yes
# design capacity: 47520 mWh
# last full capacity: 37650 mWh
# battery technology: rechargeable
# design voltage: 10800 mV
# design capacity warning: 2376 mWh
# design capacity low: 475 mWh
# capacity granularity 1: 1 mWh
# capacity granularity 2: 1 mWh
# model number: IBM-08K8039
# serial number: 155
# battery type: LION
# OEM info: Panasonic
#%# family=auto
#%# capabilities=autoconf
if [ "$1" = "autoconf" ]; then
if grep -q 'present.*yes' /proc/acpi/battery/*/info > /dev/null 2>&1; then
echo yes
exit 0
else
echo "no (battery not detected)"
exit 1
fi
fi
cd /proc/acpi/battery
if [ "$1" = "config" ]; then
echo 'graph_title Battery power'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel power in' `awk '/remaining capacity:/ { print $NF }' /proc/acpi/battery/*/state`
echo 'graph_category sensors'
echo 'graph_info This graph shows battery power based on output from ACPI.'
i=0
for battery in *
do
echo $battery.label $battery
echo $battery.info Battery $i
i=$(($i+1))
# design capacity warning: 2376 mWh
# design capacity low: 475 mWh
echo $battery.warning `awk '/design capacity warning:/ { print $4 }' $battery/info`
echo $battery.critical `awk '/design capacity low:/ { print $4 }' $battery/info`
echo ${battery}_full.label $battery capacity
echo ${battery}_full.info last full capacity \(design capacity: `awk '/design capacity:/ { print $3 " " $4 }' $battery/info`\)
done
exit 0
fi
for battery in *
do
echo $battery.value `awk '/remaining capacity:/ { print $3 }' $battery/state`
echo ${battery}_full.value `awk '/last full capacity:/ { print $4 }' $battery/info`
done

View file

@ -1,69 +0,0 @@
#! /bin/sh
# Plugin to monitor the battery status via the uevent API
#
# (c) 2015 - GPLv2 - steve.schnepp@pwkf.org
#
# It is a wildcard plugin, symlink it with the battery directory
# default is to display charge as mAh, but you can also use percentage if you
# prefer, by setting the env var "percent" to "yes".
#
# [battery_*]
# env.percent no
#
battery_name=${0##*_}
percent=${percent:-"no"}
if [ "$1" = "config" ]
then
echo "graph_title Battery $battery_name"
echo "graph_category sensors"
if [ "$percent" = "yes" ]
then
echo "graph_vlabel %"
else
echo "graph_vlabel mAh"
fi
echo "charge_design.label Design charge"
echo "charge_design.draw AREA"
[ "$percent" = "yes" ] && echo "charge_design.cdef charge_design,charge_design,/,100,*"
echo "charge_full.label Full charge"
echo "charge_full.draw AREA"
[ "$percent" = "yes" ] && echo "charge_full.cdef charge_full,charge_design,/,100,*"
echo "charge_now.label Current charge"
echo "charge_now.draw AREA"
[ "$percent" = "yes" ] && echo "charge_now.cdef charge_now,charge_design,/,100,*"
exit 0
fi
# Crudely read all the vars into the current namespace
. /sys/class/power_supply/$battery_name/uevent
echo "charge_design.value $(( $POWER_SUPPLY_CHARGE_FULL_DESIGN / 1000 )) "
echo "charge_full.value $(( $POWER_SUPPLY_CHARGE_FULL / 1000 ))"
echo "charge_now.value $(( $POWER_SUPPLY_CHARGE_NOW / 1000 ))"
exit 0
:<< DATA
cat /sys/class/power_supply/$1/uevent
POWER_SUPPLY_NAME=CMB1
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
POWER_SUPPLY_VOLTAGE_NOW=11418000
POWER_SUPPLY_CURRENT_NOW=2668000
POWER_SUPPLY_CHARGE_FULL_DESIGN=5200000
POWER_SUPPLY_CHARGE_FULL=5000000
POWER_SUPPLY_CHARGE_NOW=100000
POWER_SUPPLY_CAPACITY=2
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=CP293570
POWER_SUPPLY_MANUFACTURER=Fujitsu
DATA

View file

@ -1,165 +0,0 @@
#!/usr/bin/env perl -w
#
# Plugin to monitor Proliant server health status using hpasmcli.
#
# Config variables:
# user root -- requrired by hpasmcli
# env.hpasmcli -- path to hpasmcli executable (optional)
# env.degree -- Unit of temperatures (C or F / default value is C)
#
#
# Author: Tsuyoshi Wada <mail@tuyo.jp>
#
# v1.0 2007/12/08 - First version
#
# Copyright (c) 2007 Tsuyoshi Wada
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Magic markers
#%# family=contrib
#%# capabilities=autoconf suggest
use strict;
my $hpasmcli = exists $ENV{hpasmcli} ? $ENV{hpasmcli} : undef;
$hpasmcli = `which hpasmcli` unless $hpasmcli;
chomp $hpasmcli;
$hpasmcli = undef unless -x $hpasmcli;
my @dirs = qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin);
until ($hpasmcli or @dirs == 0) {
my $dir = shift @dirs;
my $path = $dir.'/hpasmcli';
$hpasmcli = $path if -x $path;
}
my $degree = exists $ENV{degree} ? $ENV{degree} : 'C';
my $deg_name = $degree eq 'C' ? "Celsius": "Fahrenheit";
if (defined($ARGV[0])) {
if ($ARGV[0] eq 'autoconf') {
if ($hpasmcli and -x $hpasmcli) {
my @chk_result = `$hpasmcli -s \"help\"`;
if ($? eq "0") {
print "yes\n";
exit 0;
} else {
my $reason = 'Unknown error';
foreach my $line (@chk_result) {
if ($line =~ /^ERROR/i) {
chomp($line);
$reason = $line;
last;
}
}
print "no ($reason)\n";
exit 1;
}
} else {
print "no (hpasmcli not found)\n";
exit 1;
}
} elsif ($ARGV[0] eq 'suggest') {
print "temp\nfans\n";
exit 0;
}
}
$0 =~ /hpasmcli2_(.+)*$/;
my $show_target = $1;
my @show_result = `$hpasmcli -s \"show $show_target\"`;
my %output;
if (defined($show_target) and $show_target eq 'temp') {
foreach my $line (@show_result) {
if ($line =~ /^#/) {
$line =~ s/\s+/ /g;
$line =~ s/^\s//g;
my ($sensor, $loc, $temp, $threshold) = split(/\s/, $line);
next if ($temp eq "-");
$loc =~ s/\/|#//g;
$temp = $degree eq 'C' ? (split(/\//, $temp))[0] : (split(/\//, $temp))[1];
$temp =~ s/C|F//g;
$threshold = $degree eq 'C' ? (split(/\//, $threshold))[0] : (split(/\//, $threshold))[1];
$threshold =~ s/C|F//g;
$sensor =~s/#//g;
$output{$sensor} = {
'location' => lc($loc),
'temp' => $temp,
'threshold' => $threshold
};
}
}
if (defined($ARGV[0]) and $ARGV[0] eq 'config') {
print "graph_title hpasm: Temperature\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Degrees in $deg_name\n";
print "graph_category sensors\n";
print "graph_info This graph shows the temperatures as reported by hpasmcli.\n";
foreach my $key (sort keys %output) {
print "temp$key.label $output{$key}->{'location'}\n";
print "temp$key.warning " . ($output{$key}->{'threshold'} * 0.75) . "\n";
print "temp$key.critical $output{$key}->{'threshold'}\n";
}
} else {
foreach my $key (sort keys %output) {
print "temp$key.value $output{$key}->{'temp'}\n";
}
}
} elsif (defined($show_target) and $show_target eq 'fans') {
foreach my $line (@show_result) {
if ($line =~ /^#/) {
$line =~ s/\s+/ /g;
$line =~ s/^\s//g;
my ($fan, $loc, $present, $speed, $rate, $redundant, $partner, $pluggable) = split(/\s/, $line);
next if ($present ne "Yes");
$loc =~ s/\/|#//g;
$rate =~ s/\%//g;
my $threshold = '100';
$fan =~s/#//g;
$output{$fan} = {
'location' => lc($loc),
'rate' => $rate,
'threshold' => $threshold
};
}
}
if (defined($ARGV[0]) and $ARGV[0] eq 'config') {
print "graph_title hpasm: Fans\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel of max (%)\n";
print "graph_category sensors\n";
print "graph_info This graph shows the info of fans as reported by hpasmcli.\n";
foreach my $key (sort keys %output) {
print "fan$key.label FAN$key $output{$key}->{'location'}\n";
print "fan$key.warning " . ($output{$key}->{'threshold'} * 0.75) . "\n";
print "fan$key.critical $output{$key}->{'threshold'}\n";
}
} else {
foreach my $key (sort keys %output) {
print "fan$key.value $output{$key}->{'rate'}\n";
}
}
} else {
die "Unknown target specified ($show_target)\n";
}
exit 0;

View file

@ -1,114 +0,0 @@
#! /usr/bin/perl -w
#
# Copyright (C) 2008 Rackspace US, Inc. <http://www.rackspace.com>
#
# 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; version 2 dated June,
# 1991.
#
# 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, see http://www.gnu.org/licenses/gpl.txt
#
#
# This plugin will graph the chassis fan sensors on a Dell PowerEdge Server
# via the omreport tool. It has been tested on the following chassis:
#
# PE2650/6650
# PE2850/6850
# PE2950
#
# To enable, link omreport_fan_speed to this file. E.g.
#
# ln -s /usr/share/node/node/plugins/omreport_fan_speed /etc/munin/plugins/omreport_fan_speed
#
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
#
# [omreport_*]
# user - User that has permissions to run the omreport binary
# env.omreport - Path to the omreport binary
#
# Parameters:
#
# config
# autoconf
#
# Author: Justin Shepherd <galstrom21@gmail.com>
# Revision: 1.5 2008/10/22
#
#%# family=auto
#%# capabilities=autoconf
use strict;
my $omreport = $ENV{"omreport"} || "/usr/bin/omreport";
if ($ARGV[0] && $ARGV[0] eq "autoconf") {
if (-f $omreport) {
print "yes\n";
}
else {
print "no ($omreport does not exist)\n";
exit(1);
}
} # end if
else {
my $cmd = "$omreport chassis fans";
my @result = `$cmd`;
my (%val, $index);
foreach my $line (@result) {
$line =~ s/\s+/ /g;
$line =~ s/\s$//g;
next if ($line eq "");
my ($field, $value) = split(/ \: /, $line);
if ($field eq "Index") {
$val{$value} = {};
$index = $value;
}
elsif ($field eq "Probe Name") {
$value =~ s/ RPM//g;
$val{$index}{$field} = "$value";
}
elsif ($field eq "Reading") {
$value =~ s/ RPM//g;
$val{$index}{"$field"} = "$value";
}
elsif ($field eq "Maximum Warning Threshold") {
$value =~ s/ RPM//g;
$val{$index}{"Warning Threshold"} = "$value";
}
elsif ($field eq "Maximum Failure Threshold") {
$value =~ s/ RPM//g;
$val{$index}{"Critical Threshold"} = "$value";
}
}
if ($ARGV[0] && $ARGV[0] eq "config") {
print "graph_title OpenManage - Fan Probes\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Speed in RPMs\n";
print "graph_category Sensors\n";
foreach my $j (sort keys %val) {
print "fan_$j.label $val{$j}{\"Probe Name\"}\n";
if ($val{$j}{"Warning Threshold"} !~ m/\[N\/A\]/i) {
print "fan_$j.warning " .
"$val{$j}{\"Warning Threshold\"}\n";
}
if ($val{$j}{"Critical Threshold"} !~ m/\[N\/A\]/i) {
print "fan_$j.critical " .
"$val{$j}{\"Critical Threshold\"}\n";
}
}
}
else {
foreach my $j (sort keys %val) {
print "fan_$j.value $val{$j}{\"Reading\"}\n";
}
}
}
exit(0);

View file

@ -1,105 +0,0 @@
#!/usr/bin/perl
#
# Copyright (C) 2009 Andrew Chadwick, University of Oxford <andrew.chadwick@ceu.ox.ac.uk>
# Based on work by Rackspace US, Inc. <http://www.rackspace.com>, (C) 2008.
#
# 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; version 2 dated June,
# 1991.
#
# 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, see http://www.gnu.org/licenses/gpl.txt
#
#
# This plugin will graph the per-PSU current draw of a Dell PowerEdge Server
# via the omreport tool. It has been tested on the following chassis:
#
# PowerEdge R905
#
# To enable, create a link in your plugins directory to wherever you
# installed this file, e.g.:
#
# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/omreport_pwrmon_current
#
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
#
# [omreport_*]
# user - User that has permissions to run the omreport binary
# env.omreport - Path to the omreport binary
#
# Parameters:
#
# config
# autoconf
#
# Author: Andrew Chadwick <andrew.chadwick@ceu.ox.ac.uk>
# Revision: 0.1 2008-01-28
#
#%# family=auto
#%# capabilities=autoconf
use strict;
my $omreport = $ENV{"omreport"} || "/usr/bin/omreport";
if ($ARGV[0] && $ARGV[0] eq "autoconf") {
if (-f $omreport) {
print "yes\n";
}
else {
print "no ($omreport does not exist)\n";
exit(1);
}
}
else {
my @cmd = ($omreport, qw{chassis pwrmonitoring});
my ($index, %val);
my $pid = open(my $cmd_out, '-|', @cmd) or die "@cmd: $!\n";
defined $pid or die "fork() failed: $!\n";
my $amperage_idx = 0;
while (<$cmd_out>) {
s/\s+/\040/g;
s/\s+$//;
s/^\s+//;
/^Amperage\b/ .. /^Power\s+Tracking\b/ or next;
my ($field, $value) = split(/\s+\:\s+/, $_);
if ($field eq 'Location') {
$index = "current_${amperage_idx}";
++$amperage_idx;
$val{$index} = {
label => $value,
};
}
elsif ($field eq 'Reading') {
$value =~ s{\s+A$}{};
$value =~ s{\[N/A\]}{}g;
$val{$index}{value} = $value;
}
}
close $cmd_out;
if ($ARGV[0] && $ARGV[0] eq "config") {
print "graph_title OpenManage - Power Monitoring - Current\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Amps\n";
print "graph_category Sensors\n";
foreach my $j (sort keys %val) {
print "$j.label $val{$j}{label}\n";
}
}
else {
foreach my $j (sort keys %val) {
print "$j.value $val{$j}{value}\n";
}
}
}
exit(0);

View file

@ -1,121 +0,0 @@
#!/usr/bin/perl
#
# Copyright (C) 2009 Andrew Chadwick, University of Oxford <andrew.chadwick@ceu.ox.ac.uk>
# Based on work by Rackspace US, Inc. <http://www.rackspace.com>, (C) 2008.
#
# 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; version 2 dated June,
# 1991.
#
# 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, see http://www.gnu.org/licenses/gpl.txt
#
#
# This plugin will graph the power consumption of a Dell PowerEdge Server
# via the omreport tool. It has been tested on the following chassis:
#
# PowerEdge R905
#
# To enable, create a link in your plugins directory to wherever you
# installed this file, e.g.:
#
# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/omreport_pwrmon_power
#
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
#
# [omreport_*]
# user - User that has permissions to run the omreport binary
# env.omreport - Path to the omreport binary
#
# Parameters:
#
# config
# autoconf
#
# Author: Andrew Chadwick <andrew.chadwick@ceu.ox.ac.uk>
# Revision: 0.1 2008-01-28
#
#%# family=auto
#%# capabilities=autoconf
use strict;
my $omreport = $ENV{"omreport"} || "/usr/bin/omreport";
if ($ARGV[0] && $ARGV[0] eq "autoconf") {
if (-f $omreport) {
print "yes\n";
}
else {
print "no ($omreport does not exist)\n";
exit(1);
}
}
else {
my @cmd = ($omreport, qw{chassis pwrmonitoring});
my ($index, %val);
my $pid = open(my $cmd_out, '-|', @cmd) or die "@cmd: $!\n";
defined $pid or die "fork() failed: $!\n";
my $amperage_idx = 0;
while (<$cmd_out>) {
s/\s+/\040/g;
s/\s+$//;
s/^\s+//;
/^Power\s+Consumption\b/ .. /^Amperage\b/ or next;
my ($field, $value) = split(/\s+\:\s+/, $_);
if ($field eq 'Index') {
$index = "power_${value}";
$val{$index} = {};
}
elsif ($field eq 'Probe Name') {
$val{$index}{label} = $value;
}
elsif ($field eq 'Reading') {
$value =~ s{\s+W$}{};
$value =~ s{\[N/A\]}{}g;
$val{$index}{value} = $value;
}
elsif ($field eq 'Warning Threshold') {
$value =~ s{\s+W$}{};
$value =~ s{\[N/A\]}{}g;
$val{$index}{warning} = $value;
}
elsif ($field eq 'Failure Threshold') {
$value =~ s{\s+W$}{};
$value =~ s{\[N/A\]}{}g;
$val{$index}{critical} = $value;
}
}
close $cmd_out;
if ($ARGV[0] && $ARGV[0] eq "config") {
print "graph_title OpenManage - Power Monitoring - Power\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Watts\n";
print "graph_category Sensors\n";
foreach my $j (sort keys %val) {
print "$j.label $val{$j}{label}\n";
if ($val{$j}{warning}) {
print "$j.warning $val{$j}{warning}\n";
}
if ($val{$j}{critical}) {
print "$j.critical $val{$j}{critical}\n";
}
}
}
else {
foreach my $j (sort keys %val) {
print "$j.value $val{$j}{value}\n";
}
}
}
exit(0);

View file

@ -1,195 +0,0 @@
#!/usr/bin/perl
#
# Copyright (C) 2009 Andrew Chadwick, University of Oxford <andrew.chadwick@ceu.ox.ac.uk>
# Based on work by Rackspace US, Inc. <http://www.rackspace.com>, (C) 2008.
#
# 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; version 2 dated June,
# 1991.
#
# 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, see http://www.gnu.org/licenses/gpl.txt
#
#
# This plugin will graph all available temperature probes in the storage
# array enclosures of a Dell PowerEdge Server via the omreport tool. It has
# been tested on the following combinations:
#
# PowerEdge R905 + PERC 6/E + MD1120
#
# To enable, create a link in your plugins directory to wherever you
# installed this file, e.g.:
#
# cd /etc/munin/plugins
# ln -s /usr/share/munin/plugins/omreport_storage_temp
#
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
#
# [omreport_*]
# user - User that has permissions to run the omreport binary
# env.omreport - Path to the omreport binary
#
# Parameters:
#
# config
# autoconf
#
# Author: Andrew Chadwick <andrew.chadwick@ceu.ox.ac.uk>
# Revision: 0.1 2008-01-28
#
#%# family=auto
#%# capabilities=autoconf
sub get_controllers {
my $omreport = shift;
my %ctrlrs;
my @cmd = ($omreport, 'storage', 'controller');
my $pid = open(my $cmd_out, '-|', @cmd) or die "@cmd: $!\n";
defined $pid or die "fork() failed: $!\n";
my $id;
while (<$cmd_out>) {
s/\s+/\040/g;
s/\s+$//;
s/^\s+//;
my ($field, $value) = split(/\s+\:\s+/, $_);
defined $value or next;
if ($field eq 'ID') {
$id = $value;
}
elsif ($field eq 'Name') {
defined $id or next;
$ctrlrs{$id} = $value;
}
}
close $cmd_out;
return %ctrlrs;
}
sub get_controller_enclosures {
my ($omreport, $ctrlr) = @_;
my %encs;
my @cmd = ($omreport, 'storage', 'enclosure', "controller=$ctrlr");
my $pid = open(my $cmd_out, '-|', @cmd) or die "@cmd: $!\n";
defined $pid or die "fork() failed: $!\n";
my $id;
while (<$cmd_out>) {
s/\s+/\040/g;
s/\s+$//;
s/^\s+//;
my ($field, $value) = split(/\s+\:\s+/, $_);
defined $value or next;
if ($field eq 'ID') {
$id = $value;
}
elsif ($field eq 'Name') {
defined $id or next;
$encs{$id} = $value;
}
}
close $cmd_out;
return %encs;
}
sub get_enclosure_temps {
my ($omreport, $ctrlr, $enc) = @_;
my %temp_hashes;
my @cmd = ($omreport, 'storage', 'enclosure', "controller=$ctrlr",
"enclosure=$enc", "info=temps");
my $pid = open(my $cmd_out, '-|', @cmd) or die "@cmd: $!\n";
defined $pid or die "fork() failed: $!\n";
my $idx;
while (<$cmd_out>) {
s/\s+/\040/g;
s/\s+$//;
s/^\s+//;
my ($field, $value) = split(/\s+\:\s+/, $_);
defined $value or next;
if ($field eq 'ID') {
$idx = $value;
$temp_hashes{$idx} = {
id => $value,
};
}
elsif ($field eq 'Name') {
defined $idx or next;
$temp_hashes{$idx}{name} = $value;
}
elsif ($field eq 'Reading') {
defined $idx or next;
$value =~ s{\s+C$}{};
$temp_hashes{$idx}{value} = $value;
}
elsif ($field eq 'Maximum Warning Threshold') {
defined $idx or next;
$value =~ s{\s+C$}{};
$temp_hashes{$idx}{warning} = $value;
}
elsif ($field eq 'Maximum Failure Threshold') {
defined $idx or next;
$value =~ s{\s+C$}{};
$temp_hashes{$idx}{critical} = $value;
}
}
close $cmd_out;
return %temp_hashes;
}
use strict;
my $omreport = $ENV{"omreport"} || "/usr/bin/omreport";
if ($ARGV[0] && $ARGV[0] eq "autoconf") {
if (-f $omreport) {
print "yes\n";
}
else {
print "no ($omreport does not exist)\n";
exit(1);
}
}
else {
my %ctrlrs = get_controllers($omreport);
my $is_config_pass = $ARGV[0] && $ARGV[0] eq "config";
if ($is_config_pass) {
print "graph_title OpenManage - Storage - Temperatures\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Temp in Degrees Celsius\n";
print "graph_category Sensors\n";
print "graph_info Temperature sensors within storage enclosures on the system, typically external ones managed via PERC 6/E adapters.\n";
}
foreach my $c (sort keys %ctrlrs) {
my $c_name = $ctrlrs{$c};
my %encs = get_controller_enclosures($omreport, $c);
foreach my $e (sort keys %encs) {
my $e_name = $encs{$e};
my %temp_hashes = get_enclosure_temps($omreport, $c, $e);
foreach my $t (sort keys %temp_hashes) {
my $t_hash = $temp_hashes{$t};
my ($t_name, $val, $warn, $crit) = @$t_hash{qw(
name value warning critical
)};
$c =~ s{\W+}{_}g;
$e =~ s{\W+}{_}g;
$t =~ s{\W+}{_}g;
my $g = "ctrlr${c}_enc${e}_temp${t}";
if ($is_config_pass) {
print "$g.label $c_name\: $e_name\: $t_name\n";
print "$g.warning $warn\n";
print "$g.critical $crit\n";
}
else {
print "$g.value $val\n";
}
}
}
}
}
exit(0);

View file

@ -1,109 +0,0 @@
#! /usr/bin/perl -w
#
# Copyright (C) 2008 Rackspace US, Inc. <http://www.rackspace.com>
#
# 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; version 2 dated June,
# 1991.
#
# 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, see http://www.gnu.org/licenses/gpl.txt
#
#
# This plugin will graph the chassis temp sensors on a Dell PowerEdge Server
# via the omreport tool. It has been tested on the following chassis:
#
# PE2650/6650
# PE2850/6850
# PE2950
#
# To enable, link omreport_temps to this file. E.g.
#
# ln -s /usr/share/node/node/plugins/omreport_temps /etc/munin/plugins/omreport_temps
#
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
#
# [omreport_*]
# user - User that has permissions to run the omreport binary
# env.omreport - Path to the omreport binary
#
# Parameters:
#
# config
# autoconf
#
# Author: Justin Shepherd <galstrom21@gmail.com>
# Revision: 1.5 2008/10/22
#
#%# family=auto
#%# capabilities=autoconf
use strict;
my $omreport = $ENV{"omreport"} || "/usr/bin/omreport";
if ($ARGV[0] && $ARGV[0] eq "autoconf") {
if (-f $omreport) {
print "yes\n";
} # end if
else {
print "no ($omreport does not exist)\n";
exit(1);
} # end else
} # end if
else {
my $cmd = "$omreport chassis temps";
my @result = `$cmd`;
my (%val, $index);
foreach my $line (@result) {
$line =~ s/\s+/ /g;
$line =~ s/\s$//g;
next if ($line eq "");
my ($field, $value) = split(/ \: /, $line);
if ($field eq "Index") {
$val{$value} = {};
$index = $value;
} # end if
elsif ($field eq "Probe Name") {
$value =~ s/ Temp//g;
$val{$index}{$field} = "$value";
} # end elsif
elsif ($field eq "Reading") {
$value =~ s/ C//g;
$val{$index}{"$field"} = "$value";
} # end elsif
elsif ($field eq "Maximum Warning Threshold") {
$value =~ s/ C//g;
$val{$index}{"Warning Threshold"} = "$value";
} # end elsif
elsif ($field eq "Maximum Failure Threshold") {
$value =~ s/ C//g;
$val{$index}{"Critical Threshold"} = "$value";
} # end elsif
} # end foreach
if ($ARGV[0] && $ARGV[0] eq "config") {
print "graph_title OpenManage - Temperature Probes\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Temperature in Celsius\n";
print "graph_category Sensors\n";
foreach my $j (sort keys %val) {
print "probe_$j.label $val{$j}{\"Probe Name\"}\n";
print "probe_$j.warning $val{$j}{\"Warning Threshold\"}\n";
print "probe_$j.critical $val{$j}{\"Critical Threshold\"}\n";
} # end foreach
} # end if
else {
foreach my $j (sort keys %val) {
print "probe_$j.value $val{$j}{\"Reading\"}\n";
} # end foreach
} # end else
} # end else
exit(0);

View file

@ -1,190 +0,0 @@
#!/usr/bin/perl -w
# -*- perl -*-
=head1 NAME
acpi_batt_ Munin plugin to monitor the (note|net)book battery states through procfs
=head1 APPLICABLE SYSTEMS
Notebooks and netbooks with avialable /proc/acpi/battery
=head1 CONFIGURATION
Configured change the name of symbolic link
acpi_batt_X_capacity - chart of Design capacity, Last full capacity, Design capacity low,
Design capacity warning, Capacity granularity 1, Capacity granularity 2,
Remaining capacity, Present rate (mA)
acpi_batt_X_percents - percentage chart of Current voltage, Current capacity, Full capacity (of design)
acpi_batt_X_voltage - chart of Design voltage, Present voltage
Where X is the number of battery from /proc/acpi/battery/BATX
=head1 INTERPRETATION
The plugin shows:
Design capacity
Last full capacity
Design capacity low
Design capacity warning
Capacity granularity 1
Capacity granularity 2
Remaining capacity
Present rate (mA)
Percentage Current/design voltage
Percentage Full/current capacity
Percentage Design/full capacity
Design voltage
Present voltage
=head1 MAGIC MARKERS
#%# family=power
=head1 VERSION
=head1 BUGS
None known.
=head1 AUTHOR
Gorlow Maxim <sheridan@sheridan-home.ru>
=head1 LICENSE
GPLv2
=cut
use strict;
#use Data::Dumper;
my ($graph_type, $batt_num);
if ($0 =~ /^(?:|.*\/)acpi_batt_([^_]+)_(.+)$/)
{
$graph_type = $2;
$batt_num = $1;
}
elsif (!defined($batt_num) or !defined($graph_type)) {
die "# Error: couldn't understand what I'm supposed to monitor."; }
#print "$batt_num, $graph_type \n";
sub trim
{
my($string)=@_;
for ($string)
{
s/^\s+//;
s/\s+$//;
}
return $string;
}
sub read_data
{
my $file = $_[0];
my ($fh, $var, $val);
my @tmp;
my $result = {};
open($fh, '<', "/proc/acpi/battery/BAT${batt_num}/${file}") or die $!;
foreach my $line (<$fh>)
{
chomp ($line);
($var, $val) = split(':', $line);
if ( $val =~ m/^\s*$/ )
{
$val = "unknown";
}
elsif ( $var ne "batery type" or $var ne "serial number" or $var ne "OEM info" )
{
@tmp = split(" " ,$val);
$val = trim($tmp[0]);
}
$result->{$var} = $val;
#print "$var, -$val- \n";
}
close($fh);
return $result;
}
my $batt_data = {};
$batt_data->{'info'} = read_data("info" );
$batt_data->{'state'} = read_data("state");
#print Dumper($batt_data);
if ($ARGV[0] and $ARGV[0] eq "config")
{
my $batt_name = sprintf("%s %s %s", $batt_data->{'info'}{'OEM info'}, $batt_data->{'info'}{'battery type'}, $batt_data->{'info'}{'model number'});
print ("graph_args --base 1000\n");
printf ("graph_title Battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
printf ("graph_info This graph shows battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
print ("graph_category sensors\n");
if ($graph_type eq "capacity")
{
print ("graph_vlabel Capacity, mAh\n");
print ("dc.label Design capacity\ndc.type GAUGE\ndc.draw AREA\n");
print ("lfc.label Last full capacity\nlfc.type GAUGE\nlfc.draw AREA\n");
print ("dcl.label Design capacity low\ndcl.type GAUGE\ndcl.draw LINE2\n");
print ("dcw.label Design capacity warning\ndcw.type GAUGE\ndcw.draw LINE2\n");
print ("cg1.label Capacity granularity 1\ncg1.type GAUGE\ncg1.draw LINE2\n");
print ("cg2.label Capacity granularity 2\ncg2.type GAUGE\ncg2.draw LINE2\n");
print ("rc.label Remaining capacity\nrc.type GAUGE\nrc.draw LINE2\n");
print ("pr.label Present rate (mA)\npr.type GAUGE\npr.draw LINE2\n");
}
elsif ($graph_type eq "voltage")
{
print ("graph_vlabel Voltage, mV\n");
print ("d.label Design voltage\nd.type GAUGE\nd.draw AREA\n");
print ("p.label Present voltage\np.type GAUGE\np.draw AREA\n");
}
elsif ($graph_type eq "percents")
{
print ("graph_vlabel %\n");
print ("cv.label Current voltage\ncv.type GAUGE\ncv.draw LINE2\n");
print ("cc.label Current capacity\ncc.type GAUGE\ncc.draw LINE2\n");
print ("fc.label Full capacity (of design)\nfc.type GAUGE\nfc.draw LINE2\n");
}
exit 0;
}
#$batt_data->{'info'}{''}
sub percent
{
my ($full, $current) = @_[0..1];
return $current/($full/100);
}
if ($graph_type eq "capacity")
{
printf ("dc.value %s\n", $batt_data->{'info'}{'design capacity'});
printf ("lfc.value %s\n", $batt_data->{'info'}{'last full capacity'});
printf ("dcl.value %s\n", $batt_data->{'info'}{'design capacity low'});
printf ("dcw.value %s\n", $batt_data->{'info'}{'design capacity warning'});
printf ("cg1.value %s\n", $batt_data->{'info'}{'capacity granularity 1'});
printf ("cg2.value %s\n", $batt_data->{'info'}{'capacity granularity 2'});
printf ("rc.value %s\n", $batt_data->{'state'}{'remaining capacity'});
printf ("pr.value %s\n", $batt_data->{'state'}{'present rate'});
}
elsif ($graph_type eq "voltage")
{
printf ("d.value %s\n", $batt_data->{'info'}{'design voltage'});
printf ("p.value %s\n", $batt_data->{'state'}{'present voltage'});
}
elsif ($graph_type eq "percents")
{
printf ("cv.value %s\n", percent($batt_data->{'info'}{'design voltage'},$batt_data->{'state'}{'present voltage'}));
printf ("cc.value %s\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'state'}{'remaining capacity'}));
printf ("fc.value %s\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'info'}{'last full capacity'}));
}

View file

@ -1,167 +0,0 @@
#!/usr/bin/perl -w
# -*- perl -*-
=head1 NAME
acpi_sys_batt_ Munin plugin to monitor the (note|net)book battery states through sysfs
=head1 APPLICABLE SYSTEMS
Notebooks and netbooks with avialable /sys/class/power_supply
=head1 CONFIGURATION
Configured change the name of symbolic link
acpi_sys_batt_X_capacity - chart of Charge full by design, Charge full and Charge now
acpi_sys_batt_X_current - chart of battery current
acpi_sys_batt_X_percents - percentage chart of Current/design voltage, Full/current capacity, Design/full capacity
acpi_sys_batt_X_voltage - chart of Design min voltage and Current voltage
Where X is the number of batteries from /sys/class/power_supply/BATX
=head1 INTERPRETATION
The plugin shows:
Charge full by design
Charge full
Charge now
Battery current
Percentage Current/design voltage
Percentage Full/current capacity
Percentage Design/full capacity
Design min voltage
Current voltage
=head1 MAGIC MARKERS
#%# family=power
=head1 VERSION
=head1 BUGS
None known.
=head1 AUTHOR
Gorlow Maxim <sheridan@sheridan-home.ru>
=head1 LICENSE
GPLv2
=cut
use strict;
#use Data::Dumper;
my ($graph_type, $batt_num);
if ($0 =~ /^(?:|.*\/)acpi_sys_batt_([^_]+)_(.+)$/)
{
$graph_type = $2;
$batt_num = $1;
}
elsif (!defined($batt_num) or !defined($graph_type)) {
die "# Error: couldn't understand what I'm supposed to monitor."; }
my $sys_path=sprintf("/sys/class/power_supply/BAT%s", $batt_num);
#print "$batt_num, $graph_type \n";
sub cat_file
{
my $file = $_[0];
my $fh;
my $file_content = "--";
open($fh, '<', "${sys_path}/${file}") or die $!;
foreach my $line (<$fh>)
{
chomp ($line);
$file_content = $line;
}
close($fh);
return $file_content;
}
#print Dumper($batt_data);
if ($ARGV[0] and $ARGV[0] eq "config")
{
#manufacturer
#model_name
#serial_number
# ----------- status
#technology
#type
my $batt_name = sprintf("%s %s %s %s (sn: %s)", cat_file('technology'), cat_file('type'), cat_file('manufacturer'), cat_file('model_name'), cat_file('serial_number'));
print ("graph_args --base 1000\n");
printf ("graph_title Battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
printf ("graph_info This graph shows battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
print ("graph_category sensors\n");
if ($graph_type eq "capacity")
{
print ("graph_vlabel Charge\n");
print ("cfd.label Charge full design\ncfd.type GAUGE\ncfd.draw AREA\n");
print ("cf.label Charge full\ncf.type GAUGE\ncf.draw AREA\n");
print ("cn.label Charge now\ncn.type GAUGE\ncn.draw AREA\n");
}
elsif ($graph_type eq "current")
{
print ("graph_vlabel Current, mAh\n");
print ("currn.label Current\ncurrn.type GAUGE\ncurrn.draw AREA\n");
}
elsif ($graph_type eq "voltage")
{
print ("graph_vlabel Voltage, mV\n");
print ("vmd.label Design min voltage\nvmd.type GAUGE\nvmd.draw AREA\n");
print ("vn.label Voltage now\nvn.type GAUGE\nvn.draw AREA\n");
}
elsif ($graph_type eq "percents")
{
print ("graph_vlabel %\n");
print ("cv.label Current/design voltage\ncv.type GAUGE\ncv.draw LINE2\n");
print ("cc.label Full/current capacity\ncc.type GAUGE\ncc.draw LINE2\n");
print ("fc.label Design/full capacity\nfc.type GAUGE\nfc.draw LINE2\n");
}
exit 0;
}
#$batt_data->{'info'}{''}
sub percent
{
my ($full, $current) = @_[0..1];
return $current/($full/100);
}
#charge_full
#charge_full_design
#charge_now
#current_now
#voltage_min_design
#voltage_now
if ($graph_type eq "capacity")
{
printf ("cfd.value %s\n", cat_file('charge_full_design'));
printf ("cf.value %s\n", cat_file('charge_full'));
printf ("cn.value %s\n", cat_file('charge_now'));
}
elsif ($graph_type eq "voltage")
{
printf ("vmd.value %s\n", cat_file('voltage_min_design'));
printf ("vn.value %s\n", cat_file('voltage_now'));
}
elsif ($graph_type eq "current")
{
printf ("currn.value %s\n", cat_file('current_now'));
}
elsif ($graph_type eq "percents")
{
printf ("cv.value %s\n", percent(cat_file('voltage_min_design'),cat_file('voltage_now')));
printf ("cc.value %s\n", percent(cat_file('charge_full'),cat_file('charge_now')));
printf ("fc.value %s\n", percent(cat_file('charge_full_design'),cat_file('charge_full')));
}

View file

@ -1,359 +0,0 @@
#!/usr/bin/perl -w
# -*- perl -*-
=head1 NAME
batteries Munin plugin to monitor the battery states through procfs and sysfs
=head1 APPLICABLE SYSTEMS
Systems with avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
=head1 CONFIGURATION
none
=head1 INTERPRETATION
The plugin shows:
Design capacity -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Last full capacity -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Design capacity low -> avialable only if avialable /proc/acpi/battery/BATx
Design capacity warning -> avialable only if avialable /proc/acpi/battery/BATx
Capacity granularity 1 -> avialable only if avialable /proc/acpi/battery/BATx
Capacity granularity 2 -> avialable only if avialable /proc/acpi/battery/BATx
Remaining capacity -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Present rate -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Percentage Current/design voltage -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Percentage Current/full capacity -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Percentage Full/design capacity -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Design voltage -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
Present voltage -> avialable if avialable /proc/acpi/battery/BATx or /sys/class/power_supply/BATx
=head1 MAGIC MARKERS
#%# family=power
#%# capabilities=autoconf
=head1 VERSION
1.0
=head1 BUGS
None known.
=head1 AUTHOR
Gorlow Maxim aka Sheridan <sheridan@sheridan-home.ru> - email and jabber
=head1 LICENSE
GPLv2
=cut
use strict;
use warnings;
use IO::Dir;
use Munin::Plugin;
need_multigraph();
my $proc_path = '/proc/acpi/battery';
my $sys_path = '/sys/class/power_supply';
my $proc_data_exists;
my $sys_data_exists;
my $batteryes_count;
sub trim
{
my($string)=@_;
for ($string)
{
s/^\s+//;
s/\s+$//;
}
return $string;
}
sub get_batteryes_count
{
my $path = $_[0];
return 0 unless (-e $path);
my $count = 0;
my $dir = IO::Dir->new($path);
if(defined $dir)
{
my $d;
while (defined ($d = $dir->read))
{
next unless $d =~ m/BAT\d+/;
$count++;
}
}
else { return 0; }
return $count;
}
sub init
{
my $proc_batt_count = get_batteryes_count($proc_path);
my $sys_batt_count = get_batteryes_count($sys_path );
#print "$proc_batt_count $sys_batt_count\n";
$proc_data_exists = $proc_batt_count > 0;
$sys_data_exists = $sys_batt_count > 0;
if ($proc_data_exists and $sys_data_exists and ($proc_batt_count != $sys_batt_count))
{
die "Something wrong, batteryes count from $proc_path and $sys_path not equal (proc: $proc_batt_count, sys: $sys_batt_count)!"
}
if ($proc_data_exists) { $batteryes_count = $proc_batt_count; }
elsif ($sys_data_exists) { $batteryes_count = $sys_batt_count; }
unless ($batteryes_count)
{
die "Batteryes not found."
}
}
sub read_proc_data
{
my ($batt_num, $file) = @_[0..1];
my ($var, $val, $result);
open(FH, '<', "${proc_path}/BAT${batt_num}/${file}") or die $!;
foreach my $line (<FH>)
{
chomp ($line);
($var, $val) = split(':', $line);
if ($val =~ m/^\s*$/ ) { $val = "nan"; }
elsif ($val =~ m/\w\s+\w/) { $val = (split(" " ,$val))[0]; }
$result->{$var} = trim($val);
#print "var $var - val $val\n";
}
close(FH);
return $result;
}
sub read_sys_data
{
my ($batt_num, $file) = @_[0..1];
my $file_content = "nan";
open(FH, '<', "${sys_path}/BAT${batt_num}/${file}") or die $!;
$file_content = <FH>;
close(FH);
chomp ($file_content);
if($file_content =~ m/^\s*$/) { return 'nan'; }
return $file_content;
}
sub percent
{
my ($full, $current) = @_[0..1];
return $current/($full/100);
}
sub read_info
{
my $info;
for (my $i = 0; $i < $batteryes_count; $i++)
{
if($sys_data_exists)
{
$info->{$i}{'manufacturer'} = read_sys_data($i, 'manufacturer');
$info->{$i}{'battery_type'} = read_sys_data($i, 'technology' );
$info->{$i}{'model_name'} = read_sys_data($i, 'model_name' );
$info->{$i}{'serial_number'} = read_sys_data($i, 'serial_number');
}
else
{
my $proc_info = read_proc_data($i, 'info');
$info->{$i}{'manufacturer'} = $proc_info->{'OEM info' };
$info->{$i}{'battery_type'} = $proc_info->{'battery type' };
$info->{$i}{'model_name'} = $proc_info->{'model number' };
$info->{$i}{'serial_number'} = $proc_info->{'serial number'};
}
}
return $info;
}
sub read_data
{
my $data;
for (my $i = 0; $i < $batteryes_count; $i++)
{
if($sys_data_exists)
{
my $divider = 1000000; # need for equvivalent sys and proc data
$data->{$i}{'design_capacity'} = read_sys_data($i, 'charge_full_design')/$divider;
$data->{$i}{'last_full_capacity'} = read_sys_data($i, 'charge_full') /$divider;
$data->{$i}{'remaining_capacity'} = read_sys_data($i, 'charge_now') /$divider;
$data->{$i}{'design_voltage'} = read_sys_data($i, 'voltage_min_design')/$divider;
$data->{$i}{'present_voltage'} = read_sys_data($i, 'voltage_now') /$divider;
$data->{$i}{'present_rate'} = read_sys_data($i, 'current_now') /$divider;
}
if($proc_data_exists)
{
my $divider = 1000; # need for equvivalent sys and proc data
my $proc_info = read_proc_data($i, 'info');
unless($sys_data_exists)
{
my $proc_state = read_proc_data($i, 'state');
$data->{$i}{'design_capacity'} = $proc_info ->{'design capacity'} /$divider;
$data->{$i}{'last_full_capacity'} = $proc_info ->{'last full capacity'}/$divider;
$data->{$i}{'remaining_capacity'} = $proc_state->{'remaining capacity'}/$divider;
$data->{$i}{'design_voltage'} = $proc_info ->{'design voltage'} /$divider;
$data->{$i}{'present_voltage'} = $proc_state->{'present voltage'} /$divider;
$data->{$i}{'present_rate'} = $proc_state->{'present rate'} /$divider;
}
$data->{$i}{'design_capacity_low'} = $proc_info ->{'design capacity low'} /$divider;
$data->{$i}{'design_capacity_warning'} = $proc_info ->{'design capacity warning'}/$divider;
$data->{$i}{'capacity_granularity_1'} = $proc_info ->{'capacity granularity 1'} /$divider;
$data->{$i}{'capacity_granularity_2'} = $proc_info ->{'capacity granularity 2'} /$divider;
}
$data->{$i}{'current_voltage_percent'} = percent($data->{$i}{'design_voltage'} , $data->{$i}{'present_voltage'});
$data->{$i}{'current_capacity_percent'} = percent($data->{$i}{'last_full_capacity'}, $data->{$i}{'remaining_capacity'});
$data->{$i}{'full_capacity_percent'} = percent($data->{$i}{'design_capacity'} , $data->{$i}{'last_full_capacity'});
}
return $data;
}
my $graphs =
{
'batteryes_capacity' => { 'vlabel' => 'Capacity, Ah', 'title' => '%s capacity', 'args' => '--base 1000',
'fields' => [qw/design_capacity last_full_capacity design_capacity_low design_capacity_warning capacity_granularity_1 capacity_granularity_2 remaining_capacity/] },
'batteryes_voltage' => { 'vlabel' => 'Voltage, V' , 'title' => '%s voltage' , 'args' => '--base 1000',
'fields' => [qw/design_voltage present_voltage/] },
'batteryes_percents' => { 'vlabel' => '%' , 'title' => '%s percents', 'args' => '--base 1000 --upper-limit 100 -l 0',
'fields' => [qw/current_voltage_percent current_capacity_percent full_capacity_percent/] },
'batteryes_current' => { 'vlabel' => 'Current, A' , 'title' => '%s current' , 'args' => '--base 1000',
'fields' => [qw/present_rate/] }
};
my $fields =
{
'design_capacity' => { 'source' => 'both', 'draw' => 'AREA' , 'label' => 'Design capacity' , 'info' => 'Battery design capacity' },
'last_full_capacity' => { 'source' => 'both', 'draw' => 'AREA' , 'label' => 'Last full capacity' , 'info' => 'Battery full charge capacity' },
'design_capacity_low' => { 'source' => 'proc', 'draw' => 'LINE2', 'label' => 'Design capacity low' , 'info' => 'Low battery level' },
'design_capacity_warning' => { 'source' => 'proc', 'draw' => 'LINE2', 'label' => 'Design capacity warning', 'info' => 'Warning battery level' },
'capacity_granularity_1' => { 'source' => 'proc', 'draw' => 'LINE2', 'label' => 'Capacity granularity 1' , 'info' => 'Capacity granularity 1' },
'capacity_granularity_2' => { 'source' => 'proc', 'draw' => 'LINE2', 'label' => 'Capacity granularity 2' , 'info' => 'Capacity granularity 2' },
'remaining_capacity' => { 'source' => 'both', 'draw' => 'LINE2', 'label' => 'Remaining capacity' , 'info' => 'Current battery charge' },
'present_rate' => { 'source' => 'both', 'draw' => 'LINE2', 'label' => 'Present rate' , 'info' => 'Current battery rate' },
'design_voltage' => { 'source' => 'both', 'draw' => 'AREA' , 'label' => 'Design voltage' , 'info' => 'Battery design voltage' },
'present_voltage' => { 'source' => 'both', 'draw' => 'AREA' , 'label' => 'Present voltage' , 'info' => 'Current battery voltage' },
'current_voltage_percent' => { 'source' => 'both', 'draw' => 'LINE2', 'label' => 'Current/design voltage' , 'info' => 'Current battery voltage / ( Battery design voltage / 100 )' },
'current_capacity_percent' => { 'source' => 'both', 'draw' => 'LINE2', 'label' => 'Current/full capacity' , 'info' => 'Current battery charge / ( Battery full charge capacity / 100 )' },
'full_capacity_percent' => { 'source' => 'both', 'draw' => 'LINE2', 'label' => 'Full/design capacity' , 'info' => 'Battery full charge capacity / ( Battery design capacity / 100 )' },
};
# ------------------------------------ start here -----------------------------------
if (defined($ARGV[0]) and ($ARGV[0] eq 'autoconf'))
{
printf("%s\n", (-e $proc_path or -e $sys_path) ? "yes" : "no ($proc_path and $sys_path not exists)");
exit (0);
}
init();
if ($ARGV[0] and $ARGV[0] eq "config")
{
my %config;
my $info = read_info();
foreach my $graph (keys %{$graphs})
{
my @order;
$config{$graph}{'graph'}{'title'} = sprintf($graphs->{$graph}{'title'}, 'Mean batteryes');
$config{$graph}{'graph'}{'args'} = $graphs->{$graph}{'args'};
$config{$graph}{'graph'}{'vlabel'} = $graphs->{$graph}{'vlabel'};
$config{$graph}{'graph'}{'category'} = 'power';
foreach my $field (@{$graphs->{$graph}{'fields'}})
{
if(($proc_data_exists and $fields->{$field}{'source'} eq 'proc') or $fields->{$field}{'source'} eq 'both')
{
$config{$graph}{'fields'}{$field}{'label'} = $fields->{$field}{'label'};
$config{$graph}{'fields'}{$field}{'info'} = $fields->{$field}{'info'};
$config{$graph}{'fields'}{$field}{'draw'} = $fields->{$field}{'draw'};
$config{$graph}{'fields'}{$field}{'type'} = 'GAUGE';
push(@order, $field);
}
}
$config{$graph}{'graph'}{'order'} = join(' ', @order);
for (my $i = 0; $i < $batteryes_count; $i++)
{
my @b_order;
my $battery_name = sprintf("BAT%s", $i);
my $graph_name = sprintf("%s.%s", $graph, $battery_name);
$config{$graph_name}{'graph'}{'title'} = sprintf($graphs->{$graph}{'title'}, $battery_name);
$config{$graph_name}{'graph'}{'info'} = sprintf("%s battery %s %s (sn: %s)", $info->{$i}{'battery_type'}, $info->{$i}{'manufacturer'}, $info->{$i}{'model_name'}, $info->{$i}{'serial_number'});
$config{$graph_name}{'graph'}{'args'} = '--base 1000';
$config{$graph_name}{'graph'}{'vlabel'} = $graphs->{$graph}{'vlabel'};
$config{$graph_name}{'graph'}{'category'} = 'power';
foreach my $field (@{$graphs->{$graph}{'fields'}})
{
if(($proc_data_exists and $fields->{$field}{'source'} eq 'proc') or $fields->{$field}{'source'} eq 'both')
{
$config{$graph_name}{'fields'}{$field}{'label'} = $fields->{$field}{'label'};
$config{$graph_name}{'fields'}{$field}{'info'} = $fields->{$field}{'info'};
$config{$graph_name}{'fields'}{$field}{'draw'} = $fields->{$field}{'draw'};
$config{$graph_name}{'fields'}{$field}{'type'} = 'GAUGE';
push(@b_order, $field);
}
}
$config{$graph_name}{'graph'}{'order'} = join(' ', @b_order);
}
}
# ---------------- print ------------------
foreach my $graph (sort keys %config)
{
printf("multigraph %s\n", $graph);
foreach my $g_option(sort keys %{$config{$graph}{'graph'}})
{
printf("graph_%s %s\n", $g_option, $config{$graph}{'graph'}{$g_option});
}
foreach my $field (sort keys %{$config{$graph}{'fields'}})
{
foreach my $f_option (sort keys %{$config{$graph}{'fields'}{$field}})
{
printf("%s.%s %s\n", $field, $f_option, $config{$graph}{'fields'}{$field}{$f_option});
}
}
print "\n";
}
exit (0);
}
# ----------------------------- values ---------------------------------------------
my $data = read_data();
foreach my $graph (sort keys %{$graphs})
{
printf ("multigraph %s\n", $graph);
foreach my $field (sort @{$graphs->{$graph}{'fields'}})
{
my $field_summ = 0;
if(($proc_data_exists and $fields->{$field}{'source'} eq 'proc') or $fields->{$field}{'source'} eq 'both')
{
for (my $i = 0; $i < $batteryes_count; $i++)
{
$field_summ += $data->{$i}{$field};
}
printf("%s.value %s\n", $field, $field_summ/$batteryes_count);
}
}
print "\n";
for (my $i = 0; $i < $batteryes_count; $i++)
{
my $graph_name = sprintf("%s.BAT%s", $graph, $i);
printf ("multigraph %s\n", $graph_name);
foreach my $field (sort @{$graphs->{$graph}{'fields'}})
{
if(($proc_data_exists and $fields->{$field}{'source'} eq 'proc') or $fields->{$field}{'source'} eq 'both')
{
printf("%s.value %s\n", $field, $data->{$i}{$field});
}
}
print "\n";
}
}