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

- have some dirs

This commit is contained in:
Steve Schnepp 2012-02-13 18:24:46 +01:00
parent 0b089ea777
commit 08346aac58
687 changed files with 0 additions and 0 deletions

190
plugins/power/acpi_batt_ Executable file
View file

@ -0,0 +1,190 @@
#!/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 power\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'}));
}

167
plugins/power/acpi_sys_batt_ Executable file
View file

@ -0,0 +1,167 @@
#!/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 power\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')));
}

41
plugins/power/pdns_errors Executable file
View file

@ -0,0 +1,41 @@
#!/bin/bash
#
# Script to monitor PowerDNS performance
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#%# family=auto
#%# capabilities=autoconf
command="/etc/init.d/pdns dump"
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Power DNS errors'
echo 'graph_args -l 0 --base 1000'
echo 'graph_vlabel numbers of'
echo 'graph_category Power DNS'
echo 'graph_info This graph shows Power DNS performance on the machine.'
echo 'corrupt_packets.label corrupt packets'
echo 'corrupt_packets.type DERIVE'
echo 'corrupt_packets.min 0'
echo 'corrupt_packets.info Number of corrupt packets received'
echo 'servfail_packets.label servfail packets'
echo 'servfail_packets.type DERIVE'
echo 'servfail_packets.min 0'
echo 'servfail_packets.info Number of times a server-failed packet was sent out'
echo 'timedout_packets.label timedout packets'
echo 'timedout_packets.type DERIVE'
echo 'timedout_packets.min 0'
echo 'timedout_packets.info Number of packets which weren not answered within timeout set'
exit 0
fi
$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | grep corrupt'\|'servfail'\|'timedout | sed 's/-/_/g'

34
plugins/power/pdns_latency Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
#
# Script to monitor PowerDNS performance
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#%# family=auto
#%# capabilities=autoconf
command="/etc/init.d/pdns show"
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Power DNS latency'
echo 'graph_args -l 0'
echo 'graph_vlabel usec'
echo 'graph_category Power DNS'
echo 'graph_info This graph shows Power DNS latency on the machine.'
echo 'latency.label latency'
echo 'latency.info Average number of microseconds needed to answer a question'
echo 'latency.type GAUGE'
exit 0
fi
echo "latency.value $($command latency | awk -F= '{print $2}')"

35
plugins/power/pdns_qsize Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash
#
# Script to monitor PowerDNS performance
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#%# family=auto
#%# capabilities=autoconf
command="/etc/init.d/pdns show"
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Power DNS database queue'
echo 'graph_args -l 0'
echo 'graph_vlabel number of waiting queries'
echo 'graph_category Power DNS'
echo 'graph_info This graph shows Power DNS database performance on the machine.'
echo 'qsize.label qsize'
echo 'qsize.info Number of questions waiting for database attention'
echo 'qsize.type GAUGE'
exit 0
fi
echo "qsize.value $($command qsize_q | awk -F= '{print $2}')"

53
plugins/power/pdns_queries Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
#
# Script to monitor PowerDNS performance
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#%# family=auto
#%# capabilities=autoconf
command="/etc/init.d/pdns dump"
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Power DNS queries'
echo 'graph_args -l 0 --base 1000'
echo 'graph_vlabel numbers of'
echo 'graph_category Power DNS'
echo 'graph_info This graph shows Power DNS performance on the machine.'
echo 'recursing_answers.label recursing answers'
echo 'recursing_answers.type DERIVE'
echo 'recursing_answers.min 0'
echo 'recursing_answers.info Number of recursive answers sent out'
echo 'recursing_questions.label recursing queries'
echo 'recursing_questions.type DERIVE'
echo 'recursing_questions.min 0'
echo 'recursing_questions.info Number of queries sent to recursor'
echo 'tcp_answers.label tcp answers'
echo 'tcp_answers.type DERIVE'
echo 'tcp_answers.min 0'
echo 'tcp_answers.info Number of answers sent out over TCP'
echo 'tcp_queries.label tcp queries'
echo 'tcp_queries.type DERIVE'
echo 'tcp_queries.min 0'
echo 'tcp_queries.info Number of TCP queries received'
echo 'udp_answers.label udp answers'
echo 'udp_answers.type DERIVE'
echo 'udp_answers.min 0'
echo 'udp_answers.info Number of answers sent out over UDP'
echo 'udp_queries.label udp queries'
echo 'udp_queries.type DERIVE'
echo 'udp_queries.min 0'
echo 'udp_queries.info Number of UDP queries received'
exit 0
fi
$command | sed 's/=\([0-9]\+\),/.value \1\n/g' | grep udp-'\|'recursing'\|'tcp | sed 's/-/_/g'

48
plugins/power/pdns_rel Executable file
View file

@ -0,0 +1,48 @@
#!/bin/bash
#
# Script to monitor PowerDNS performance
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#%# family=auto
#%# capabilities=autoconf
command="/etc/init.d/pdns show"
state_file=/var/lib/munin/plugin-state/pdns_rel.state
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Power DNS Packet Cache Performance'
echo 'graph_args -l 0 --upper-limit 100 --base 1000'
echo 'graph_vlabel %'
echo 'graph_category Power DNS'
echo 'graph_info This graph shows the Power DNS packet cache performance on the machine.'
echo 'packetcache_hitrate.label packet cache hitrate'
echo 'packetcache_hitrate.type GAUGE'
echo 'packetcache_hitrate.min 0'
echo 'packetcache_hitrate.max 100'
echo 'packetcache_hitrate.info Hits on the packets cache'
exit 0
fi
hits=$($command packetcache-hit | awk -F= '{print $2}')
queries=$($command udp-queries | awk -F= '{print $2}')
old_hits=$(cat $state_file | head -n1)
old_queries=$(cat $state_file | tail -n1)
if [ -f $state_file ] && [ $(ls -l --time-style=+%s $state_file | awk '{print $6}') -gt $(date --date="7 minutes ago" +%s) ] ; then
d_hits=$(($hits - $old_hits))
d_queries=$(($queries - $old_queries))
if [ $d_queries -gt 0 ] ; then
echo packetcache_hitrate.value $(( $d_hits * 100 / $d_queries ))
fi
fi
echo $hits > $state_file
echo $queries >> $state_file