check_users: list the users?

Gary Every gevery at gmail.com
Thu Apr 17 23:37:54 CEST 2008


Could write a script that runs on the local machine(s) when called from
nagios via snmp

This will require that all snmp's are set up alike on all the local
machines, and a line formatted similarly below be added to each
/etc/snmp/snmpd.conf file:

exec check_users /usr/local/bin/check_users.sh

<snip>
#!/bin/bash
## Title: check_users.sh

## This will check the users logged in and report a crit if there are too
many
WHO=/usr/bin/who
WC=/usr/bin/wc
WARN=1
CRIT=3
users=`$WHO`
output=`$WHO | $WC -l`

if [ "$output" = "1" ]  || [ "$output" = "2" ]
then
RETVAL=1
elif [ "$output" -gt "2" ]
then
RETVAL=2
fi


if [ "$users" = "" ]
then
users="No users logged in"
fi

## Let's output it:
echo $users
exit $RETVAL
</snip>

Restart your snmpd

Now, from the nagios box cli:
/usr/lib/nagios/plugins/check_snmp -H YOUR_HOST_TO_CHECK  -C
YOUR_SNMP_COMMUNITY_STRING -o
enterprises.ucdavis.extTable.extEntry.extResult.NUMBER,enterprises.ucdavis.extTable.extEntry.extOutput.NUMBER
-w 0 -c 1

where:
NUMBER above is actually the exec command you want to execute in the
snmpd.conf file. You can have many "exec" lines, and they are accessed via
this number. For example:

<snip from snmpd.conf>\
exec check_users /usr/local/bin/check_users.sh
exec check_procs /usr/local/bin/check_procs.sh
</snip>

If those are the only two, then you access check_users.sh by replacing
NUMBER with 1
or check_procs.sh by replacing it with 2, and so on . . . .

HTH!
G.~



On Thu, Apr 17, 2008 at 2:06 PM, Jay R. Ashworth <jra at baylink.com> wrote:

> I've just installed Nagios 3 and begun to configure it for my network
> (25ish servers, all but 2 running Linux, 250ish workstations, all but
> about 25 running Ubuntu), and after slogging through "SSL error" on
> check_nrpe -- which means about 3 different things having nothing to do
> with SSL -- and the ever popular "audio embeds *aren't*
> application/wav; they're audio/x-wav, just ask my mime.types file"
> problems, I'm now up to the possibly uncommon way I want to use
> check_users...
>
> I'm setting check_users (via nrpe) to warn at 1 and CRIT at 3 users --
> I'm putting this on servers that, typically, have no humans logged in
> at all.
>
> Since that's true, I'd like to have the list of users from who -q
> returned as part of the status message.
>
> a) Is this a not uncommon usage, and when I patch the program, should I
> therefore post and or submit a patch to do this?
>
> b) How long can that status message become without breaking 1) nagios
> and 2) nrpe?
>
> Anyone have opinions, answers, or pointers?
>
> Cheers,
> -- jra
> --
> Jay R. Ashworth                   Baylink
> jra at baylink.com
> Designer                     The Things I Think                       RFC
> 2100
> Ashworth & Associates     http://baylink.pitas.com                     '87
> e24
> St Petersburg FL USA      http://photo.imageinc.us             +1 727 647
> 1274
>
>             Those who cast the vote decide nothing.
>             Those who count the vote decide everything.
>               -- (Joseph Stalin)
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
>
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when
> reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>



-- 
Gary Every
"Pay it Forward!"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20080417/9ad35a1b/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list