security.d/chk_smart

Sat, 15 Aug 2009 16:01:10 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 15 Aug 2009 16:01:10 +0200
changeset 12
3179bc45c83c
parent 5
fe3130d22800
child 14
59e07bba67cc
permissions
-rw-r--r--

Added high disk temp reporting

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

mercurial