Adds new IPFire specific monitoring capabilities to Zabbix Agent:
- ipfire.locationdb.lookup[<ip>,<ip>,...]: Perform IPFire LocationDB lookups
  from within Zabbix. Returns a JSON dict.
- ipfire.locationdb.version: Get LocationDB version timestamp in unixtime.

Signed-off-by: Robin Roevens <[email protected]>
---
 config/rootfiles/packages/zabbix_agentd            | 1 +
 config/zabbix_agentd/userparameter_locationdb.conf | 6 ++++++
 lfs/zabbix_agentd                                  | 2 ++
 3 files changed, 9 insertions(+)
 create mode 100644 config/zabbix_agentd/userparameter_locationdb.conf

diff --git a/config/rootfiles/packages/zabbix_agentd 
b/config/rootfiles/packages/zabbix_agentd
index 52cb37e93..7f1f39b64 100644
--- a/config/rootfiles/packages/zabbix_agentd
+++ b/config/rootfiles/packages/zabbix_agentd
@@ -23,6 +23,7 @@ 
var/ipfire/zabbix_agentd/userparameters/userparameter_ipfire.conf
 var/ipfire/zabbix_agentd/userparameters/userparameter_ovpn.conf
 var/ipfire/zabbix_agentd/userparameters/userparameter_gateway.conf
 var/ipfire/zabbix_agentd/userparameters/userparameter_wireguard.conf
+var/ipfire/zabbix_agentd/userparameters/userparameter_locationdb.conf
 var/ipfire/zabbix_agentd/scripts
 var/ipfire/zabbix_agentd/scripts/ipfire_certificate_detail.sh
 var/ipfire/zabbix_agentd/scripts/ipfire_services.pl
diff --git a/config/zabbix_agentd/userparameter_locationdb.conf 
b/config/zabbix_agentd/userparameter_locationdb.conf
new file mode 100644
index 000000000..4aa540762
--- /dev/null
+++ b/config/zabbix_agentd/userparameter_locationdb.conf
@@ -0,0 +1,6 @@
+# Parameters for querying IPFire Location DB
+#
+# Returns Location DB lookup for one or more IP addresses
+UserParameter=ipfire.locationdb.lookup[*],/usr/bin/location lookup $1 $2 $3 $4 
$5 $6 $7 $8 $9 2>&1 | awk -F"[[:space:]]*:[[:space:]]*" 'BEGIN { printf "{" } 
/[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+:/ { printf 
"%s\"%s\":{",separator,$$1; separator = "," } /^[[:space:]]*Network/ { printf 
"\"network\":\"" $$2 "\"" } /^[[:space:]]*Country/ { printf ",\"country\":\"" 
$$2 "\"" } /^[[:space:]]*Autonomous System/ { printf ",\"as\":\"" $$2 "\"}" } 
/Errno [[:digit:]]+/ { printf "\"error\":\"%s\"",$$0 } END { printf "}" }'
+# Returns the Unix timestamp of the IPFire Location DB version
+UserParameter=ipfire.locationdb.version,date -d"$(/usr/bin/location version)" 
+%s
diff --git a/lfs/zabbix_agentd b/lfs/zabbix_agentd
index 6d0a6b4ea..db43bd611 100644
--- a/lfs/zabbix_agentd
+++ b/lfs/zabbix_agentd
@@ -116,6 +116,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
                
/var/ipfire/zabbix_agentd/userparameters/userparameter_gateway.conf
        install -v -m 644 
$(DIR_SRC)/config/zabbix_agentd/userparameter_wireguard.conf \
                
/var/ipfire/zabbix_agentd/userparameters/userparameter_wireguard.conf
+       install -v -m 644 
$(DIR_SRC)/config/zabbix_agentd/userparameter_locationdb.conf \
+               
/var/ipfire/zabbix_agentd/userparameters/userparameter_locationdb.conf
 
        # Install IPFire-specific Zabbix Agent scripts
        -mkdir -pv /var/ipfire/zabbix_agentd/scripts
-- 
2.50.1


-- 
Dit bericht is gescanned op virussen en andere gevaarlijke
inhoud door MailScanner en lijkt schoon te zijn.


Reply via email to