diff --git a/sm5/TODO b/sm5/TODO index 4ad6eeae9b7bd5e1580d18fe5c2fe8c822ab7bbb..dc0bdf1d9269f3a9bad7580a498a20c57ac905a9 100644 --- a/sm5/TODO +++ b/sm5/TODO @@ -4,7 +4,7 @@ Home page of code is: http://smartmontools.sourceforge.net Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> -$Id: TODO,v 1.16 2002/10/26 09:24:26 ballen4705 Exp $ +$Id: TODO,v 1.17 2002/10/29 13:38:49 ballen4705 Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -34,27 +34,12 @@ Produce version for ATA/ATAPI-7 Modifications ------------- +smartctl: + Handle extended error and self-test logs gracefully. Can someone tell me a disk that supports more than log pages 1 and 6? I need to get a disk so I can test this functionality, when I add it. -Change smartd so that it also monitors usage as well as prefail -attributes for failure or changes. Make this a command line option - -Perhaps change smartd to look in /proc/ide and /proc/scsi to see what -exists? If something doesn't exit then don't try to open it? - -Currently smartd looks at attribute values and thresholds, then prints -out if there is an error condition. Make it also look at the smart -status, if that is enabled and working and do that test as well. -Perhaps also see if the number of device errors has changed. - -Add optional flags to /etc/smartd.conf, so that certain attributes are -ignored, or so that all usage attributes are ignored. - -Change smartd so that it monitors the ATA disk error log, and if the -number of errors changes, log an entry.. - Perhaps modify the -q option (quiet mode) so that it only warns of ATA errors if they have (say) taken place in the last 168 hours (week). @@ -65,10 +50,19 @@ helpful in adding device specific options. Parse and print more attribute flag meanings (IBM ones, eg performance etc). -Fixes ------ +smartd: + +Perhaps change smartd to look in /proc/ide and /proc/scsi to see what +exists? If something doesn't exit then don't try to open it? This +should probably be the default option if there is no configuration +file. + + + +General Fixes +------------- Fix lots of syntax like if (a != 0) Pass pointer to big structures like "device" and smartval, not the -whole 2kB of data! +whole 2kB of data! I've started doing this but haven't finished yet. diff --git a/sm5/VERSION b/sm5/VERSION index 3c032078a4a21c5c51d3c93d91717c1dabbb8cd0..d6b24041cf04154f8f902651969675021f4d93a5 100644 --- a/sm5/VERSION +++ b/sm5/VERSION @@ -1 +1 @@ -18 +19 diff --git a/sm5/smartd.c b/sm5/smartd.c index 0e42d282e5607782c81b22089a26e1f08f0811a0..7184e94e16e8673af5ea92267bd5895710920cba 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -43,7 +43,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.c,v 1.39 2002/10/29 10:06:20 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.c,v 1.40 2002/10/29 13:38:49 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -76,12 +76,12 @@ void pout(char *fmt, ...){ return; } -void goobye(){ - printout(LOG_CRIT,"smartd is exiting\n"); +// tell user that we ignore HUP signals +void huphandler(int sig){ + printout(LOG_CRIT,"HUP ignored. smartd does NOT re-read /etc/smartd.conf.\n"); return; } -volatile sig_atomic_t fatal = 0; // simple signal handler to print goodby message to syslog void sighandler(int sig){ printout(LOG_CRIT,"smartd received signal %d: %s\n", @@ -89,6 +89,10 @@ void sighandler(int sig){ exit(1); } +void goobye(){ + printout(LOG_CRIT,"smartd is exiting\n"); + return; +} // Forks new process, closes all file descriptors, redirects stdin, // stdout, stderr @@ -249,6 +253,7 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ printout(LOG_INFO,"Device: %s, opened\n", device); // Get drive identity structure + // May want to add options to enable autosave, automatic online testing if (ataReadHDIdentity (fd,&drive) || !ataSmartSupport(drive) || ataEnableSmart(fd)){ // device exists, but not able to do SMART printout(LOG_INFO,"Device: %s, not SMART capable, or couldn't enable SMART\n",device); @@ -277,6 +282,10 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ printout(LOG_INFO,"Device: %s, Read SMART Values and/or Thresholds Failed\n",device); free(devices->smartval); free(devices->smartthres); + + // make it easy to recognize that we've deallocated + devices->smartval=NULL; + devices->smartthres=NULL; cfg->usagefailed=cfg->prefail=cfg->usage=0; } } @@ -820,14 +829,15 @@ int parseconfigline(int entry, int lineno,char *line){ #endif } - // basic sanity check -- are any options turned on? - if (!(cfg->smartcheck || cfg->usagefailed || cfg->prefail || cfg->usage || cfg->selftest || cfg->errorlog || cfg->tryscsi)){ + // basic sanity check -- are any directives enabled? + if (!(cfg->smartcheck || cfg->usagefailed || cfg->prefail || cfg->usage || + cfg->selftest || cfg->errorlog || cfg->tryscsi)){ printout(LOG_CRIT,"Drive: %s, no monitoring Directives on line %d of file %s\n", cfg->name, cfg->lineno, CONFIGFILE); Directives(); exit(1); } - + entry++; free(copy); return 1; @@ -1077,6 +1087,7 @@ int main (int argc, char **argv){ con->quietmode=0; con->veryquietmode=debugmode?0:1; + // look in configuration file CONFIGFILE (normally /etc/smartd.conf) entries=parseconfigfile(); @@ -1092,6 +1103,9 @@ int main (int argc, char **argv){ signal(SIGTERM, SIG_IGN); if (signal(SIGQUIT, sighandler)==SIG_IGN) signal(SIGQUIT, SIG_IGN); + if (signal(SIGHUP, huphandler)==SIG_IGN) + signal(SIGHUP, SIG_IGN); + // install goobye message atexit(goobye); diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index f0e6fe996490971e85ffb1bd2b7b68aa327cbba6..f6d4b80761e9a1ebc9fc356c582b94a4916cad6e 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -43,7 +43,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.cpp,v 1.39 2002/10/29 10:06:20 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.cpp,v 1.40 2002/10/29 13:38:49 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -76,12 +76,12 @@ void pout(char *fmt, ...){ return; } -void goobye(){ - printout(LOG_CRIT,"smartd is exiting\n"); +// tell user that we ignore HUP signals +void huphandler(int sig){ + printout(LOG_CRIT,"HUP ignored. smartd does NOT re-read /etc/smartd.conf.\n"); return; } -volatile sig_atomic_t fatal = 0; // simple signal handler to print goodby message to syslog void sighandler(int sig){ printout(LOG_CRIT,"smartd received signal %d: %s\n", @@ -89,6 +89,10 @@ void sighandler(int sig){ exit(1); } +void goobye(){ + printout(LOG_CRIT,"smartd is exiting\n"); + return; +} // Forks new process, closes all file descriptors, redirects stdin, // stdout, stderr @@ -249,6 +253,7 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ printout(LOG_INFO,"Device: %s, opened\n", device); // Get drive identity structure + // May want to add options to enable autosave, automatic online testing if (ataReadHDIdentity (fd,&drive) || !ataSmartSupport(drive) || ataEnableSmart(fd)){ // device exists, but not able to do SMART printout(LOG_INFO,"Device: %s, not SMART capable, or couldn't enable SMART\n",device); @@ -277,6 +282,10 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){ printout(LOG_INFO,"Device: %s, Read SMART Values and/or Thresholds Failed\n",device); free(devices->smartval); free(devices->smartthres); + + // make it easy to recognize that we've deallocated + devices->smartval=NULL; + devices->smartthres=NULL; cfg->usagefailed=cfg->prefail=cfg->usage=0; } } @@ -820,14 +829,15 @@ int parseconfigline(int entry, int lineno,char *line){ #endif } - // basic sanity check -- are any options turned on? - if (!(cfg->smartcheck || cfg->usagefailed || cfg->prefail || cfg->usage || cfg->selftest || cfg->errorlog || cfg->tryscsi)){ + // basic sanity check -- are any directives enabled? + if (!(cfg->smartcheck || cfg->usagefailed || cfg->prefail || cfg->usage || + cfg->selftest || cfg->errorlog || cfg->tryscsi)){ printout(LOG_CRIT,"Drive: %s, no monitoring Directives on line %d of file %s\n", cfg->name, cfg->lineno, CONFIGFILE); Directives(); exit(1); } - + entry++; free(copy); return 1; @@ -1077,6 +1087,7 @@ int main (int argc, char **argv){ con->quietmode=0; con->veryquietmode=debugmode?0:1; + // look in configuration file CONFIGFILE (normally /etc/smartd.conf) entries=parseconfigfile(); @@ -1092,6 +1103,9 @@ int main (int argc, char **argv){ signal(SIGTERM, SIG_IGN); if (signal(SIGQUIT, sighandler)==SIG_IGN) signal(SIGQUIT, SIG_IGN); + if (signal(SIGHUP, huphandler)==SIG_IGN) + signal(SIGHUP, SIG_IGN); + // install goobye message atexit(goobye);