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.

2 replies on “A Logwatcher Tool to Trigger Integrations After Changes in phpIPAM”

Hey there, how are you doing? Awesome content in your site.
I was wondering, what sources did you use to manage to integrate kea Dhcp and phpipam, I want to try to integrate ours. Thanks in advance.

Leave a Reply to Jay Tuckey Cancel reply

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