mirror of
https://github.com/bsmithio/OPNsense-Dashboard.git
synced 2026-02-16 14:14:16 +00:00
Initial changes to convert to OPNsense
This commit is contained in:
parent
4b832342d9
commit
d71174920f
13 changed files with 35 additions and 373 deletions
81
README.md
81
README.md
|
|
@ -9,60 +9,18 @@
|
|||
- Load Average
|
||||
- Load Average Graph
|
||||
- CPU and ACPI Temperature Sensors
|
||||
- pfBlocker IP Stats
|
||||
- pfBlocker DNS Stats
|
||||
- Gateway Response time - dpinger
|
||||
- List of interfaces with IPv4, IPv6, Subnet, MAC, Status and pfSense labels thanks to [/u/trumee](https://www.reddit.com/r/PFSENSE/comments/fsss8r/additional_grafana_dashboard/fmal0t6/)
|
||||
- WAN Statistics - Traffic & Throughput (Identified by dashboard variable)
|
||||
- LAN Statistics - Traffic & Throughput (Identified by dashboard variable)
|
||||
- Unbound stats - Plugin and config included and working but not implemented
|
||||
|
||||

|
||||
|
||||
## Running on
|
||||
|
||||
Grafana 7.4.3
|
||||
Influxdb 1.8.3
|
||||
|
||||
## Changelog
|
||||
This is just a summary, for more details look at the commits.
|
||||
|
||||
- Big Performance boost for subqueries in dashboard: https://github.com/influxdata/influxdb/issues/9122
|
||||
- This update includes plugins, telegraf config and the dashboard
|
||||
- Added more pfBlocker information in separate panel to keep things organized.
|
||||
- Replaced telegraph_gateways.py with telegraph_gateways.php
|
||||
- Added gateway interface detail table
|
||||
- If things render weird, drop the following measurements: tail_ip_block_log, gateways, tail_dnsbl_log
|
||||
|
||||
## Heads up!
|
||||
|
||||
Due to the update in the Gateway plugin (move from py to php), you may need to drop your gateways measurement.
|
||||
|
||||
In the recent commits I updated the telegraf config to use the [Tails Input Plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/tail) in place of the [Logparser Input Plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/logparser) since it's been deprecated.
|
||||
|
||||
I renamed many of the columns to reflect [what's being logged by pfBlockerNG-devel](https://github.com/pfsense/FreeBSD-ports/blob/232722ac52edaeede58b551e7e2efb690ce1023d/net/pfSense-pkg-pfBlockerNG-devel/files/usr/local/pkg/pfblockerng/pfblockerng.inc#L4597) and fixed some parsing bugs that cause lines to be skipped due to inconsistent log formatting. As a result, the measurements ip_block_log and dnsbl_log have been replaced with tail_ip_block_log and tail_dnsbl_log respectively.
|
||||
|
||||
I dropped the old measurements: ip_block_log, dnsbl_log
|
||||
|
||||
If you cannot live without this data, you could use the panels [from this commit](https://github.com/VictorRobellini/pfSense-Dashboard/blob/0df10172506242105891a81f5076019b5a5867b0/pfSense-Grafana-Dashboard.json) and not update the config. Read my note about the Logparser Input Plugin above!
|
||||
|
||||
If you want to load the complete logs files, you could probably change the telegraf config to:
|
||||
|
||||
from_beginning = false
|
||||
|
||||
to
|
||||
|
||||
from_beginning = true
|
||||
|
||||
I'm sure you can even rename the measurements, columns and update the tags, but that's beyond my influx capabilities.
|
||||
|
||||
|
||||
|
||||
### Templates of what I currently run in my Kubernetes homelab
|
||||
Kubernetes deployed locally with [these instructions](https://www.reddit.com/r/homelab/comments/ipsc4r/howto_k8s_metallb_and_external_dns_access_for/)
|
||||
|
||||
Stripped [yaml templates](https://github.com/VictorRobellini/K8s-homelab-pub) used to deploy my homelab (including Influx and Grafana) are here
|
||||
|
||||
Grafana 8.2.4
|
||||
Influxdb 2.1.1
|
||||
Graylog 4.2
|
||||
|
||||
### docker-compose example with persistent storage
|
||||
##### I've recently migrated my stack to Kubernetes, the image versions are updated but the docker-compose is untested.
|
||||
|
|
@ -117,8 +75,7 @@ Stripped [yaml templates](https://github.com/VictorRobellini/K8s-homelab-pub) us
|
|||
max-size: "100M"
|
||||
network_mode: bridge
|
||||
```
|
||||
|
||||
**Make sure you are using pfBlockerNG-devel**
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
@ -129,9 +86,8 @@ Dashboard Settings -> Variables
|
|||
|
||||
WAN - $WAN is a static variable defined so that a separate dashboard panel can be created for WAN interfaces stats. Use a comma-separated list for multiple WAN interfaces.
|
||||
|
||||
LAN_Interfaces - $LAN_Interfaces uses a regex to remove any interfaces you don't want to be grouped as LAN. The filtering happens in the "Regex" field. I use a negative lookahead regex to match the interfaces I want excluded. It should be pretty easy to understand what you need to do here. I have excluded igb0 (WAN) and igb1,igb2,igb3 (only used to host vlans).
|
||||
LAN - $LAN uses a regex to remove any interfaces you don't want to be grouped as LAN. The filtering happens in the "Regex" field. I use a negative lookahead regex to match the interfaces I want excluded. It should be pretty easy to understand what you need to do here. I have excluded igb0 (WAN) and igb1,igb2,igb3 (only used to host vlans).
|
||||
|
||||
After writing this up, I realize I need to change this variable name, it's just not going to happen right now.
|
||||
|
||||
### Telegraf
|
||||
[Telegraf Config](config/additional_config.conf)
|
||||
|
|
@ -143,11 +99,9 @@ I also included the config for Unbound DNS and it's commented out. I'm not curr
|
|||
### Plugins
|
||||
[Plugins](plugins)
|
||||
|
||||
**Plugins get copied to your pfSense system**
|
||||
**Plugins get copied to your OPNsense system**
|
||||
|
||||
I put all my plugins in /usr/local/bin and set them to 555
|
||||
|
||||
I also included a wrapper script for Unbound DNS. I'm not currently using it, but it's fully functional.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
|
@ -237,26 +191,3 @@ How to drop influx measurement
|
|||
> use pfsense
|
||||
Using database pfsense
|
||||
> drop measurement ip_block_log
|
||||
|
||||
## [Original Reddit thread](https://www.reddit.com/r/PFSENSE/comments/fsss8r/additional_grafana_dashboard/ "Originial Reddit thread")
|
||||
|
||||
I was going to post this in the thread made by [/u/seb6596](https://www.reddit.com/u/seb6596 "/u/seb6596") since this is based on [their dashboard](https://www.reddit.com/r/PFSENSE/comments/fsf7f7/my_pfsense_monitor_dashboard_in_grafana/ "their dashboard"), but I made quite a few changes and wanted to include information that would get lost in the thread.
|
||||
|
||||
What I updated:
|
||||
|
||||
- Created dashboard wide variables to make the dashboard more portable and easily configurable. You shouldn't need to update any of the queries.
|
||||
- Took some inspiration and panels [from this dashboard](https://grafana.com/grafana/dashboards/9806 "from this dashboard")
|
||||
- Included gateway RTT from dpinger thanks to [this integration](https://forum.netgate.com/topic/142093/can-telegraf-package-gather-latency-packet-loss-information/3 "this integration")
|
||||
- Pulled information from the "return_gateways_status_text" function in "/etc/inc/gwlb.inc" to return the actual status of the gateway, as well as the current loss/rtt and IP values.
|
||||
- Used[ telegraf configs](https://www.reddit.com/r/pfBlockerNG/comments/bu0ms0/pfblockerngtelegrafinfluxdb_ip_block_list/ " telegraf configs") from this post by [/u/PeskyWarrior](https://www.reddit.com/u/PeskyWarrior "/u/PeskyWarrior")
|
||||
- Tag, templating - No need to specify all cpus or interfaces in the graph queries. These values are pulled in with queries.
|
||||
- Added chart to show all adapters, IP, MAC and Status[ from here](https://github.com/influxdata/telegraf/issues/3756#issuecomment-485606025 " from here")
|
||||
- Added Temperature data based on feedback from[ /u/tko1982](https://www.reddit.com/u/tko1982 " /u/tko1982") - CPU Temp and any other ACPI device that reports temp is now collected and reported
|
||||
|
||||
### TODO
|
||||
|
||||
- Include IP and ping methods from [/u/seb6596](https://www.reddit.com/u/seb6596 "/u/seb6596") when they are back online.
|
||||
- Make it pretty. I've never been good at this part
|
||||
- Get the RTT calculations right from the dpinger integration. It's in microseconds but for some reason doesn't match the graphs in pfSense when I compare them.
|
||||
- Figure out if I can show subnet and media speed/duplex for the interfaces
|
||||
- Use the pfSense labels in the graphs that show network stats - 2 different measurements
|
||||
|
|
|
|||
|
|
@ -4,23 +4,3 @@
|
|||
"sh /usr/local/bin/telegraf_temperature.sh"
|
||||
]
|
||||
data_format = "influx"
|
||||
|
||||
[[inputs.tail]]
|
||||
files = ["/var/log/pfblockerng/dnsbl.log"]
|
||||
data_format = "grok"
|
||||
from_beginning = false
|
||||
name_suffix = "_dnsbl_log"
|
||||
grok_timezone = "Local"
|
||||
grok_patterns = ["^%{WORD:blocktype}-%{WORD:blocksubtype},%{SYSLOGTIMESTAMP:timestamp:ts-syslog},%{IPORHOST:domain},%{IPORHOST:src_ip:tag},%{GREEDYDATA:req_agent},%{WORD:blockmethod},%{WORD:blocklist:tag},%{IPORHOST:tld:tag},%{WORD:feed_name:tag},%{GREEDYDATA:duplicateeventstatus}"]
|
||||
|
||||
[[inputs.tail]]
|
||||
files = ["/var/log/pfblockerng/ip_block.log"]
|
||||
data_format = "grok"
|
||||
from_beginning = false
|
||||
name_suffix = "_ip_block_log"
|
||||
grok_timezone = "Local"
|
||||
grok_patterns = ["^%{SYSLOGTIMESTAMP:timestamp:ts-syslog},%{NUMBER:rulenum},%{DATA:interface},%{WORD:friendlyname},%{WORD:action},%{NUMBER:ip_version},%{NUMBER:protocolid},%{DATA:protocol:tag},%{IPORHOST:src_ip:tag},%{IPORHOST:dest_ip:tag},%{WORD:src_port:tag},%{NUMBER:dest_port:tag},%{WORD:direction},%{WORD:geoip_code:tag},%{DATA:ip_alias_name},%{DATA:ip_evaluated},%{DATA:feed_name:tag},%{HOSTNAME:resolvedhostname},%{GREEDYDATA:clienthostname},%{GREEDYDATA:ASN},%{GREEDYDATA:duplicateeventstatus}"]
|
||||
|
||||
#[[inputs.unbound]]
|
||||
# server = "127.0.0.1:953"
|
||||
# binary = "/usr/local/bin/telegraf_unbound.sh"
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/local/bin/python2.7
|
||||
# Taken From
|
||||
# https://forum.netgate.com/topic/142093/can-telegraf-package-gather-latency-packet-loss-information/3
|
||||
|
||||
import glob, os, socket
|
||||
|
||||
DPINGER_SOCK_PATH = "/var/run/"
|
||||
|
||||
os.chdir(DPINGER_SOCK_PATH)
|
||||
|
||||
for sock_name in glob.glob("dpinger*.sock"):
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
sock_path = DPINGER_SOCK_PATH+sock_name
|
||||
s = sock.connect(sock_path)
|
||||
line = sock.recv(1024).split('\n', 1)[0]
|
||||
values = line.split()
|
||||
print "gateways,gateway_name=" + values[0] + " rtt=" + str(int(values[1])/100.0) + \
|
||||
",rttsd=" + str(int(values[2])/100.0) + ",loss=" + str(int(values[3])) + "i"
|
||||
sock.close()
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/local/bin/python3.7
|
||||
|
||||
# telegraf_gateways-3.7.py
|
||||
# https://gist.github.com/fastjack/a0feb792a9655da7aa3e2a7a1d9f812f#file-gateways-py-for-pfsense-2-4-5
|
||||
# Special thanks to fashjack - https://gist.github.com/fastjack
|
||||
|
||||
import glob, os, socket
|
||||
|
||||
DPINGER_SOCK_PATH = "/var/run/"
|
||||
|
||||
os.chdir(DPINGER_SOCK_PATH)
|
||||
|
||||
for sock_name in glob.glob("dpinger*.sock"):
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
sock_path = DPINGER_SOCK_PATH+sock_name
|
||||
s = sock.connect(sock_path)
|
||||
line = sock.recv(1024).decode().split('\n', 1)[0]
|
||||
values = line.split()
|
||||
print("gateways,gateway_name="+values[0]+" rtt="+str(int(values[1])/1.0)+ \
|
||||
",rttsd="+str(int(values[2])/1.0)+",loss="+str(int(values[3]))+"i")
|
||||
sock.close()
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
#!/usr/local/bin/php-cgi -f
|
||||
<?php
|
||||
require_once("config.inc");
|
||||
require_once("gwlb.inc");
|
||||
|
||||
$host = gethostname();
|
||||
$source = "pfconfig";
|
||||
|
||||
$a_gateways = return_gateways_array();
|
||||
$gateways_status = return_gateways_status(true);
|
||||
|
||||
foreach ($a_gateways as $i => $gateway) {
|
||||
|
||||
$name = $gateways_status[$i]["name"];
|
||||
$monitor = $gateways_status[$i]["monitorip"];
|
||||
$source = $gateways_status[$i]["srcip"];
|
||||
$delay = $gateways_status[$i]["delay"];
|
||||
$stddev = $gateways_status[$i]["stddev"];
|
||||
$loss = $gateways_status[$i]["loss"];
|
||||
$status = $gateways_status[$i]["status"];
|
||||
$substatus = $gateways_status[$i]["substatus"];
|
||||
|
||||
$interface = $gateway["interface"];
|
||||
$friendlyname = $gateway["friendlyiface"]; # This is not the friendly interface name so I'm not using it
|
||||
$friendlyifdescr = $gateway["friendlyifdescr"];
|
||||
$gwdescr = $gateway["descr"];
|
||||
$defaultgw = $gateway['isdefaultgw'];
|
||||
|
||||
if (isset($gateway['isdefaultgw'])) {
|
||||
$defaultgw = "1";
|
||||
} else {
|
||||
$defaultgw = "0";
|
||||
}
|
||||
|
||||
if ($gateways_status[$i]) {
|
||||
if (isset($gateway['monitor_disable'])) {
|
||||
$monitor = "Unmonitored";
|
||||
$delay = "Pending";
|
||||
$stdev = "Pending";
|
||||
$loss = "Pending";
|
||||
}
|
||||
}
|
||||
|
||||
printf("gateways,host=%s,interface=%s monitor=\"%s\",source=\"%s\",defaultgw=%s,gwdescr=\"%s\",delay=%s,stddev=%s,loss=%s,status=\"%s\",substatus=\"%s\"\n",
|
||||
$host,
|
||||
$interface,
|
||||
# $friendlyifdescr,
|
||||
#$name,
|
||||
$monitor,
|
||||
$source,
|
||||
$defaultgw,
|
||||
$gwdescr,
|
||||
floatval($delay),
|
||||
floatval($stddev),
|
||||
floatval($loss),
|
||||
$status,
|
||||
$substatus
|
||||
);
|
||||
};
|
||||
?>
|
||||
Binary file not shown.
|
|
@ -1,51 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
//----------------------
|
||||
// Get the local machine IP address
|
||||
// https://www.socketloop.com/tutorials/golang-how-do-I-get-the-local-ip-non-loopback-address
|
||||
//----------------------
|
||||
|
||||
var currentIP, currentNetworkHardwareName string
|
||||
|
||||
// get all the system's or local machine's network interfaces
|
||||
|
||||
interfaces, _ := net.Interfaces()
|
||||
for _, interf := range interfaces {
|
||||
|
||||
if addrs, err := interf.Addrs(); err == nil {
|
||||
for _, addr := range addrs {
|
||||
// check the address type and if it is not a loopback the display it
|
||||
// = GET LOCAL IP ADDRESS
|
||||
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
currentIP = ipnet.IP.String()
|
||||
|
||||
// only interested in the name with current IP address`
|
||||
if strings.Contains(addr.String(), currentIP) {
|
||||
currentNetworkHardwareName = interf.Name
|
||||
}
|
||||
|
||||
macAddress := interf.HardwareAddr
|
||||
hwAddr, err := net.ParseMAC(macAddress.String())
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
currentNetworkHardwareName = strings.Replace(currentNetworkHardwareName, " ", "", -1)
|
||||
|
||||
fmt.Printf("interface,name=%s,ip_address=%s,mac_address=%s status=1\n",
|
||||
currentNetworkHardwareName, currentIP, hwAddr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
#!/usr/local/bin/php-cgi -f
|
||||
<?php
|
||||
require_once("config.inc");
|
||||
require_once("gwlb.inc");
|
||||
require_once("interfaces.inc");
|
||||
|
||||
$host = gethostname();
|
||||
$source = "pfconfig";
|
||||
|
||||
$iflist = get_configured_interface_with_descr(true);
|
||||
foreach ($iflist as $ifname => $friendly) {
|
||||
$ifinfo = get_interface_info($ifname);
|
||||
$ifstatus = $ifinfo['status'];
|
||||
$ifconf = $config['interfaces'][$ifname];
|
||||
$ip4addr = get_interface_ip($ifname);
|
||||
$ip4subnet = get_interface_subnet($ifname);
|
||||
$ip6addr = get_interface_ipv6($ifname);
|
||||
$ip6subnet = get_interface_subnetv6($ifname);
|
||||
$realif = get_real_interface($ifname);
|
||||
$mac = get_interface_mac($realif);
|
||||
|
||||
if (!isset($ip4addr)){
|
||||
$ip4addr = "Unassigned";
|
||||
}
|
||||
if (!isset($ip4subnet)){
|
||||
$ip4subnet = "Unassigned";
|
||||
}
|
||||
if (!isset($ip6addr)){
|
||||
$ip6addr = "Unassigned";
|
||||
}
|
||||
if (!isset($ip6subnet)){
|
||||
$ip6subnet = "Unassigned";
|
||||
}
|
||||
if (!isset($mac)){
|
||||
$mac = "Unavailable";
|
||||
}
|
||||
if (strtolower($ifstatus) == "up"){
|
||||
$ifstatus = 1;
|
||||
}
|
||||
if (strtolower($ifstatus) == "active"){
|
||||
$ifstatus = 1;
|
||||
}
|
||||
if (strtolower($ifstatus) == "no carrier"){
|
||||
$ifstatus = 0;
|
||||
}
|
||||
if (strtolower($ifstatus) == "down"){
|
||||
$ifstatus = 0;
|
||||
}
|
||||
if (!isset($ifstatus)){
|
||||
$ifstatus = 2;
|
||||
}
|
||||
|
||||
printf("interface,host=%s,name=%s,ip4_address=%s,ip4_subnet=%s,ip6_address=%s,ip6_subnet=%s,mac_address=%s,friendlyname=%s,source=%s status=%s\n",
|
||||
$host,
|
||||
$realif,
|
||||
$ip4addr,
|
||||
$ip4subnet,
|
||||
$ip6addr,
|
||||
$ip6subnet,
|
||||
$mac,
|
||||
$friendly,
|
||||
$source,
|
||||
$ifstatus
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,10 +3,6 @@ Perhaps the easiest method of installing these plugins is by utlizing the "Filer
|
|||
|
||||
# telegraf_pfifgw.php
|
||||
|
||||
*Replaces telegraf_gateways.py scripts (2.7 & 3.7)*
|
||||
|
||||
*Replaces telegraf_pfinterface.php and telegraf_gateways.php*
|
||||
|
||||
This single script collects information for Interfaces and gateways.
|
||||
|
||||
**Interfaces:**
|
||||
|
|
@ -30,20 +26,3 @@ This single script collects information for Interfaces and gateways.
|
|||
* Loss (%)
|
||||
* Status (Online/Offline/etc.)
|
||||
* Substatus (None/Packetloss/Latency/Etc.)
|
||||
|
||||
This has been modified from the original python version to a native PHP script. The new script calls the builtin "return_gateways_status_text" function from "/etc/inc/gwlb.inc". In addition to the loss, rtt, and rttsd included in the original plugin, the new version will also return the gateway IP, monitored IP, status, and substatus of the gateway. This eliminates the guess work of whether or not pfSense has marked this gateway as down.
|
||||
|
||||
# telegraf_unbound_lite.sh
|
||||
#### This plugin is not in use on my system but it's still worth documenting.
|
||||
If you only care about some of the unbound metrics and don't want to waste space collecting all the unwanted unbound metrics, here's a plugin for you.
|
||||
|
||||
# telegraf_netifinfo_plugin
|
||||
#### This plugin is not in use on my system but it's still worth documenting.
|
||||
I found a plugin to get IP, MAC, IF Name and Status. [On this thread](https://github.com/influxdata/telegraf/issues/3756#issuecomment-485606025 "On this thread") a user posts some go code for a telegraf plugin. I fired up a FreeBSD 11 ami on amazon, installed go and compiled a binary version of the code. It's worked as expected but my queries and formatting could use some help.
|
||||
|
||||
I saved the code as telegraf_netifinfo_plugin.go and compiled with the following commands:
|
||||
|
||||
setenv CGO_ENABLED 0
|
||||
setenv GOOS freebsd
|
||||
setenv GOARCH amd64
|
||||
go build -o telegraf_netifinfo_plugin
|
||||
|
|
|
|||
62
plugins/telegraf_pfifgw.php
Executable file → Normal file
62
plugins/telegraf_pfifgw.php
Executable file → Normal file
|
|
@ -1,22 +1,25 @@
|
|||
#!/usr/local/bin/php-cgi -f
|
||||
<?php
|
||||
require_once("config.inc");
|
||||
require_once("gwlb.inc");
|
||||
require_once("interfaces.inc");
|
||||
require_once("plugins.inc.d/dpinger.inc");
|
||||
require_once("util.inc");
|
||||
|
||||
$host = gethostname();
|
||||
$source = "pfconfig";
|
||||
|
||||
$iflist = get_configured_interface_with_descr(true);
|
||||
$iflist = get_configured_interface_with_descr();
|
||||
foreach ($iflist as $ifname => $friendly) {
|
||||
$ifinfo = get_interface_info($ifname);
|
||||
$ifsinfo = get_interfaces_info();
|
||||
$ifinfo = $ifsinfo[$ifname];
|
||||
$ifstatus = $ifinfo['status'];
|
||||
$iswireless = is_interface_wireless($ifdescr);
|
||||
$ifconf = $config['interfaces'][$ifname];
|
||||
$ip4addr = get_interface_ip($ifname);
|
||||
$ip4subnet = get_interface_subnet($ifname);
|
||||
$ip6addr = get_interface_ipv6($ifname);
|
||||
$ip6subnet = get_interface_subnetv6($ifname);
|
||||
$realif = get_real_interface($ifname);
|
||||
$ip4addr = get_interface_ip($ifname);
|
||||
$ip4subnet = find_interface_network($realif, true, $ifconfig_details);
|
||||
$ip6addr = get_interface_ipv6($ifname);
|
||||
$ip6subnet = find_interface_networkv6($realif, true, $ifconfig_details);
|
||||
$mac = get_interface_mac($realif);
|
||||
|
||||
if (!isset($ifinfo)) {
|
||||
|
|
@ -71,13 +74,13 @@ foreach ($iflist as $ifname => $friendly) {
|
|||
$mac,
|
||||
$friendly,
|
||||
$source,
|
||||
$ifstatus
|
||||
$ifstatus,
|
||||
);
|
||||
}
|
||||
|
||||
$gw_array = return_gateways_array();
|
||||
$gw_array = (new \OPNsense\Routing\Gateways(legacy_interfaces_details()))->gatewaysIndexedByName();
|
||||
//$gw_statuses is not guarranteed to contain the same number of gateways as $gw_array
|
||||
$gw_statuses = return_gateways_status(true);
|
||||
$gw_statuses = return_gateways_status();
|
||||
|
||||
$debug = false;
|
||||
|
||||
|
|
@ -91,20 +94,17 @@ foreach ($gw_array as $gw => $gateway) {
|
|||
//take the name from the $a_gateways list
|
||||
$name = $gateway["name"];
|
||||
|
||||
$monitor = $gw_statuses[$gw]["monitorip"];
|
||||
$source = $gw_statuses[$gw]["srcip"];
|
||||
$delay = $gw_statuses[$gw]["delay"];
|
||||
$stddev = $gw_statuses[$gw]["stddev"];
|
||||
$loss = $gw_statuses[$gw]["loss"];
|
||||
$status = $gw_statuses[$gw]["status"];
|
||||
$substatus;
|
||||
|
||||
$interface = $gateway["interface"];
|
||||
$friendlyname = $gateway["friendlyiface"]; # This is not the friendly interface name so I'm not using it
|
||||
$friendlyifdescr = $gateway["friendlyifdescr"];
|
||||
$gwdescr = $gateway["descr"];
|
||||
$defaultgw = $gateway['isdefaultgw'];
|
||||
|
||||
$monitor = $gateway["monitor"];
|
||||
$source = $gateway["gateway"];
|
||||
$loss = $gateway["loss"];
|
||||
if (!isset($monitor)) {
|
||||
$monitor = "Unavailable";
|
||||
}
|
||||
|
|
@ -120,6 +120,15 @@ foreach ($gw_array as $gw => $gateway) {
|
|||
if (!isset($loss)) {
|
||||
$loss = "0";
|
||||
}
|
||||
if (strtolower($status) == "none") {
|
||||
$status = 1;
|
||||
}
|
||||
if (strtolower($status) == "force_down") {
|
||||
$status = 0;
|
||||
}
|
||||
if (strtolower($status) == "down") {
|
||||
$status = 0;
|
||||
}
|
||||
if (!isset($status)) {
|
||||
$status = "Unavailable";
|
||||
}
|
||||
|
|
@ -136,37 +145,22 @@ foreach ($gw_array as $gw => $gateway) {
|
|||
$gwdescr = "Unassigned";
|
||||
}
|
||||
|
||||
if (isset($gateway['isdefaultgw'])) {
|
||||
$defaultgw = "1";
|
||||
} else {
|
||||
$defaultgw = "0";
|
||||
}
|
||||
|
||||
if (isset($gateway['monitor_disable'])) {
|
||||
$monitor = "Unmonitored";
|
||||
}
|
||||
|
||||
// Some earlier versions of pfSense do not return substatus
|
||||
if (isset($gw_statuses[$gw]["substatus"])) {
|
||||
$substatus = $gw_statuses[$gw]["substatus"];
|
||||
} else {
|
||||
$substatus = "N/A";
|
||||
}
|
||||
|
||||
printf(
|
||||
"gateways,host=%s,interface=%s,gateway_name=%s monitor=\"%s\",source=\"%s\",defaultgw=%s,gwdescr=\"%s\",delay=%s,stddev=%s,loss=%s,status=\"%s\",substatus=\"%s\"\n",
|
||||
"gateways,host=%s,interface=%s,gateway_name=%s monitor=\"%s\",source=\"%s\",gwdescr=\"%s\",delay=%s,stddev=%s,loss=%s,status=\"%s\"\n",
|
||||
$host,
|
||||
$interface,
|
||||
$name, //name is required as it is possible to have 2 gateways on 1 interface. i.e. WAN_DHCP and WAN_DHCP6
|
||||
$monitor,
|
||||
$source,
|
||||
$defaultgw,
|
||||
$gwdescr,
|
||||
floatval($delay),
|
||||
floatval($stddev),
|
||||
floatval($loss),
|
||||
$status,
|
||||
$substatus
|
||||
$status
|
||||
);
|
||||
};
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
1
plugins/telegraf_temperature.sh
Executable file → Normal file
1
plugins/telegraf_temperature.sh
Executable file → Normal file
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#!/bin/sh
|
||||
HOSTNAME=$(hostname)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
/usr/local/sbin/unbound-control -c /var/unbound/unbound.conf $* | grep -vE 'thread[0-9]+'
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
HOSTNAME=$(hostname)
|
||||
|
||||
/usr/local/sbin/unbound-control -c /var/unbound/unbound.conf stats | grep -E 'total.num.cachemiss|total.num.cachehits'| xargs printf "unbound_lite,host=$HOSTNAME %s,%s\n"
|
||||
Loading…
Reference in a new issue