summaryrefslogtreecommitdiff
path: root/files/plugins
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2008-01-30 21:37:34 +0000
committermh <mh@immerda.ch>2008-01-30 21:37:34 +0000
commit9082862f719e3fe9eac5192114893e4281a6d1fb (patch)
treeb25e6395540683e05e2da32a9b507e296ff9bc87 /files/plugins
parent67c51ff64235a6e4df9acdd9d7aa7c28fa547354 (diff)
rearranged some stuff
Diffstat (limited to 'files/plugins')
-rwxr-xr-xfiles/plugins/gentoo_lastupdated71
-rwxr-xr-xfiles/plugins/selinux_avcstats111
-rwxr-xr-xfiles/plugins/selinuxenforced32
-rwxr-xr-xfiles/plugins/xen52
-rwxr-xr-xfiles/plugins/xen-cpu125
-rwxr-xr-xfiles/plugins/xen_memory63
-rwxr-xr-xfiles/plugins/xen_vbd109
7 files changed, 563 insertions, 0 deletions
diff --git a/files/plugins/gentoo_lastupdated b/files/plugins/gentoo_lastupdated
new file mode 100755
index 0000000..42fd362
--- /dev/null
+++ b/files/plugins/gentoo_lastupdated
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+# -*- perl -*-
+#
+# (C) 2007 immerda project
+#
+# Plugin to monitor the last update of the gentoo
+#
+# Parameters:
+#
+# config
+# autoconf
+#
+# $Id: users.in 1212 2006-10-29 20:11:58Z janl $
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+# update /etc/munin/plugin-conf.d/munin-node with:
+# [gentoo_*]
+# user root
+# env.logfile /var/log/emerge.log
+# env.tail /usr/bin/tail
+# env.grep /bin/grep
+
+my $logfile = $ENV{'logfile'} || '/var/log/emerge.log';
+my $grep = $ENV{'grep'} || `which grep`;
+my $date = $ENV{'date'} || `which date`;
+my $tail = $ENV{'tail'} || `which tail`;
+chomp($grep);
+chomp($date);
+chomp($tail);
+
+if ( defined($ARGV[0])) {
+ if ($ARGV[0] eq 'autoconf') {
+ print "yes\n";
+ exit 0;
+ }
+
+ if ( $ARGV[0] eq "config" ) {
+ print "graph_title Gentoo: Last update X days ago\n";
+ #print "graph_args --base 1000 -l 0\n";
+ print "graph_vlabel days\n";
+ print "graph_scale no\n";
+ print "graph_category system\n";
+ #print "graph_printf %.1lf\n";
+ print "lastupdated.label last updated [d ago]\n";
+ print "lastupdated.type GAUGE\n";
+ #print "tty.draw AREASTACK\n";
+ #print "tty.colour 00FF00\n";
+ exit 0;
+ }
+}
+
+$days = 0;
+$last = 0;
+$now = 0;
+
+$l=`$grep "emerge" $logfile | $grep world | $grep -v fetchonly | tail -1`;
+
+($last,$rest) = split /:/,$l;
+$now = `$date +%s`;
+if($last eq "" or $last == 0 or $now == 0 or $date eq ""){
+ $days = "";
+}else{
+ $days=($now-$last)/60/60/24; # in tagen
+}
+
+print "lastupdated.value $days\n";
+
+# vim:syntax=perl
+
diff --git a/files/plugins/selinux_avcstats b/files/plugins/selinux_avcstats
new file mode 100755
index 0000000..9687be0
--- /dev/null
+++ b/files/plugins/selinux_avcstats
@@ -0,0 +1,111 @@
+#!/bin/sh
+#
+# Plugin to monitor SELinux's Access Vector Cache (AVC).
+#
+# config (required)
+# autoconf (optional - used by munin-config)
+#
+# Lars Strand, 2007
+#
+#
+# Magic markers (used by munin-config and some installation scripts (i.e.
+# optional)):
+#%# family=auto
+#%# capabilities=autoconf
+
+
+AVCSTATS="/selinux/avc/cache_stats"
+
+if [ "$1" = "autoconf" ]; then
+ if [ -r $AVCSTATS ]; then
+ echo yes
+ exit 0
+ else
+ echo no
+ exit 1
+ fi
+fi
+
+if [ "$1" = "config" ]; then
+
+ echo "graph_title SELinux's Access Vector Cache"
+ echo 'graph_args -l 0 --base 1000'
+ echo 'graph_vlabel AVC operations'
+ echo 'graph_category system'
+
+ echo 'lookups.label lookups'
+ echo 'lookups.type DERIVE'
+ echo 'lookups.min 0'
+ echo 'lookups.max 1000000000'
+ echo 'lookups.draw AREA'
+ echo 'lookups.colour ff0000' # Red
+ echo 'lookups.info Number of access vector lookups. This number is a good indicator of the load beeing placed on the AVC.'
+
+ echo 'hits.label hits'
+ echo 'hits.type DERIVE'
+ echo 'hits.min 0'
+ echo 'hits.max 1000000000'
+ echo 'hits.draw STACK'
+ echo 'hits.colour 0022ff' # Blue
+ echo 'hits.info Number of access vector hits.'
+
+ echo 'misses.label misses'
+ echo 'misses.type DERIVE'
+ echo 'misses.min 0'
+ echo 'misses.max 1000000000'
+ echo 'misses.draw STACK'
+ echo 'misses.colour 990000' # Darker red
+ echo 'misses.info Number of cache misses.'
+
+ echo 'allocations.label allocations'
+ echo 'allocations.type DERIVE'
+ echo 'allocations.min 0'
+ echo 'allocations.max 100000000'
+ echo 'allocations.draw STACK'
+ echo 'allocations.colour ffa500' # Orange
+ echo 'allocations.info Number of AVC entries allocated.'
+
+ echo 'reclaims.label reclaims'
+ echo 'reclaims.type DERIVE'
+ echo 'reclaims.min 0'
+ echo 'reclaims.max 1000000000'
+ echo 'reclaims.draw STACK'
+ echo 'reclaims.colour 00aaaa' # Darker turquoise
+ echo 'reclaims.info Number of current total reclaimed AVC entries. If this keeps changing, you may need to increase the cache size (/selinux/avc/cache_threshold).'
+
+ echo 'frees.label frees'
+ echo 'frees.type DERIVE'
+ echo 'frees.min 0'
+ echo 'frees.max 1000000000'
+ echo 'frees.draw STACK'
+ echo 'frees.colour 00ff7f' # Spring green
+ echo 'frees.info Number of free AVC entries.'
+
+ exit 0
+fi
+
+if [ -r $AVCSTATS ]; then
+ awk ' NR > 1 {
+ lookups += $1;
+ hits += $2;
+ misses += $3;
+ allocations += $4;
+ reclaims += $5;
+ frees += $6;
+ } END {
+ print "lookups.value " lookups;
+ print "hits.value " hits;
+ print "misses.value " misses;
+ print "allocations.value " allocations;
+ print "reclaims.value " reclaims;
+ print "frees.value " frees;
+ } ' < $AVCSTATS
+else
+ echo "lookups.value U"
+ echo "hits.value U"
+ echo "misses.value U"
+ echo "allocations.value U"
+ echo "reclaims.value U"
+ echo "frees.value U"
+fi
+
diff --git a/files/plugins/selinuxenforced b/files/plugins/selinuxenforced
new file mode 100755
index 0000000..2f88b9b
--- /dev/null
+++ b/files/plugins/selinuxenforced
@@ -0,0 +1,32 @@
+#!/bin/sh
+# -*- sh -*-
+#
+# Plugin to count the daily amount of Virii (qmailscan)
+#
+# Contributed by David Obando (david@cryptix.de) - 03.12.2005
+#
+
+# define the logfiles. when you rotate them at any other time than 00:00 you have to define two logfiles:
+#LOG0=/var/spool/qmailscan/quarantine.log
+#LOG1=/var/spool/qmailscan/quarantine.log.1
+
+if [ "$1" = "autoconf" ]; then
+ echo yes
+ exit 0
+fi
+
+if [ "$1" = "config" ]; then
+ echo 'graph_title enforced amount'
+ echo 'graph_args --upper-limit 1 -l 0 '
+ echo 'graph_vlabel Is the system selinux enforced?'
+ echo 'graph_scale no\n';
+ echo 'graph_category selinux'
+ echo 'enforced.label IsEnforced'
+ #echo 'enforced.draw AREA'
+ echo 'enforced.draw LINE2'
+
+ exit 0
+fi
+
+echo -n "enforced.value " && cat /selinux/enforce
+
diff --git a/files/plugins/xen b/files/plugins/xen
new file mode 100755
index 0000000..575cd3b
--- /dev/null
+++ b/files/plugins/xen
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# Script to monitor CPU usage of Xen domains
+#
+# Parameters understood:
+#
+# conifg (required)
+# autoconf (optinal - used by munin-config)
+#
+
+MAXDOMAINS=16
+
+if [ "$1" = "autoconf" ]; then
+ if which xm > /dev/null ; then
+ echo yes
+ exit 0
+ fi
+ echo "no (xm not found)"
+ exit 1
+fi
+
+if [ "$1" = "config" ]; then
+
+ echo 'graph_title Xen Domain Utilerisation'
+ echo 'graph_args --base 1000 -l 0'
+ echo 'graph_scale no'
+ echo 'graph_vlabel mS'
+ echo 'graph_category xen'
+ echo 'graph_info This graph shows of many mS wall time where used by a domain'
+ /usr/sbin/xm list | grep -v "^Name .* Console$" | \
+ while read name domid mem cpu state time console; do
+ name=`echo $name | sed -e"s/-/_/"`
+ echo "$name.label $name"
+ echo "$name.type COUNTER"
+# if [ "$name" = "Domain_0" ]; then
+# echo "$name.draw AREA"
+# else
+# echo "$name.draw STACK"
+# fi
+ echo "$name.min 0"
+ echo "$name.info Wall clock time spend for $name"
+ done
+ exit 0
+fi
+
+/usr/sbin/xm list | grep -v "^Name" | grep -v "^Name .* Console$" | \
+while read name domid mem cpu state time console; do
+ name=`echo $name | sed -e"s/-/_/"`
+ time=`echo $time | sed -e "s/\.//"`
+ echo "$name.value $time"
+done
+
diff --git a/files/plugins/xen-cpu b/files/plugins/xen-cpu
new file mode 100755
index 0000000..0ef301e
--- /dev/null
+++ b/files/plugins/xen-cpu
@@ -0,0 +1,125 @@
+#!/usr/bin/perl -wT
+#
+# Script to minitor the cpu usage of Xen domains
+#
+# Author: Adam Crews <doo <at> shroom <dot> com>
+#
+# License: GPL
+# Based on the origional xen script from Matthias Pfafferodt, syntron at web.de
+#
+# Note: Your munin config must run this as root.
+#
+# Parameters
+# config (required)
+# autoconf (optional - used by munin-config)
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+# Define where to find xm tools
+my $XM = '/usr/sbin/xm';
+my $XMTOP = '/usr/sbin/xentop';
+
+##############
+# You should not need to edit anything below here
+#
+
+use strict;
+
+$ENV{PATH} = '/bin:/usr/bin:/usr/sbin';
+
+my $arg; undef($arg);
+if (defined($ARGV[0])) {
+ $arg = 'config' if ($ARGV[0] eq 'config');
+ $arg = 'autoconf' if ($ARGV[0] eq 'autoconf');
+
+ if ( "$arg" eq 'autoconf') {
+ if ( -e $XM && -e $XMTOP ) {
+ print "yes\n";
+ exit 0;
+ } else {
+ print "no ($XM and/or $XMTOP not found\n";
+ exit 1;
+ }
+ }
+
+ if ( "$arg" eq 'config') {
+ my %cnf; undef(%cnf);
+ %cnf = (
+ 'graph_title' => 'Xen Domain CPU Usage',
+ 'graph_args' => '--base 1000 -l 0 --upper-limit 100 --rigid',
+ 'graph_vlabel' => 'Percent (%)',
+ 'graph_category' => 'xen',
+ 'graph_info' => 'Display the % of CPU Usage for each domain',
+ );
+
+ my @domains = `$XM list`;
+ shift(@domains); # we dont need the header line
+ my $cnt = "0";
+ foreach my $domain ( @domains ) {
+ my ($dom,undef) = split(/\s/, $domain, 2);
+ # we need to change - and . to _ or things get weird with the graphs
+ # some decent quoting would probably fix this, but this works for now
+ $dom =~ s/[-.]/_/g;
+
+ $cnf{ "$dom" . '.label' } = "$dom";
+ $cnf{ "$dom" . '.draw' } = 'STACK';
+ $cnf{ "$dom" . '.min' } = '0';
+ $cnf{ "$dom" . '.max' } = '100';
+ $cnf{ "$dom" . '.info' } = '% CPU used for ' . "$dom";
+
+ if ( "$cnt" == "0") { $cnf{$dom.'.draw'} = 'AREA'; }
+ $cnt++;
+ }
+
+ foreach my $key (sort(keys(%cnf))) {
+ print "$key $cnf{$key}\n";
+ }
+ exit 0;
+ }
+}
+
+# Nothing was passed as an argument, so let's just return the proper values
+
+my @chunks; undef(@chunks);
+
+{
+ # run the xentop command a few times because the first reading is not always accurate
+ local $/ = undef;
+ @chunks = split(/^xentop - .*$/m, `$XMTOP -b -i2 -d2`);
+}
+
+# Take only the last run of xentop
+my @stats = split (/\n/,pop(@chunks));
+
+# remove the first 4 items that are junk that we don't need.
+shift(@stats);
+shift(@stats);
+shift(@stats);
+shift(@stats);
+
+my %vals; undef(%vals);
+
+foreach my $domain (@stats) {
+ # trim the leading whitespace
+ $domain =~ s/^\s+//;
+ my @v_tmp = split(/\s+/, $domain);
+
+ # we need to change - and . to _ or things get weird with the graphs
+ # some decent quoting would probably fix this, but this works for now
+ $v_tmp[0] =~ s/[-.]/_/g;
+
+ $vals{$v_tmp[0]}{'cpu_percent'} = $v_tmp[3];
+ $vals{$v_tmp[0]}{'vcpu'} = $v_tmp[8];
+ if ( $vals{$v_tmp[0]}{'vcpu'} =~ m/n\/a/ ) {
+ my $cpu = `grep -c "processor" < /proc/cpuinfo`;
+ if ( $cpu =~ m/^(\d+)$/ ) {
+ $vals{$v_tmp[0]}{'vcpu'} = $1;
+ }
+ }
+}
+
+foreach my $key (sort(keys(%vals))) {
+ print "$key.value " . ($vals{$key}{'cpu_percent'}/$vals{'Domain_0'}{'vcpu'}), "\n";
+}
+
diff --git a/files/plugins/xen_memory b/files/plugins/xen_memory
new file mode 100755
index 0000000..90bc705
--- /dev/null
+++ b/files/plugins/xen_memory
@@ -0,0 +1,63 @@
+#!/bin/sh
+#
+# Script to monitor memory status of the xen host
+#
+# Parameters understood:
+#
+# config (required)
+# autoconf (optional - used by munin-config)
+#
+
+MAXDOMAINS=16
+
+if [ "$1" = "autoconf" ]; then
+ if which xm > /dev/null ; then
+ echo yes
+ exit 0
+ fi
+ echo "no (xm not found)"
+ exit 1
+fi
+
+if [ "$1" = "config" ]; then
+
+ echo 'graph_title Xen Memory'
+ echo 'graph_args --base 1000 -l 0'
+ echo 'graph_scale no'
+ echo 'graph_vlabel MB'
+ echo 'graph_category xen'
+ echo 'graph_info This graph shows of many mS wall time where used by a domain'
+ # xm info | while read name bla value; do echo "$name $value"; done
+ /usr/sbin/xm info | while read name bla value; do
+ #total_memory 2047
+ #free_memory 1476
+ name=`echo $name | sed -e"s/-/_/"`
+
+ if [ "$name" = "total_memory" ]; then
+ echo "$name.label $name"
+ echo "$name.type GAUGE"
+ echo "$name.min 0"
+ echo "$name.info total memory"
+ fi
+ if [ "$name" = "free_memory" ]; then
+ echo "$name.label $name"
+ echo "$name.type GAUGE"
+ echo "$name.draw AREA"
+# echo "$name.draw STACK"
+ echo "$name.min 0"
+ echo "$name.info free memory"
+ fi
+ done
+ exit 0
+fi
+
+/usr/sbin/xm info | while read name bla value; do
+ name=`echo $name | sed -e"s/-/_/"`
+ if [ "$name" = "total_memory" ]; then
+ echo "$name.value $value"
+ fi
+ if [ "$name" = "free_memory" ]; then
+ echo "$name.value $value"
+ fi
+done
+
diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd
new file mode 100755
index 0000000..238bf08
--- /dev/null
+++ b/files/plugins/xen_vbd
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+#
+# 2007-06-01 Zoltan HERPAI <wigyori@uid0.hu>
+#
+# Credits goes for:
+# Adam Crews for his xen_cpu plugin
+# Mario Manno for his xen_traffic_all plugin
+#
+# Script to monitor the I/O usage of Xen domains
+# Version 0.1
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+# Location of xm tools
+$XM = '/usr/sbin/xm';
+$XMTOP = '/usr/sbin/xentop';
+
+# ah, parameters coming in
+if ( defined($ARGV[0]))
+{
+ if ($ARGV[0] eq 'config') { $arg = 'config'; }
+ if ($ARGV[0] eq 'autoconf') { $arg = 'autoconf'; }
+
+ if ( $arg eq 'autoconf' )
+ {
+ if ( -e $XM && -e $XMTOP )
+ {
+ print "yes\n";
+ exit 0;
+ }
+ else
+ {
+ print "no ($XM and/or $XMTOP not found\n";
+ exit 0;
+ }
+ }
+
+ if ( $arg eq 'config' )
+ {
+ %cnf = (
+ 'graph_title' => 'Xen Domain I/O usage',
+ 'graph_args' => '--base 1024 -l 0',
+ 'graph_vlabel' => 'read (-), write (+)',
+ 'graph_category' => 'xen',
+ 'graph_info' => 'Display the I/O operations for each domain',
+ );
+
+ @domains = `$XM list`;
+ shift(@domains); # we don't need the header line
+
+ foreach $domain ( @domains )
+ {
+ ($dom, undef) = split(/\s/, $domain);
+ $dom =~ s/[-.]/_/g;
+
+ $cnf{ $dom.'RD' . '.label' } = 'read';
+ $cnf{ $dom.'RD' . '.type' } = 'COUNTER';
+ $cnf{ $dom.'RD' . '.graph' } = 'no';
+ $cnf{ $dom.'RD' . '.cdef' } = $dom.'RD,8,*';
+
+ $cnf{ $dom.'WR' . '.label' } = $dom;
+ $cnf{ $dom.'WR' . '.type' } = 'COUNTER';
+ $cnf{ $dom.'WR' . '.negative' } = $dom.'RD';
+ $cnf{ $dom.'WR' . '.cdef' } = $dom.'WR,8,*';
+
+ if ( "$cnt" == "0" )
+ {
+ $cnf { "$dom" . '.draw' } = 'AREA';
+ }
+ $cnt++;
+ }
+
+ foreach $key ( sort(keys(%cnf)) )
+ {
+ print "$key $cnf{$key}\n";
+ }
+ exit 0;
+
+ }
+}
+
+
+# No args, get rolling
+# NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR SSID
+$tmpfile = "/tmp/munin_xen_vbd_tmp";
+
+system("$XMTOP -b -i1 > $tmpfile");
+open(I,"$tmpfile");
+while(<I>){
+ chomp;
+ s/^\s*//g;
+ @tmp=split(/\s+/, $_);
+ next if $tmp[0] eq "NAME";
+
+ $domname = $tmp[0];
+ $domname =~ s/[-.]/_/g;
+ $vbdrd = $tmp[14];
+ $vbdwr = $tmp[15];
+
+ $vals{$domname."RD"}{'value'} = $vbdrd;
+ $vals{$domname."WR"}{'value'} = $vbdwr;
+}
+
+foreach $key ( sort(keys(%vals)) )
+{
+ print "$key.value " . ($vals{$key}{'value'}) . "\n";
+}
+