Skip to main content
  1. posts/

Adding Slack Notifications to phpipam

·213 words·1 min·
Christian Mohn
Virtualization
Author
Christian Mohn
IT veteran, podcaster, author, and blogger from Bergen, Norway.

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:

screenshot-2016-11-03-22-24-18

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]";
system($command);

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.

Related

Running telnetlogger on my home IP
·435 words·3 mins
Christian Mohn
Virtualization
VMworld 2016 Europe
·155 words·1 min
Christian Mohn
Virtualization Barcelona conference vmworld
Goodbye PernixData FVP and Architect
·150 words·1 min
Christian Mohn
News Virtualization Nutanix PernixData