From fc6d32923d68216a6b56b59fb988ae475adc699e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 18 Apr 2013 14:37:28 +0200 Subject: [PATCH] Add discovery script and conf for nut ups --- zabbix_conf/nut_ups.conf | 6 ++++++ zabbix_scripts/disco_nut_ups | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 zabbix_scripts/disco_nut_ups diff --git a/zabbix_conf/nut_ups.conf b/zabbix_conf/nut_ups.conf index 91b7f54..5f5c1c4 100644 --- a/zabbix_conf/nut_ups.conf +++ b/zabbix_conf/nut_ups.conf @@ -30,3 +30,9 @@ UserParameter=ups.status[*],upsc $1 ups.status # Key: ups.model[UPS] # Type of information: Text UserParameter=ups.model[*],upsc $1 ups.model + +# UPS discovery +UserParameter=hardware.ups.discovery[*],/var/lib/zabbix/bin/disco_nut_ups $1 + +# This is a new, more generic nut ups UserParameter +UserParameter=hardware.ups[*],upsc $1 $2 diff --git a/zabbix_scripts/disco_nut_ups b/zabbix_scripts/disco_nut_ups new file mode 100644 index 0000000..c74a2b8 --- /dev/null +++ b/zabbix_scripts/disco_nut_ups @@ -0,0 +1,17 @@ +#!/usr/bin/perl -w + +use JSON; + +my $json; + +if (system("upsc -l >/dev/null 2>&1") == 0){ + foreach my $ups (`upsc -l`){ + chomp($ups); + push @{$json->{data}}, {"{#UPSNAME}" => $ups}; + } + print to_json($json) if (defined $json->{data}); +} +else{ + print 'ZBX_NOTSUPPORTED'; +} +exit(0);