Simple web server monitoring (alive)
Solution 1
You can use wget in a script like this
wget --timeout=3 --tries=1 --spider --no-check-certificate http://serverfault.com
if [ $? -ne 0 ];then
echo "Site Down" | mail -s "Site Down" [email protected]
fi
And you will get an email if wget cannot access the site first time within three seconds.
Set up a cron job to run the script every few minutes.
There are many other alternatives but this is probably the simplest to set up from scratch.
Solution 2
You have many options, I'll give you two.
Nagios is a full-blown monitoring application capable of monitoring much much more than http, but it handles that as well. It can also create all kinds of repots ("Tell me the uptime percentage of our server/service X this week/month/year...")
Monit is another popular choice. Maybe not as feature-filled as Nagios, but nevertheless it's nice.
Solution 3
I've upvoted Richard and Janne's answer, but if you want some more detail as to what your webserver is sending and receiving, the first couple chapters of the O'Reilly book "Web Client Programming with Perl" by Clinton Wong gives a great overview of the HTTP protocol. If you want more detailed monitoring than just up/down and want to include response codes, etc, it is a fine place to start.
The book is old, but still valid. Published in 1997, O'Reilly has posted the contents of the book online for free at http://oreilly.com/openbook/webclient/ as part of their OpenBook initiative.
Solution 4
Well, if you want to run something yourself.
These are some options:
Or if you want a managed solution:
Personally I think Zabbix and Zenoss are overkill if you simply wish to monitor the status of a web server. But if you also plan to monitor anything else than they have more features than you'll ever need ;)
Related videos on Youtube
Zitrax
Updated on September 17, 2022Comments
-
Zitrax over 1 year
Any tip about software to monitor if a web server is up and running on linux ? It should be able to run with not knowing anything more than the URL. And it must have functionality to send an email alert when the site goes down. Should not be hard to write a script for this myself but seems pointless if there is already something nice out there.
Note that I am going to monitor internal servers, so this need to be a tool that runs on my machine on the same network, not external web based services.
And note that small and simple solutions are preferred.
Update: I eventually created a small python script that I am currently using for this, it can be found here.
-
Warner almost 14 yearsSee also: serverfault.com/questions/44/… -- This topic has been covered extensively on a high level.
-
-
Zitrax almost 14 yearsI guess pingdom and uptrends can't monitor the sites on my internal network.
-
Geraint Jones almost 14 yearsas long as you don`t run it on the server that its monitoring - you have no idea how often I have seen that done ;-)
-
Zitrax almost 14 yearsI was looking for something small and simple, so monit seems closer to that.
-
Wolph almost 14 years@Zitrax: no, they can't. I read over that part.
-
Zitrax over 13 yearsAnd without installing 'postfix' the mail command just silently fails to send.
-
Richard Holloway over 13 years@Zitrax: And without wget being installed you will get an error. Without the network being up the wget will fail. Without the script being executable the cron job will fail and so on. Also I don't have 'postfix' installed and it works fine for me because I am using exim.
-
SDsolar over 6 yearsHere is how to install ssmtp to use gmail: unix.stackexchange.com/questions/363814/…
-
SDsolar over 6 yearsThis is great. I monitor my cron log with
wcron
but had the screen shut off. So when my scp's to the hosting service (that happen every 10 minutes for sdsolarblog.com/montage ) were failing I didn't see it. In my case,mail
can't reach the world, butssmtp
sure can,via gmail. So I will use this logic to send me a message as soon as the scp exits with a non-zero status. TNX MCH - Here is how to buildwcron
askubuntu.com/questions/966194/… -
Avamander over 5 yearsWhy the
--no-check-certificate
? Getting warned about broken TLS deployment is also valuable information.