Annotation of embedaddon/smartmontools/examplescripts/Example1, revision 1.1.1.1

1.1       misho       1: #!/bin/bash 
                      2: #
                      3: # This is a script from the smartmontools examplescripts/ directory.
                      4: # It can be used as an argument to the -M exec Directive in
                      5: # /etc/smartd.conf, in a line like 
                      6: # -m root@localhost -M exec /path/to/this/file
                      7: #
                      8: # Please see man 8 smartd or man 5 smartd.conf for further
                      9: # information.
                     10: #
                     11: # $Id: Example1,v 1.7 2004/08/29 02:33:17 ballen4705 Exp $
                     12: 
                     13: # Save standard input into a temp file
                     14: cat > /root/tempfile
                     15: 
                     16: # Echo command line arguments into temp file
                     17: echo "Command line argument 1:" >> /root/tempfile
                     18: echo $1 >> /root/tempfile
                     19: echo "Command line argument 2:" >> /root/tempfile
                     20: echo $2 >> /root/tempfile
                     21: echo "Command line argument 3:" >> /root/tempfile
                     22: echo $3 >> /root/tempfile
                     23: 
                     24: # Echo environment variables into a temp file
                     25: echo "Variables are":       >> /root/tempfile
                     26: echo "$SMARTD_DEVICE"       >> /root/tempfile
                     27: echo "$SMARTD_DEVICESTRING" >> /root/tempfile
                     28: echo "$SMARTD_DEVICETYPE"   >> /root/tempfile
                     29: echo "$SMARTD_MESSAGE"      >> /root/tempfile
                     30: echo "$SMARTD_FULLMESSAGE"  >> /root/tempfile
                     31: echo "$SMARTD_ADDRESS"      >> /root/tempfile
                     32: echo "$SMARTD_SUBJECT"      >> /root/tempfile
                     33: echo "$SMARTD_TFIRST"       >> /root/tempfile
                     34: echo "$SMARTD_TFIRSTEPOCH"  >> /root/tempfile
                     35: 
                     36: # Run smartctl -a and save output in temp file
                     37: /usr/sbin/smartctl -a -d $SMARTD_DEVICETYPE $SMARTD_DEVICE >> /root/tempfile
                     38: 
                     39: # Email the contents of the temp file. Solaris and other OSes
                     40: # may need to use /bin/mailx not /bin/mail.
                     41: /bin/mail -s "SMART errors detected on host: `hostname`" $SMARTD_ADDRESS < /root/tempfile
                     42: 
                     43: # And exit
                     44: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>