Page 1 of 1

Simple shell script with SNMP to remote host

Posted: Mon Apr 27, 2015 3:41 am
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

Posted: Mon Apr 27, 2015 7:05 am
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

Posted: Mon Apr 27, 2015 7:06 am
by KS-Soft
May we see script?

Regards
Alex

Posted: Mon Apr 27, 2015 8:19 am
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

Posted: Mon Apr 27, 2015 10:35 am
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

Posted: Mon Apr 27, 2015 1:33 pm
by KS-Soft
I see.
Thank you for details

Regards
Alex