Wednesday, April 8, 2009

Zenoss monitor remote customized application via SSH

I have used 3 open source NMS apps, nagios,openNMS, Zenoss. Zenos is the best i have found so far. Nagios doesn’t support SNMP and no graphing ability. OpenNMS supports SNMP and graphing but it needs restart for new config to be effective.
Zenoss doesn’t have native NRPE plugin like OpenNMS, But Zenoss has the ability to run customized application though the ZenCommand process, ZenCommand can run any command locally and remotely by using a native SSH transport. When run, Zenoss tracks the return code( 0 =success, !0= fail)
Zenoss can monitor customized applications by various methods e.g SSH/NRPE/SNMP, this note demonstrates SSH method

#==On the remote host, create a test script
$vi /usr/local/bin/

if [ $flag -eq 0 ]; then
echo "check test-OK"
exit 0
echo "check test-FAILED"
exit 1

$chmod +rx /usr/local/bin/

#==On zenoss
#====Test ssh remote command manually with password authentication
ssh zenoss@remote-ip /usr/local/bin/

#====set ssh username/password on Zenoss

zCommandUsername =zenoss
if you prefer to use ssh key, only enter zCommandUsername ( it appears only dsa type key works)
It is global setting for all devices, it apply to any devices.

#====Create template to use the script

Classes--Devices--Templates--Add Template (add template is hidden drop down menu brought up by clicking the small triangle button)
New data Source ( ID: userdefined TYPE: command)

use ssh :true
Event Class:/cmd/fail
Command Template:/usr/local/bin/
#====Bind the template to your Device
Device List--yourdevice--Open--
Click the small triangle button--More--Template
Click the small triangle button--Bind Templates--add new template to selection (You can select multiple templates)
/opt/zenoss/zenoss/bin/zencommand run -d -v10

INFO:zen.zencommand:---------- - schedule has 1 commands
DEBUG:zen.zencommand:Next command in 299.977344 seconds
DEBUG:zen.SshClient: host key: 66:d3:e2:09:45:80:36:0d:16:77:0a:db:7a:9d:4a:e6
DEBUG:zen.SshClient:creating new SSH connection...
DEBUG:zen.SshClient:Attempting to authenticate using username: zenoss
DEBUG:zen.SshClient:Getting SSH public key from ~/.ssh/id_dsa
DEBUG:zen.SshClient:Expanded key path from ~/.ssh/id_dsa to /home/zenoss/.ssh/id_dsa
DEBUG:zen.SshClient:Getting SSH private key from ~/.ssh/id_dsa
DEBUG:zen.SshClient:Expanded key path from ~/.ssh/id_dsa to /home/zenoss/.ssh/id_dsa
INFO:zen.SshClient:Connected to device
DEBUG:zen.SshClient:started the channel
DEBUG:zen.SshClient:opening command channel for /usr/local/bin/
DEBUG:zen.SshClient:running command remotely: exec /usr/local/bin/
DEBUG:zen.SshClient:command /usr/local/bin/ data: 'check test-FAILED\n'
DEBUG:zen.zencommand:Process stopped (1), 1.614611 elapsed
DEBUG:zen.zencommand:The result of "/usr/local/bin/" was "check test-FAILED

As output shows, it connected to remote host via ssh then run the command /usr/local/bin/
Back to GUI, the alarm should appear in event log of the device.


  1. [root@zenoss ~]# /opt/zenoss/bin/zencommand run -d -v10
    /opt/zenoss/bin/zencommand: line 12: /bin/zenfunctions: No such file or directory
    /opt/zenoss/bin/zencommand: line 18: generic: command not found

  2. Remote Monitoring
    We are a Remote Monitoring & System Integration Companies and control 4 authorised dealers. We integrate all aspects of technology through the control 4 amarthome app.