#!/bin/sh set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions y=0 #Temps CPUoutfile="/usr/share/openmediavault/mkconf/collectd.d/sensors" MBoutfile="/usr/share/openmediavault/mkconf/collectd.d/mb" #Fans FANoutfile="/usr/share/openmediavault/mkconf/collectd.d/fan" SYSoutfile="/usr/share/openmediavault/mkconf/collectd.d/sys" end='\' starteof2='cat <> ${OMV_COLLECTD_RRDTOOL_MKGRAPH}' starteof1='cat <> ${OMV_COLLECTD_CONFIG}' endeof='EOF' graph='OMV_COLLECTD_RRDTOOL_MKGRAPH=${OMV_COLLECTD_RRDTOOL_MKGRAPH:-"/usr/sbin/omv-mkgraph"}' collected='OMV_COLLECTD_CONFIG=${OMV_COLLECTD_CONFIG:-"/etc/collectd/collectd.conf"}' XPATH="/config/services/sensors" # Custom settings TABmain="$(omv_config_get "${XPATH}/tabmain")" TABcpuTEMP="$(omv_config_get "${XPATH}/tabcputemp")" TABmbTEMP="$(omv_config_get "${XPATH}/tabmbtemp")" TABcpuFAN="$(omv_config_get "${XPATH}/tabcpufan")" TABsysFAN="$(omv_config_get "${XPATH}/tabsysfan")" GRAPHcpuTITLE="$(omv_config_get "${XPATH}/graphcputitle")" GRAPHmbTITLE="$(omv_config_get "${XPATH}/graphmbtitle")" GRAPHcfanTITLE="$(omv_config_get "${XPATH}/graphcfantitle")" GRAPHsfanTITLE="$(omv_config_get "${XPATH}/graphsfantitle")" LINEcpuTEMP="$(omv_config_get "${XPATH}/linecputemp")" LINEcpuFAN="$(omv_config_get "${XPATH}/linecpufan")" LINEmbTEMP="$(omv_config_get "${XPATH}/linembtemp")" LINEsysFAN="$(omv_config_get "${XPATH}/linesysfan")" do_cpu1() { if [ ! -z $main_cpu ]; then if [ "$main_cpu" = "sensors-emc6d103-i2c-1-2e" ]; then cat <> $CPUoutfile DEF:cpu1pavg=\\\${DATA}/sensors-emc6d103-i2c-1-2e/temperature-temp3.rrd:value:AVERAGE ${end} DEF:cpu1pmin=\\\${DATA}/sensors-emc6d103-i2c-1-2e/temperature-temp3.rrd:value:MIN ${end} DEF:cpu1pmax=\\\${DATA}/sensors-emc6d103-i2c-1-2e/temperature-temp3.rrd:value:MAX ${end} DEF:cpu2pavg=\\\${DATA}/sensors-emc6d103-i2c-1-2d/temperature-temp3.rrd:value:AVERAGE ${end} DEF:cpu2pmin=\\\${DATA}/sensors-emc6d103-i2c-1-2d/temperature-temp3.rrd:value:MIN ${end} DEF:cpu2pmax=\\\${DATA}/sensors-emc6d103-i2c-1-2d/temperature-temp3.rrd:value:MAX ${end} EOF else case "$main_cpu" in "sensors-nct6792*"*) rrd=2 ;; "sensors-nct6776"*) rrd=2 ;; "sensors-nct6779"*) rrd=2 ;; "sensors-w83627thf"*) rrd=2 ;; "sensors-it8728"*) rrd=3 ;; "sensors-f71808a"*) rrd=2 ;; *) rrd=1 ;; esac if [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/temperature-temp7.rrd ]; then rrd=7 fi cat <> $CPUoutfile DEF:cpupavg=\\\${DATA}/${main_cpu}/temperature-temp${rrd}.rrd:value:AVERAGE ${end} DEF:cpupmin=\\\${DATA}/${main_cpu}/temperature-temp${rrd}.rrd:value:MIN ${end} DEF:cpupmax=\\\${DATA}/${main_cpu}/temperature-temp${rrd}.rrd:value:MAX ${end} EOF fi fi } do_cpu2() { x=0 for items in $cores_no; do if [ "$y" = "1" ] && [ $x != "0" ] || [ "$y" = "0" ]; then cat <> $CPUoutfile DEF:cpuc$((x - y))avg=\\\${DATA}/${cores}/${items}:value:AVERAGE ${end} DEF:cpuc$((x - y))min=\\\${DATA}/${cores}/${items}:value:MIN ${end} DEF:cpuc$((x - y))max=\\\${DATA}/${cores}/${items}:value:MAX ${end} EOF fi x=$((x + 1)) done if [ -e /var/lib/rrdcached/db/localhost/sensors-coretemp-isa-0001 ]; then for items in $cores_no1; do if [ "$y" = "1" ] && [ $x != "0" ] || [ "$y" = "0" ]; then cat <> $CPUoutfile DEF:cpuc$((x - y))avg=\\\${DATA}/${cores1}/${items}:value:AVERAGE ${end} DEF:cpuc$((x - y))min=\\\${DATA}/${cores1}/${items}:value:MIN ${end} DEF:cpuc$((x - y))max=\\\${DATA}/${cores1}/${items}:value:MAX ${end} EOF fi x=$((x + 1)) done fi } do_cpu3() { if [ ! -z $main_cpu ]; then if [ "$main_cpu" = "sensors-emc6d103-i2c-1-2e" ]; then cat <> $CPUoutfile LINE1:cpu1pavg\\\${COLOR_CPU1_PHYSICAL}:"${LINEcpuTEMP}1" ${end} GPRINT:cpu1pmin:MIN:"%4.2lf Min" ${end} GPRINT:cpu1pavg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:cpu1pmax:MAX:"%4.2lf Max" ${end} GPRINT:cpu1pavg:LAST:"%4.2lf Last\l" ${end} LINE1:cpu2pavg\\\${COLOR_CPU2_PHYSICAL}:"${LINEcpuTEMP}2" ${end} GPRINT:cpu2pmin:MIN:"%4.2lf Min" ${end} GPRINT:cpu2pavg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:cpu2pmax:MAX:"%4.2lf Max" ${end} GPRINT:cpu2pavg:LAST:"%4.2lf Last\l" ${end} EOF else cat <> $CPUoutfile LINE1:cpupavg\\\${COLOR_CPU1_PHYSICAL}:"${LINEcpuTEMP}" ${end} GPRINT:cpupmin:MIN:"%4.2lf Min" ${end} GPRINT:cpupavg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:cpupmax:MAX:"%4.2lf Max" ${end} GPRINT:cpupavg:LAST:"%4.2lf Last\l" ${end} EOF fi fi } do_cpu3f() { if [ ! -z $main_cpu ]; then if [ "$main_cpu" = "sensors-emc6d103-i2c-1-2e" ]; then cat <> $CPUoutfile CDEF:farc1=9,5,/,cpu1pavg,*,32,+ ${end} CDEF:farc2=9,5,/,cpu1pmin,*,32,+ ${end} CDEF:farc3=9,5,/,cpu1pmax,*,32,+ ${end} LINE1:farc1\\\${COLOR_CPU1_PHYSICAL}:"${LINEcpuTEMP}1" ${end} GPRINT:farc2:MIN:"%4.2lf Min" ${end} GPRINT:farc1:AVERAGE:"%4.2lf Avg" ${end} GPRINT:farc3:MAX:"%4.2lf Max" ${end} GPRINT:farc1:LAST:"%4.2lf Last\l" ${end} CDEF:farc4=9,5,/,cpu1pavg,*,32,+ ${end} CDEF:farc5=9,5,/,cpu1pmin,*,32,+ ${end} CDEF:farc6=9,5,/,cpu1pmax,*,32,+ ${end} LINE1:farc1\\\${COLOR_CPU2_PHYSICAL}:"${LINEcpuTEMP}2" ${end} GPRINT:farc5:MIN:"%4.2lf Min" ${end} GPRINT:farc4:AVERAGE:"%4.2lf Avg" ${end} GPRINT:farc6:MAX:"%4.2lf Max" ${end} GPRINT:farc4:LAST:"%4.2lf Last\l" ${end} EOF else cat <> $CPUoutfile CDEF:farc1=9,5,/,cpupavg,*,32,+ ${end} CDEF:farc2=9,5,/,cpupmin,*,32,+ ${end} CDEF:farc3=9,5,/,cpupmax,*,32,+ ${end} LINE1:farc1\\\${COLOR_CPU1_PHYSICAL}:"${LINEcpuTEMP}" ${end} GPRINT:farc2:MIN:"%4.2lf Min" ${end} GPRINT:farc1:AVERAGE:"%4.2lf Avg" ${end} GPRINT:farc3:MAX:"%4.2lf Max" ${end} GPRINT:farc1:LAST:"%4.2lf Last\l" ${end} EOF fi fi } do_cpu4() { x=0 for items in $cores_no; do if [ "$y" = "1" ] && [ $x != "0" ] || [ "$y" = "0" ]; then cat <> $CPUoutfile LINE1:cpuc$((x - y))avg\\\${COLOR_CPU_CORE_$((x - y))}:"Core $((x - y + 1))" ${end} GPRINT:cpuc$((x - y))min:MIN:"%4.2lf Min" ${end} GPRINT:cpuc$((x - y))avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:cpuc$((x - y))max:MAX:"%4.2lf Max" ${end} GPRINT:cpuc$((x - y))avg:LAST:"%4.2lf Last\l" ${end} EOF fi x=$((x + 1)) done if [ -e /var/lib/rrdcached/db/localhost/sensors-coretemp-isa-0001 ]; then for items in $cores_no1; do if [ "$y" = "1" ] && [ $x != "0" ] || [ "$y" = "0" ]; then cat <> $CPUoutfile LINE1:cpuc$((x - y))avg\\\${COLOR_CPU_CORE_$((x - y))}:"Core $((x - y + 1))" ${end} GPRINT:cpuc$((x - y))min:MIN:"%4.2lf Min" ${end} GPRINT:cpuc$((x - y))avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:cpuc$((x - y))max:MAX:"%4.2lf Max" ${end} GPRINT:cpuc$((x - y))avg:LAST:"%4.2lf Last\l" ${end} EOF fi x=$((x + 1)) done fi } do_cpu4f() { x=0 for items in $cores_no; do if [ "$y" = "1" ] && [ $x != "0" ] || [ "$y" = "0" ]; then cat <> $CPUoutfile CDEF:far$((x - y))avg=9,5,/,cpuc$((x - y))avg,*,32,+ ${end} CDEF:far$((x - y))min=9,5,/,cpuc$((x - y))min,*,32,+ ${end} CDEF:far$((x - y))max=9,5,/,cpuc$((x - y))max,*,32,+ ${end} LINE1:far$((x - y))avg\\\${COLOR_CPU_CORE_$((x - y))}:"Core $((x - y + 1))" ${end} GPRINT:far$((x - y))min:MIN:"%4.2lf Min" ${end} GPRINT:far$((x - y))avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:far$((x - y))max:MAX:"%4.2lf Max" ${end} GPRINT:far$((x - y))avg:LAST:"%4.2lf Last\l" ${end} EOF fi x=$((x + 1)) done if [ -e /var/lib/rrdcached/db/localhost/sensors-coretemp-isa-0001 ]; then for items in $cores_no1; do if [ "$y" = "1" ] && [ $x != "0" ] || [ "$y" = "0" ]; then cat <> $CPUoutfile CDEF:far$((x - y))avg=9,5,/,cpuc$((x - y))avg,*,32,+ ${end} CDEF:far$((x - y))min=9,5,/,cpuc$((x - y))min,*,32,+ ${end} CDEF:far$((x - y))max=9,5,/,cpuc$((x - y))max,*,32,+ ${end} LINE1:far$((x - y))avg\\\${COLOR_CPU_CORE_$((x - y))}:"Core $((x - y + 1))" ${end} GPRINT:far$((x - y))min:MIN:"%4.2lf Min" ${end} GPRINT:far$((x - y))avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:far$((x - y))max:MAX:"%4.2lf Max" ${end} GPRINT:far$((x - y))avg:LAST:"%4.2lf Last\l" ${end} EOF fi x=$((x + 1)) done fi } do_mb1() { if [ ! -z $mb_temp ]; then case "$mb_temp" in "sensors-nct6792*"*) rrd=1 ;; "sensors-nct6776"*) rrd=1 ;; "sensors-nct6779"*) rrd=1 ;; "sensors-w83627thf"*) rrd=1 ;; "sensors-it877"*) rrd=1 ;; "sensors-it8728"*) rrd=1 ;; "sensors-thinkpad-isa"*) rrd=11 ;; "sensors-fschds-"*) rrd=3 ;; *) rrd=2 ;; esac if [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/temperature-temp5.rrd ]; then rrd=5 fi cat <> $MBoutfile DEF:mbtavg=\\\${DATA}/${mb_temp}/temperature-temp${rrd}.rrd:value:AVERAGE ${end} DEF:mbtpmin=\\\${DATA}/${mb_temp}/temperature-temp${rrd}.rrd:value:MIN ${end} DEF:mbtpmax=\\\${DATA}/${mb_temp}/temperature-temp${rrd}.rrd:value:MAX ${end} LINE1:mbtavg\\\${COLOR_MBT}:"${LINEmbTEMP}" ${end} GPRINT:mbtpmin:MIN:"%4.2lf Min" ${end} GPRINT:mbtavg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:mbtpmax:MAX:"%4.2lf Max" ${end} GPRINT:mbtavg:LAST:"%4.2lf Last\l" ${end} EOF fi } do_mb1f() { if [ ! -z $mb_temp ]; then case "$mb_temp" in "sensors-nct6792*"*) rrd=1 ;; "sensors-nct6776"*) rrd=1 ;; "sensors-nct6779"*) rrd=1 ;; "sensors-w83627thf"*) rrd=1 ;; "sensors-it877"*) rrd=1 ;; "sensors-it8728"*) rrd=1 ;; "sensors-thinkpad-isa"*) rrd=11 ;; "sensors-fschds-"*) rrd=3 ;; *) rrd=2 ;; esac cat <> $MBoutfile DEF:mbtavg=\\\${DATA}/${mb_temp}/temperature-temp${rrd}.rrd:value:AVERAGE ${end} DEF:mbtpmin=\\\${DATA}/${mb_temp}/temperature-temp${rrd}.rrd:value:MIN ${end} DEF:mbtpmax=\\\${DATA}/${mb_temp}/temperature-temp${rrd}.rrd:value:MAX ${end} CDEF:far1=9,5,/,mbtavg,*,32,+ ${end} CDEF:far2=9,5,/,mbtpmin,*,32,+ ${end} CDEF:far3=9,5,/,mbtpmax,*,32,+ ${end} LINE1:far1\\\${COLOR_MBT}:"${LINEmbTEMP}" ${end} GPRINT:far2:MIN:"%4.2lf Min" ${end} GPRINT:far1:AVERAGE:"%4.2lf Avg" ${end} GPRINT:far3:MAX:"%4.2lf Max" ${end} GPRINT:far1:LAST:"%4.2lf Last\l" ${end} EOF fi } do_fan1() { if [ ! -z $cpu_fan ]; then if [ "$cpu_fan" = "sensors-emc6d103-i2c-1-2e" ]; then cat <> $FANoutfile DEF:fan1avg=\\\${DATA}/sensors-emc6d103-i2c-1-2e/fanspeed-fan2.rrd:value:AVERAGE ${end} DEF:fan1pmin=\\\${DATA}/sensors-emc6d103-i2c-1-2e/fanspeed-fan2.rrd:value:MIN ${end} DEF:fan1pmax=\\\${DATA}/sensors-emc6d103-i2c-1-2e/fanspeed-fan2.rrd:value:MAX ${end} LINE1:fan1avg\\\${COLOR_CPU1_FAN}:"${LINEcpuFAN}1" ${end} GPRINT:fan1pmin:MIN:"%4.2lf Min" ${end} GPRINT:fan1avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:fan1pmax:MAX:"%4.2lf Max" ${end} GPRINT:fan1avg:LAST:"%4.2lf Last\l" ${end} DEF:fan2avg=\\\${DATA}/sensors-emc6d103-i2c-1-2e/fanspeed-fan1.rrd:value:AVERAGE ${end} DEF:fan2pmin=\\\${DATA}/sensors-emc6d103-i2c-1-2e/fanspeed-fan1.rrd:value:MIN ${end} DEF:fan2pmax=\\\${DATA}/sensors-emc6d103-i2c-1-2e/fanspeed-fan1.rrd:value:MAX ${end} LINE1:fan2avg\\\${COLOR_CPU2_FAN}:"${LINEcpuFAN}2" ${end} GPRINT:fan2pmin:MIN:"%4.2lf Min" ${end} GPRINT:fan2avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:fan2pmax:MAX:"%4.2lf Max" ${end} GPRINT:fan2avg:LAST:"%4.2lf Last\l" ${end} EOF else case "$cpu_fan" in "sensors-nct6792*"*) rrd=2 ;; "sensors-nct6776"*) rrd=2 ;; "sensors-nct6779"*) rrd=2 ;; "sensors-w83627thf"*) rrd=2 ;; "sensors-fschds-"*) rrd=2 ;; *) rrd=1 ;; esac cat <> $FANoutfile DEF:fan1avg=\\\${DATA}/${cpu_fan}/fanspeed-fan${rrd}.rrd:value:AVERAGE ${end} DEF:fan1pmin=\\\${DATA}/${cpu_fan}/fanspeed-fan${rrd}.rrd:value:MIN ${end} DEF:fan1pmax=\\\${DATA}/${cpu_fan}/fanspeed-fan${rrd}.rrd:value:MAX ${end} LINE1:fan1avg\\\${COLOR_CPU1_FAN}:"${LINEcpuFAN}" ${end} GPRINT:fan1pmin:MIN:"%4.2lf Min" ${end} GPRINT:fan1avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:fan1pmax:MAX:"%4.2lf Max" ${end} GPRINT:fan1avg:LAST:"%4.2lf Last\l" ${end} EOF fi fi } do_sys1() { if [ ! -z $sys_fan ]; then case "$sys_fan" in "sensors-emc6d103-i2c-1-2d"*) rrd=1 ;; "sensors-nct6792*"*) rrd=1 ;; "sensors-nct6776"*) rrd=1 ;; "sensors-nct6779"*) rrd=1 ;; "sensors-w83627thf"*) rrd=1 ;; "sensors-it8728"*) rrd=3 ;; "sensors-fschds-"*) rrd=3 ;; "sensors-f71869a"*) rrd=1 ;; *) rrd=2 ;; esac if [ ! -z "$(omv_config_get "${XPATH}/sysoffset")" ]; then rrd=$(echo "$(($rrd+$(omv_config_get "${XPATH}/sysoffset")))") fi cat <> $SYSoutfile DEF:sfan1avg=\\\${DATA}/${sys_fan}/fanspeed-fan${rrd}.rrd:value:AVERAGE ${end} DEF:sfan1pmin=\\\${DATA}/${sys_fan}/fanspeed-fan${rrd}.rrd:value:MIN ${end} DEF:sfan1pmax=\\\${DATA}/${sys_fan}/fanspeed-fan${rrd}.rrd:value:MAX ${end} LINE1:sfan1avg\\\${COLOR_SYS_FAN}:"${LINEsysFAN}" ${end} GPRINT:sfan1pmin:MIN:"%4.2lf Min" ${end} GPRINT:sfan1avg:AVERAGE:"%4.2lf Avg" ${end} GPRINT:sfan1pmax:MAX:"%4.2lf Max" ${end} GPRINT:sfan1avg:LAST:"%4.2lf Last\l" ${end} EOF fi } #Check status of the enable checkboxs if [ "$(omv_config_get "${XPATH}/cpuenable")" = "0" -o "$(omv_config_get "${XPATH}/mbtemp")" = "0" ] && [ "$(omv_config_get "${XPATH}/jntemp")" = "1" ]; then #Change value to zero xmlstarlet ed -L -u "${XPATH}/jntemp" -v 0 -n ${OMV_CONFIG_FILE} fi if [ "$(omv_config_get "${XPATH}/cpufanenable")" = "0" -o "$(omv_config_get "${XPATH}/sysfanenable")" = "0" ] && [ "$(omv_config_get "${XPATH}/jnfans")" = "1" ]; then #Change value to zero xmlstarlet ed -L -u "${XPATH}/jnfans" -v 0 -n ${OMV_CONFIG_FILE} fi if [ "$(omv_config_get "${XPATH}/cpuenable")" = "1" ]; then # Get main CPU # Like cores but ATM i don't know values if [ -e /var/lib/rrdcached/db/localhost/sensors-atk011*/temperature-temp1.rrd ]; then main_cpu="sensors-atk0110*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/temperature-temp7.rrd ]; then main_cpu="sensors-w83795adg-i2c-0-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-f71808a* ]; then main_cpu="sensors-f71808a*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6792*/temperature-temp2.rrd ]; then main_cpu="sensors-nct6792*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6776*/temperature-temp2.rrd ]; then main_cpu="sensors-nct6776*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6779*/temperature-temp2.rrd ]; then main_cpu="sensors-nct6779*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627thf*/temperature-temp2.rrd ]; then main_cpu="sensors-w83627thf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-fschds-*/temperature-temp1.rrd ]; then main_cpu="sensors-fschds-*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-axp20_mfd*/temperature-temp1.rrd ]; then main_cpu="sensors-axp20_mfd*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-thinkpad-isa*/temperature-temp1.rrd ]; then main_cpu="sensors-thinkpad-isa*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-sun4i_ts-isa*/temperature-temp1.rrd ]; then main_cpu="sensors-sun4i_ts-isa*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-k10temp*/temperature-temp1.rrd ]; then main_cpu="sensors-k10temp*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8718*/temperature-temp1.rrd ]; then main_cpu="sensors-it8718*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8728*/temperature-temp1.rrd ]; then main_cpu="sensors-it8728*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627hf*/temperature-temp1.rrd ]; then main_cpu="sensors-w83627hf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8720* ]; then main_cpu="sensors-it8720*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-4-2f/temperature-temp1.rrd ]; then main_cpu="sensors-w83795adg-i2c-4-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/temperature-temp1.rrd ]; then main_cpu="sensors-w83795adg-i2c-0-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it877*/temperature-temp1.rrd ]; then mb_temp="sensors-it877*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83667hg*/temperature-temp1.rrd ]; then main_cpu="sensors-w83667hg*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-emc6d103-i2c-1-2e/temperature-temp3.rrd ] && [ -e /var/lib/rrdcached/db/localhost/sensors-emc6d103-i2c-1-2d/temperature-temp3.rrd ]; then main_cpu="sensors-emc6d103-i2c-1-2e" elif [ -e /var/lib/rrdcached/db/localhost/sensors-acpitz*/temperature-temp1.rrd ]; then main_cpu="sensors-acpitz*" else main_cpu="" fi # Get Cores if [ -e /var/lib/rrdcached/db/localhost/sensors-coretemp-isa-0000 ]; then core="sensors-coretemp-isa-0000" elif [ -e /var/lib/rrdcached/db/localhost/sensors-coretemp* ]; then core="sensors-coretemp*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-via686a* ]; then core="sensors-via686a*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-vt8231* ]; then core="sensors-vt8231*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-k8temp* ]; then core="sensors-k8temp*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-fam15h_power* ]; then core="sensors-fam15h_power*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-sis5595* ]; then core="sensors-sis5595*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-i5k_amb* ]; then core="sensors-sensors-i5k_amb*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-via-cputemp* ]; then core="sensors-via-cputemp*" else core="" fi if [ ! -z $core ]; then cd /var/lib/rrdcached/db/localhost/$core cores=`basename $PWD` # Other Method to get cores cpucore1=`cat /proc/cpuinfo | grep -m1 "cpu cores" | cut -d ":" -f2` cpucore2=`ls -l temp* | grep ^- | wc -l` cores_no=`ls temp* | xargs -n1 basename` if [ -e /var/lib/rrdcached/db/localhost/sensors-coretemp-isa-0001 ]; then cd /var/lib/rrdcached/db/localhost/sensors-coretemp-isa-0001 cores1=`basename $PWD` cores_no1=`ls temp* | xargs -n1 basename` fi if [ "$cpucore1" = "" ]; then cpucore1=1 fi if [ $cpucore2 != $cpucore1 ]; then y=1 fi fi if [ "$y" = "1" ]; then main_cpu=$cores fi if [ ! -z $main_cpu ]; then cd /var/lib/rrdcached/db/localhost/$main_cpu main_cpu=`basename $PWD` fi fi if [ "$(omv_config_get "${XPATH}/mbtemp")" = "1" ]; then # Get MB temp if [ -e /var/lib/rrdcached/db/localhost/sensors-atk011*/temperature-temp2.rrd ]; then mb_temp="sensors-atk0110*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-f71869a*/temperature-temp2.rrd ]; then mb_temp="sensors-f71869a*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/temperature-temp5.rrd ]; then mb_temp="sensors-w83795adg-i2c-0-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6792*/temperature-temp1.rrd ]; then mb_temp="sensors-nct6792*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6779*/temperature-temp1.rrd ]; then mb_temp="sensors-nct6779*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6776*/temperature-temp1.rrd ]; then mb_temp="sensors-nct6776*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627thf*/temperature-temp1.rrd ]; then mb_temp="sensors-w83627thf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-fschds-*/temperature-temp3.rrd ]; then mb_temp="sensors-fschds-*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-axp20_mfd*/temperature-temp2.rrd ]; then mb_temp="sensors-axp20_mfd*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8718*/temperature-temp2.rrd ]; then mb_temp="sensors-it8718*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-thinkpad-isa*/temperature-temp11.rrd ]; then mb_temp="sensors-thinkpad-isa*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8728*/temperature-temp2.rrd ]; then mb_temp="sensors-it8728*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627hf*/temperature-temp2.rrd ]; then mb_temp="sensors-w83627hf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8720*/temperature-temp2.rrd ]; then mb_temp="sensors-it8720*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-k10temp*/temperature-temp2.rrd ]; then mb_temp="sensors-k10temp*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83667hg*/temperature-temp2.rrd ]; then mb_temp="sensors-w83667hg*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-4-2f/temperature-temp2.rrd ]; then mb_temp="sensors-w83795adg-i2c-4-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/temperature-temp2.rrd ]; then mb_temp="sensors-w83795adg-i2c-0-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it877*/temperature-temp1.rrd ]; then mb_temp="sensors-it877*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-emc6d103-i2c-1-2e/temperature-temp2.rrd ]; then mb_temp="sensors-emc6d103-i2c-1-2e" elif [ -e /var/lib/rrdcached/db/localhost/sensors-acpitz*/temperature-temp2.rrd ]; then mb_temp="sensors-acpitz*" else mb_temp="" fi if [ ! -z $mb_temp ]; then cd /var/lib/rrdcached/db/localhost/$mb_temp mb_temp=`basename $PWD` fi fi if [ "$(omv_config_get "${XPATH}/cpufanenable")" = "1" ]; then # Get CPU FAN if [ -e /var/lib/rrdcached/db/localhost/sensors-atk011*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-atk0110*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/fanspeed-fan1.rrd ]; then cpu_fan="sensors-w83795adg-i2c-0-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-f71808a*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-f71808a*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6792*/fanspeed-fan2.rrd ]; then cpu_fan="sensors-nct6792*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6776*/fanspeed-fan2.rrd ]; then cpu_fan="sensors-nct6776*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6779*/fanspeed-fan2.rrd ]; then cpu_fan="sensors-nct6779*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627thf*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-w83627thf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-fschds-*/fanspeed-fan2.rrd ]; then cpu_fan="sensors-fschds-*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-axp20_mfd*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-axp20_mfd*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8718*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-it8718*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8728*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-it8728*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-thinkpad-isa*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-thinkpad-isa*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627hf*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-w83627hf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8720*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-it8720*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it877*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-it877*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-k10temp*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-k10temp*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-4-2f/fanspeed-fan1.rrd ]; then cpu_fan="sensors-w83795adg-i2c-4-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83667hg*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-w83667hg*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-emc6d103-i2c-1-2e/fanspeed-fan1.rrd ] && [ -e /var/lib/rrdcached/db/localhost/sensors-emc6d103-i2c-1-2e/fanspeed-fan2.rrd ]; then cpu_fan="sensors-emc6d103-i2c-1-2e" elif [ -e /var/lib/rrdcached/db/localhost/sensors-acpitz*/fanspeed-fan1.rrd ]; then cpu_fan="sensors-acpitz*" else cpu_fan="" fi if [ ! -z $cpu_fan ]; then cd /var/lib/rrdcached/db/localhost/$cpu_fan cpu_fan=`basename $PWD` fi fi if [ "$(omv_config_get "${XPATH}/sysfanenable")" = "1" ]; then # Get SYS FAN if [ -e /var/lib/rrdcached/db/localhost/sensors-atk011*/fanspeed-fan1.rrd ]; then sys_fan="sensors-atk0110*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-f71869a*/fanspeed-fan1.rrd ]; then sys_fan="sensors-f71869a*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-0-2f/fanspeed-fan2.rrd ]; then sys_fan="sensors-w83795adg-i2c-0-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6792*/fanspeed-fan2.rrd ]; then sys_fan="sensors-nct6792*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6776*/fanspeed-fan1.rrd ]; then sys_fan="sensors-nct6776*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-nct6779*/fanspeed-fan1.rrd ]; then sys_fan="sensors-nct6779*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627thf*/fanspeed-fan2.rrd ]; then sys_fan="sensors-w83627thf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-fschds-*/fanspeed-fan1.rrd ]; then sys_fan="sensors-fschds-*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-axp20_mfd*/fanspeed-fan1.rrd ]; then sys_fan="sensors-axp20_mfd*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8718*/fanspeed-fan1.rrd ]; then sys_fan="sensors-it8718*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8728*/fanspeed-fan1.rrd ]; then sys_fan="sensors-it8728*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83627hf*/fanspeed-fan1.rrd ]; then sys_fan="sensors-w83627hf*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it8720*/fanspeed-fan1.rrd ]; then sys_fan="sensors-it8720*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-it877*/fanspeed-fan2.rrd ]; then sys_fan="sensors-it877*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-k10temp*/fanspeed-fan1.rrd ]; then sys_fan="sensors-k10temp*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83795adg-i2c-4-2f/fanspeed-fan2.rrd ]; then sys_fan="sensors-w83795adg-i2c-4-2f" elif [ -e /var/lib/rrdcached/db/localhost/sensors-w83667hg*/fanspeed-fan1.rrd ]; then sys_fan="sensors-w83667hg*" elif [ -e /var/lib/rrdcached/db/localhost/sensors-emc6d103-i2c-1-2d/fanspeed-fan1.rrd ]; then sys_fan="sensors-emc6d103-i2c-1-2d" elif [ -e /var/lib/rrdcached/db/localhost/sensors-acpitz*/fanspeed-fan1.rrd ]; then sys_fan="sensors-acpitz*" else sys_fan="" fi if [ ! -z $sys_fan ]; then cd /var/lib/rrdcached/db/localhost/$sys_fan sys_fan=`basename $PWD` fi fi if [ -f /usr/share/openmediavault/mkconf/collectd.d/sensors ]; then rm -f /usr/share/openmediavault/mkconf/collectd.d/sensors fi if [ -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js ]; then rm -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js fi if grep -q "LoadPlugin sensors" /etc/collectd/collectd.conf; then sed -i '/LoadPlugin sensors/d' /etc/collectd/collectd.conf fi sed -i '/#\ <<<\ \[openmediavault\]\ sensors-script/,/#\ >>>\ \[openmediavault\]\ sensors-script/d' /usr/sbin/omv-mkgraph if [ -f /usr/share/openmediavault/mkconf/collectd.d/mb ]; then rm -f /usr/share/openmediavault/mkconf/collectd.d/mb fi if [ -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Mb.js ]; then rm -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Mb.js fi if grep -q "LoadPlugin mb" /etc/collectd/collectd.conf; then sed -i '/LoadPlugin mb/d' /etc/collectd/collectd.conf fi sed -i '/#\ <<<\ \[openmediavault\]\ mb-script/,/#\ >>>\ \[openmediavault\]\ mb-script/d' /usr/sbin/omv-mkgraph if [ -f /usr/share/openmediavault/mkconf/collectd.d/fan ]; then rm -f /usr/share/openmediavault/mkconf/collectd.d/fan fi if [ -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Fan.js ]; then rm -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Fan.js fi if grep -q "LoadPlugin fan" /etc/collectd/collectd.conf; then sed -i '/LoadPlugin fan/d' /etc/collectd/collectd.conf fi sed -i '/#\ <<<\ \[openmediavault\]\ fan-script/,/#\ >>>\ \[openmediavault\]\ fan-script/d' /usr/sbin/omv-mkgraph if [ -f /usr/share/openmediavault/mkconf/collectd.d/sys ]; then rm -f /usr/share/openmediavault/mkconf/collectd.d/sys fi if [ -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sys.js ]; then rm -f /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sys.js fi if grep -q "LoadPlugin sys" /etc/collectd/collectd.conf; then sed -i '/LoadPlugin sys/d' /etc/collectd/collectd.conf fi sed -i '/#\ <<<\ \[openmediavault\]\ sys-script/,/#\ >>>\ \[openmediavault\]\ sys-script/d' /usr/sbin/omv-mkgraph #Run /usr/sbin/omv-sensors-detect > /dev/null 2>&1 here ONLY once if [ "$(omv_config_get "${XPATH}/cpuenable")" = "1" -o "$(omv_config_get "${XPATH}/sysfanenable")" = "1" -o "$(omv_config_get "${XPATH}/cpufanenable")" = "1" -o "$(omv_config_get "${XPATH}/mbtemp")" = "1" ]; then #Another if here? does not need to run again. /usr/sbin/omv-sensors-detect --auto fi if ([ "$(omv_config_get "${XPATH}/cpuenable")" = "1" ] && [ ! -z $main_cpu ]) || ([ ! -z $core ] && [ "$(omv_config_get "${XPATH}/shcore")" = "1" ]); then if [ ! -f /usr/share/openmediavault/mkconf/collectd.d/sensors ]; then cat < $CPUoutfile #!/bin/sh # # This file is part of OpenMediaVault. # # @license http://www.gnu.org/licenses/gpl.html GPL Version 3 # @author Volker Theile # @copyright Copyright (c) 2009-2015 Volker Theile # # OpenMediaVault is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # OpenMediaVault is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenMediaVault. If not, see . set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions ${collected} ${graph} ${starteof1} LoadPlugin sensors ${endeof} ${starteof2} # <<< [openmediavault] sensors-script # Plugin: sensors TITLE_LOAD="${GRAPHcpuTITLE}" COLOR_CPU1_PHYSICAL="#00cc00" # green COLOR_CPU2_PHYSICAL="#004f00" # dark green COLOR_CPU_CORE_0="#0000fd" # blue COLOR_CPU_CORE_1="#ff0000" # red COLOR_CPU_CORE_2="#cc00cc" # purple COLOR_CPU_CORE_3="#0000cc" # dark blue COLOR_CPU_CORE_4="#cc6600" # brown COLOR_CPU_CORE_5="#ff8308" # orange COLOR_CPU_CORE_6="#ffce3b" # yellow COLOR_CPU_CORE_7="#004f00" # dark green COLOR_MBT="#000000" # black $endeof for ucperiod in HOUR DAY WEEK MONTH YEAR; do lcperiod=\$(echo \${ucperiod} | tr '[:upper:]' '[:lower:]') ${starteof2} rrdtool graph \\\${IMGDIR}/sensors-\${lcperiod}.png --start \\\${\${ucperiod}START} \\\${DEFAULTS} --title "\\\${TITLE_LOAD}\\\${\${ucperiod}TITLE}" --slope-mode --upper-limit 80 --lower-limit 0 --units-exponent 0 ${end} EOF do_cpu1; if [ "$(omv_config_get "${XPATH}/jntemp")" = "1" ]; then MBoutfile=$CPUoutfile if [ "$(omv_config_get "${XPATH}/fheit")" = "1" ]; then do_mb1f; else do_mb1; fi fi if [ ! -z $core ] && [ "$(omv_config_get "${XPATH}/shcore")" = "1" ]; then do_cpu2; fi if [ "$(omv_config_get "${XPATH}/fheit")" = "1" ]; then do_cpu3f; else do_cpu3; fi if [ ! -z $core ] && [ "$(omv_config_get "${XPATH}/shcore")" = "1" ]; then if [ "$(omv_config_get "${XPATH}/fheit")" = "1" ]; then do_cpu4f; else do_cpu4; fi fi cat <> $CPUoutfile COMMENT:"\\\${LASTUPDATE}" >/dev/null ${endeof} done ${starteof2} # >>> [openmediavault] sensors-script ${endeof} EOF fi chmod +x $CPUoutfile $CPUoutfile fi if [ "$(omv_config_get "${XPATH}/mbtemp")" = "1" ] && [ "$(omv_config_get "${XPATH}/jntemp")" = "0" ] && [ ! -z $mb_temp ]; then if [ ! -f /usr/share/openmediavault/mkconf/collectd.d/mb ]; then cat < $MBoutfile #!/bin/sh # # This file is part of OpenMediaVault. # # @license http://www.gnu.org/licenses/gpl.html GPL Version 3 # @author Volker Theile # @copyright Copyright (c) 2009-2015 Volker Theile # # OpenMediaVault is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # OpenMediaVault is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenMediaVault. If not, see . set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions ${collected} ${graph} EOF if ! grep -q "LoadPlugin sensors" /etc/collectd/collectd.conf; then cat <> $MBoutfile ${starteof1} LoadPlugin sensors ${endeof} EOF fi cat <> $MBoutfile ${starteof2} # <<< [openmediavault] mb-script # Plugin: mb TITLE_LOAD="${GRAPHmbTITLE}" COLOR_MBT="#000000" # black $endeof for ucperiod in HOUR DAY WEEK MONTH YEAR; do lcperiod=\$(echo \${ucperiod} | tr '[:upper:]' '[:lower:]') ${starteof2} rrdtool graph \\\${IMGDIR}/mb-\${lcperiod}.png --start \\\${\${ucperiod}START} \\\${DEFAULTS} --title "\\\${TITLE_LOAD}\\\${\${ucperiod}TITLE}" --slope-mode --upper-limit 80 --lower-limit 0 --units-exponent 0 ${end} EOF if [ "$(omv_config_get "${XPATH}/fheit")" = "1" ]; then do_mb1f; else do_mb1; fi cat <> $MBoutfile COMMENT:"\\\${LASTUPDATE}" >/dev/null ${endeof} done ${starteof2} # >>> [openmediavault] mb-script ${endeof} EOF fi chmod +x $MBoutfile $MBoutfile fi if [ "$(omv_config_get "${XPATH}/cpufanenable")" = "1" ] && [ ! -z $cpu_fan ]; then if [ ! -f /usr/share/openmediavault/mkconf/collectd.d/fan ]; then cat < $FANoutfile #!/bin/sh # # This file is part of OpenMediaVault. # # @license http://www.gnu.org/licenses/gpl.html GPL Version 3 # @author Volker Theile # @copyright Copyright (c) 2009-2015 Volker Theile # # OpenMediaVault is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # OpenMediaVault is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenMediaVault. If not, see . set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions ${collected} ${graph} EOF if ! grep -q "LoadPlugin sensors" /etc/collectd/collectd.conf; then cat <> $FANoutfile ${starteof1} LoadPlugin sensors ${endeof} EOF fi cat <> $FANoutfile ${starteof2} # <<< [openmediavault] fan-script # Plugin: fan TITLE_LOAD="${GRAPHcfanTITLE}" COLOR_CPU1_FAN="#000000" # black COLOR_CPU2_FAN="#ff0000" # red COLOR_SYS_FAN="#00CC00" # black $endeof for ucperiod in HOUR DAY WEEK MONTH YEAR; do lcperiod=\$(echo \${ucperiod} | tr '[:upper:]' '[:lower:]') ${starteof2} rrdtool graph \\\${IMGDIR}/fan-\${lcperiod}.png --start \\\${\${ucperiod}START} \\\${DEFAULTS} --title "\\\${TITLE_LOAD}\\\${\${ucperiod}TITLE}" --slope-mode --upper-limit 2000 --lower-limit 0 --units-exponent 0 ${end} EOF do_fan1; if [ "$(omv_config_get "${XPATH}/jnfans")" = "1" ]; then SYSoutfile=$FANoutfile do_sys1; fi cat <> $FANoutfile COMMENT:"\\\${LASTUPDATE}" >/dev/null ${endeof} done ${starteof2} # >>> [openmediavault] fan-script ${endeof} EOF fi chmod +x $FANoutfile $FANoutfile fi if [ "$(omv_config_get "${XPATH}/sysfanenable")" = "1" ] && [ "$(omv_config_get "${XPATH}/jnfans")" = "0" ] && [ ! -z $sys_fan ]; then if [ ! -f /usr/share/openmediavault/mkconf/collectd.d/sys ]; then cat < $SYSoutfile #!/bin/sh # # This file is part of OpenMediaVault. # # @license http://www.gnu.org/licenses/gpl.html GPL Version 3 # @author Volker Theile # @copyright Copyright (c) 2009-2015 Volker Theile # # OpenMediaVault is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # OpenMediaVault is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenMediaVault. If not, see . set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions ${collected} ${graph} EOF if ! grep -q "LoadPlugin sensors" /etc/collectd/collectd.conf; then cat <> $SYSoutfile ${starteof1} LoadPlugin sensors ${endeof} EOF fi cat <> $SYSoutfile ${starteof2} # <<< [openmediavault] sys-script # Plugin: sys TITLE_LOAD="${GRAPHsfanTITLE}" COLOR_SYS_FAN="#000000" # black $endeof for ucperiod in HOUR DAY WEEK MONTH YEAR; do lcperiod=\$(echo \${ucperiod} | tr '[:upper:]' '[:lower:]') ${starteof2} rrdtool graph \\\${IMGDIR}/sys-\${lcperiod}.png --start \\\${\${ucperiod}START} \\\${DEFAULTS} --title "\\\${TITLE_LOAD}\\\${\${ucperiod}TITLE}" --slope-mode --upper-limit 2000 --lower-limit 0 --units-exponent 0 ${end} EOF do_sys1; cat <> $SYSoutfile COMMENT:"\\\${LASTUPDATE}" >/dev/null ${endeof} done ${starteof2} # >>> [openmediavault] sys-script ${endeof} EOF fi chmod +x $SYSoutfile $SYSoutfile fi #Create .js file. if [ "$(omv_config_get "${XPATH}/cpuenable")" = "1" -o "$(omv_config_get "${XPATH}/mbtemp")" = "1" -o "$(omv_config_get "${XPATH}/cpufanenable")" = "1" -o "$(omv_config_get "${XPATH}/sysfanenable")" = "1" ]; then cat < /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js /** * This file is part of OpenMediaVault. * * @license http://www.gnu.org/licenses/gpl.html GPL Version 3 * @author Volker Theile * @copyright Copyright (c) 2009-2015 Volker Theile * * OpenMediaVault is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * OpenMediaVault is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenMediaVault. If not, see . */ // require("js/omv/Rpc.js") // require("js/omv/workspace/tab/Panel.js") /** * @class OMV.module.admin.diagnostic.system.plugin.Sensors * @derived OMV.workspace.tab.Panel */ Ext.define("OMV.module.admin.diagnostic.system.plugin.Sensors", { extend: "OMV.workspace.tab.Panel", alias: "omv.plugin.diagnostic.system.sensors", title: _("${TABmain}"), initComponent: function() { var me = this; me.callParent(arguments); // Add Sub Tabs. EOF if [ "$(omv_config_get "${XPATH}/cpuenable")" = "1" ]; then cat <> /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js me.add(Ext.create("OMV.workspace.panel.RrdGraph", { title: "${TABcpuTEMP}", rrdGraphName: "sensors" })); EOF fi if [ "$(omv_config_get "${XPATH}/mbtemp")" = "1" ] && [ "$(omv_config_get "${XPATH}/jntemp")" = "0" ]; then cat <> /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js me.add(Ext.create("OMV.workspace.panel.RrdGraph", { title: "${TABmbTEMP}", rrdGraphName: "mb" })); EOF fi if [ "$(omv_config_get "${XPATH}/cpufanenable")" = "1" ]; then cat <> /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js me.add(Ext.create("OMV.workspace.panel.RrdGraph", { title: "${TABcpuFAN}", rrdGraphName: "fan" })); EOF fi if [ "$(omv_config_get "${XPATH}/sysfanenable")" = "1" ] && [ "$(omv_config_get "${XPATH}/jnfans")" = "0" ]; then cat <> /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js me.add(Ext.create("OMV.workspace.panel.RrdGraph", { title: "${TABsysFAN}", rrdGraphName: "sys" })); EOF fi cat <> /var/www/openmediavault/js/omv/module/admin/diagnostic/system/plugin/Sensors.js } }); EOF fi #add these last service collectd restart > /dev/null 2>&1 /usr/sbin/omv-mkgraph > /dev/null 2>&1 rm -f /var/cache/openmediavault/cache.*.json > /dev/null 2>&1 exit 0 ############################################################## Rpi cpu temp method to check. ############################################################## #!/bin/bash # base_dir='/opt/zping' graph_dir='/var/www/zping' log="$base_dir/log/zping.log" function write_log() { echo "`date '+%m/%d %H:%M:%S'` $1" >> $log } # if called with arguments this is a worker process, ping a target #output=`ping -c 20 -i .2 -W 1 -q $1` output=`/opt/vc/bin/vcgencmd measure_temp` retval=$? if [ $retval -eq 0 ] # at least some pings were returned then recvd=`echo $output | grep -o '[0-9]\+ received'` recvd=${recvd% received} lost=`expr 20 - $recvd` stats=(`echo $output | grep -o '[0-9.]\+/[0-9.]\+/[0-9.]\+' | tr '/' ' '`) min=${stats[0]} avg=${stats[1]} max=${stats[2]} elif [ $retval -eq 1 ] # no pings were returned then lost=20 min='U' avg='U' max='U' elif [ $retval -eq 2 ] # host not found then write_log "unknown host $1" exit $retval else # other errors write_log "error pinging $1 retval $retval" exit $retval fi if [ ! -f $base_dir/rrd/$1.rrd ] # create rrd if it doesn't exist then rrdtool create $base_dir/rrd/$1.rrd \ --step 60 \ DS:lost:GAUGE:120:0:20 \ DS:min:GAUGE:120:0:1000 \ DS:avg:GAUGE:120:0:1000 \ DS:max:GAUGE:120:0:1000 \ RRA:MAX:0.5:1:525600 retval=$? if [ $retval -gt 0 ] then write_log "unable to create rrd for $1 retval $retval" exit 200 fi fi rrdtool update $base_dir/rrd/$1.rrd $2:$lost:$min:$avg:$max retval=$? if [ $retval -gt 0 ] then write_log "rrd update for $1 failed retval $retval" exit 201 fi