Categories
Linux Networking Programming Systems Administration

A Logwatcher Tool to Trigger Integrations After Changes in phpIPAM

We use phpIPAM to manage all our IP Addresses, and we have recently built integrations between phpIPAM and our Kea DHCP server for reservations, and also into our BIND DNS server.

These have been running on a schedule, which has worked well, but doing it that way means that it can take a while after a change inside phpIPAM for that change to be reflected in DNS/DHCP.

What I have made is a simple tool that watches the phpIPAM logs, and when it sees a change it will trigger the integrations to run immediately, avoiding all the waiting. This is written in the nim programing language. I’ve uploaded the code as a snippet to gitlab here:

https://gitlab.com/-/snippets/2075063

To make this work I also needed to configure phpIPAM to log changes to syslog as well as to the database:

The way the tool works is it runs the journalctl --follow command and then looks in the output for ipamprd1.example.org phpipam-changelog (obviously you need to replace with your hostname)

If it sees a line that matches it kicks off all the integrations, using either systemctl start integration.service or using ssh to connect to another server where the integration runs.

Leave a Reply

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