diff options
Diffstat (limited to 'lib/Plugins/KerneloopsScanner.cpp')
-rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index fdcc3e5..b3fe1ec 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -50,7 +50,7 @@ static int scan_dmesg(vector_string_t& oopsList) /* "dumpoops" tool uses these two functions too */ extern "C" { -int scan_syslog_file(vector_string_t& oopsList, const char *filename) +int scan_syslog_file(vector_string_t& oopsList, const char *filename, time_t *last_changed_p) { VERB1 log("Scanning syslog file '%s'", filename); @@ -59,7 +59,6 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename) int fd; int cnt_FoundOopses; ssize_t sz; - fd = open(filename, O_RDONLY); if (fd < 0) return 0; @@ -69,6 +68,15 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename) return 0; } + if (last_changed_p != NULL) { + if (*last_changed_p == statb.st_mtime) { + VERB1 log("Syslog file '%s' hasn't changed since last scan, skipping", filename); + close(fd); + return 0; + } + *last_changed_p = statb.st_mtime; + } + /* * In theory we have a race here, since someone could spew * to /var/log/messages before we read it in... we try to @@ -137,6 +145,7 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList) CKerneloopsScanner::CKerneloopsScanner() { int cnt_FoundOopses; + m_syslog_last_change = 0; /* Scan dmesg, on first call only */ vector_string_t oopsList; @@ -155,7 +164,7 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs, int forc } vector_string_t oopsList; - int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file); + int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file, &m_syslog_last_change); if (cnt_FoundOopses > 0) { save_oops_to_debug_dump(oopsList); /* |