Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to monitor three server pages. These three pages contain a simple text (for example it says it's "working fine"). I want to be notified when anything other than this message is displayed, e.g. via email.

I want shell scripting code for displaying the status of the three pages in an html file.

share|improve this question
add comment

2 Answers

if your pages are proper HTML-pages and you do not want to parse that, you might want to use lynx (the old-school text-base browser) for rendering the HTML into plaintext first (using the --dump flag):

for lnk in http://foo.example.com \
           http://bar.example.com \
           http://stats.example.com/stillrunning.html
do
   lynx --dump "${lnk}" \
   | grep "working fine" \
   || mailx -s "${lnk} failed" you@example.com
done
share|improve this answer
add comment

You could use either curl or wget along with bash to accomplish what you want.

$ wget -O- http://example.com | grep "working fine" || mailx -s "Oh NO" you ...
share|improve this answer
add comment

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.