# no need for shebang - this file is loaded from charts.d.plugin # netdata # real-time performance and health monitoring, done right! # (C) 2016 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 nut_timeout=2 # 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" } 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 <