File: sensors.test

package info (click to toggle)
yasat 848-1
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 1,052 kB
  • ctags: 9
  • sloc: sh: 6,127; makefile: 47
file content (80 lines) | stat: -rwxr-xr-x 3,112 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
################################################################################
#                                                                              #
#   Copyright (C) 2008-2015 LABBE Corentin <clabbe.montjoie@gmail.com>
#
#    YASAT 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
#    (at your option) any later version.
#
#    YASAT 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 YASAT.  If not, see <http://www.gnu.org/licenses/>.
#                                                                              #
################################################################################


Title "Check sensors and temperature monitoring"

#TODO detect if we are inside a VM (so no need of IPMI/sensors)

#TODO on many servers there are no sensors and the use of IPMI is necessary
if [ "$OS_TYPE" = 'Linux' ] ; then
	Check_tool_presence sensors
	if [ $? -eq 1 ] ;then
		Display --indent 2 --text "No sensors binary" --result WARNING --color RED --advice TEMP_SENSORS
	else
		Display --indent 2 --text "sensors binary" --result FOUND --color GREEN
	fi
else
    	Display --indent 2 --text "HW temperature monitoring" --result NOTFOUND --color BLUE --advice TEMP_SENSOR_PROGRAM_UNK
fi

#check /dev/ipmi0
FOUND_IPMI=0
if [ -e /dev/ipmi0 ] ;then
	Display --indent 2 --text "IPMI BMC" --result FOUND --color BLUE
	FOUND_IPMI=1
fi

if [ $FOUND_IPMI -ge 1 -o "$SCAN_PROFILE" = 'server' ];then
	Check_tool_presence ipmitool
	if [ $? -eq 1 ] ;then
		Display --indent 2 --text "No ipmitool binary" --result WARNING --color RED --advice IPMI_NO_BINARY
	else
		IPMI_TMP="${TEMPYASATDIR}/ipmi.out"
		#when doing ipmitool lan print seek for snmp community string
		ipmitool lan print > $IPMI_TMP
		#TODO test ret value of ipmitool
		IPMI_SNMP_COMM="`grep -i snmp $IPMI_TMP | cut -d\: -f2- | sed 's/[[:space:]]*//g'`"
		if [ -z "$IPMI_SNMP_COMM" ];then
			Display --indent 2 --text "IPMI SNMP Comunity" --result NOTFOUND --color BLUE
		else
			if [ "$IPMI_SNMP_COMM" = "public" ];then
				Display --indent 2 --text "IPMI SNMP Community" --result WARNING --color RED --advice IPMI_BAD_SNMP_COMM
			else
				Display --indent 2 --text "IPMI SNMP Community" --result GOOD --color GREEN
			fi
		fi
	fi
fi

#Usefull http://wiki.nagios-fr.org/supervision/ipmi

#MCELOG this test is present here and in kernel, need to find the best place
if [ -e /dev/mcelog ] ;then
	Display --indent 2 --text "/dev/mcelog" --result FOUND --color BLUE
	Check_tool_presence mcelog
	if [ $? -eq 1 ];then
		Display --indent 4 --text "mcelog tool" --result NOTFOUND --color RED --advice MCELOG_TOOL
	else
		Display --indent 4 --text "mcelog tool" --result FOUND --color GREEN
	fi
fi

return 0;