From b485aab7e71c1625cfc27e0f92c9509f42378458 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 13:19:16 +0200 Subject: Adding upstream version 1.45.3+dfsg. Signed-off-by: Daniel Baumann --- src/collectors/charts.d.plugin/apcupsd/README.md | 1 + .../charts.d.plugin/apcupsd/apcupsd.chart.sh | 305 +++++++++++++++++++++ .../charts.d.plugin/apcupsd/apcupsd.conf | 25 ++ .../apcupsd/integrations/apc_ups.md | 203 ++++++++++++++ .../charts.d.plugin/apcupsd/metadata.yaml | 256 +++++++++++++++++ 5 files changed, 790 insertions(+) create mode 120000 src/collectors/charts.d.plugin/apcupsd/README.md create mode 100644 src/collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh create mode 100644 src/collectors/charts.d.plugin/apcupsd/apcupsd.conf create mode 100644 src/collectors/charts.d.plugin/apcupsd/integrations/apc_ups.md create mode 100644 src/collectors/charts.d.plugin/apcupsd/metadata.yaml (limited to 'src/collectors/charts.d.plugin/apcupsd') diff --git a/src/collectors/charts.d.plugin/apcupsd/README.md b/src/collectors/charts.d.plugin/apcupsd/README.md new file mode 120000 index 000000000..fc6681fe6 --- /dev/null +++ b/src/collectors/charts.d.plugin/apcupsd/README.md @@ -0,0 +1 @@ +integrations/apc_ups.md \ No newline at end of file diff --git a/src/collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh b/src/collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh new file mode 100644 index 000000000..da9cd19c3 --- /dev/null +++ b/src/collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh @@ -0,0 +1,305 @@ +# shellcheck shell=bash +# no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later + +# netdata +# real-time performance and health monitoring, done right! +# (C) 2016 Costa Tsaousis +# + +apcupsd_ip= +apcupsd_port= + +declare -A apcupsd_sources=( + ["local"]="127.0.0.1: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() { + run -t $apcupsd_timeout apcaccess status "$1" +} + +is_ups_alive() { + local status + status="$(apcupsd_get "$1" | sed -e 's/STATUS.*: //' -e 't' -e 'd')" + case "$status" in + "" | "COMMLOST" | "SHUTTING DOWN") return 1 ;; + *) return 0 ;; + esac +} + +apcupsd_check() { + + # this should return: + # - 0 to enable the chart + # - 1 to disable the chart + + require_cmd apcaccess || return 1 + + # backwards compatibility + if [ "${apcupsd_ip}:${apcupsd_port}" != ":" ]; then + apcupsd_sources["local"]="${apcupsd_ip}:${apcupsd_port}" + fi + + local host working=0 failed=0 + for host in "${!apcupsd_sources[@]}"; do + apcupsd_get "${apcupsd_sources[${host}]}" >/dev/null + # shellcheck disable=2181 + if [ $? -ne 0 ]; then + error "cannot get information for apcupsd server ${host} on ${apcupsd_sources[${host}]}." + failed=$((failed + 1)) + else + if ! is_ups_alive ${apcupsd_sources[${host}]}; then + error "APC UPS ${host} on ${apcupsd_sources[${host}]} is not online." + failed=$((failed + 1)) + else + working=$((working + 1)) + fi + fi + done + + if [ ${working} -eq 0 ]; then + error "No APC UPSes found available." + return 1 + fi + + return 0 +} + +apcupsd_create() { + local host + for host in "${!apcupsd_sources[@]}"; do + # create the charts + cat < +# GPL v3+ + +# add all your APC UPSes in this array - uncomment it too +#declare -A apcupsd_sources=( +# ["local"]="127.0.0.1:3551" +#) + +# how long to wait for apcupsd to respond +#apcupsd_timeout=3 + +# the data collection frequency +# if unset, will inherit the netdata update frequency +#apcupsd_update_every=10 + +# the charts priority on the dashboard +#apcupsd_priority=90000 + +# the number of retries to do in case of failure +# before disabling the module +#apcupsd_retries=10 diff --git a/src/collectors/charts.d.plugin/apcupsd/integrations/apc_ups.md b/src/collectors/charts.d.plugin/apcupsd/integrations/apc_ups.md new file mode 100644 index 000000000..4e3aa3352 --- /dev/null +++ b/src/collectors/charts.d.plugin/apcupsd/integrations/apc_ups.md @@ -0,0 +1,203 @@ + + +# APC UPS + + + + + +Plugin: charts.d.plugin +Module: apcupsd + + + +## Overview + +Monitor APC UPS performance with Netdata for optimal uninterruptible power supply operations. Enhance your power supply reliability with real-time APC UPS metrics. + +The collector uses the `apcaccess` tool to contact the `apcupsd` daemon and get the APC UPS statistics. + +This collector is supported on all platforms. + +This collector only supports collecting metrics from a single instance of this integration. + + +### Default Behavior + +#### Auto-Detection + +By default, with no configuration provided, the collector will try to contact 127.0.0.1:3551 with using the `apcaccess` utility. + +#### Limits + +The default configuration for this integration does not impose any limits on data collection. + +#### Performance Impact + +The default configuration for this integration is not expected to impose a significant performance impact on the system. + + +## Metrics + +Metrics grouped by *scope*. + +The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels. + + + +### Per ups + +Metrics related to UPS. Each UPS provides its own set of the following metrics. + +This scope has no labels. + +Metrics: + +| Metric | Dimensions | Unit | +|:------|:----------|:----| +| apcupsd.charge | charge | percentage | +| apcupsd.battery.voltage | voltage, nominal | Volts | +| apcupsd.input.voltage | voltage, min, max | Volts | +| apcupsd.output.voltage | absolute, nominal | Volts | +| apcupsd.input.frequency | frequency | Hz | +| apcupsd.load | load | percentage | +| apcupsd.load_usage | load | Watts | +| apcupsd.temperature | temp | Celsius | +| apcupsd.time | time | Minutes | +| apcupsd.online | online | boolean | +| apcupsd.selftest | OK, NO, BT, NG | status | +| apcupsd.status | ONLINE, ONBATT, OVERLOAD, LOWBATT, REPLACEBATT, NOBATT, SLAVE, SLAVEDOWN, COMMLOST, CAL, TRIM, BOOST, SHUTTING_DOWN | status | + + + +## Alerts + + +The following alerts are available: + +| Alert name | On metric | Description | +|:------------|:----------|:------------| +| [ apcupsd_ups_charge ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.charge | average UPS charge over the last minute | +| [ apcupsd_10min_ups_load ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.load | average UPS load over the last 10 minutes | +| [ apcupsd_last_collected_secs ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.load | number of seconds since the last successful data collection | +| [ apcupsd_selftest_warning ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.selftest | self-test failed due to insufficient battery capacity or due to overload. | +| [ apcupsd_status_onbatt ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.status | APC UPS has switched to battery power because the input power has failed | +| [ apcupsd_status_overload ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.status | APC UPS is overloaded and cannot supply enough power to the load | +| [ apcupsd_status_lowbatt ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.status | APC UPS battery is low and needs to be recharged | +| [ apcupsd_status_replacebatt ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.status | APC UPS battery has reached the end of its lifespan and needs to be replaced | +| [ apcupsd_status_nobatt ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.status | APC UPS has no battery | +| [ apcupsd_status_commlost ](https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf) | apcupsd.status | APC UPS communication link is lost | + + +## Setup + +### Prerequisites + +#### Install charts.d plugin + +If [using our official native DEB/RPM packages](https://github.com/netdata/netdata/blob/master/packaging/installer/UPDATE.md#determine-which-installation-method-you-used), make sure `netdata-plugin-chartsd` is installed. + + +#### Required software + +Make sure the `apcaccess` and `apcupsd` are installed and running. + + +### Configuration + +#### File + +The configuration file name for this integration is `charts.d/apcupsd.conf`. + + +You can edit the configuration file using the `edit-config` script from the +Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration.md#the-netdata-config-directory). + +```bash +cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata +sudo ./edit-config charts.d/apcupsd.conf +``` +#### Options + +The config file is sourced by the charts.d plugin. It's a standard bash file. + +The following collapsed table contains all the options that can be configured for the apcupsd collector. + + +
Config options + +| Name | Description | Default | Required | +|:----|:-----------|:-------|:--------:| +| apcupsd_sources | This is an array of apcupsd sources. You can have multiple entries there. Please refer to the example below on how to set it. | 127.0.0.1:3551 | no | +| apcupsd_timeout | How long to wait for apcupsd to respond. | 3 | no | +| apcupsd_update_every | The data collection frequency. If unset, will inherit the netdata update frequency. | 1 | no | +| apcupsd_priority | The charts priority on the dashboard. | 90000 | no | +| apcupsd_retries | The number of retries to do in case of failure before disabling the collector. | 10 | no | + +
+ +#### Examples + +##### Multiple apcupsd sources + +Specify a multiple apcupsd sources along with a custom update interval + +```yaml +# add all your APC UPSes in this array - uncomment it too +declare -A apcupsd_sources=( + ["local"]="127.0.0.1:3551", + ["remote"]="1.2.3.4:3551" +) + +# how long to wait for apcupsd to respond +#apcupsd_timeout=3 + +# the data collection frequency +# if unset, will inherit the netdata update frequency +apcupsd_update_every=5 + +# the charts priority on the dashboard +#apcupsd_priority=90000 + +# the number of retries to do in case of failure +# before disabling the module +#apcupsd_retries=10 + +``` + + +## Troubleshooting + +### Debug Mode + +To troubleshoot issues with the `apcupsd` collector, run the `charts.d.plugin` with the debug option enabled. The output +should give you clues as to why the collector isn't working. + +- Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on + your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`. + + ```bash + cd /usr/libexec/netdata/plugins.d/ + ``` + +- Switch to the `netdata` user. + + ```bash + sudo -u netdata -s + ``` + +- Run the `charts.d.plugin` to debug the collector: + + ```bash + ./charts.d.plugin debug 1 apcupsd + ``` + + diff --git a/src/collectors/charts.d.plugin/apcupsd/metadata.yaml b/src/collectors/charts.d.plugin/apcupsd/metadata.yaml new file mode 100644 index 000000000..0af9c98e6 --- /dev/null +++ b/src/collectors/charts.d.plugin/apcupsd/metadata.yaml @@ -0,0 +1,256 @@ +plugin_name: charts.d.plugin +modules: + - meta: + plugin_name: charts.d.plugin + module_name: apcupsd + monitored_instance: + name: APC UPS + link: "https://www.apc.com" + categories: + - data-collection.ups + icon_filename: "apc.svg" + related_resources: + integrations: + list: [] + info_provided_to_referring_integrations: + description: "" + keywords: + - ups + - apc + - power + - supply + - battery + - apcupsd + most_popular: false + overview: + data_collection: + metrics_description: "Monitor APC UPS performance with Netdata for optimal uninterruptible power supply operations. Enhance your power supply reliability with real-time APC UPS metrics." + method_description: "The collector uses the `apcaccess` tool to contact the `apcupsd` daemon and get the APC UPS statistics." + supported_platforms: + include: [] + exclude: [] + multi_instance: false + additional_permissions: + description: "" + default_behavior: + auto_detection: + description: "By default, with no configuration provided, the collector will try to contact 127.0.0.1:3551 with using the `apcaccess` utility." + limits: + description: "" + performance_impact: + description: "" + setup: + prerequisites: + list: + - title: "Install charts.d plugin" + description: | + If [using our official native DEB/RPM packages](https://github.com/netdata/netdata/blob/master/packaging/installer/UPDATE.md#determine-which-installation-method-you-used), make sure `netdata-plugin-chartsd` is installed. + - title: "Required software" + description: "Make sure the `apcaccess` and `apcupsd` are installed and running." + configuration: + file: + name: charts.d/apcupsd.conf + options: + description: | + The config file is sourced by the charts.d plugin. It's a standard bash file. + + The following collapsed table contains all the options that can be configured for the apcupsd collector. + folding: + title: "Config options" + enabled: true + list: + - name: apcupsd_sources + description: This is an array of apcupsd sources. You can have multiple entries there. Please refer to the example below on how to set it. + default_value: "127.0.0.1:3551" + required: false + - name: apcupsd_timeout + description: How long to wait for apcupsd to respond. + default_value: 3 + required: false + - name: apcupsd_update_every + description: The data collection frequency. If unset, will inherit the netdata update frequency. + default_value: 1 + required: false + - name: apcupsd_priority + description: The charts priority on the dashboard. + default_value: 90000 + required: false + - name: apcupsd_retries + description: The number of retries to do in case of failure before disabling the collector. + default_value: 10 + required: false + examples: + folding: + enabled: false + title: "Config" + list: + - name: Multiple apcupsd sources + description: Specify a multiple apcupsd sources along with a custom update interval + config: | + # add all your APC UPSes in this array - uncomment it too + declare -A apcupsd_sources=( + ["local"]="127.0.0.1:3551", + ["remote"]="1.2.3.4:3551" + ) + + # how long to wait for apcupsd to respond + #apcupsd_timeout=3 + + # the data collection frequency + # if unset, will inherit the netdata update frequency + apcupsd_update_every=5 + + # the charts priority on the dashboard + #apcupsd_priority=90000 + + # the number of retries to do in case of failure + # before disabling the module + #apcupsd_retries=10 + troubleshooting: + problems: + list: [] + alerts: + - name: apcupsd_ups_charge + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.charge + info: average UPS charge over the last minute + os: "*" + - name: apcupsd_10min_ups_load + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.load + info: average UPS load over the last 10 minutes + os: "*" + - name: apcupsd_last_collected_secs + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.load + info: number of seconds since the last successful data collection + - name: apcupsd_selftest_warning + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.selftest + info: self-test failed due to insufficient battery capacity or due to overload. + - name: apcupsd_status_onbatt + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.status + info: APC UPS has switched to battery power because the input power has failed + - name: apcupsd_status_overload + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.status + info: APC UPS is overloaded and cannot supply enough power to the load + - name: apcupsd_status_lowbatt + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.status + info: APC UPS battery is low and needs to be recharged + - name: apcupsd_status_replacebatt + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.status + info: APC UPS battery has reached the end of its lifespan and needs to be replaced + - name: apcupsd_status_nobatt + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.status + info: APC UPS has no battery + - name: apcupsd_status_commlost + link: https://github.com/netdata/netdata/blob/master/src/health/health.d/apcupsd.conf + metric: apcupsd.status + info: APC UPS communication link is lost + metrics: + folding: + title: Metrics + enabled: false + description: "" + availability: [] + scopes: + - name: ups + description: "Metrics related to UPS. Each UPS provides its own set of the following metrics." + labels: [] + metrics: + - name: apcupsd.charge + description: UPS Charge + unit: "percentage" + chart_type: area + dimensions: + - name: charge + - name: apcupsd.battery.voltage + description: UPS Battery Voltage + unit: "Volts" + chart_type: line + dimensions: + - name: voltage + - name: nominal + - name: apcupsd.input.voltage + description: UPS Input Voltage + unit: "Volts" + chart_type: line + dimensions: + - name: voltage + - name: min + - name: max + - name: apcupsd.output.voltage + description: UPS Output Voltage + unit: "Volts" + chart_type: line + dimensions: + - name: absolute + - name: nominal + - name: apcupsd.input.frequency + description: UPS Input Voltage + unit: "Hz" + chart_type: line + dimensions: + - name: frequency + - name: apcupsd.load + description: UPS Load + unit: "percentage" + chart_type: area + dimensions: + - name: load + - name: apcupsd.load_usage + description: UPS Load Usage + unit: "Watts" + chart_type: area + dimensions: + - name: load + - name: apcupsd.temperature + description: UPS Temperature + unit: "Celsius" + chart_type: line + dimensions: + - name: temp + - name: apcupsd.time + description: UPS Time Remaining + unit: "Minutes" + chart_type: area + dimensions: + - name: time + - name: apcupsd.online + description: UPS ONLINE flag + unit: "boolean" + chart_type: line + dimensions: + - name: online + - name: apcupsd.selftest + description: UPS Self-Test status + unit: status + chart_type: line + dimensions: + - name: OK + - name: NO + - name: BT + - name: NG + - name: apcupsd.status + description: UPS Status + unit: status + chart_type: line + dimensions: + - name: ONLINE + - name: ONBATT + - name: OVERLOAD + - name: LOWBATT + - name: REPLACEBATT + - name: NOBATT + - name: SLAVE + - name: SLAVEDOWN + - name: COMMLOST + - name: CAL + - name: TRIM + - name: BOOST + - name: SHUTTING_DOWN -- cgit v1.2.3