Sat, 15 Aug 2009 16:01:10 +0200
Added high disk temp reporting
5 | 1 | #!/bin/bash |
2 | # | |
3 | ############################################################################# | |
12
3179bc45c83c
Added high disk temp reporting
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
4 | # Copyright (C) 2005-2009 |
5 | 5 | # |
6 | # Michiel Broek <mbse@mbse.dds.nl> | |
7 | # Beekmansbos 10 | |
8 | # 1971 BV IJmuiden | |
9 | # the Netherlands | |
10 | # | |
11 | # This file is part of SlackSecCheckSripts. | |
12 | # | |
13 | # This package is free software; you can redistribute it and/or modify it | |
14 | # under the terms of the GNU General Public License as published by the | |
15 | # Free Software Foundation; either version 2, or (at your option) any | |
16 | # later version. | |
17 | # | |
18 | # SlackSecCheckSripts is distributed in the hope that it will be useful, but | |
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | # General Public License for more details. | |
22 | # | |
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with MBSE BBS; see the file COPYING. If not, write to the Free | |
25 | # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
26 | ############################################################################# | |
27 | ||
28 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
29 | ||
30 | umask 077 | |
31 | TZ=UTC; export TZ | |
32 | LANG=C; export LANG | |
33 | ||
34 | SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1 | |
35 | ||
36 | trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE | |
37 | ||
38 | if ! cd "$SECUREDIR"; then | |
39 | echo "Can not cd to $SECUREDIR". | |
40 | exit 1 | |
41 | fi | |
42 | ||
43 | TMP=$SECUREDIR/tmp | |
44 | ||
45 | if [ -x /usr/sbin/smartctl ] && [ -f /etc/smartd.conf ]; then | |
46 | kill -0 `pidof /usr/sbin/smartd` 2>/dev/null | |
47 | if [ "$?" != "0" ]; then | |
48 | printf "\nWarning: smartd is not running.\n" | |
49 | fi | |
50 | ||
12
3179bc45c83c
Added high disk temp reporting
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
51 | DISKS=$( egrep '^[^#]*(dev)' /etc/smartd.conf | awk '{ print $1 }' ) |
5 | 52 | for f in $DISKS ; do |
53 | # /usr/sbin/smartctl -H -i -l error -l selftest $f | |
54 | /usr/sbin/smartctl -q errorsonly -H -l error $f > $TMP | |
55 | if [ -s $TMP ]; then | |
56 | printf "\nS.M.A.R.T. error information for disk %s\n\n" $f | |
57 | cat $TMP | |
58 | fi | |
12
3179bc45c83c
Added high disk temp reporting
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
59 | # Most harddisk manufactures specify 60 degrees Celsius, warn a little below that |
3179bc45c83c
Added high disk temp reporting
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
60 | TEMP=$( /usr/sbin/smartctl -A $f | grep ^194 | awk '{ print $10 }' ) |
3179bc45c83c
Added high disk temp reporting
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
61 | if [ ! -z "$TEMP" ] && [ ${TEMP} -ge 53 ]; then |
3179bc45c83c
Added high disk temp reporting
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
62 | printf "\nS.M.A.R.T. high temperature for disk %s, %s degrees Celsius\n" $f $TEMP |
3179bc45c83c
Added high disk temp reporting
Michiel Broek <mbroek@mbse.eu>
parents:
5
diff
changeset
|
63 | fi |
5 | 64 | done |
65 | fi | |
66 |