Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We do not have any sort of proper server monitoring solution in place (a situation I'd like to rectify this summer), but I've got one service in particular that I'd like to monitor. [Our current monitoring system, waiting for clients to call in with a problem, works well for widely-used systems, but this does not affect as many people, as, say, DHCP.]

I'm running All The Right Type 3 Server on (sigh) an OS X 10.3 (Panther) box [because it doesn't start itself automatically on something newer and our software procurement person really doesn't want to get updated software.] The client software is working fine the student's machines, under OS X 10.5 (Leopard).

Now then, I occassionally get a call that this server is down [and the machine itself is still up!], and I'd really prefer to know before someone has to pick up the phone. The process appears to be called "atrtserv.osx". While it does use the network, I would be surprized if the documentation for it spoke of how to send a message to see if the service is up, so something gross-grained, like check every five minutes that the process exists.

Is there a simple way to monitor one service, esp. on the Mac?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

I don't guarantee that this code works right (most especially the line that starts with "RUNNING=", but substitute some test of your own that can return a string if it's running and no string when it isn't.

#!/bin/bash  

while true ; do 
RUNNING=`ps aux | grep atrtserv | grep -v grep`
if [ -n "$RUNNING" ] ; then
    echo "atrtserv.osx is broken" | mail -s "atrtserv down" whoever@whatever.com
    sleep 300
else 
    sleep 300
    fi
done

Edit Use the pgrep above instead of my hack

share|improve this answer
    
I haven't tried it yet, but this sure looks like the right answer. pgrep is not built-in on the Mac. –  Clinton Blackmore Jun 2 '09 at 21:37

Well, the real simple way probably looks like:

pgrep atrtserv.osx >/dev/null || (
    date |
    mail -s 'atrtserv.osx down on yourmachine.foo' yourSMSphonenumber@yourtelco.com
)

in a cron job running at the interval of your choice.

share|improve this answer

You could write a small script that runs ps, and have cron run it every 5 mins.

mail will then mail you if it finds something wrong.

Total implementation time would be able 15 minutes I think.

share|improve this answer

Try monit from darwinports.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.