diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2015-11-18 01:07:09 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2015-11-18 01:07:09 +0200 |
commit | c5572d0ddaf88f58995cfe4f916494e714c2f7ca (patch) | |
tree | d1a6ce7de038535b41179c463069eb2c35e1f2f4 /charts.d | |
parent | 1b68ee4b7b809471f52a63708d4fc020dbc93ee0 (diff) |
updated docs; nut.chart.sh now autodetects multiple UPSes, web and cache directories are chowned; charts.d is now enabled by default
Diffstat (limited to 'charts.d')
-rw-r--r-- | charts.d/Makefile.am | 1 | ||||
-rw-r--r-- | charts.d/README.md | 1 | ||||
-rwxr-xr-x | charts.d/mysql.chart.sh | 6 | ||||
-rwxr-xr-x | charts.d/nut.chart.sh | 74 |
4 files changed, 54 insertions, 28 deletions
diff --git a/charts.d/Makefile.am b/charts.d/Makefile.am index 431b0b8f51..7ff064c358 100644 --- a/charts.d/Makefile.am +++ b/charts.d/Makefile.am @@ -4,6 +4,7 @@ MAINTAINERCLEANFILES= $(srcdir)/Makefile.in dist_charts_SCRIPTS = \ + README.md \ airsearches.chart.sh \ cpu_apps.chart.sh \ cpufreq.chart.sh \ diff --git a/charts.d/README.md b/charts.d/README.md new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/charts.d/README.md @@ -0,0 +1 @@ + diff --git a/charts.d/mysql.chart.sh b/charts.d/mysql.chart.sh index 72cbb41949..9390f972fe 100755 --- a/charts.d/mysql.chart.sh +++ b/charts.d/mysql.chart.sh @@ -7,7 +7,7 @@ # This statement does not require any privilege. # It requires only the ability to connect to the server. -mysql_cmd_opts="" +mysql_cmd_opts= mysql_update_every=5 mysql_get_stats() { @@ -15,6 +15,10 @@ mysql_get_stats() { } mysql_check() { + require_cmd mysql || exit 1 + require_cmd egrep || exit 1 + require_cmd sed || exit 1 + # check once if the url works local x="$(mysql_get_stats | grep "^Connections[[:space:]]")" if [ ! $? -eq 0 -o -z "$x" ] diff --git a/charts.d/nut.chart.sh b/charts.d/nut.chart.sh index 551ee4074b..7762e6c65a 100755 --- a/charts.d/nut.chart.sh +++ b/charts.d/nut.chart.sh @@ -4,56 +4,70 @@ nut_ups= nut_update_every=2 nut_check() { - if [ -z "${nut_ups}" ] + local x all + + require_cmd upsc || return 1 + require_cmd awk || return 1 + + all="$nut_ups" + [ -z "$all" ] && all="$(upsc -l)" + + nut_ups= + for x in $all + do + upsc "$x" >/dev/null + [ $? -eq 0 ] && nut_ups="$nut_ups $x" && continue + echo >&2 "nut: ERROR: Cannot get information for NUT UPS '$x'." + done + + if [ -z "$nut_ups" ] then echo >&2 "nut: Please set nut_ups='ups_name' in $confd/nut.conf" return 1 fi - upsc "${nut_ups}" >/dev/null - if [ ! $? -eq 0 ] - then - echo >&2 "nut: failed to fetch info for ups '$nut_ups'. Please set nut_ups='ups_name' in $confd/nut.conf" - return 1 - fi - return 0 } nut_create() { # create the charts - cat <<EOF -CHART nut.charge '' "UPS Charge" "percentage" nut '' area 21001 $nut_update_every + local x + + for x in $nut_ups + do + cat <<EOF +CHART nut_$x.charge '' "UPS Charge" "percentage" $x nut area 21001 $nut_update_every DIMENSION battery_charge charge absolute 1 100 -CHART nut.battery_voltage '' "UPS Battery Voltage" "Volts" nut '' line 21002 $nut_update_every +CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" $x nut line 21002 $nut_update_every DIMENSION battery_voltage voltage absolute 1 100 DIMENSION battery_voltage_high high absolute 1 100 DIMENSION battery_voltage_low low absolute 1 100 DIMENSION battery_voltage_nominal nominal absolute 1 100 -CHART nut.input_voltage '' "UPS Input Voltage" "Volts" nut '' line 21003 $nut_update_every +CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" $x nut line 21003 $nut_update_every DIMENSION input_voltage voltage absolute 1 100 DIMENSION input_voltage_fault fault absolute 1 100 DIMENSION input_voltage_nominal nominal absolute 1 100 -CHART nut.input_current '' "UPS Input Current" "Ampere" nut '' line 21004 $nut_update_every +CHART nut_$x.input_current '' "UPS Input Current" "Ampere" $x nut line 21004 $nut_update_every DIMENSION input_current_nominal nominal absolute 1 100 -CHART nut.input_frequency '' "UPS Input Frequency" "Hz" nut '' line 21005 $nut_update_every +CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" $x nut line 21005 $nut_update_every DIMENSION input_frequency frequency absolute 1 100 DIMENSION input_frequency_nominal nominal absolute 1 100 -CHART nut.output_voltage '' "UPS Output Voltage" "Volts" nut '' line 21006 $nut_update_every +CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" $x nut line 21006 $nut_update_every DIMENSION output_voltage voltage absolute 1 100 -CHART nut.load '' "UPS Load" "percentage" nut '' area 21000 $nut_update_every +CHART nut_$x.load '' "UPS Load" "percentage" $x nut area 21000 $nut_update_every DIMENSION load load absolute 1 100 -CHART nut.temp '' "UPS Temperature" "temperature" nut '' line 21007 $nut_update_every +CHART nut_$x.temp '' "UPS Temperature" "temperature" $x nut line 21007 $nut_update_every DIMENSION temp temp absolute 1 100 EOF - + done + return 0 } @@ -66,7 +80,11 @@ nut_update() { # for each dimension # remember: KEEP IT SIMPLE AND SHORT - upsc "${nut_ups}" | awk " + local x + + for x in $nut_ups + do + upsc "$x" | awk " BEGIN { battery_charge = 0; battery_voltage = 0; @@ -98,45 +116,47 @@ BEGIN { /^ups.load: .*/ { load = \$2 * 100 }; /^ups.temperature: .*/ { temp = \$2 * 100 }; END { - print \"BEGIN nut.charge $1\"; + print \"BEGIN nut_$x.charge $1\"; print \"SET battery_charge = \" battery_charge; print \"END\" - print \"BEGIN nut.battery_voltage $1\"; + print \"BEGIN nut_$x.battery_voltage $1\"; print \"SET battery_voltage = \" battery_voltage; print \"SET battery_voltage_high = \" battery_voltage_high; print \"SET battery_voltage_low = \" battery_voltage_low; print \"SET battery_voltage_nominal = \" battery_voltage_nominal; print \"END\" - print \"BEGIN nut.input_voltage $1\"; + print \"BEGIN nut_$x.input_voltage $1\"; print \"SET input_voltage = \" input_voltage; print \"SET input_voltage_fault = \" input_voltage_fault; print \"SET input_voltage_nominal = \" input_voltage_nominal; print \"END\" - print \"BEGIN nut.input_current $1\"; + print \"BEGIN nut_$x.input_current $1\"; print \"SET input_current_nominal = \" input_current_nominal; print \"END\" - print \"BEGIN nut.input_frequency $1\"; + print \"BEGIN nut_$x.input_frequency $1\"; print \"SET input_frequency = \" input_frequency; print \"SET input_frequency_nominal = \" input_frequency_nominal; print \"END\" - print \"BEGIN nut.output_voltage $1\"; + print \"BEGIN nut_$x.output_voltage $1\"; print \"SET output_voltage = \" output_voltage; print \"END\" - print \"BEGIN nut.load $1\"; + print \"BEGIN nut_$x.load $1\"; print \"SET load = \" load; print \"END\" - print \"BEGIN nut.temp $1\"; + print \"BEGIN nut_$x.temp $1\"; print \"SET temp = \" temp; print \"END\" } " + done + return 0 } |