This plugin collects metrics from an APC UPS (Uninterruptible Power Supply) using the apcaccess
command and reports them to Mackerel.
- Go 1.16 or later
apcaccess
command (usually provided by theapcupsd
package)- Mackerel agent
sudo mkr plugin install matsubo/mackerel-plugin-apcupsd
-
Clone this repository:
git clone https://github.com/matsubo/mackerel-plugin-apcupsd.git cd mackerel-plugin-apcupsd
-
Build the plugin:
go build -o mackerel-plugin-apcupsd
-
Place the built binary in a directory where the Mackerel agent can access it (e.g.,
/opt/mackerel-agent/plugins/bin/
):sudo mkdir -p /opt/mackerel-agent/plugins/bin/ sudo cp mackerel-plugin-apcupsd /opt/mackerel-agent/plugins/bin/
Add the following configuration to your Mackerel agent configuration file (usually located at /etc/mackerel-agent/mackerel-agent.conf
):
[plugin.metrics.apcapcupsd]
command = "/opt/mackerel-agent/plugins/bin/mackerel-plugin-apcapcupsd"
This plugin collects the following metrics:
custom.ups.linev
: Input line voltage (Volts)custom.ups.loadpct
: UPS load (Percent)custom.ups.bcharge
: Battery charge (Percent)custom.ups.timeleft
: Estimated runtime left (Minutes)custom.ups.battv
: Battery voltage (Volts)
To run the tests for this plugin, use the following command:
go test -v
Note that the TestFetchMetrics
test requires the apcaccess
command to be available and will be skipped if it's not.
- Ensure that the
apcupsd
service is running and that theapcaccess
command is available and executable by the Mackerel agent. - Check the Mackerel agent logs for any error messages related to this plugin.
- Verify that the UPS is properly connected and recognized by the system.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.