[prev in list] [next in list] [prev in thread] [next in thread]
List: smartmontools-support
Subject: [smartmontools-support] suggested diff for Example1
From: "Martin A. Brown" <martin () wonderfrog ! net>
Date: 2006-06-14 1:03:31
Message-ID: Pine.LNX.4.63.0606131954540.30090 () solidus ! wonderfrog ! net
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello all,
I have attached a diff to Example1 in the examplscripts directory.
There are two things that I wanted to improve in this script:
- The monitoring system (smartmon) monitors disks, so it is very
possible (likely in some cases) that the disk to which we wish
to write the temporary file is no longer available. I'm sure
this is not news to the smartmontools developers.
- It is possible, though that a script invoked from the smartd
system, doesn't need to rely on the filesystem to actually send
output. If "bash", "cat", "hostname" and "smartctl" are in the
filesystem cache, then no reading from disk is required. Let's
send the message down a pipe.
And, by the way, thanks to the developers for this software. I just
recently experienced a data loss scare (just a scare, no loss!), and
I was happy to discover that this software will help me keep better
tabs on my disks.
Best regards,
- -Martin
- --
Martin A. Brown --- Wonderfrog Enterprises --- martin@wonderfrog.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: For info see http://quantumlab.net/pine_privacy_guard/
iD8DBQFEj2Blki79Zb8hnmwRAhYjAJ48YgrQKB0mjB5GsQtqMrN24Fbl8gCdHmRh
ZvhyBPNb9r7niqmEC9YxIzM=
=VLdH
-----END PGP SIGNATURE-----
["examplescripts.diff" (TEXT/PLAIN)]
diff --git a/Example1 b/Example1
index 9f4726f..8e3e3f0 100755
--- a/Example1
+++ b/Example1
@@ -10,35 +10,27 @@ # information.
#
# $Id: Example1,v 1.7 2004/08/29 02:33:17 ballen4705 Exp $
+{
# Save standard input into a temp file
-cat > /root/tempfile
+cat -
# Echo command line arguments into temp file
-echo "Command line argument 1:" >> /root/tempfile
-echo $1 >> /root/tempfile
-echo "Command line argument 2:" >> /root/tempfile
-echo $2 >> /root/tempfile
-echo "Command line argument 3:" >> /root/tempfile
-echo $3 >> /root/tempfile
+printf "\n\nCommand line arguments:\n" "$*"
# Echo environment variables into a temp file
-echo "Variables are": >> /root/tempfile
-echo "$SMARTD_DEVICE" >> /root/tempfile
-echo "$SMARTD_DEVICESTRING" >> /root/tempfile
-echo "$SMARTD_DEVICETYPE" >> /root/tempfile
-echo "$SMARTD_MESSAGE" >> /root/tempfile
-echo "$SMARTD_FULLMESSAGE" >> /root/tempfile
-echo "$SMARTD_ADDRESS" >> /root/tempfile
-echo "$SMARTD_SUBJECT" >> /root/tempfile
-echo "$SMARTD_TFIRST" >> /root/tempfile
-echo "$SMARTD_TFIRSTEPOCH" >> /root/tempfile
+printf "\n%s\n" "Variables are":
+
+for var in ${!SMARTD_*} ; do
+ printf "%-20s %-40s\n" "${var}:" "${!var}"
+done
# Run smartctl -a and save output in temp file
-/usr/sbin/smartctl -a -d $SMARTD_DEVICETYPE $SMARTD_DEVICE >> /root/tempfile
+printf "\n%s\n" "smartctl output":
+/usr/sbin/smartctl -a -d "$SMARTD_DEVICETYPE" "$SMARTD_DEVICE"
# Email the contents of the temp file. Solaris and other OSes
# may need to use /bin/mailx not /bin/mail.
-/bin/mail -s "SMART errors detected on host: `hostname`" $SMARTD_ADDRESS < /root/tempfile
+} | /bin/mail -s "SMART errors detected on host: `hostname`" "$SMARTD_ADDRESS"
# And exit
exit 0
diff --git a/Example2 b/Example2
index f653433..8a7355a 100755
--- a/Example2
+++ b/Example2
@@ -10,13 +10,14 @@ # information.
#
# $Id: Example2,v 1.4 2004/01/07 16:49:56 ballen4705 Exp $
+{
# Save the email message (STDIN) to a file:
-cat > /root/msg
+cat -
# Append the output of smartctl -a to the message:
-/usr/sbin/smartctl -a -d $SMARTD_DEVICETYPE $SMARTD_DEVICE >> /root/msg
+/usr/sbin/smartctl -a -d "$SMARTD_DEVICETYPE" "$SMARTD_DEVICE"
# Now email the message to the user at address ADD. Solaris and
# other OSes may need to use /bin/mailx below.
-/bin/mail -s "$SMARTD_SUBJECT" $SMARTD_ADDRESS < /root/msg
+} | /bin/mail -s "$SMARTD_SUBJECT" "$SMARTD_ADDRESS"
_______________________________________________
Smartmontools-support mailing list
Smartmontools-support@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/smartmontools-support
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic