]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - examplescripts/Example1
Imported Upstream version 6.3+svn3990
[mirror_smartmontools-debian.git] / examplescripts / Example1
CommitLineData
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
14cat > /root/tempfile
15
16# Echo command line arguments into temp file
17echo "Command line argument 1:" >> /root/tempfile
18echo $1 >> /root/tempfile
19echo "Command line argument 2:" >> /root/tempfile
20echo $2 >> /root/tempfile
21echo "Command line argument 3:" >> /root/tempfile
22echo $3 >> /root/tempfile
23
24# Echo environment variables into a temp file
25echo "Variables are": >> /root/tempfile
26echo "$SMARTD_DEVICE" >> /root/tempfile
27echo "$SMARTD_DEVICESTRING" >> /root/tempfile
28echo "$SMARTD_DEVICETYPE" >> /root/tempfile
29echo "$SMARTD_MESSAGE" >> /root/tempfile
30echo "$SMARTD_FULLMESSAGE" >> /root/tempfile
31echo "$SMARTD_ADDRESS" >> /root/tempfile
32echo "$SMARTD_SUBJECT" >> /root/tempfile
33echo "$SMARTD_TFIRST" >> /root/tempfile
34echo "$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
44exit 0