diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index 4ee3216ad1d28c9223b7a5c4817fbd4af2bcb74b..cc87a8f576073a2b225b24ffb36e83d2a0212e24 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.69 2002/12/12 13:42:59 ballen4705 Exp $ +$Id: CHANGELOG,v 1.70 2002/12/16 12:27:00 ballen4705 Exp $ Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> @@ -32,6 +32,10 @@ NOTES FOR FUTURE RELEASES: see TODO file. CURRENT RELEASE (see VERSION file in this directory): + ]BA] Use strerror() to generate system call error messages. + + [BA] smartd: fflush() all open streams before fork(). + [BA] smartctl, smartd simplified internal handling of checksums for simpler porting and less code. diff --git a/sm5/smartd.c b/sm5/smartd.c index 3d3a56df42406dbd7268c15329a13e1ff0911062..eb66adf5d9e6e1d576d646d0ae8d8a9e961f04bf 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -50,7 +50,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.c,v 1.87 2002/12/15 21:08:23 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.c,v 1.88 2002/12/16 12:27:00 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -111,7 +111,8 @@ void printout(int priority,char *fmt, ...){ // If address is null, this just prints a warning message. But if // address is non-null then send and log a warning email. void printandmail(cfgfile *cfg, int which, int priority, char *fmt, ...){ - char command[2048], message[256], hostname[256], additional[256], original[256], further[256]; + char command[2048], message[256], hostname[256], additional[256]; + char original[256], further[256], domainname[256]; int status; time_t epoch; va_list ap; @@ -154,11 +155,15 @@ void printandmail(cfgfile *cfg, int which, int priority, char *fmt, ...){ mail->firstsent=epoch; mail->lastsent=epoch; - // get system host name (not null terminated if length=MAX) + // get system host & domain names (not null terminated if length=MAX) if (gethostname(hostname, 256)) sprintf(hostname,"Unknown host"); else hostname[255]='\0'; + if (getdomainname(domainname, 256)) + sprintf(hostname,"Unknown domain"); + else + domainname[255]='\0'; // print warning string into message va_start(ap, fmt); @@ -190,14 +195,14 @@ void printandmail(cfgfile *cfg, int which, int priority, char *fmt, ...){ // now construct a command to send this as EMAIL snprintf(command, 2048, "mail -s 'SMART errors detected on host: %s' %s > /dev/null 2> /dev/null << \"ENDMAIL\"\n" "This email was generated by the smartd daemon running on host:\n" - "%s\n\n" + "%s in domain: %s\n\n" "The following warning/error was logged by the smartd daemon:\n" "%s\n" "For further details see the syslog (/var/log/messages) on host:\n" "%s\n\n" "%s%s%s" "ENDMAIL\n", - hostname, address, hostname, message, hostname, further, original, additional); + hostname, address, hostname, domainname, message, hostname, further, original, additional); // issue the command to send email status=system(command); diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index da8c47940f5074cb3da22d184d93d4638ae12184..72dafec7c273d2bf4cde9c42cab7de102ff1e3aa 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -50,7 +50,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.cpp,v 1.87 2002/12/15 21:08:23 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.cpp,v 1.88 2002/12/16 12:27:00 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -111,7 +111,8 @@ void printout(int priority,char *fmt, ...){ // If address is null, this just prints a warning message. But if // address is non-null then send and log a warning email. void printandmail(cfgfile *cfg, int which, int priority, char *fmt, ...){ - char command[2048], message[256], hostname[256], additional[256], original[256], further[256]; + char command[2048], message[256], hostname[256], additional[256]; + char original[256], further[256], domainname[256]; int status; time_t epoch; va_list ap; @@ -154,11 +155,15 @@ void printandmail(cfgfile *cfg, int which, int priority, char *fmt, ...){ mail->firstsent=epoch; mail->lastsent=epoch; - // get system host name (not null terminated if length=MAX) + // get system host & domain names (not null terminated if length=MAX) if (gethostname(hostname, 256)) sprintf(hostname,"Unknown host"); else hostname[255]='\0'; + if (getdomainname(domainname, 256)) + sprintf(hostname,"Unknown domain"); + else + domainname[255]='\0'; // print warning string into message va_start(ap, fmt); @@ -190,14 +195,14 @@ void printandmail(cfgfile *cfg, int which, int priority, char *fmt, ...){ // now construct a command to send this as EMAIL snprintf(command, 2048, "mail -s 'SMART errors detected on host: %s' %s > /dev/null 2> /dev/null << \"ENDMAIL\"\n" "This email was generated by the smartd daemon running on host:\n" - "%s\n\n" + "%s in domain: %s\n\n" "The following warning/error was logged by the smartd daemon:\n" "%s\n" "For further details see the syslog (/var/log/messages) on host:\n" "%s\n\n" "%s%s%s" "ENDMAIL\n", - hostname, address, hostname, message, hostname, further, original, additional); + hostname, address, hostname, domainname, message, hostname, further, original, additional); // issue the command to send email status=system(command);