From feeb5a5c029cea62996f2e43cad6214401091643 Mon Sep 17 00:00:00 2001 From: Victor Robellini Date: Fri, 3 Apr 2020 15:07:45 -0400 Subject: [PATCH] Testing php addon to see about pulling in interface information from pfSense rather than the system. --- plugins/telegraf_pfinterface.php | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 plugins/telegraf_pfinterface.php diff --git a/plugins/telegraf_pfinterface.php b/plugins/telegraf_pfinterface.php new file mode 100755 index 0000000..6f01b59 --- /dev/null +++ b/plugins/telegraf_pfinterface.php @@ -0,0 +1,43 @@ +#!/usr/local/bin/php-cgi -f + $friendly) { + $ifinfo = get_interface_info($ifname); + $ifstatus = $ifinfo['status']; + $ifconf = $config['interfaces'][$ifname]; + $ipaddr = get_interface_ip($ifname); + $subnet = get_interface_subnet($ifname); + $ipaddr6 = get_interface_ipv6($ifname); + $subnet6 = get_interface_subnetv6($ifname); + $realif = get_real_interface($ifname); + $mac = get_interface_mac($realif); + + if (strtolower($ifstatus) == "up"){ + $ifstatus = 1; + } + if (strtolower($ifstatus) == "no carrier"){ + $ifstatus = 0; + } + if (!isset($ifstatus)){ + $ifstatus = "Unknown"; + } + + if (!empty($ipaddr)) { + printf("interfaces,host=%s,name=%s,ip_address=%s,friendlyname=%s,source=%s status=%s\n", + $host, + $realif, + $ipaddr, + $friendly, + $source, + $ifstatus + ); + } +} +?> \ No newline at end of file