Skip to content
Snippets Groups Projects
Commit dbef5df1 authored by ballen4705's avatar ballen4705
Browse files

Added domainname to contents of error message from smartd.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@378 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 68532044
No related branches found
No related tags found
No related merge requests found
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.
......
......@@ -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);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment