From c0bbc42b0260f6f8103b52227fa302ca46396373 Mon Sep 17 00:00:00 2001 From: Kyle Lucy Date: Mon, 12 Sep 2016 13:43:35 -0400 Subject: create apcupsd plugin --- charts.d/Makefile.am | 1 + charts.d/apcupsd.chart.sh | 152 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100755 charts.d/apcupsd.chart.sh (limited to 'charts.d') diff --git a/charts.d/Makefile.am b/charts.d/Makefile.am index e131d508f5..ec0e101f31 100644 --- a/charts.d/Makefile.am +++ b/charts.d/Makefile.am @@ -5,6 +5,7 @@ MAINTAINERCLEANFILES= $(srcdir)/Makefile.in dist_charts_SCRIPTS = \ ap.chart.sh \ + apcupsd.chart.sh \ apache.chart.sh \ cpu_apps.chart.sh \ cpufreq.chart.sh \ diff --git a/charts.d/apcupsd.chart.sh b/charts.d/apcupsd.chart.sh new file mode 100755 index 0000000000..df18aaa2e8 --- /dev/null +++ b/charts.d/apcupsd.chart.sh @@ -0,0 +1,152 @@ +# no need for shebang - this file is loaded from charts.d.plugin + +apcupsd_ip=127.0.0.1 +apcupsd_port=3551 + +# how frequently to collect UPS data +apcupsd_update_every=10 + +apcupsd_timeout=3 + +# the priority of apcupsd related to other charts +apcupsd_priority=90000 + +apcupsd_get() { + timeout $apcupsd_timeout apcaccess status "$1:$2" +} + +apcupsd_check() { + + # this should return: + # - 0 to enable the chart + # - 1 to disable the chart + + require_cmd apcaccess || return 1 + + apcupsd_get $apcupsd_ip $apcupsd_port >/dev/null + if [ $? -ne 0 ] + then + echo >&2 "apcupsd: ERROR: Cannot get information for apcupsd server." + return 1 + elif [ $(apcupsd_get $apcupsd_ip $apcupsd_port | awk '/^STATUS.*/{ print $3 }') != "ONLINE" ] + then + echo >&2 "apcupsd: ERROR: UPS not online." + return 1 + fi + + return 0 +} + +apcupsd_create() { + # create the charts + cat <&2 "apcupsd: failed to get values" && return 1 + + return 0 +} -- cgit v1.2.3