#!/usr/bin/perl -w # # Original script by Michael Kaiser - tools (at) micha (dot) de # # Adapted to FreeBSD by Pierre Bauduin (pierre@baudu.in) # January 21st 2007 # August 21st 2007 # October 2nd 2007 # # Plugin to monitor the number users logged in to a unix box. # Based on an idea of a hotsanic script. # # Usage: copy or link into /etc/munin/node.d/ # # Parameters: # # config (required) # # $Log$ # # Revision 1.2 2007/10/02 14:00:00 pbn # Adapted to FreeBSD 6.2 / PC-BSD 1.4 # Fixed some bugs # Added "use strict;" # # Revision 1.1.2.1 2005/01/11 13:48:33 ilmari # Fix linux/users #! line. # # Revision 1.1 2004/12/20 13:43:36 jimmyo # Added plugin linux/users, created by Michael Kaiser. # # #%# family=contrib # use strict; if ( $ARGV[0] and $ARGV[0] eq "config" ) { print "graph_title Logged in users\n"; print "graph_args --base 1000 -l 0\n"; print "graph_vlabel Count/min\n"; print "graph_scale no\n"; print "ttyv.label ttyv\n"; print "ttyv.draw AREA\n"; print "ttyp.label ttyp\n"; print "ttyp.draw STACK\n"; exit 0; } open (WHO,"/usr/bin/who|tr -s ' '|cut -d' ' -f2|"); my @who = ; close (WHO); my $ttyv =0; my $ttyp =0; my $tt; foreach $tt (@who) { $ttyv++ if ($tt =~ /ttyv/); $ttyp++ if ($tt =~ /ttyp/); } print "ttyv.value $ttyv\n"; print "ttyp.value $ttyp\n"; # vim:syntax=perl