Automate Bulk Host Addition for Cacti and Nagios with Simple Scripts
The article explains how to automate the tedious process of adding multiple hosts to Cacti and Nagios by using shell‑wrapped PHP scripts and custom templates, provides download links, and shares practical tips to avoid common installation pitfalls.
For a long time the author used Cacti + Nagios to build a monitoring and alerting system, but as the number of monitored hosts grew, manual addition became time‑consuming and error‑prone. Cacti’s web interface required several clicks per host, while Nagios required editing configuration files by hand, leading to delays and missed alerts.
To solve this, two batch‑addition scripts were created. The Cacti script leverages the built‑in PHP CLI tool in Cacti’s cli directory, wrapped by a shell script that mimics the manual host‑addition workflow. It uses the “better‑cacti‑templates” package from Google, which includes templates for MySQL, Apache, Nginx, etc. Users are advised to read the accompanying README for required settings.
During development the author encountered a persistent “Duplicate entry” bug in Cacti 0.8.7g that produced red error messages in the logs. Attempts to patch the spine source failed, so the author abandoned that version and recommends using a stable release where graph rendering is smoother.
The Nagios batch script follows a similar philosophy: two template files are provided—one for host definitions and another for service definitions. By customizing these templates to match the typical hosts and services the team monitors, the script can generate the necessary .cfg entries automatically. Again, the README contains important usage notes.
Both scripts are hosted on SourceForge at https://sourceforge.net/projects/easy-naca/. Users can download the packages, review the documentation, and adapt the scripts to their own environments to achieve faster, repeatable, and less error‑prone monitoring configuration.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
