Cecilia Gripenberg – Senior Consultant
Pulses
In our last post, we talked about monitoring site-to-site VPNs and some of the metrics/methods that can be used.
Today we’ll concentrate on setting up monitoring using heartbeats. The idea behind this is that a server sends regular heartbeat messages across the VPN tunnel, and if one is not received by a predetermined deadline by a remote server, an alert is triggered. This can be useful if your application is particularly vulnerable to outages due to the remote server being a part of a rapid workflow. In our example, we’ll be using three different technologies, Python, Redis and OP5 monitor. Any of these components can be swapped out with other software.
These are the roles that each component plays:
The engine
Python will be used to send heartbeats to a Redis database. This runs on both the remote server (sender) and monitoring server (receiver).
The database
Redis is a simple key-value database that is optimized for speed. Redis will host the database and provide a way to time out the heartbeat messages. This runs on the monitoring server here, but could be easily moved to another server that is reachable via the VPN.
The monitoring system
OP5 monitor will make sure that the heartbeats never fail by providing a stop-gap alert which will be triggered if both the Python script and Redis database are down. This is accomplished using a mechanism called check_freshness. This mechanism will ensure that status information is ‘fresh’.
So as you can see, setting up heartbeats is quite straightforward.
The source for this example is located here: https://github.com/opsdis/heartbeat_monitoring
There you’ll find everything you need to set up Heartbeat monitoring on your own.
Should you need any assistance with setting up your own heartbeat monitoring, please contact us to know more.
About the author

Deep knowledge on Icinga, op5 Monitor and Nagios. Plugin developer and automation engineer with focus on Ansible.