[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A proposed patch
From: |
Sami J. Mäkinen |
Subject: |
A proposed patch |
Date: |
Fri, 20 Aug 2004 18:21:14 +0300 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 |
Hello all.
I am suggesting that the cfagent log files generated by cfexecd
should be named slightly differently. If the directory
/var/cfengine/outputs/ is rather crowded, it would be nice
to have them sorted chronologically by ls, wouldn't it?
This means that filenames like
cf_niitti_almamedia_fi_Fri_Aug_20_18_00_00_2004_
would look like:
cf_niitti_almamedia_fi_20040820-180353
I found this easier to read, too. :)
My patch to cfexecd.c is attached.
I guess this _may_ break something,
so the filename format might be a configurable option
with the old naming convention as a default.
I don't think that would be necessary, though.
Any comments are appreciated.
-sjm
*** cfexecd.c.orig 2004-08-20 17:43:34.000000000 +0300
--- cfexecd.c 2004-08-20 17:51:30.000000000 +0300
***************
*** 545,550 ****
--- 545,567 ----
/**************************************************************/
+ static char *timestamp(time_t stamp, char *buf, size_t len)
+ {
+ struct tm *ltime;
+
+ ltime = localtime(&stamp);
+ snprintf(buf, len, "%04d%02d%02d-%02d%02d%02d",
+ ltime->tm_year+1900,
+ ltime->tm_mon+1,
+ ltime->tm_mday,
+ ltime->tm_hour,
+ ltime->tm_min,
+ ltime->tm_sec);
+ return buf;
+ }
+
+ /**************************************************************/
+
void *LocalExec(void *dummy)
{ FILE *pp;
***************
*** 575,584 ****
{
snprintf(cmd,CF_BUFSIZE-1,"%s/bin/cfagent",WORKDIR);
}
-
- snprintf(line,100,CanonifyName(ctime(&starttime)));
-
snprintf(filename,CF_BUFSIZE-1,"%s/outputs/cf_%s_%s",WORKDIR,CanonifyName(VFQNAME),line);
/* What if no more processes? Could sacrifice and exec() - but we need a
sentinel */
--- 592,602 ----
{
snprintf(cmd,CF_BUFSIZE-1,"%s/bin/cfagent",WORKDIR);
}
+ /* snprintf(line, CF_BUFSIZE-1, CanonifyName(ctime(&starttime))); */
+ timestamp(starttime, line, CF_BUFSIZE);
+ snprintf(filename, CF_BUFSIZE-1, "%s/outputs/cf_%s_%s",
+ WORKDIR, CanonifyName(VFQNAME), line);
/* What if no more processes? Could sacrifice and exec() - but we need a
sentinel */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- A proposed patch,
Sami J. Mäkinen <=