3 # if this chart is called X.chart.sh, then all functions and global variables
6 # _update_every is a special variable - it holds the number of seconds
7 # between the calls of the _update() function
10 sensors_find_all_files() {
11 find $1 -name temp\?_input -o -name temp -o -name in\?_input -o -name fan\?_input 2>/dev/null
14 sensors_find_all_dirs() {
15 sensors_find_all_files $1 | while read
21 # _check is called once, to find out if this chart should be enabled or not
25 # - 0 to enable the chart
26 # - 1 to disable the chart
28 [ ! -z "$( sensors_find_all_files /sys/devices/ )" ] && return 0
32 # _create is called once, to create the charts
34 local path= dir= name= x= file= lfile= labelname= labelid= device= subsystem= id= type= mode= files= multiplier= divisor=
36 echo >$TMP_DIR/temp.sh "sensors_update() {"
38 for path in $( sensors_find_all_dirs /sys/devices/ | sort -u )
40 dir=$( basename $path )
47 [ -h $path/device ] && device=$( readlink -f $path/device )
48 [ ! -z "$device" ] && device=$( basename $device )
49 [ -z "$device" ] && device="$dir"
51 [ -h $path/subsystem ] && subsystem=$( readlink -f $path/subsystem )
52 [ ! -z "$subsystem" ] && subsystem=$( basename $subsystem )
53 [ -z "$subsystem" ] && subsystem="$dir"
55 [ -f $path/name ] && name=$( cat $path/name )
56 [ -z "$name" ] && name="$dir"
58 [ -f $path/type ] && type=$( cat $path/type )
59 [ -z "$type" ] && type="$dir"
61 id="$( fixid "$device.$subsystem.$dir" )"
63 echo >&2 "charts.d: temperature sensors on path='$path', dir='$dir', device='$device', subsystem='$subsystem', id='$id', name='$name'"
65 for mode in temperature voltage fans
72 files="$( find $path -name temp\?_input -o -name temp | sort -u)"
73 [ -z "$files" ] && continue
74 echo "CHART sensors.temp_${id} '' '${name} Temperature' 'Temperature' 'Celcius Degrees' '' line 6000 $sensors_update_every"
75 echo >>$TMP_DIR/temp.sh "echo \"BEGIN sensors.temp_${id} \$1\""
80 files="$( find $path -name in\?_input )"
81 [ -z "$files" ] && continue
82 echo "CHART sensors.volt_${id} '' '${name} Voltage' 'Voltage' 'Volts' '' line 6001 $sensors_update_every"
83 echo >>$TMP_DIR/temp.sh "echo \"BEGIN sensors.volt_${id} \$1\""
88 files="$( find $path -name fan\?_input )"
89 [ -z "$files" ] && continue
90 echo "CHART sensors.fan_${id} '' '${name} Fans Speed' 'Fans' 'Rotations Per Minute (RPM)' '' line 6002 $sensors_update_every"
91 echo >>$TMP_DIR/temp.sh "echo \"BEGIN sensors.fan_${id} \$1\""
102 fid="$( fixid "$file" )"
103 lfile="$( basename $file | sed "s|_input$|_label|g" )"
104 labelname="$( basename $file )"
106 if [ ! "$path/$lfile" = "$file" -a -f "$path/$lfile" ]
108 labelname="$( cat "$path/$lfile" )"
111 echo "DIMENSION $fid '$labelname' absolute $multiplier $divisor"
112 echo >>$TMP_DIR/temp.sh "printf \"SET $fid = \"; cat $file "
115 echo >>$TMP_DIR/temp.sh "echo END"
119 echo >>$TMP_DIR/temp.sh "}"
125 # _update is called continiously, to collect the values
127 # the first argument to this function is the microseconds since last update
128 # pass this parameter to the BEGIN statement (see bellow).
130 # do all the work to collect / calculate the values
132 # remember: KEEP IT SIMPLE AND SHORT
134 # . $TMP_DIR/temp.sh $1