mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Initial version
This commit is contained in:
parent
55847bc83a
commit
25dc57f7fa
1 changed files with 97 additions and 0 deletions
97
plugins/other/lpar_cpu
Executable file
97
plugins/other/lpar_cpu
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Plugin to monitor physical cpu usage in an IBM POWER P5 / OpenPower LPAR
|
||||
#
|
||||
# Usage: Place in /etc/munin/plugins (or make a symlink to it there)
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# This should be run as root, so drop a file with something like this in
|
||||
# /etc/munin/plugin-conf.d/lpar_cpu:
|
||||
# [lpar_cpu]
|
||||
# user root
|
||||
#
|
||||
# Great thanks to Nigel Griffith of IBM for the magic to get these values
|
||||
#
|
||||
# Author: Ingvar Hagelund <ingvar(at)linpro.no>
|
||||
#
|
||||
# Licence: GNU General Public Licence v2.0,
|
||||
# see http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
use strict;
|
||||
|
||||
my $stats="/proc/ppc64/lparcfg";
|
||||
my $cpuinfo="/proc/cpuinfo";
|
||||
my $seconds=2;
|
||||
my $counter="";
|
||||
my $after="";
|
||||
my $timebase="";
|
||||
|
||||
sub readstats {
|
||||
my $stats=shift;
|
||||
my $purr;
|
||||
|
||||
open (STATS,"$stats") or die "Unable to read $stats, $!";
|
||||
while (<STATS>) {
|
||||
if ( /^purr\=(\d+)$/ ) { $purr = $1; }
|
||||
}
|
||||
close STATS;
|
||||
return $purr;
|
||||
}
|
||||
|
||||
sub error {
|
||||
print "something horrible happened\n";
|
||||
exit 2;
|
||||
}
|
||||
|
||||
|
||||
################
|
||||
#
|
||||
# Main
|
||||
#
|
||||
#
|
||||
|
||||
if ( defined $ARGV[0] ) {
|
||||
|
||||
if ( $ARGV[0] eq 'autoconf' ) {
|
||||
if ( -e $stats && -e $cpuinfo ) {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
else {
|
||||
print "no\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
elsif ( $ARGV[0] eq 'config' ) {
|
||||
print "graph_title LPAR physical CPU usage\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel percent\n";
|
||||
print "graph_category system\n";
|
||||
print "cpu.label cpu\n";
|
||||
print "cpu.type DERIVE\n";
|
||||
print "cpu.min 0\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
$counter=readstats($stats);
|
||||
|
||||
open (CPUINFO,$cpuinfo) or die "Unable to read $cpuinfo, $!";
|
||||
while (<CPUINFO>) {
|
||||
if (/^timebase\s+\:\s+(\d+)/) { $timebase=$1; }
|
||||
}
|
||||
close CPUINFO;
|
||||
|
||||
error() if $cpuinfo eq "";
|
||||
error() if $counter eq "";
|
||||
error() if $timebase eq "";
|
||||
|
||||
my $val=100*$counter/$timebase;
|
||||
$val =~ s/(\d+)\..+/$1/;
|
||||
print "cpu.value " . $val . "\n";
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue