Do you have a website hosted on a server somewhere – either in your home or in the cloud? Has it ever gone down and you didn’t know about it for hours? I have, and it has happened to me too many times.
As a result, I have often wanted/needed a way to verify that the server which is hosting my websites is up and running properly. While many fine graphical tools exist such as Munin for this purpose, I wanted a simple set of utilities that could return just the parameters I needed and how I needed them.
What’s Needed
There are two different ways in which I want to get my metrics. The first is a command-line utility that I can run from my local computer to test the parameter needed. The second is a set of python functions that deliver the same metrics that I can then use to create a custom webpage.
This webpage (a future project) would run on a local server such as a Raspberry Pi, which could then display all my metrics on a tablet display in a convenient location. A quick glance could then show that everything was running smoothly or that problems have arisen.
Many other possibilities exist as well – sending an SMS message when a site goes down, lighting up LEDs to indicate site performance, etc.
The various metrics needed to maintain server and website health can be grouped into two categories:
- Server performance – these metrics indicate the health of the server itself. Metrics such as cpu load and memory usage are most desired.
- Website performance – these metrics indicate the health of the webserver application as well as the websites themselves. Metrics include page load speed, site verification, and number of requests per hour.
The Solution
In order to meet the goals cited, I decided to create a custom site monitoring library. This library is a collection of python scripts that provide monitoring tools for servers and websites. These scripts can be:- Run from the command line on a local computer in order to get the needed information any time it is needed without having to login to the server. An added benefit is once the library is downloaded to the local computer, it can be used to monitor any server without needing any further installation on that server.
- Individual functions in each file can be loaded and called from custom python applications to provide customizable output. I mentioned some possibilities already. I hope to implement some of those in a future project.
Each of these utilities require a host
to be specified. The host
can be either a named host in your ~/.ssh/config
file, or it can be specified as USER@DOMAIN/IP
. Server utilities can also be called to monitor your local computer. In this case, use either local
or localhost
for the host specification.
Note: if you do not have a computer running Linux or Mac, you may have difficulty using them due to the lack of SSH support in Windows. In that case, I suggest using either a Raspberry Pi to run them on, or upgrade your computer to a more modern operating system.
Getting Started
Installation
Download the library from github, or use git to clone the repo via:
$ git clone https://github.com/provideyourown/SiteMonitoring.git
To execute these utilities as standalone scripts, make them executable via:
$ chmod +x FILENAME.py
You can also execute the standalone scripts repeatedly with a simple bash function (add to your ~/.bashrc or .bash_aliases file):
repeat() { INT=$1; shift; while true; do $*; sleep $INT; done; }
Usage, e.g. repeat systemload
every 15 secs:
repeat 15 ./systemload.py local
The repeat function can be very handy to monitor changes in server loads, memory usage or any other parameter provided in this library.
Now let’s examine the utilities themselves. They are grouped into Server utilities and Website utilities.
Monitoring Tools for your Website/Server by Provide Your Own is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
One Trackback
[…] How to Get Your Website Indexed by Search Engines in 24 Hours Or Less! | PlusCaptcha Homepage24-Hour House, In-Kind Sponsors Recognized | HabiJax How To Get On The First Page Of Google Within 24 Hours Free – Blogging Tips and Tricks Why Buick’s Free 24 Hour Test Drive Might Cost You Bargaining Power – Game Theory Tuesdays | Mind Your DecisionsChecking Your Resource UsageRock online reviews with one widget! – localbiz360Monitoring Tools for your Website/Server […]