security.d/chk_smart

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

mercurial