# no need for shebang - this file is loaded from charts.d.plugin # netdata # real-time performance and health monitoring, done right! # (C) 2016-2017 Costa Tsaousis # GPL v3+ # # a space separated list of UPS names # if empty, the list returned by 'upsc -l' will be used nut_ups= # how frequently to collect UPS data nut_update_every=2 # how much time in seconds, to wait for nut to respond nut_timeout=2 # set this to 1, to enable another chart showing the number # of UPS clients connected to upsd nut_clients_chart=0 # the priority of nut related to other charts nut_priority=90000 declare -A nut_ids=() nut_get_all() { run -t $nut_timeout upsc -l } nut_get() { run -t $nut_timeout upsc "$1" if [ "${nut_clients_chart}" -eq "1" ] then printf "ups.connected_clients: " run -t $nut_timeout upsc -c "$1" | wc -l fi } nut_check() { # this should return: # - 0 to enable the chart # - 1 to disable the chart local x require_cmd upsc || return 1 [ -z "$nut_ups" ] && nut_ups="$( nut_get_all )" for x in $nut_ups do nut_get "$x" >/dev/null if [ $? -eq 0 ] then nut_ids[$x]="$( fixid "$x" )" continue fi error "cannot get information for NUT UPS '$x'." done if [ ${#nut_ids[@]} -eq 0 ] then error "Cannot find UPSes - please set nut_ups='ups_name' in $confd/nut.conf" return 1 fi return 0 } nut_create() { # create the charts local x for x in "${nut_ids[@]}" do cat <