Today is the world of data and cloud servers. Both theses situations bring up cases where you need to track the available disk space or the performance of your servers. Questions like how much disk space is still left for the database or whether the machine is running out of virtual memory and hence killing some tasks by force. These situations should be avoided and you should be prepared well before in hand.
In this blog, I will show you how to set up a monitoring tool for your servers. First of all we need a separate server which we will use as a central monitoring server for all servers.
Simple Network Management Protocol (SNMP) is one such protocol which can be used. For this you first need to install snmp in all your servers which are supposed to be tracked. However I personally do not like this and avoid as much extra sudo installation in servers as possible. Moreover you need to change your firewall to allow incoming udp connection from the central tracking server (because eventually after snmp installation, the central tracking server will pull the performance data from all the servers via snmp). Personally I always prefer to drop most of the incoming connections to the servers to be on the safe side to prevent any possible hacks.
To go around this problem, thanks to REST APIs, instead of doing all that, all the servers can send the data to central tracking server via APIs and in this way you only need to alter the firewal of the central tracking server only (for allowing the incoming pakets at port 80 or 443) from the rest of the servers. In addition you do not need to sudo install anything in any other servers. This can be achieved in a very simple and quick way if you follow the following instructions.
Central tracking server
The solution is based on Python programming language. Redis will be used to create alarms if you need to get notified. Next you just need to clone the repository locally and install the python dependencies. Thats it, your central tracking server will be ready to track your severs (Note: keep your firewall open for incoming connections either via port 80 for http or 443 for https). More details about how to add new servers/devices and alarms can be found in the repository documentation.
Source code: https://github.com/shubhamdipt/monitoring-dashboard
Servers to be tracked
Here its even more simpler. Just git clone the following repository, create a virtual environment in the project folder and change the config file as documented in the follwing repository. Lastly you need to create a cron job for sending the data to the central tracking server at regular intervals.
Source code: https://github.com/shubhamdipt/server-monitoring
There you go! Your monitoring set up is ready. If you have further questions, please feel free to contact me or contribute to the project.