1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 02:18:08 +00:00

Whitespace cleanup

* remove trailing whitespace
* remove empty lines at the end of files
This commit is contained in:
Lars Kruse 2018-08-02 02:03:42 +02:00
parent ef851f0c34
commit 17f784270a
604 changed files with 2927 additions and 2945 deletions

View file

@ -29,7 +29,7 @@
E_OK="0" # everything went allright
E_UNKNOWN="1" # "catch all" for otherwise unhandled errors
E_ARG="81" # invalid argument
E_ARG="81" # invalid argument
E_USAGE="82" # wrong program name or arguments
E_SNMPGET="83" # error while executing the 'snmpget' utility
@ -57,12 +57,12 @@ SENS_VALUE_OID=".1.3.6.1.4.1.21796.3.3.3.1.6." # integer (decimal * 10)
SENS_ID_OID=".1.3.6.1.4.1.21796.3.3.99.1.2.1.4." # unique sensor ID (integer)
#+ representation of the
#+ temperature (integer)
SENS_UNIT_OID=".1.3.6.1.4.1.21796.3.3.3.1.9." # 0=°C,1=°F,2=°K,3=%,4=V,5=mA,
SENS_UNIT_OID=".1.3.6.1.4.1.21796.3.3.3.1.9." # 0=°C,1=°F,2=°K,3=%,4=V,5=mA,
RTS_OUTPUT_OID=".1.3.6.1.4.1.21796.3.3.2.1.2." # binary input state (integer)
#+ 6=unknown, 7=pulse, 8=switch
# define some Poseidon specific stuff:
STATE_OK="1"
STATE_OK="1"
STATE_WARN="2"
STATE_CRIT="3"
UNITS=("C" "F" "K" "%" "V" "mA" "unknown" "pulse" "switch")
@ -100,13 +100,13 @@ EOT
cat <<- EOT
multigraph $sensorType
graph_title $sensorLocation - $sensorType [$sensorUnit]
graph_args --base 1000 -l 0
graph_args --base 1000 -l 0
graph_vlabel $sensorUnit
graph_category sensors
graph_info This graph shows $sensorType history.
EOT
fi
_firstSensor="0"
_firstSensor="0"
cat <<- EOT
$sensorType$_sensorNr.label $sensorName
$sensorType$_sensorNr.info This graph shows $sensorType$_sensorNr history.
@ -158,7 +158,7 @@ EOT
# getSensorData(sensorNr)
# fetch state, value, name unit and sensor type for the sensor
#+ with the number "sensorNr"
#+ with the number "sensorNr"
getSensorData() {
_sensorNr=$1
sensorState=`snmpGet $hostAddr $SENS_STATE_OID$_sensorNr || err \
@ -172,7 +172,7 @@ getSensorData() {
}
# getSystemInfo()
# fetch general information about the system
# fetch general information about the system
getSystemInfo() {
sensorLocation="`snmpGet $hostAddr $SYS_LOC_OID`"
}
@ -185,22 +185,22 @@ snmpGet () {
_host="$1"
_exit="0"
# fetch the requested OID
# fetch the requested OID
_longValue="`snmpget -O v\
-m $MIBS\
-v $SNMPVERSION\
-c $SNMPCOMMUNITY\
$_host $_oid 2>/dev/null`"
_exitStatus="$?"
echo ${_longValue#*:} # remove the type from the answer
return $_exitStatus
}
}
# get unit (string)
#+ find out the unit of the output of a given sensor. possible units are:
#+ "C" "F" "K" "%" "V" "mA" "unknown" "pulse" "switch"
#+ find out the unit of the output of a given sensor. possible units are:
#+ "C" "F" "K" "%" "V" "mA" "unknown" "pulse" "switch"
getSensorUnitString () {
_sensorNr=$1
_sensorUnit=`snmpGet $hostAddr $SENS_UNIT_OID$_sensorNr || err \
@ -209,7 +209,7 @@ getSensorUnitString () {
}
# get type (string)
#+ find out what type of sensor we are dealing with. possible types are:
#+ find out what type of sensor we are dealing with. possible types are:
#+ "Temp" "Hum" "Volt" "Curr" "Unkn" "Pulse" "Switch"
getSensorType () {
_sensorNr=$1
@ -223,19 +223,19 @@ getSensorType () {
#+ in the array for the respective unit
getAvailableSensorsByType () {
_thisSensorNr="1"
# initial fetch
_snmpget=`snmpGet $hostAddr $SENS_UNIT_OID$_thisSensorNr`
_nextSensorExits=$?
_unit=`echo "$_snmpget" | tr -d " "`
# add next sensor if it exists
while [ true ]; do
# add next sensor if it exists
while [ true ]; do
# add sensors of the same type to a list
sensorsOfType[$_unit]="${sensorsOfType[$_unit]} $_thisSensorNr"
sensorsOfType[$_unit]="${sensorsOfType[$_unit]} $_thisSensorNr"
# fetch next sensor
_thisSensorNr=$(($_thisSensorNr+1))
_thisSensorNr=$(($_thisSensorNr+1))
_snmpget=`snmpGet $hostAddr $SENS_UNIT_OID$_thisSensorNr`
_nextSensorExits=$?
@ -243,7 +243,7 @@ getAvailableSensorsByType () {
if [ $_nextSensorExits -ne 0 ]; then
break
fi
_unit=`echo "$_snmpget" |cut -d" " -f 4`
done
}
@ -264,7 +264,7 @@ sanitize () {
}
# usage ()
# print usage
# print usage
usage () {
echo "usage: snmp_<host>_poseidon-sensors [config|snmpconf]" 1>&2
exit $E_USAGE
@ -279,7 +279,7 @@ err () {
else
_errorMsg="Fatal: An unknown error occurred! Exiting..."
_exitCode="$E_UNKNOWN"
fi
# print error message to STDERR ...
@ -291,13 +291,13 @@ err () {
#==============================================================================#
# SNMP Config
MIBS=":" # we don't use any configured MIBs so we don't
MIBS=":" # we don't use any configured MIBs so we don't
#+ have to deal with errors in the MIBs
if [ -z $SNMPVERSION ]; then
if [ -z $SNMPVERSION ]; then
SNMPVERSION="1" # as of firmware 3.1.5 only SNMPv1 is supported
fi
if [ -z $SNMPCOMMUNITY ]; then
if [ -z $SNMPCOMMUNITY ]; then
SNMPCOMMUNITY="public" # SNMP community string to read from the device
fi
@ -326,11 +326,11 @@ hostAddr="`basename "$0" | cut -d "_" -f 2`"
if [ "$myName" = "snmp_poseidon-sensors" ]; then
hostAddr=`sanitize $hostAddr || err \
"Fatal: Invalid argument \"$hostAddr\"! Exiting..." $E_ARG`
if [ -z "$hostAddr" ]; then
if [ -z "$hostAddr" ]; then
usage munin
fi
getAvailableSensorsByType
if [ "$1" = "config" ]; then
if [ "$1" = "config" ]; then
printMuninConfig
exit $E_OK
elif [ "$1" = "snmpconfig" ]; then