Joe L. Posted December 22, 2007 Share Posted December 22, 2007 One more question. I noticed Joe L. said: The last few lines in the "go" script will then be: # Start the management utility emhttp & cp /boot/smtp_check_unraid.sh /etc/cron.hourly/ My "go" file now looks like: #!/bin/bash # Start the Management Utility /usr/local/sbin/emhttp & sleep 30 for i in /dev/md* do blockdev --setra 2048 $i done cp /boot/smtp_check_unraid.sh /etc/cron.hourly/ Is this O? I'm not sure why there's no "emhttp &" in there. It is there..on line 3, but with a full path instead of just the executable name. The script is designed to alert you if the array is not started and on-line with all disks valid parity errors or read errors that do not take result in a disk being marked as defective (disabled or invalid) will not result in an error e-mail. Glad you had a different mail host to use that did not use TLS (SSL) Joe L. Quote Link to comment
JarDo Posted December 26, 2007 Share Posted December 26, 2007 Only one e-mail is being sent, with two recipients listed in its header. Not sure what to say about that. The contents of /proc/mdcmd are sent through the stream editor with he following series of shown below They are supposed to add a carriage return/newline to each line in turn. See if those were entered correctly. # Add <CRLF> to each line file=/proc/mdcmd sEcho+=`sed "s/$/\\r\\n/" <$file` sEcho+="\r\n" Well, I've verified that my script is written exactly as above, but I still can't figure out why the email I receive does not contain line-feeds. At first I thought it was an Outlook problem, but when I view the email on the web-based email client I'm missing line-feeds there too. Is it possible that I need to run the script in a shell other than the bash shell? It seems that it is the sed command that isn't running as advertised but everything else about the script seems to be working properly for me. Quote Link to comment
Joe L. Posted December 26, 2007 Share Posted December 26, 2007 The beauty of Unix is that there are a multitude of tools available to do many tasks. Try this (I changed the sed command to an "awk" command): # Add <CRLF> to each line file=/proc/mdcmd sEcho+=`awk 'sub("$","\r")' <$file` sEcho+="\r\n" To see this in action without sending the mail try using the "od" (octal dump) command for some debugging. od -c /proc/mdcmd you will see newline characters, displayed as "\n", at the end of each line. Then try awk 'sub("$","\r")' </proc/mdcmd | od -c You will see newline, carriage-return pairs shown as "\r\n" at the end of each line. Joe L. Quote Link to comment
WeeboTech Posted February 22, 2008 Share Posted February 22, 2008 Here's a chunk of code to add resync status messages if the parity check is resyncing. I pulled it out of unmenu... thanks. P=${0##*/} # basename of program R=${0%%$P} # dirname of program P=${P%.*} # strip off after last . character export T=/tmp/${P}.$$ trap "rm -f ${T}" EXIT HUP INT QUIT strings < /proc/mdcmd > ${T} RESYNC=`egrep "^mdResync" ${T} | cut -d "=" -f2` if [ $? = 0 ] then RESYNCPERCENT=`egrep "^mdResyncPrcnt" ${T} | cut -d "=" -f2` RESYNCFINISH=`egrep "^mdResyncFinish" ${T} | cut -d "=" -f2` RESYNCSPEED=`egrep "^mdResyncSpeed" ${T} | cut -d "=" -f2` NL=`echo "\n"` sSubject="unRaid Resync Notification" emsg="The unRaid array is resync/rebuilding parity.${NL}${NL}" if [ ! -z "${RESYNCPERCENT}" ] then emsg="${emsg}Parity CHECK/RESYNC in progress, " emsg="${emsg} ${RESYNCPERCENT}% complete, " emsg="${emsg} est. finish in $RESYNCFINISH minutes." emsg="${emsg} Speed: ${RESYNCSPEED} kb/s." fi bIncludeMdcmd="False" fi I put it after this block egrep "=DISK_INVALID|=DISK_DSBL" /proc/mdcmd >/dev/null 2>&1 if [ $? = 0 ] then sSubject="unRaid Failure Notification" emsg="The unRaid array needs attention. One or more disks are disabled o r invalid." bIncludeMdcmd="True" fi Perhaps it should be before. Also near the end I changed the Date and Status message display to be: sEcho+="Date: " sEcho+="`date 2>/dev/null`\r\n" sEcho+="Status: $emsg\r\n" This lets the status message be last and be able to span more then one line. Just looks neater. Quote Link to comment
NLS Posted March 29, 2008 Share Posted March 29, 2008 ok a few questions: 1) I read about DAILY reports... how do I make those? Because in the script I only see about hourly (nonono) and default is weekly? Or am I confused? 2) Why is the full domain name needed? Isn't the mail server's name enough? (and from/to email addresses?) 3) About this last post (WeeboTech). Will it report (whenever a mail is sent) on if the array is resyncing? That is to say that it was NOT reported in the original version? (just to be clear) thanks people Quote Link to comment
Joe L. Posted March 29, 2008 Share Posted March 29, 2008 ok a few questions: 1) I read about DAILY reports... how do I make those? Because in the script I only see about hourly (nonono) and default is weekly? Or am I confused? Unix (and Linux) has available a program to schedule repeating tasks. It is known as "cron" (short for chronological scheduler) This is configured in a file: /etc/crontab This is a editable file with a fairly flexible set of fields for scheduling. I recommend googling "man crontab" for full details... It is somewhat complicated for many to set up... to make it easier for most Linux users there are several pre-scheduled tasks. These tasks will run scripts placed in specific folders at specific intervals: At 47 minutes after the hour: scripts in the /etc/cron.hourly folder are run. At 4:40 AM every day: scripts in the /etc/cron.daily are run. At 4:30 AM on the first day of the week: scripts in the /etc/cron.weekly are run. At 4:20 AM on the first day of the month: scripts in the /etc/cron.monthly are run. So, you can copy just about any script to any of the above folders and have it execute once an hour/day/week/month. There is no "default" for any periodic alert e-mail, just copy your script, once you get it working, to the appropriate folder. 2) Why is the full domain name needed? Isn't the mail server's name enough? (and from/to email addresses?) I don't honestly know if you can use shorter names. Try it and see once you get things working and report back. 3) About this last post (WeeboTech). Will it report (whenever a mail is sent) on if the array is resyncing? That is to say that it was NOT reported in the original version? (just to be clear) Correct... my original script did not send mail if you pressed the "Check Parity" button on the array, or if it was checking parity on its own. It only sent mail if the array was disabled (you had stopped the array), or if it was invalid (a disk had failed) I think the addition might be useful. I check parity about once a month or so, just to exercise the disks, and a few extra e-mail messages would not bother me. The only other time a parity check might occur is if I had a power failure and then power was restored. Seeing an un-expected e-mail message might alert me to something going on I was not aware of otherwise. thanks people You are welcome Joe L. Quote Link to comment
NLS Posted March 29, 2008 Share Posted March 29, 2008 ok thank you for the reply 1) I know about cron, didn't know about the "preset" folders though. So if I want daily reports I copy to cron.daily. Maybe I missed something in those four pages, but how can the script be triggered when there is an actual problem? (i.e. not called from cron schedules) Or this cannot happen? 2) You probably didn't get me right: In the script there is a variable named sDomain. I don't get its use when you have sSmtpServer (plus why a domain has to be related to my mail... for example I might have my mail service hosted somewhere that is not related to "my" local or non-local domain). 3) OK clear. Quote Link to comment
Joe L. Posted March 29, 2008 Share Posted March 29, 2008 ok thank you for the reply 1) I know about cron, didn't know about the "preset" folders though. So if I want daily reports I copy to cron.daily. Maybe I missed something in those four pages, but how can the script be triggered when there is an actual problem? (i.e. not called from cron schedules) Or this cannot happen? No event/trigger exists that I am aware of when a problem occurs to trigger an e-mail. Best we can do is "poll" (at some reasonable interval) and look to see if a problem has occurred. Even if Tom were to add e-mail support to his process, it would have to do the same unless he added a /proc "file" that when read, did not return until status had changed. (in technical terms, it is called a "blocked read") If that was the case, we could just wait on that event. 2) You probably didn't get me right: In the script there is a variable named sDomain. I don't get its use when you have sSmtpServer (plus why a domain has to be related to my mail... for example I might have my mail service hosted somewhere that is not related to "my" local or non-local domain). sSmtpServer, in my script, is only used to get the IP address of the mail server. sDomain is the domain name used in the mail header itself. (I think they might be different, but I could envision a mail server only wanting to accept mail requests originating from its own users) Joe L. Quote Link to comment
NLS Posted March 29, 2008 Share Posted March 29, 2008 hm.... then I guess in my case sSmtpServer = sDomain... Quote Link to comment
Joe L. Posted March 29, 2008 Share Posted March 29, 2008 In mine, the two variables are different... Now I understand the context of your question... two variables, in your case with the same value... you would think you only needed one. Joe L. Quote Link to comment
NLS Posted March 29, 2008 Share Posted March 29, 2008 So when you ping www.yourdomain.com and mail.yourdomain.com you get two different addresses AND you need both? Because yes in my case both resolve to the same address but even if they didn't I wonder what I would need my web server's IP (or name) for. Quote Link to comment
Joe L. Posted March 29, 2008 Share Posted March 29, 2008 So when you ping www.yourdomain.com and mail.yourdomain.com you get two different addresses AND you need both? Because yes in my case both resolve to the same address but even if they didn't I wonder what I would need my web server's IP (or name) for. In my case, I do get different IP addresses. root@Tower:/boot# net lookup www.triad.rr.com 24.28.227.96 root@Tower:/boot# net lookup smtp-server.triad.rr.com 71.74.56.22 Quote Link to comment
NLS Posted March 29, 2008 Share Posted March 29, 2008 Sure but... but even if they didn't (match) I wonder what I would need my web server's IP (or name) for. Esp. since the basic script is for non secured smtp (no password sent or any authentication to any server). I (just) looked at the script and I see you use sdomain variable only in EHLO handshaking (along with the sender mail). EHLO in RFC2821 just needs the FQDN and not the sender mail IIRC. Also this FQDN is (again IIRC) the mail servers FQDN. In some EHLO implementations (I think in Windows Exchange too), EHLO is even ok without parameters. So are you sure sdomain is not redundant or even wrong by the RFC? Can you check using ssmtpserver in the EHLO echo? (I would check but my unraid is not ready and I already told you my www and mail are the same IP anyway) I am curious. Quote Link to comment
NLS Posted April 17, 2008 Share Posted April 17, 2008 Problem: Script works but report is wrong. Status: The unRaid array is resync/rebuilding parity. (and erm... it is not) Report is the same (except the list of mounted drives) both when array is started and stopped. Quote Link to comment
Joe L. Posted April 17, 2008 Share Posted April 17, 2008 Where did you get your copy of the script? That part about "parity check in progress" is something somebody else added.. I saw it a few posts ago in this thread, Did you edit it in? Or is a complete script downloadable from somewhere? If a complete script is not downloadable, send it to me in a "PM" I'll take a look. You can just paste it in the body of the PM, or zip it and attach it. Joe L. Quote Link to comment
NLS Posted April 17, 2008 Share Posted April 17, 2008 I got it from this thread. But is probably an edit I did before I actually implemented my unRAID - I just tested it now. Still need the code? (it obviously doesn't work too well) Quote Link to comment
Joe L. Posted April 17, 2008 Share Posted April 17, 2008 I got it from this thread. But is probably an edit I did before I actually implemented my unRAID - I just tested it now. Still need the code? (it obviously doesn't work too well) sure, send in PM, otherwise somebody else will copy bad code. I'll repost the working version Joe L. Quote Link to comment
Joe L. Posted April 17, 2008 Share Posted April 17, 2008 NLS, A correct block of code to add notifications when a parity check is in progress is here. Only one line needs to be corrected. It was incorrectly testing the exit status of the "cut" command on the prior line. That command always is successful, therefore, the message was always sent. The author intended that the message only be sent when the value of the mdResync parameter was not zero. I'm now testing for that in my modified line of code. Have fun. Joe L. # RESYNC MESSAGES P=${0##*/} # basename of program R=${0%%$P} # dirname of program P=${P%.*} # strip off after last . character export T=/tmp/${P}.$$ trap "rm -f ${T}" EXIT HUP INT QUIT strings < /proc/mdcmd > ${T} RESYNC=`egrep "^mdResync" ${T} | cut -d "=" -f2` if [ "$RESYNC" != "0" ] then RESYNCPERCENT=`egrep "^mdResyncPrcnt" ${T} | cut -d "=" -f2` RESYNCFINISH=`egrep "^mdResyncFinish" ${T} | cut -d "=" -f2` RESYNCSPEED=`egrep "^mdResyncSpeed" ${T} | cut -d "=" -f2` NL=`echo "\n"` sSubject="unRaid Resync Notification" emsg="The unRaid array is resync/rebuilding parity.${NL}${NL}" if [ ! -z "${RESYNCPERCENT}" ] then emsg="${emsg}Parity CHECK/RESYNC in progress, " emsg="${emsg} ${RESYNCPERCENT}% complete, " emsg="${emsg} est. finish in $RESYNCFINISH minutes." emsg="${emsg} Speed: ${RESYNCSPEED} kb/s." fi bIncludeMdcmd="False" fi Quote Link to comment
NLS Posted April 18, 2008 Share Posted April 18, 2008 ...erm linux troubleshooting? - I edited the file, ONLY that line. - I made sure it is in "UNIX" format (EOL characters) - I rechecked and even reapplied chmod to execute: -rwxr-xr-x 1 root root 5494 Apr 18 09:36 smtp_check_unraid.sh* Still when I run the command, produces nothing. Not even an error. Yesterday it did output as it progressed. Haven't touched any other line... any ideas? Quote Link to comment
Joe L. Posted April 18, 2008 Share Posted April 18, 2008 Unless your array is stopped, or has a failed drive, or, with the added code block fixed, doing a parity check, the script will do exactly as you described. It will print nothing after testing to see if your array is off line, etc. To build your linux shell script debugging skills you can run it in a way where it will show you each line and variable as they are interpreted. Instructions here: http://lime-technology.com/forum/index.php?topic=911.msg7052#msg7052 The top of the script you sent me via PM has these lines # initialize the error message to an empty string if no hourly OK message is desired # like this: emsg="" #emsg="unRAID is OK" Lines starting with a "#" are comments. The "emsg" variable is set to an empty string. If you want to get an e-mail every time the script is run, you should remove the "#" from the beginning of the line emsg="unRAID is OK" I just tested the script you sent me in the PM, changing only the one line that I already described and the few lines at the top to use my e-mail provider. It works very well. I found only one trivial "error" These three lines have an incorrect comment. The comment should not say # SHOW DATE, it instead should say: # SHOW DISK FREE # SHOW DATE sEcho+=`df -h | sed "s/$/\\r\\n/"` sEcho+="\r\n" Changing that line will not change how it works, but will make it easier for those new to shell scripts to figure out what is going on. Corrected code is below. Note: this version does not perform an AUTH (authentication) Login to the SMTP provider. Instructions on how to add that is in this thread in prior posts. Joe L. #!/bin/bash # # Title: smtp_check_status.sh # # Summary: # The purpose of this script is to check the status of the unRAID # array by searching the /proc/mdcmd file for known bad states. # This script was originally created by Joe. L for use with Yak # and has been modified by kenshin (twelston) on 08-17-2007 to add smtp # functionality, and increase the information transmitted by the script # (i.e. adding ip, date, and the output of the /proc/mdcmd file if # elected by the user) # # If you have any questions or problems while using this script please # post them to the unRaid forum: # # http://support.lime-technology.com/forum/ # # DISCLAIMER: # Your use of this script is at your sole risk. This script is provided # "as -is", without any warranty # # Further, the authors of this script shall not be liable for any damages # you may sustain by using this information, whether direct, indirect, # special, incidental or consequential, even if they have been advised of # the possibility of such damages. # Define the following six values to setup this script # The name of your SMTP server sSmtpServer="your.SMTP.server.name.here" # Your domain name sDomain="www.your.domain" # The "from" email address sMailFrom="your.from.email.address" # The "to" mail address (The addressess must be separated by a space, a # single address requires no spaces) sRcptTo="[email protected]" # The email subject sSubject="unRAID Status Notification" # Choose whether to include the contents of /proc/mdcmd in your status # notifications (Setting this value to anything but "True" is the same # as setting it to "False") bIncludeMdcmd="True" # A copy of netcat (nc) is on the flash drive, add /boot/ to the PATH so it # will be found when executed. PATH=$PATH:/boot/ # initialize the error message to an empty string if no hourly OK message is desired # like this: emsg="" # if hourly unrAID OK message is desired, set emsg to the desired status message # like this: #emsg="unRAID is OK" # request that status be updated echo "status" >/proc/mdcmd # now check the status and report as needed # Even if the contents of /proc/mdcmd are not normally included if all is OK, # include it if something is wrong by setting the flag to True. grep "mdState=STARTED" /proc/mdcmd >/dev/null 2>&1 if [ $? != 0 ] then emsg="unRAID array not started" bIncludeMdcmd="True" fi egrep "=DISK_INVALID|=DISK_DSBL" /proc/mdcmd >/dev/null 2>&1 if [ $? = 0 ] then sSubject="*** unRAID server needs your attention. One or more disks are disabled or invalid. ****" emsg="The unRAID array needs attention. One or more disks are disabled or invalid." bIncludeMdcmd="True" fi # RESYNC MESSAGES P=${0##*/} # basename of program R=${0%%$P} # dirname of program P=${P%.*} # strip off after last . character export T=/tmp/${P}.$$ trap "rm -f ${T}" EXIT HUP INT QUIT strings < /proc/mdcmd > ${T} RESYNC=`egrep "^mdResync" ${T} | cut -d "=" -f2` if [ "$RESYNC" = "0" ] then RESYNCPERCENT=`egrep "^mdResyncPrcnt" ${T} | cut -d "=" -f2` RESYNCFINISH=`egrep "^mdResyncFinish" ${T} | cut -d "=" -f2` RESYNCSPEED=`egrep "^mdResyncSpeed" ${T} | cut -d "=" -f2` NL=`echo "\n"` sSubject="unRaid Resync Notification" emsg="The unRaid array is resync/rebuilding parity.${NL}${NL}" if [ ! -z "${RESYNCPERCENT}" ] then emsg="${emsg}Parity CHECK/RESYNC in progress, " emsg="${emsg} ${RESYNCPERCENT}% complete, " emsg="${emsg} est. finish in $RESYNCFINISH minutes." emsg="${emsg} Speed: ${RESYNCSPEED} kb/s." fi bIncludeMdcmd="False" fi # if an error message was set, broadcast it to all the email addresses # in the notify list if [ "$emsg" != "" ] then # look up the ip address given the machine name ip_addr=`net lookup $sSmtpServer 2>/dev/null` if [ $? = 0 ] then # Build the echo string sEcho="ehlo $sDomain\r\nmail from:$sMailFrom\r\n" # Add each recipient to the RCPT list for i in $sRcptTo do sEcho+="RCPT TO:"$i"\r\n" done # Message header sEcho+="data\r\nFrom:$sMailFrom\r\nTo:" # Add each recipient to the message header for i in $sRcptTo do sEcho+=$i";" done sEcho+="\r\n" # Message Subject sEcho+="Subject:$sSubject\r\n" # Message Body (You can change this to look how you want. Just # to include \r\n at the end of each line.) sEcho+="This message is a status update for unRAID $HOSTNAME\r\n" sEcho+="-----------------------------------------------------------------\r\n" sEcho+="Server Name: $HOSTNAME\r\n" sEcho+="Server IP: `net lookup $HOSTNAME 2>/dev/null`\r\n" sEcho+="Date: " sEcho+="`date 2>/dev/null`\r\n" sEcho+="Status: $emsg\r\n" # SHOW DISK FREE sEcho+=`df -h | sed "s/$/\\r\\n/"` sEcho+="\r\n" # Add the contents of /proc/mdcmd if elected by the user if [ "$bIncludeMdcmd" = "True" ] then sEcho+="\r\n" sEcho+="Output of /proc/mdcmd:\r\n" sEcho+="-----------------------------------------------------------------\r\n" # Add <CRLF> to each line file=/proc/mdcmd sEcho+=`sed "s/$/\\r\\n/" <$file` sEcho+="\r\n" fi # End the message sEcho+=".\r\n" sEcho+="QUIT\r\n" # Send the message we just built echo -e $sEcho|nc -i 1 -q 1 $ip_addr 25 # Use the following line for debug #echo -e $sEcho|nc -w 1 -q 2 -i 1 -vv $ip_addr 25 fi fi Quote Link to comment
NLS Posted April 18, 2008 Share Posted April 18, 2008 erm... oups I thought this sends mail every time. Seems after your edit, I didn't test with array stopped. Yeap. Seems to work (can't read my mail right now, I only have telnet - but it was sending before, so it probably sends now too). Thanks... if it is just when there is a problem, I will probably make the script hourly not daily (or maybe two versions). Quote Link to comment
bluto Posted July 11, 2008 Share Posted July 11, 2008 Hi -- will someone please try to help me with this? I'm pretty close to getting it to work thanks to all of the great help from the contributors of this thread. When I run the smtp_check_unraid.sh script from telnet the only text in the resulting email is output from the /proc/mdcmd: section -- nothing else is included in the email message. When inspecting the smtp_check.log it appears that the echo string was built correctly and that it was also correctly passed to the email server. However, the only text that comes through is from the /proc/mdcmd: section. Attached is the smtp_check.log file and a syslog file for your inspection. Any ideas how to get all of the appropriate sections to be included in the email would be appreciated -- thanks again. Quote Link to comment
Joe L. Posted July 11, 2008 Share Posted July 11, 2008 Please zip up your smtp_check_unraid.sh script and send it to me in a PM. I see what is happening, (the stream edit of the mdcmd status is not occurring correctly) but would love to see how you edited the script so I can advise how to fix it. (please blank out your ID/Password. I don't need them. ) Joe L. Quote Link to comment
Joe L. Posted July 11, 2008 Share Posted July 11, 2008 Try this version. Note: I moved the login/ID needed for some smtp providers to near the top of the script. Leave them blank if your smtp host does not require a LOGIN/PASSWORD I suspect the problems you were having were because of strange characters in the output of /proc/mdcmd . I now use its output in a temp file filtered by "strings" to deal with the printable strings only. I also now use the "todos" program to deal with LF vs. CR/LF. Let me know if it works better. Joe L. #!/bin/bash # # Title: smtp_check_status.sh # # Summary: # The purpose of this script is to check the status of the unRAID # array by searching the /proc/mdcmd file for known bad states. # This script was originally created by Joe. L for use with Yak # and has been modified by kenshin (twelston) on 08-17-2007 to add smtp # functionality, and increase the information transmitted by the script # (i.e. adding ip, date, and the output of the /proc/mdcmd file if # elected by the user) # # If you have any questions or problems while using this script please # post them to the unRaid forum: # # http://support.lime-technology.com/forum/ # # DISCLAIMER: # Your use of this script is at your sole risk. This script is provided # "as -is", without any warranty # # Further, the authors of this script shall not be liable for any damages # you may sustain by using this information, whether direct, indirect, # special, incidental or consequential, even if they have been advised of # the possibility of such damages. # Define the following six values to setup this script # The name of your SMTP server sSmtpServer="smtp.comcast.net" # Your domain name sDomain="www.comcast.net" # The "from" email address sMailFrom="[email protected]" # The "to" mail address (The addressess must be separated by a space, a # single address requires no spaces) sRcptTo="[email protected] [email protected] [email protected]" # The email subject sSubject="unRaid Status Notification" # Your base64 encrypted login and password, if needed by your e-mail provider. # Note: this is the ID/password needed to send mail, not the same as those to get mail. # If your provider does not need an ID/Password, leave these as empty strings "" #login="my_login" #password="my_password" login="" password="" # Choose whether to include the contents of /proc/mdcmd in your status # notifications (Setting this value to anything but "True" is the same # as setting it to "False") bIncludeMdcmd="True" # A copy of netcat (nc) is on the flash drive, add /boot/ to the PATH so it # will be found when executed. PATH=$PATH:/boot/ # initialize the error message to an empty string if no hourly OK message is desired # like this: #emsg="" emsg="unRaid is OK" # request that status be updated echo "status" >/proc/mdcmd # now check the status and report as needed P=${0##*/} # basename of program R=${0%%$P} # dirname of program P=${P%.*} # strip off after last . character export T=/tmp/${P}.$$ trap "rm -f ${T}" EXIT HUP INT QUIT strings < /proc/mdcmd > ${T} # Even if the contents of /proc/mdcmd are not normally included if all is OK, # include it if something is wrong by setting the flag to True. grep "mdState=STARTED" ${T} >/dev/null 2>&1 if [ $? != 0 ] then emsg="unRaid array not started" bIncludeMdcmd="True" fi RESYNC=`egrep "^mdResync" ${T} | cut -d "=" -f2` if [ "$RESYNC" != "0" ] then RESYNCPERCENT=`egrep "^mdResyncPrcnt" ${T} | cut -d "=" -f2` RESYNCFINISH=`egrep "^mdResyncFinish" ${T} | cut -d "=" -f2` RESYNCSPEED=`egrep "^mdResyncSpeed" ${T} | cut -d "=" -f2` NL=`echo "\n"` sSubject="unRaid Resync Notification" emsg="The unRaid array is resync/rebuilding parity.${NL}${NL}" if [ ! -z "${RESYNCPERCENT}" ] then emsg="${emsg}Parity CHECK/RESYNC in progress, " emsg="${emsg} ${RESYNCPERCENT}% complete, " emsg="${emsg} est. finish in $RESYNCFINISH minutes." emsg="${emsg} Speed: ${RESYNCSPEED} kb/s." fi bIncludeMdcmd="False" fi egrep "=DISK_INVALID|=DISK_DSBL" ${T} >/dev/null 2>&1 if [ $? = 0 ] then sSubject="*** unRaid server needs your attention. One or more disks are disabled or invalid. ****" emsg="The unRaid array needs attention. One or more disks are disabled or invalid." bIncludeMdcmd="True" fi # if an error message was set, broadcast it to all the email addresses # in the notify list if [ "$emsg" != "" ] then # look up the ip address given the machine name ip_addr=`net lookup $sSmtpServer 2>/dev/null` if [ $? = 0 ] then # Build the echo string sEcho="ehlo $sDomain\r\n" if [ "$password" != "" ] then sEcho+="auth login\r\n" sEcho+="$login\r\n" sEcho+="$password\r\n" fi sEcho+="mail from:$sMailFrom\r\n" # Add each recipient to the RCPT list for i in $sRcptTo do sEcho+="RCPT TO:"$i"\r\n" done # Message header sEcho+="data\r\nFrom:$sMailFrom\r\nTo:" # Add each recipient to the message header for i in $sRcptTo do sEcho+=$i";" done sEcho+="\r\n" # Message Subject sEcho+="Subject:$sSubject\r\n" # Message Body (You can change this to look how you want. Just # to include \r\n at the end of each line.) sEcho+="This message is a status update for unRAID $HOSTNAME\r\n" sEcho+="-----------------------------------------------------------------\r\n" sEcho+="Server Name: $HOSTNAME\r\n" sEcho+="Server IP: `net lookup $HOSTNAME 2>/dev/null`\r\n" sEcho+="Date: " sEcho+="`date 2>/dev/null`\r\n" sEcho+="Status: $emsg\r\n" sEcho+=`df -h | todos` sEcho+="\r\n" # Add the contents of /proc/mdcmd if elected by the user if [ "$bIncludeMdcmd" = "True" ] then sEcho+="\r\n" sEcho+="Output of /proc/mdcmd:\r\n" sEcho+="-----------------------------------------------------------------\r\n" # Add <CRLF> to each line sEcho+=`todos <${T}` sEcho+="\r\n" fi # End the message sEcho+=".\r\n" sEcho+="QUIT\r\n" # Send the message we just built echo -e $sEcho|nc -i 1 -q 1 $ip_addr 25 # Use the following line for debug #echo -e $sEcho|nc -w 1 -q 2 -i 1 -vv $ip_addr 25 fi fi Quote Link to comment
bluto Posted July 11, 2008 Share Posted July 11, 2008 Thanks for the help. It didn't solve the problem though (in my case). Here is the email text from the old script -- Output of /proc/mdcmd: ----------------------------------------------------------------- cmdOper=status cmdResult=ok sbName=/boot/config/super.dat sbVersion=0.94.0 sbCreated=1213816671 sbUpdated=1215746197 sbEvents=83 sbState=0 sbNumDisks=12 sbSynced=1214754107 sbSyncErrs=0 mdVersion=0.94.0 mdState=STARTED mdNumProtected=11 mdNumDisabled=0 mdDisabledDisk=0 mdNumInvalid=0 mdInvalidDisk=0 mdNumMissing=0 mdMissingDisk=0 mdNumNew=0 mdResync=0 diskNumber.0=0 diskName.0= diskState.0=7 diskSize.0=976762552 diskModel.0=MAXTOR STM310003 diskSerial.0=9QJ0G5RG diskNumReads.0=112 diskNumWrites.0=124 diskNumErrors.0=0 diskId.0=MAXTOR STM310003 / 9QJ0G5RG rdevNumber.0=0 rdevStatus.0=DISK_OK rdevName.0=sdh rdevType.0=SATA rdevSize.0=976762552 rdevModel.0=MAXTOR STM310003 rdevSerial.0=9QJ0G5RG rdevId.0=MAXTOR STM310003 / 9QJ0G5RG diskNumber.1=1 diskName.1=md1 diskState.1=7 diskSize.1=976762552 diskModel.1=WDC WD10EACS-00D diskSerial.1=WD-WCAU40229133 diskNumReads.1=82350 diskNumWrites.1=8 diskNumErrors.1=0nd diskId.1=WDC WD10EACS-00D / WD-WCAU40229133 rdevNumber.1=1 rdevStatus.1=DISK_OK rdevName.1=sdj rdevType.1=SATA rdevSize.1=976762552 rdevModel.1=WDC WD10EACS-00D rdevSerial.1=WD-WCAU40229133 rdevId.1=WDC WD10EACS-00D / WD-WCAU40229133 and here is the output from your new script -- Output of /proc/mdcmd: ----------------------------------------------------------------- cmdOper=status cmdResult=ok sbName=/boot/config/super.dat sbVersion=0.94.0 sbCreated=1213816671 sbUpdated=1215797989 sbEvents=85 sbState=0 sbNumDisks=12 sbSynced=1214754107 sbSyncErrs=0 mdVersion=0.94.0 mdState=STARTED mdNumProtected=11 mdNumDisabled=0 mdDisabledDisk=0 mdNumInvalid=0 mdInvalidDisk=0 mdNumMissing=0 mdMissingDisk=0 mdNumNew=0 mdResync=0 diskNumber.0=0 diskName.0= diskState.0=7 diskSize.0=976762552 diskModel.0=MAXTOR STM310003 diskSerial.0=9QJ0G5RG diskNumReads.0=62 diskNumWrites.0=73 diskNumErrors.0=0 diskId.0=MAXTOR STM310003 / 9QJ0G5RG rdevNumber.0=0 rdevStatus.0=DISK_OK rdevName.0=sdh rdevType.0=SATA rdevSize.0=976762552 rdevModel.0=MAXTOR STM310003 rdevSerial.0=9QJ0G5RG rdevId.0=MAXTOR STM310003 / 9QJ0G5RG diskNumber.1=1 Same info - not as much for formatting (I personally do not care about the formating of this section) for the /proc/mdcmd/ section. Thanks for the help so far, any other ideas? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.