no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:termuser [2010/01/21 02:58] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== termuser ====== | ||
+ | |||
+ | ^ Author | [[ gjohnson@trantor.org | Galen Johnson ]] | | ||
+ | ^ Compatibility | Xymon 4.2 | | ||
+ | ^ Requirements | Perl, Windows | | ||
+ | ^ Download | None | | ||
+ | ^ Last Update | 2007-06-30 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | termusers.pl is an external script that is run by the Big Brother client on a Windows Terminal Servers. It counts the number of users and determines how many are active or disconnected users. | ||
+ | |||
+ | ===== Installation ===== | ||
+ | === Client side === | ||
+ | - Add to BBWin.cfg in externals< | ||
+ | < | ||
+ | < | ||
+ | |||
+ | |||
+ | === Server side === | ||
+ | - Add ' | ||
+ | - Add < | ||
+ | - Add ' | ||
+ | - Update hobbitgraph.cfg with: < | ||
+ | TITLE Terminal Server Users | ||
+ | YAXIS # | ||
+ | DEF: | ||
+ | DEF: | ||
+ | LINE1: | ||
+ | LINE2: | ||
+ | COMMENT:\n | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Source ===== | ||
+ | |||
+ | ==== termusers.pl ==== | ||
+ | <hidden onHidden=" | ||
+ | <code perl> | ||
+ | ######################################################################## | ||
+ | # Name: termusers.pl | ||
+ | # Version: 1.0 | ||
+ | # Author: Brandon Kitchen | ||
+ | # Purpose: termusers.pl is an external script that is run by the Big | ||
+ | # | ||
+ | # the number of users and determines how many are active | ||
+ | # and disconnected users. | ||
+ | # | ||
+ | # Changelog: | ||
+ | # | ||
+ | # | ||
+ | ######################################################################## | ||
+ | |||
+ | use strict; | ||
+ | use Sys:: | ||
+ | |||
+ | # Constants | ||
+ | use constant RED_ALERT | ||
+ | use constant YELLOW_ALERT => 25; | ||
+ | use constant DEBUG => 0; | ||
+ | |||
+ | # Globals | ||
+ | use vars qw($total_users); | ||
+ | use vars qw($active_users $disc_users); | ||
+ | use vars qw($computer $service $line $userattr $bblogs); | ||
+ | use vars qw(@userinfo @query); | ||
+ | |||
+ | # This is the name of the column in the BB display. | ||
+ | $service | ||
+ | $bblogs | ||
+ | |||
+ | # Get the local system name. | ||
+ | $computer = hostname(); | ||
+ | |||
+ | # Setup where output goes. | ||
+ | if ( DEBUG ) { | ||
+ | open(STATUS, | ||
+ | } else { | ||
+ | open(STATUS, | ||
+ | } | ||
+ | |||
+ | # Get the list of terminal users. | ||
+ | @query = `query user`; | ||
+ | |||
+ | # Setup the counters. | ||
+ | $total_users = 0; | ||
+ | $active_users = 0; | ||
+ | $disc_users = 0; | ||
+ | |||
+ | # Go through the list of users looking for different types (ie group1 vs group2) | ||
+ | for $line (@query) { | ||
+ | # Discard the header line. | ||
+ | next if $line =~ / | ||
+ | |||
+ | $total_users++; | ||
+ | print " | ||
+ | |||
+ | # Get rid of whitespace at the start of the line. Also fix | ||
+ | # the special case user (console) that starts with <. | ||
+ | if ( $line =~ /^\s+/ ) { $line =~ s/^\s+//g; } | ||
+ | if ( $line =~ / | ||
+ | |||
+ | # Split the line into tokens and start counting special users. | ||
+ | @userinfo = split /\s+/, $line; | ||
+ | if ($line =~ /Active/) { | ||
+ | $active_users++; | ||
+ | } elsif ($line =~ /Disc/) { | ||
+ | $disc_users++; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | # Check the total_users count and alert as appropriate. Also alert red if | ||
+ | # any users in the Revoked OU have sessions on the system. | ||
+ | if ($total_users <= YELLOW_ALERT) { | ||
+ | print STATUS " | ||
+ | } elsif ($total_users <= RED_ALERT) { | ||
+ | print STATUS " | ||
+ | } else { | ||
+ | print STATUS " | ||
+ | } | ||
+ | print STATUS qq/There are $total_users terminal users on $computer.\n | ||
+ | Of the $total_users total users:\n | ||
+ | \t Active Sessions: | ||
+ | \tDisconnected Sessions: | ||
+ | |||
+ | /; | ||
+ | |||
+ | # Send the list of users. | ||
+ | print STATUS " | ||
+ | |||
+ | # All done now. | ||
+ | close(STATUS); | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | * No known bugs. | ||
+ | |||
+ | ===== To Do ===== | ||
+ | * Provide instructions for tracking disparate customers. | ||
+ | |||
+ | ===== Credits ===== | ||
+ | * Brandon Kitchen - I took it over because I know he isn't going to want to support it. | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2007-06-30** | ||
+ | * Initial release | ||