#!@@PERL@@
#
# (c) 2004 Michael Kaiser
# tools (at) micha (dot) de
# 
# 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 910 2005-04-15 20:31:27Z jo $
#
#%# 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 "tty.label tty\n";
    print "tty.draw AREA\n";
    print "pty.label pty\n";
    print "pty.draw STACK\n";
    print "pts.label pts\n";
    print "pts.draw STACK\n";
    exit 0;
}

open (WHO,"who|tr -s ' '|cut -d' ' -f2|cut -d'/' -f1|");
@who = <WHO>;
close (WHO);

$tty =0;
$pty =0;
$pts =0;

foreach $tt (@who) {
	$tty++ if ($tt =~ /ttyv?/);
	$pty++ if ($tt =~ /pty|ttyp/);
	$pts++ if ($tt =~ /pts/);
}

print "tty.value $tty\n";
print "pty.value $pty\n";
print "pts.value $pts\n";

# vim:syntax=perl
