Adding Slack Notifications to phpipam

Published by Christian Mohn · Read in about 1 min (213 words)

As mentioned before, I’ve kinda turned my home lab into some sort of Slack-Ops deal, where various services in my home lab notify me of events in a private Slack channel.

The latest rendition of that, is adding Slack notifications from phpipam. Once phpipam detects a new device picking up an IP in my network, it notifies me like this:

In order to get this working, I had to edit the /var/www/phpipam/functions/scripts/discoveryCheck.php file in phpipam. discoveryCheck.php is the script that is run when phpipam does local subnet discovery  check, so this was a natural place to add my custom curl command.

I added the following code on line 254 in that file, just below the  code block that ends with $Addresses->modify_address($values);

// Log to Slack -- Run custom CURL script
$command = "curl -s -X POST -H \"Content-type: application/json\" --data '{\"text\":\"$values[lastSeen] - new host autodiscovered: IP: $ip Hostname: $values[dns_name] \"} https://[WEBHOOK URL]";

Replace [WEBHOOK URL] with your actual URL. For more details on how to set up a webhook URL, check Logging SSH logins to Slack.

Pretty easy to do locally, but it would be nice of the phpipam developers could make alerting to third party services a native feature - I’m sure there are other use cases for this as well.

Post last updated on January 2, 2024: Add author

About is the digital home of Christian Mohn and Stine Elise Larsen.

The primary focus is on IT architecture and data center technologies like virtualization and related topics, but other content also pops up from time to time.