KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Linux external SSH Shell Script check help

 
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX
View previous topic :: View next topic  
Author Message
MeBrian



Joined: 18 May 2011
Posts: 4

PostPosted: Thu Nov 10, 2011 11:16 pm    Post subject: Linux external SSH Shell Script check help Reply with quote

Hi,

I need some help using the External - SSH – “Shell Script Result” – check aginst Linux boxes.
I’ve been trying to figure out the syntax /scripting structure for this test but so far have not had much luck.
The most I’ve been able to get to work is abc=ls; echo ScriptRes:'Ok':$abc and this just echos ls for the result.

Do you have any examples for this?
Like something for a simple memory check that looks up the current free memory, compares that against a hardcoded value, shows Ok or Bad depending on if the free mem is greater or less than the min and then also displays the current free memory in the reply output, like the below:
op = cat /proc/meminfo | awk '$1=="MemFree:"{print $2;exit}'
if op > 3000 then
ScriptRes:'Ok':$op
Else
ScriptRes:'Bad':$op
fi

Also with in the External – SSH test – Text Output -- check, I have successfully run a script on the remote box by doing ./script but I do not see any results from this test show up in the reply.
Is there a way to tune up the reply so to show its output?

Thanks for the help
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 11916
Location: USA

PostPosted: Fri Nov 11, 2011 1:27 pm    Post subject: Reply with quote

You made several mistakes in this script.
It should look like
Code:
op=`cat /proc/meminfo | awk '$1=="MemFree:"{print $2;exit}'`;
if [ $op -gt 30000 ]
then
 echo "ScriptRes:Ok:"$op
else
 echo "ScriptRes:Bad:"$op
fi


Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
MeBrian



Joined: 18 May 2011
Posts: 4

PostPosted: Fri Nov 11, 2011 3:34 pm    Post subject: Reply with quote

Thank you for your reply.

My provided script was only meant as sudo code for what I was trying to do so yes, it did have some errors.

The HM External SSH checks only allow for a one line command.
Unfortunately, when I collapse your script down to a one line string it does not all fit on the single command line.
op=`cat /proc/meminfo | awk '$1=="MemFree:"{print $2;exit}'`; if [ $op -lt 30000 ] ;then echo "ScriptRes:Ok:"$op ; else echo "ScriptRes:Bad:"$op;fi
It’s too long. I can only fit 127 characters on the line.

I rewrote it such that it would fit and was able to get it to work:
op=`./freemem`; if [ $op -lt 30000 ] then echo "ScriptRes:Ok:"$op else echo "ScriptRes:Bad:"$op fi
./freemem is a script local to the box that runs cat /proc/meminfo | awk '$1=="MemFree:"{print $2;exit}'.
This option defeats the some of the purpose of HostMon if I have to put an bash script or (RMA agent) on each box to run Linux tests.

While yes, there are other scripting options that I can do, they all either require me to touch/configure (in some fashion script or manually) each box that I want to check.
If you only have a few, this is not an issue, but when that number gets into the hundreds or more across the Globe and is dynamic, that can start to become a chore.

Is there any way I can combine the SSH functionality of the External SSH test with the scripting capability of the External Shell script tests?
In short, I would like to be able to run the full length External Shell Scripts through SSH on each remote Linux box I have without having to actually having to touch each one first.
Is this a feature that I’m missing or is it not implemented in HM?

Thank you for your Help.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 11916
Location: USA

PostPosted: Fri Nov 11, 2011 8:59 pm    Post subject: Reply with quote

Quote:
Is there any way I can combine the SSH functionality of the External SSH test with the scripting capability of the External Shell script tests?
In short, I would like to be able to run the full length External Shell Scripts through SSH on each remote Linux box I have without having to actually having to touch each one first.

Sorry, there is no such posibility in current version of HostMonitor and truth to say I am not 100% sure its possible to implement

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index