xfb52 at dial.pipex.com
Wed Dec 14 03:43:45 PST 2005
Anirban Adhikary wrote:
>This is Anirban. I have a doubts on the following question.
>How to write a shell program that will check whether a server is up or down
>(on ping) and log the report to a file.
You may be wondering why no-one is replying to you and the main reasons
1) You show no evidence of even having *tried* to write something.
If you'd said "I did X but it didn't work" then maybe some kind soul
would have helped you out. All you are asking is for someone else to
write your script for you.
2) It's pretty clear that you know next to nothing about shell
scripting, in which case you should do what everyone else who has needed
to write shell scripts has done:
a) Buy a book or
b) study some examples of which there must be hundreds on your
FreeBSD installation or
c) get someone to teach you or
d) search google for tutorials
And always, always, always read the manual pages.
Here's a quick sh script for you. You can figure out how to do the
redirection and how to run it from cron.
$ for host in host1 host2
> if ping -c 1 $host 2>&1 > /dev/null
> echo $host: UP
> echo $host: DOWN
You might also consider nagios from the ports but it may be far more
than you want. With the limited information you provided about why you
want to do this, no-one will ever know.
More information about the freebsd-questions