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:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
94
plugins/openvz/openvz-load-avg
Executable file
94
plugins/openvz/openvz-load-avg
Executable file
|
@ -0,0 +1,94 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (c) 2008, Maxime Besson
|
||||
# Copyright (c) 2011, David Bernard
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
#
|
||||
# Graph VE load averages on an OpenVZ server
|
||||
#
|
||||
# This plugin needs root privileges to call vzlist, so add this :
|
||||
#
|
||||
# [openvz_loadavg]
|
||||
# user root
|
||||
#
|
||||
# to your munin config (or use sudo)
|
||||
#
|
||||
# Changelog
|
||||
# version 0.1 - 2008 September 17
|
||||
# Maxime Besson <mabes@smile.fr>
|
||||
# - Script creation
|
||||
# version 0.2 - 2011 July 18
|
||||
# Bernard David <daber@smile.fr>
|
||||
# - Script improvements : multigraph
|
||||
|
||||
use strict;
|
||||
my $arg=shift(@ARGV);
|
||||
|
||||
# Various tests
|
||||
if ( ! -d "/proc/vz" ) {
|
||||
print "This server does not seem to run OpenVZ\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( $> ne "0" ) {
|
||||
print "Must run as root\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
# Autoconfig
|
||||
if ( $arg eq "autoconf" ) {
|
||||
print "yes\n";
|
||||
} elsif ( $arg eq "config" ) {
|
||||
print "multigraph openvz_loadavg\n";
|
||||
print "graph_title load average of VE\n";
|
||||
print "graph_args --base 1000 -l 0 -N\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_vlabel load average\n";
|
||||
print "graph_info Shows 5-minute load average per VE\n";
|
||||
print "graph_category OpenVZ\n";
|
||||
|
||||
# Dynamic config
|
||||
my @result=`/usr/sbin/vzlist -H -a -s veid -o veid,name`;
|
||||
my $A=0; # draw an area only under the first line
|
||||
|
||||
for (@result ) {
|
||||
( my $veid,my $label ) = /^\s*(\d+)\s*([\w\-]+)\s*$/ ;
|
||||
my $name = $label;
|
||||
$name =~ s/\W/_/g;
|
||||
|
||||
print "$name.label $label\n";
|
||||
print "$name.min 0\n";
|
||||
if ($A==0) {
|
||||
print "$name.draw AREA\n";
|
||||
$A=1;
|
||||
}else{
|
||||
print "$name.draw STACK\n";
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
# Getting the values
|
||||
my @result=`/usr/sbin/vzlist -H -s veid -o veid,name,laverage`;
|
||||
my $A=0;
|
||||
|
||||
for (@result ) {
|
||||
if (( my $veid,my $label, my $laverage ) = /^\s*(\d+)\s+([\w\-]+)\s+[\d\.]+\/([\d\.]+)\/[\d\.]+\s*$/) {
|
||||
my $name = $label;
|
||||
$name =~ s/\W/_/g;
|
||||
print "$name.value $laverage\n"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
43
plugins/openvz/openvz_
Executable file
43
plugins/openvz/openvz_
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to plot OpenVZ VE Stats
|
||||
#
|
||||
# by Rene Weselowski
|
||||
# http://www.dead.at
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
ATTRIBUTE=`basename $0 | sed 's/^openvz_//g'`
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title $ATTRIBUTE"
|
||||
echo "graph_args --base 1000 -l 0"
|
||||
echo "graph_scale yes"
|
||||
echo "graph_vlabel $ATTRIBUTE Value"
|
||||
echo "graph_category openvz"
|
||||
echo "graph_info This graph shows OpenVZ: $ATTRIBUTE"
|
||||
vzlist -a -H -o hostname | awk '{gsub(/\./,"_",$1)
|
||||
print("'$ATTRIBUTE'"$1".label "$1"\n" \
|
||||
"'$ATTRIBUTE'"$1".info '$ATTRIBUTE' for VE"$1)}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vzlist -a -H -o hostname,$ATTRIBUTE | awk '{gsub(/\./,"_",$1)
|
||||
print("'$ATTRIBUTE'"$1".value "$2)}'
|
||||
|
||||
exit 0
|
||||
|
311
plugins/openvz/openvzcpu
Executable file
311
plugins/openvz/openvzcpu
Executable file
|
@ -0,0 +1,311 @@
|
|||
#!/usr/bin/perl -w
|
||||
# -*- perl -*-
|
||||
# vim: sts=8 sw=8 ts=8
|
||||
|
||||
#
|
||||
# Run "perldoc thisfilename" to get a well-formated set of documentation
|
||||
# for this munin plugin.
|
||||
#
|
||||
=head1 NAME
|
||||
|
||||
openvzcpu - Munin plugin to monitor the amount of CPU used by each OpenVZ
|
||||
container running on this machine.
|
||||
|
||||
=head2 SYNOPSIS
|
||||
|
||||
Draws a stacked graph showing system/user/nice CPU usage for each container
|
||||
running on a OpenVZ hardware node. Must be run from outside of any container
|
||||
in order to gain access to the values generated by the OpenVZ kernel code in
|
||||
C</proc/vz/vestat>
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
The following perl libraries are used:
|
||||
|
||||
Graphics::ColorNames
|
||||
Graphics::ColorObject
|
||||
|
||||
... on Debian based systems (i.e. Ubuntu etc.) you may just:
|
||||
|
||||
aptitude install libcolor-calc-perl libgraphics-colorobject-perl
|
||||
|
||||
Must be run as root in order to read C</proc/vz/vestat>
|
||||
|
||||
Place the following in a file such as C</etc/munin/plugin-conf.d/openvzcpu>
|
||||
B<and then restart munin-node>.
|
||||
|
||||
[openvzcpu]
|
||||
user root
|
||||
|
||||
=head2 OPTIONS
|
||||
|
||||
The following may be added to the file above, in order to enable the graphing
|
||||
of idle and iowait times:
|
||||
|
||||
env.drawidle 1
|
||||
|
||||
For kernels which have other than 100 jiffies per second (sic) n.b. this is
|
||||
unlikely to be necessary - you may add the followin to the plugin-specific
|
||||
configuration:
|
||||
|
||||
env.HZ 1000
|
||||
|
||||
|
||||
If you have a high number of containers running on the machine, you may be
|
||||
able to gain extra clarity by asking munin to create a "taller" graph by
|
||||
adding the following to /etc/munin.conf, or in a file under
|
||||
C</etc/munin/munin-conf.d/> if you are using Munin v1.4 or above:
|
||||
|
||||
openvzcpu.graph_height 700
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
http://wiki.openvz.org/Vestat
|
||||
|
||||
=head1 TODO
|
||||
|
||||
. Add Munin 1.4 multigraph support
|
||||
|
||||
. Sort graphing order so that the smallest container is rendered at the
|
||||
bottom of the graph.
|
||||
|
||||
. Make the colour list into a configuration item.
|
||||
|
||||
. Fix graphing of non-container CPU usage.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
0.6 Initial Public Release
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Tim Small <tim@seoss.co.uk>
|
||||
|
||||
Copyright 2010 South East Open Source Solutions Ltd.
|
||||
|
||||
The creation of this plugin was funded by Latitude Hosting
|
||||
|
||||
http://www.latitudehosting.net/
|
||||
|
||||
Patches welcome.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=begin comment
|
||||
|
||||
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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA.
|
||||
|
||||
=end comment
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Carp;
|
||||
use Graphics::ColorNames 2.10;
|
||||
use Graphics::ColorObject;
|
||||
|
||||
my $vestat = '/proc/vz/vestat';
|
||||
my $stat = '/proc/stat';
|
||||
|
||||
my @vestatitems = ('user', 'system', 'nice');
|
||||
|
||||
my @colorlist = ('purple', 'green', 'red', 'pink2', 'green', 'brown', 'cyan', 'orange', 'blue', 'grey');
|
||||
|
||||
############
|
||||
# autoconf #
|
||||
############
|
||||
|
||||
if ( defined $ARGV[0] && $ARGV[0] eq 'autoconf' ) {
|
||||
if ( -r '/proc/stat' && -r '/proc/vz/vestat' ) {
|
||||
print "yes\n";
|
||||
} else {
|
||||
print "no\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $hz = 100;
|
||||
|
||||
|
||||
#use Data::Dumper; croak Dumper(\%ENV);
|
||||
|
||||
|
||||
$hz = $ENV{'HZ'} if ( defined $ENV{'HZ'} );
|
||||
|
||||
my $drawidle = 0;
|
||||
|
||||
$drawidle = $ENV{'drawidle'} if ( defined $ENV{'drawidle'} );
|
||||
|
||||
open VESTAT, "<$vestat" or croak "Failed to open $vestat\n";
|
||||
|
||||
my %vejif;
|
||||
|
||||
while (<VESTAT>) {
|
||||
my ($veid, $user, $nice, $system);
|
||||
($veid, $user, $nice, $system) = m,^\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+),;
|
||||
if (defined $veid) {
|
||||
$vejif{$veid}->{'user'} = $user;
|
||||
$vejif{$veid}->{'nice'} = $nice;
|
||||
$vejif{$veid}->{'system'} = $system;
|
||||
}
|
||||
}
|
||||
|
||||
close VESTAT or croak "Failed to close $vestat\n";
|
||||
|
||||
open STAT, "<$stat" or croak "Failed to open $stat\n";
|
||||
|
||||
my $line = 0;
|
||||
my $cores = 0;
|
||||
|
||||
while (<STAT>) {
|
||||
my ($user, $nice, $system, $idle, $iowait, $irq, $softirq);
|
||||
($user, $nice, $system, $idle, $iowait, $irq, $softirq) = m,^cpu\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+)\W+(\d+),;
|
||||
if (defined $user) {
|
||||
$vejif{'global'}->{'user'} = $user;
|
||||
$vejif{'global'}->{'nice'} = $nice;
|
||||
$vejif{'global'}->{'system'} = $system;
|
||||
$vejif{'global'}->{'idle'} = $idle;
|
||||
$vejif{'global'}->{'iowait'} = $iowait;
|
||||
$vejif{'global'}->{'irq'} = $irq;
|
||||
$vejif{'global'}->{'softirq'} = $softirq;
|
||||
}
|
||||
# Count number of CPU cores on this system while we are here
|
||||
$cores++ if m,cpu\d,;
|
||||
}
|
||||
|
||||
$cores = 1 if $cores == 0;
|
||||
|
||||
foreach my $thing (@vestatitems) {
|
||||
##FIXME this doesn't appear to work on 2.6.32. OpenVZ bug?
|
||||
## #Subtract total container usage from overall usage to get non-openvz
|
||||
## # usage (AKA VEID 0)
|
||||
## $vejif{'0'}->{$thing} = $vejif{'global'}->{$thing};
|
||||
## foreach my $veid (keys %vejif) {
|
||||
## next if $veid eq 'global';
|
||||
## $vejif{'0'}->{$thing} = $vejif{'0'}->{$thing} - $vejif{$veid}->{$thing};
|
||||
## }
|
||||
delete $vejif{'global'}->{$thing};
|
||||
}
|
||||
|
||||
|
||||
##########
|
||||
# config #
|
||||
##########
|
||||
|
||||
if ( defined $ARGV[0] && $ARGV[0] eq 'config' ) {
|
||||
my $uplimit = $cores;
|
||||
my $first = 1;
|
||||
my $veprocessed = 0;
|
||||
#print 'graph_args --base 1000 -r --lower-limit 0 --units-length 4 --y-grid 0.01:10';
|
||||
print 'graph_args --base 1000 -r --lower-limit 0 -Y';
|
||||
print " --upper-limit $uplimit" if $drawidle;
|
||||
print <<STDCONFIG;
|
||||
|
||||
graph_title OpenVZ container CPU usage
|
||||
graph_vlabel CPU cores used ($cores available)
|
||||
graph_scale no
|
||||
graph_info This graph shows how CPU time is spent.
|
||||
graph_category openvz
|
||||
graph_period second
|
||||
STDCONFIG
|
||||
if (0) {
|
||||
print "graph_printf %6.3lf\n";
|
||||
}
|
||||
foreach my $veid (keys %vejif) {
|
||||
next if $veid eq 'global';
|
||||
my $color = $colorlist[$veprocessed++ % @colorlist];
|
||||
my $vename = `vzlist -H -o name $veid`;
|
||||
($vename) = ($vename =~ m,(\w*),);
|
||||
|
||||
my $cnameobj = new Graphics::ColorNames(qw( X ));
|
||||
|
||||
# Use LCHab colour space in order to be able to change the
|
||||
# Apparent brightness of the color (by scaling the "L"
|
||||
# component). Convert back to RGB for munin.
|
||||
my @lchab = @{
|
||||
(Graphics::ColorObject->new_RGBhex(
|
||||
$cnameobj->hex($color)
|
||||
))->as_LCHab()
|
||||
};
|
||||
|
||||
foreach my $item ('system', 'user', 'nice') {
|
||||
my @itemc;
|
||||
@itemc = @lchab;
|
||||
$itemc[0] = 1.3 * $itemc[0] if ($item eq 'nice');
|
||||
$itemc[0] = 0.7 * $itemc[0] if ($item eq 'system');
|
||||
my $itemcolor = Graphics::ColorObject->new_LCHab(\@itemc);
|
||||
print "v${veid}${item}.label $vename $item\n";
|
||||
if($first) {
|
||||
print "v${veid}${item}.draw AREA\n";
|
||||
$first = 0;
|
||||
} else {
|
||||
print "v${veid}${item}.draw STACK\n";
|
||||
}
|
||||
print "v${veid}${item}.colour " . $itemcolor->as_RGBhex() . "\n";
|
||||
print "v${veid}${item}.min 0\n";
|
||||
print "v${veid}${item}.type DERIVE\n";
|
||||
print "v${veid}${item}.cdef v${veid}${item},100,/\n";
|
||||
}
|
||||
}
|
||||
print <<STDCONFIG;
|
||||
vglobalirq.label irq
|
||||
vglobalirq.draw STACK
|
||||
vglobalirq.min 0
|
||||
vglobalirq.colour EEEE00
|
||||
vglobalirq.type DERIVE
|
||||
vglobalirq.cdef vglobalirq,100,/
|
||||
vglobalirq.info CPU time spent handling interrupts
|
||||
vglobalsoftirq.label softirq
|
||||
vglobalsoftirq.draw STACK
|
||||
vglobalsoftirq.min 0
|
||||
vglobalsoftirq.colour CCCC00
|
||||
vglobalsoftirq.type DERIVE
|
||||
vglobalsoftirq.cdef vglobalsoftirq,100,/
|
||||
vglobalsoftirq.info CPU time spent handling "batched" interrupts
|
||||
STDCONFIG
|
||||
if ($drawidle) {
|
||||
print <<STDCONFIG
|
||||
vglobalidle.label idle
|
||||
vglobalidle.draw STACK
|
||||
vglobalidle.colour EEEEEE
|
||||
vglobalidle.min 0
|
||||
vglobalidle.type DERIVE
|
||||
vglobalidle.cdef vglobalidle,100,/
|
||||
vglobalidle.info Idle CPU time
|
||||
vglobaliowait.label iowait
|
||||
vglobaliowait.draw STACK
|
||||
vglobaliowait.colour DDDDDD
|
||||
vglobaliowait.min 0
|
||||
vglobaliowait.type DERIVE
|
||||
vglobaliowait.cdef vglobaliowait,100,/
|
||||
vglobaliowait.info CPU time spent waiting for I/O operations to finish when there is nothing else to do.
|
||||
STDCONFIG
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
foreach my $veid (keys %vejif) {
|
||||
foreach my $datapoint (keys %{$vejif{$veid}}) {
|
||||
printf "v${veid}${datapoint}.value %.0f\n", $vejif{$veid}->{$datapoint} / $hz * 100;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue