#!/bin/bash

date=$(date --utc +%s%N)

METRICS=$(apcaccess)

for METRIC in TIMELEFT LOADPCT BCHARGE
do
  echo "apcupsd $METRIC=$(grep $METRIC <<< $METRICS | cut -d ':' -f 2 | xargs | cut -d ' ' -f 1 ) $date"
done