Skip to content

Adrian Giacometti

  • Home
  • Useful links
  • About Me

The power of simplicity applied to monitoring

26th July 2021 by Adrian Giacometti

Some time ago I was asked for help to develop a “simple and quick” Python script to monitor the status of a Linux service. They were in the middle of a deployment and they needed something fast.

They added, keep the result in a JSON file with the date, serve the directory with HTTP for quick view, and finally post it to ELK for graphics.

Ok, this looks simple part by part, but the sum ends up in a very complete solution at the same time!

Since simplicity was the key, the script has to do just that with the fewest lines of code, and I added that it shouldn’t be necessary to install additional libraries or SDKs (aka dependencies).

This made me remind of the funny but true acronym KISS (Keep It Simple Stupid), well known in software development groups.

In a couple of hours, the script was ready, and in less than 100 lines of code, it was all included.

https://github.com/aegiacometti/pymond/blob/master/pymond.py

But this process made me think a lot about those huge monitoring platforms with which I had worked before, and I fell in love with the idea of keeping it extremely simple but fully functional.

Because, this script IS simple, has a small footprint, gives a lot of functionalities, and can be deployed to multiple servers with a simple Ansible playbook or any other automation tool (Chef, Puppet, etc).

But wait, to push a bit more I daemonized the script to be controlled by systemd (it could have been a simple cron task)

And lastly, to make it even better, I added ICMP checks, and send events to Slack with a webhook.

That’s it! pymond was born.

Everything in only 150 lines of code.

Voilà a light but very complete monitoring solution.

https://github.com/aegiacometti/pymond/blob/master/pymond2.py

It is not hard at all to customize and monitor whatever you need in a server, and make it push the results to a collector, or even a slack message straight to you when there are problems. You only need to add your functions to the loop.

Today I’m using this script to monitor my workstation and a couple of servers.

I receive the alerts in Slack

 and I can easily check all previous statuses

Very interesting, the power of simplicity!

Check the full repo for the configuration files to tweak:

https://github.com/aegiacometti/pymond

Cheers

Share on Social Media
linkedin twitter email

Post navigation

Previous Post:

How To Netmiko – Full Speed (concurrency options)

Next Post:

How to configure 1 Linux host with 2 NICs and 2 Default Gateways

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Translate to your language

Site search

Tags

ansible automation aws bcp bgp books chatbot chatops cisco cisco aci cloud automation datacenter desing devops drp enterprise f5 fastapi free gitlab ci gitops high availability internet iproute2 isp learning linux monitoring nat netdevops netmiko netops network network automation network backup opensource oracle oci python saltstack slack slackops terraform vpn vrf webinar

Blog Stats

  • 13,367 hits

RSS ipSpace.net Blog Posts

  • Video: Packet Buffers in Data Center ASICs
  • Will ChatGPT Replace Stack Overflow?
  • New: CI/CD in Networking Resource Page
  • External Links on Spine Switches
  • Test VRF-Aware DHCP Relaying with netlab

RSS Unknown Feed

Archives

  • 2021 (10)
    • November (1)
    • August (2)
    • July (1)
    • May (2)
    • April (3)
    • February (1)
  • 2020 (15)
    • December (2)
    • October (1)
    • September (1)
    • June (1)
    • April (5)
    • March (1)
    • February (2)
    • January (2)
  • 2019 (3)
    • December (3)

Follow & Contact info

  • LinkedIn
  • GitHub
  • Twitter
  • YouTube
  • Email
  • RSS Feed

Subscribe to stay updated

Loading
© 2023 Adrian Giacometti