Simple shell script with SNMP to remote host

Remote Monitoring Agent for Linux, FreeBSD, and other UNIX-like platforms.
Post Reply
Christiane
Posts: 12
Joined: Tue Nov 15, 2011 2:37 am

Simple shell script with SNMP to remote host

Post by Christiane »

Hi,

I wrote a little shell script to get some info from remote host (SNMP) and I want to use this script with RMA for UNIX (located on one of our debians).
On cmd the script is running fine but with RMA (script is in HM script manager) I get "Agent error: Connection error".
Other scripts from script manager are working perfect.

May be the problem is getting info from other remote host or would this be possible?

Christiane
Christiane
Posts: 12
Joined: Tue Nov 15, 2011 2:37 am

Post by Christiane »

Oh sorry - I just realized this happens only in test mode of script manager. And there it happens for all shell scripts with RMA for Unix. But in live mode the test is working fine and I am happy now.

May be this is a bug of the test feature ("let's try")?

Christiane
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

May we see script?

Regards
Alex
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

So, if you setup test, it works fine with agent?
May be you are using Remote Control Console (RCC) started on some system with blocked network connection to RMA agent?

Regards
Alex
Christiane
Posts: 12
Joined: Tue Nov 15, 2011 2:37 am

Post by Christiane »

That was exactly the problem, thanks!!
Now both work fine - the test in RCC an the test in real life ;)

And here ist my sample script:

#!/bin/sh
if [ $# -ge 2 ]
then
diskfree=`snmpget $1 .1.3.6.1.4.1.2021.9.1.7.1 | awk '{print $NF}'`
diskfree=$(($diskfree / 1024 / 1024))

if [ $diskfree -ge $2 ]
then
echo 'ScriptRes:Ok:'$diskfree' GB'
else
echo 'ScriptRes:Bad:'$diskfree' GB'
fi
else
echo 'ScriptRes:Unknown:not enough parameters specified'
fi

I know we can do same test with RMA itself but all of our debians are located in DMZ and we don't want RMA on each of them and open the necessary ports. With shell script / SNMP over one RMA we now are able to monitor all other hosts. :D

Christiane
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I see.
Thank you for details

Regards
Alex
Post Reply