]>
Commit | Line | Data |
---|---|---|
d2e702cf | 1 | #! /bin/sh |
832b75ed GG |
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 | # | |
d2e702cf | 11 | # $Id: Example1 3958 2014-07-18 19:13:32Z chrfranke $ |
832b75ed GG |
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 | ||
d2e702cf GI |
39 | # Email the contents of the temp file. Solaris and |
40 | # other OSes may need to use /usr/bin/mailx below. | |
41 | /usr/bin/mail -s "SMART errors detected on host: `hostname`" $SMARTD_ADDRESS < /root/tempfile | |
832b75ed GG |
42 | |
43 | # And exit | |
44 | exit 0 |