package Requester::who;

use strict;

@Requester::who::ISA = qw(Requester::Requester);

my $requester = new Requester::who;

sub new
{
    my ($this, $args ) = @_;
    my  $class = ref($this) || $this;
    my  $self = {};

    bless($self, $class);
    $self->register( "who" );
    return $self;
}




# the default "request()" method is good enough for our purposes


sub getinfo {
    my( $self ) = @_;

    open( WHO, "who 2>/dev/null|" );
    my %user = ();
    my $count = 0;
    while( <WHO> ) {
        chomp;
	$count++;
	s/[\s\t].*//;
	if( defined $user{$_} ) {
	    $user{$_}++;
	}
	else {
	    $user{$_} = 1;
	}
    }
    close WHO;
    return( {} ) if( $? );

    print "who: $count\n";
    my @distinct = keys %user;
    return { 0 => {
        "hrSystemNumUsers" => $count,
	"hrSystemDistinctUsers" => $#distinct + 1
    } };
}


1;

