summaryrefslogtreecommitdiffstats
path: root/charts.d
diff options
context:
space:
mode:
authorpaulfantom <paulfantom@gmail.com>2016-06-07 20:44:06 +0200
committerpaulfantom <paulfantom@gmail.com>2016-06-07 20:44:06 +0200
commite71f2d62cd25d7ef81afb1b5ba89cf49f2f0f6f5 (patch)
tree593311880a560bd952a5b757fc79063e2a76600d /charts.d
parenta3a08b610a487f2d390c7833db1fdf699a292873 (diff)
add script to monitor disk temperatures via hddtemp daemon
Diffstat (limited to 'charts.d')
-rwxr-xr-xcharts.d/hddtemp.chart.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/charts.d/hddtemp.chart.sh b/charts.d/hddtemp.chart.sh
new file mode 100755
index 0000000000..e42db092b9
--- /dev/null
+++ b/charts.d/hddtemp.chart.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# if this chart is called X.chart.sh, then all functions and global variables
+# must start with X_
+hddtemp_host="localhost"
+hddtemp_port="7634"
+declare -A hddtemp_disks=()
+
+# _update_every is a special variable - it holds the number of seconds
+# between the calls of the _update() function
+hddtemp_update_every=3
+hddtemp_priority=90000
+
+# _check is called once, to find out if this chart should be enabled or not
+hddtemp_check() {
+ nc $hddtemp_host $hddtemp_port &>/dev/null && return 0 || return 1
+}
+
+# _create is called once, to create the charts
+hddtemp_create() {
+ if [ ${#hddtemp_disks[@]} -eq 0 ]; then
+ local all
+ all=$(nc $hddtemp_host $hddtemp_port )
+ unset hddtemp_disks
+ hddtemp_disks=( `grep -Po '/dev/[^|]+' <<< "$all" | cut -c 6-` )
+ fi
+ local disk_names
+ disk_names=(`sed -e 's/||/\n/g;s/^|//' <<< "$all" | cut -d '|' -f2 | tr ' ' '_'`)
+
+ echo "CHART hddtemp.temperature 'disks_temp' 'temperature' 'Celsius' 'Disks temperature' 'hddtemp.temp' line $((hddtemp_priority)) $hddtemp_update_every"
+ for i in `seq 0 $((${#hddtemp_disks[@]}-1))`; do
+ echo "DIMENSION ${hddtemp_disks[i]} ${disk_names[i]} absolute 1 1"
+ done
+ return 0
+}
+
+# _update is called continiously, to collect the values
+hddtemp_last=0
+hddtemp_count=0
+hddtemp_update() {
+ #local all
+
+ local all=( `nc $hddtemp_host $hddtemp_port | sed -e 's/||/\n/g;s/^|//' | cut -d '|' -f3` )
+
+ # write the result of the work.
+ echo "BEGIN hddtemp.temperature $1"
+ for i in `seq 0 $((${#hddtemp_disks[@]}-1))`; do
+ echo "SET ${hddtemp_disks[i]} = ${all[i]}"
+ done
+ echo "END"
+
+ return 0
+}