Révision 2578e754
Initial version
| plugins/other/users | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
|
|
| 3 |
#Plugin created by: |
|
| 4 |
# Stephen Hodgson |
|
| 5 |
# Malone College - CPSC |
|
| 6 |
|
|
| 7 |
#This script is provided as-is with no warranty or guarantee of any kind. |
|
| 8 |
|
|
| 9 |
#-This simple plugin figures out how many users are logged into the linux box and writes it to a simple Gauge-style graph. |
|
| 10 |
#-The plugin takes advantage of the linux 'who' command. |
|
| 11 |
# -The who command is cut into the first field (to the first space). |
|
| 12 |
# -This is the username field. |
|
| 13 |
# -Unfortunately this will log multiples for the same user if multiple terminals are open. |
|
| 14 |
# -Then we need to sort the results since uniq only deals with unique elements next in line to each other. |
|
| 15 |
# -We find the uniqe usernames logged on. |
|
| 16 |
# -Then wc -l counts how many lines (users) we're left with. |
|
| 17 |
|
|
| 18 |
|
|
| 19 |
if [ "$1" = "config" ]; then |
|
| 20 |
echo 'graph_title Users Online' |
|
| 21 |
echo 'graph_args --base 1000 -l 0 ' |
|
| 22 |
echo 'graph_vlabel Number of users' |
|
| 23 |
echo 'graph_category system' |
|
| 24 |
echo 'users.label users' |
|
| 25 |
echo 'graph_args --base 1000 -l 0' |
|
| 26 |
echo 'graph_scale no' |
|
| 27 |
exit 0 |
|
| 28 |
fi |
|
| 29 |
echo -n "users.value " |
|
| 30 |
echo `who | cut -f -1 -d ' ' | sort | uniq | wc -l` |
|
Formats disponibles : Unified diff