check_users_cacti_nagios
This script provides the number of shell users logged into the target machine. Should work with many flavors of Linux and UNIX.
This script requires:
1) Change the username to match the one you use for Nagios/Cacti data collection. 2) ssh key set up from the Nagios/Cacti server to the desired user on the remote machine 3) If the user that connects to the remote machine is different from the one that Nagios/Cacti run under, then you need something like this in sudoers:
cacti  ALL=NOPASSWD: /bin/su - *
In Nagios command.cfg:
define command{
      command_name   check_users
      command_line   $USER1$/check_users_cacti_nagios.sh $HOSTADDRESS$ $ARG1$ $ARG2$ nagios
      }
In Nagios services.cfg
define service{
      use                            service_1_min     Â
      host_name                      remotehost1,remotehost2
      service_description            users
      check_command                  check_users!40!50
      max_check_attempts             7
      contact_groups                 admins
      }