From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 8 Nov 2006 20:14:21 -0000 Subject: [Cluster-devel] conga/ricci/modules/log LogParser.cpp Message-ID: <20061108201421.5922.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2006-11-08 20:14:21 Modified files: ricci/modules/log: LogParser.cpp Log message: make the log module ignore files whose mtime is older than current time minus max age Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/LogParser.cpp.diff?cvsroot=cluster&r1=1.7&r2=1.8 --- conga/ricci/modules/log/LogParser.cpp 2006/10/23 18:43:35 1.7 +++ conga/ricci/modules/log/LogParser.cpp 2006/11/08 20:14:21 1.8 @@ -165,7 +165,8 @@ set& get_files(const String& path_, - set& files) + set& files, + time_t age_time) { String path = utils::rstrip(utils::strip(path_), "/"); if (path.empty() || path.find_first_of(" ; & $ ` ? > < ' \" ; | \\ * \n \t") != path.npos) @@ -178,11 +179,12 @@ // throw String("unable to stat ") + path; return files; if (S_ISREG(st.st_mode)) { - files.insert(path); + if (st.st_mtime >= age_time) + files.insert(path); // get rotated logs for (int i=0; i<25; i++) - get_files(path + "." + utils::to_string(i), files); + get_files(path + "." + utils::to_string(i), files, age_time); return files; } else if (S_ISDIR(st.st_mode)) @@ -204,7 +206,7 @@ if (kid_path == "." || kid_path == "..") continue; kid_path = path + "/" + kid_path; - get_files(kid_path, files); + get_files(kid_path, files, age_time); } } catch ( ... ) { closedir(d); @@ -366,6 +368,13 @@ const list& paths) { set ret; + time_t age_time = time(NULL); + + if ((long long) age_time - age < 0) + age_time = 0; + else + age_time -= age; + // set of requested tags set req_tags(domains.begin(), domains.end()); @@ -375,10 +384,10 @@ for (list::const_iterator iter = paths.begin(); iter != paths.end(); iter++) - get_files(*iter, files); + get_files(*iter, files, age_time); if (files.empty()) { - get_files("/var/log/messages", files); - get_files("/var/log/syslog", files); + get_files("/var/log/messages", files, age_time); + get_files("/var/log/syslog", files, age_time); } // process log files