#!/bin/sh #Plugin created by: # Stephen Hodgson # Malone College - CPSC #This script is provided as-is with no warranty or guarantee of any kind. #-This simple plugin figures out how many users are logged into the linux box and writes it to a simple Gauge-style graph. #-The plugin takes advantage of the linux 'who' command. # -The who command is cut into the first field (to the first space). # -This is the username field. # -Unfortunately this will log multiples for the same user if multiple terminals are open. # -Then we need to sort the results since uniq only deals with unique elements next in line to each other. # -We find the uniqe usernames logged on. # -Then wc -l counts how many lines (users) we're left with. if [ "$1" = "config" ]; then echo 'graph_title Users Online' echo 'graph_args --base 1000 -l 0 ' echo 'graph_vlabel Number of users' echo 'graph_category system' echo 'users.label users' echo 'graph_args --base 1000 -l 0' echo 'graph_scale no' exit 0 fi echo -n "users.value " echo `who | cut -f -1 -d ' ' | sort | uniq | wc -l`