Forum Discussion
Troy_93881
Nimbostratus
Apr 01, 2011Monitor using "grep"
All,
Looking for a little guidance. I would like to know if I can set up a monitor ( multiple monitors ) that would run a "grep" command and based on results -- mark a member up or down.
Appreciate and help anyone can provide,
Thanks
11 Replies
- hoolio
Cirrostratus
Hi Troy,
What do you want to grep for and from what and where? Which protocol of pool member are you trying to check?
Aaron - Troy_93881
Nimbostratus
Hello Aaron,
We are looking to design a monitor to log in to a server via CLI and perform the following commands:
ps -ef | grep arserverd and ps -ef | grep arplugin
Based on the results of those commands -- the server will be marked up or down - hoolio
Cirrostratus
Hi Troy,
You could use SSH to connect to an IP address and performs the commands. You could then reference that SSH command in an external monitor, using this template:
http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/TemplateForExternalLtmMonitors.html
Here's another option which would probably require fewer resources on LTM:
Build a web app on each server which runs those commands to check for the processes and returns text in a web page indicating an up or down status. You could then use a built in HTTP monitor to check that status page.
Aaron - Troy_93881
Nimbostratus
Thanks Aaron
I'm not real experienced with scripting. I am working on an external monitor now that may do the trick if I can get it figured out.
Unfortunately, these boxes do not have web servers on them. A "keep alive" web page would have been my first choice due to simplicity regarding the F5 side..
Troy - hoolio
Cirrostratus
You should probably just be able to plug in this command to the template script:
ssh $IP -p $PORT 'ps -ef | grep arserverd | grep -v grep && ps -ef | grep arplugin | grep -v grep' 2>&1 > /dev/null
in replacement of this line:
nc $IP $PORT | grep "my receive string" 2>&1 > /dev/null
I haven't tested this, but I think it looks about right.
Aaron - Troy_93881
Nimbostratus
Hey Aaron,
It appears to marking it up regardless as long as there is any response. In this case -- I need to see a "./" in the response to both commands in order for it to be up. If the ./ is missing in either response -- the server should be marked down.
How do I change that in the script section below or do I need 2 external programs?
send request & check for expected response
ssh $IP -p $PORT 'ps -ef | grep arserverd | grep -v grep && ps -ef | grep arplugin | grep -v grep' 2>&1 > /dev/null
mark node UP if expected response was received
if [ $? -eq 0 ]
then
echo "UP"
fi
rm -f $PIDFILE
exit - hoolio
Cirrostratus
Can you run this from one of the hosts you want to monitor:
ps -ef | grep arserverd | grep -v grep | grep \\\. && ps -ef | grep arplugin | grep -v grep | grep \\\.
If that returns something on success and nothing on failure, can you try this in the script?
ssh $IP -p $PORT 'ps -ef | grep arserverd | grep -v grep | grep \\\. && ps -ef | grep arplugin | grep -v grep | grep \\\. 2>&1 > /dev/null'
Aaron - Troy_93881
Nimbostratus
I will test that -- right now that command does return the 2 expected responses from the server when all is working. I will need to have the owner drop one of processes to see if it causes the server to be marked down when the other is still working and vice versa.
I'll update here with the results
Thank you very much for the help,
Troy - Troy_93881
Nimbostratus
Aaron,
I tested the monitor and it is still leaving the member marked up despite no response to that command. At the server prompt ( xxxxxx/xxx/xxx/xxx/arserverd> ) I entered the command and now it just comes back to the prompt with no output ( xxxxxx/xxx/xxx/xxx/arserverd> ).
"arserverd" does appear in the server prompt though as you can see. "arplugin" does not.
I am getting lots of log messages now due to the debug addition -- EAV ars_mon.bash: exceeded monitor interval, needed to kill xxx.xxx.xxx.xxx:443 with PID 32378
It does take time to log into the server -- once you ssh and enter user / password -- it takes approx 15 sec to bring up the prompt. I'm wondering if this is hanging it up. If so -- why would the member remain online? How is the F5 logging in using you template? - Troy_93881
Nimbostratus
Aaron,
After running several tests -- it appears that the script really isn't looging in completely and because there is something other than a "null" response, the server is being marked up. It looks like I need to incorporate a ssh key gen or some other way to get completely into the server or get the script to answer the password prompt and then perform the command if thats possible.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects