So I have a script that monitors my drives (/dev/sda and /dev/sdb) using smartctl (smartmontools). I'm by no means an expert in scripting, so this was my attempt at creating a way to email me if one of the values in smartctl output goes above a set threshold.
My question is, I'm trying to edit the "Subject" line of the email that it sends, so that I can tell which 'test' is failing. Is it temperature_celsius, etc? Is there a way to name each one and then use a variable like $failedtest in the subject line?
I'm at a loss for how to write this..
In case it matters, here is an output of `smartctl -d marvell -a /dev/sda`:
Any cleanup/shorter command suggestions are always welcome too, this was just the best I could come up with.
I parse those datalines and comparing values.
I also create variable which name is column ATTRIBUTE_NAME. Possible to use variable and comparing those. Only example if needed.
the code given as solution is nothing but reading the output file from /tmp it is indisual script just using variable of origional script you can put in end of your origional script.
---------- Post updated at 01:07 PM ---------- Previous update was at 01:00 PM ----------
the code given as solution is nothing but reading the output file from /tmp it is indisual script just using variable of origional script you can put in end of your origional script.
---------- Post updated at 01:07 PM ---------- Previous update was at 01:07 PM ----------
the code given as solution is nothing but reading the output file from /tmp it is indisual script just using variable of origional script you can put in end of your origional script.
You could use a function to log the messages...
Also all those awks are expensive and your script will take a long time to run. You might want to consider using a case statement instead. Further, you could use a list of devices so the script becomes generic and it becomes easier to log to what device an error belongs and what the error message was. For example (not tested):
The variable PROBLEM indicates if a problem occurred. You can test for it like this:
Last edited by Scrutinizer; 01-22-2011 at 06:16 AM..
I am installing Oracle DBD to PERL 5.16.3 and during make test , I am running into this error :rm -f blib/arch/auto/DBD/Oracle/Oracle.so
LD_RUN_PATH="/opt/oracle/product/11.2.0/racdb11204/lib" gcc -m32 -shared -O2 -L/usr/local/lib -fstack-protector Oracle.o dbdimp.o oci8.o -o... (3 Replies)
Testing some old script developed by different user.
#!/usr/bin/sh
case "$0" in
*/*) cmd="$0";;
*) cmd=`which "$0"`;;
esac
dir=`dirname "$cmd"`
node="$dir/."
echo $node
below two simple tests are failing, I am not seeing any Control+M characters in the script file and I am not able... (4 Replies)
I have a following script to evaluate if file exist in the directory and then archive it.
#!/bin/bash
#master directory
scriptdir="/flex/sh/interfaces" #change this path only - all other paths are connected with it
filedir="/flex/interfaces" #change this path only - all other paths are... (3 Replies)
Hi,
I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)