Argument order irrelevant/ sensor parsing improved
- -s/ --sensor first does not ignore following -c/ -w anymore - current sensor's multiline output without adapter and temperatur in 2nd line
This commit is contained in:
parent
c60b88813a
commit
b504956f4f
5
HISTORY
5
HISTORY
@ -34,3 +34,8 @@ Version 1.0:
|
|||||||
- Enriched performance data output. For example, "CPU=34;40;55 MB=32;40;55"
|
- Enriched performance data output. For example, "CPU=34;40;55 MB=32;40;55"
|
||||||
- Changed (and improved) the way temperatures are retrieved
|
- Changed (and improved) the way temperatures are retrieved
|
||||||
- Other fixes and touch-ups, such as the help text now shows long options
|
- Other fixes and touch-ups, such as the help text now shows long options
|
||||||
|
|
||||||
|
Version 1.1:
|
||||||
|
Improvements for Icinga 2, made by Onkobu
|
||||||
|
- order of arguments is irrelevant now, --sensor first ignored following -c & -w
|
||||||
|
- current sensors' multiline output needs sophisticated treatment
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
# #
|
# #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
VERSION="Version 1.0"
|
VERSION="Version 1.1"
|
||||||
AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se)"
|
AUTHOR="(c) 2011 Jack-Benny Persson (jack-benny@cyberinfo.se), (c) 2020 Onkobu Tanaake (oss@onkobutanaake.de)"
|
||||||
|
|
||||||
# Sensor program
|
# Sensor program
|
||||||
SENSORPROG=$(whereis -b -B /{bin,sbin,usr} /{bin,sbin,usr}/* -f sensors | awk '{print $2}')
|
SENSORPROG=$(whereis -b -B /{bin,sbin,usr} /{bin,sbin,usr}/* -f sensors | awk '{print $2}')
|
||||||
@ -144,7 +144,7 @@ function process_sensor {
|
|||||||
fi
|
fi
|
||||||
# Get the temperature
|
# Get the temperature
|
||||||
# Grep the first float with a plus sign and keep only the integer
|
# Grep the first float with a plus sign and keep only the integer
|
||||||
WHOLE_TEMP=$(${SENSORPROG} | grep "$sensor" | head -n1 | grep -o "+[0-9]\+\(\.[0-9]\+\)\?[^ \t,()]*" | head -n1)
|
WHOLE_TEMP=$(${SENSORPROG} -A "$sensor" | sed -n '2 p' | grep -o "+[0-9]\+\(\.[0-9]\+\)\?[^ \t,()]*" | head -n1)
|
||||||
TEMPF=$(echo "$WHOLE_TEMP" | grep -o "[0-9]\+\(\.[0-9]\+\)\?")
|
TEMPF=$(echo "$WHOLE_TEMP" | grep -o "[0-9]\+\(\.[0-9]\+\)\?")
|
||||||
TEMP=$(echo "$TEMPF" | cut -d. -f1)
|
TEMP=$(echo "$TEMPF" | cut -d. -f1)
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ while [[ -n "$1" ]]; do
|
|||||||
exit $STATE_UNKNOWN
|
exit $STATE_UNKNOWN
|
||||||
fi
|
fi
|
||||||
sensor_declared=true
|
sensor_declared=true
|
||||||
process_sensor "$2"
|
sensors_to_check="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -262,6 +262,8 @@ done
|
|||||||
|
|
||||||
if [ "$sensor_declared" = false ]; then
|
if [ "$sensor_declared" = false ]; then
|
||||||
process_sensor "$default_sensor"
|
process_sensor "$default_sensor"
|
||||||
|
else
|
||||||
|
process_sensor "$sensors_to_check"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$STATE" in
|
case "$STATE" in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user