From f637dc37d96a1715634734c5ef9d7d5ecd13a447 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 30 Jan 2008 21:37:34 +0000 Subject: rearranged some stuff git-svn-id: https://svn/ipuppet/trunk/modules/munin@607 d66ca3ae-40d7-4aa7-90d4-87d79ca94279 --- files/plugins/gentoo_lastupdated | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 files/plugins/gentoo_lastupdated (limited to 'files/plugins/gentoo_lastupdated') 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 + -- cgit v1.2.3