Public feed #723183

pbn

public text v1 · immutable
Raw Edit
·published 2007-10-02 16:01 UTC
rendered paste body
#!/usr/bin/perl -w
#
# (c) 2004 Michael Kaiser
# tools (at) micha (dot) de
# 
# Adapted to FreeBSD by Pierre Bauduin (pierre@baudu.in)
# January 21st 2007
# August 21st 2007
# October 1st 2007
#
# Plugin to monitor the number users logged in to a unix box.
# Based on an idea of a hotsanic script.
# Never tested for any other class than pts users. Until now,
# I've only tested on various Linux boxen, but it might work
# on other Un*x-alike systems as well. I'd like to hear from 
# you, if you can report this script running on any other 
# platform than Linux.
# 
#
# Usage: copy or link into /etc/munin/node.d/
#
# Parameters:
#
# 	config   (required)
#
# $Id: users.in 860 2005-03-29 20:32:59Z ilmari $
#
# $Log$
# 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

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|");
@who = <WHO>;
close (WHO);

$ttyv =0;
$ttyp =0;

foreach $tt (@who) {
	chomp($tt);
	print("DEBUG ->$tt<-\n");
	$ttyv++ if ($tt =~ /ttyv?/);
	$ttyp++ if ($tt =~ /ttyp?/);
}

print "ttyv.value $ttyv\n";
print "ttyp.value $ttyp\n";

# vim:syntax=perl