[Sysfence-commit] sysfence Makefile,1.25,1.26 datastruct.c,1.11,1.12 getstats.c,1.20,1.21 mainloop.c
Status: Alpha
Brought to you by:
emes
|
From: Michal S. <em...@us...> - 2004-06-05 12:49:50
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17425 Modified Files: Makefile datastruct.c getstats.c mainloop.c sysfence.c Log Message: * bugfixes. nproc seems to be working Index: getstats.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/getstats.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- getstats.c 4 Jun 2004 13:07:03 -0000 1.20 +++ getstats.c 5 Jun 2004 12:49:40 -0000 1.21 @@ -142,7 +142,7 @@ db->load[2] = atof (three); #ifdef DEBUG - printf ("fetch_la(): la1=%0.2f la5=%0.2f la15=%0.2f\n", + syslog (LOG_DEBUG, "fetch_la(): la1=%0.2f la5=%0.2f la15=%0.2f\n", db->load[0], db->load[1], db->load[2]); #endif } @@ -196,7 +196,7 @@ db->mem[VA_AVAIL] = db->mem[VA_FREE]; #ifdef DEBUG - printf ("fetch_mem(): memfree=%d memused=%d swapfree=%d swapused=%d\n", + syslog (LOG_DEBUG, "fetch_mem(): memfree=%llu memused=%llu swapfree=%llu swapused=%llu\n", db->mem[VA_FREE], db->mem[VA_USED], db->swap[VA_FREE], Index: Makefile =================================================================== RCS file: /cvsroot/sysfence/sysfence/Makefile,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Makefile 5 Jun 2004 10:40:14 -0000 1.25 +++ Makefile 5 Jun 2004 12:49:40 -0000 1.26 @@ -28,11 +28,22 @@ $(CC) -ggdb -o sysfence ${objects} ${parseopt} ${sys} debug: + $(CC) -DDEBUG -c conditions.c -o conditions.o + $(CC) -DDEBUG -c getstats.c -o getstats.o + $(CC) -DDEBUG -c datastruct.c -o datastruct.o + make -C parseopt/ debug + make -C sys/ debug + $(CC) -DDEBUG -c mainloop.c -o mainloop.o + $(CC) -DDEBUG -c cp2memory.c -o cp2memory.o + $(CC) -DDEBUG -c sysfence.c -o sysfence.o + $(CC) -o sysfence ${objects} ${parseopt} ${sys} + +debugdb: $(CC) -DDEBUG -ggdb -c conditions.c -o conditions.o $(CC) -DDEBUG -ggdb -c getstats.c -o getstats.o $(CC) -DDEBUG -ggdb -c datastruct.c -o datastruct.o - make -C parseopt/ debug - make -C sys/ debug + make -C parseopt/ debugdb + make -C sys/ debugdb $(CC) -DDEBUG -ggdb -c mainloop.c -o mainloop.o $(CC) -DDEBUG -ggdb -c cp2memory.c -o cp2memory.o $(CC) -DDEBUG -ggdb -c sysfence.c -o sysfence.o Index: datastruct.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/datastruct.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- datastruct.c 5 Jun 2004 10:46:29 -0000 1.11 +++ datastruct.c 5 Jun 2004 12:49:40 -0000 1.12 @@ -18,6 +18,7 @@ #include <stdlib.h> #include <string.h> #include "sys/xalloc.h" +#include "sys/users.h" #include "parseopt/lex.h" #include "datastruct.h" #ifdef DEBUG @@ -129,15 +130,11 @@ * used to register new paths while parsing config file */ sf_list *l = *hd; - sf_fs_stat *e; + sf_fs_stat *e; #ifdef DEBUG - if (!hd) - syslog (LOG_DEBUG, "add_fs_entry_to_list(NULL, %s)", path); - else if (! l) - syslog (LOG_DEBUG, "add_fs_entry_to_list(%x -> NULL, %s)", hd, path); - else - syslog (LOG_DEBUG, "add_fs_entry_to_list(%x -> %x, %s)", hd, l, path); + if (! l) + syslog (LOG_DEBUG, "add_fs_entry_to_list: %s", path); #endif if (! l) { @@ -157,9 +154,6 @@ e = (sf_fs_stat *) l->el; /* do not insert duplicates */ -#ifdef DEBUG - syslog (LOG_DEBUG, "? %s == %s : %d", e->path, path, strcmp (e->path, path)); -#endif if (strcmp (e->path, path) == 0) return; add_fs_entry_to_list (&(l->next), path); @@ -170,17 +164,10 @@ /* finds an entry in list of paths being watched */ sf_fs_stat *st; -#ifdef DEBUG - syslog (LOG_DEBUG, "get_fs_entry_from_list(%x, %s)", hd, path); -#endif - // not found if (! hd) return NULL; st = (sf_fs_stat *) hd->el; -#ifdef DEBUG - syslog (LOG_DEBUG, " +-- list element: %s)", st->path); -#endif if (strcmp (st->path, path) == 0) return st; else return get_fs_entry_from_list (hd->next, path); } @@ -191,7 +178,7 @@ #ifdef DEBUG syslog (LOG_DEBUG, - "checking [%s] == [%s]", + "equal_defs [%s] == [%s]", def_2_string (d1), def_2_string (d2) ); @@ -270,7 +257,7 @@ case ST_PROC: snprintf (buf, STRBUF, - "nproc (uid(s): %s) (state: %d)", + "nproc %sstate: %d", uids_2_str (def->arg[0].uids), def->arg[1].procstates ); @@ -283,17 +270,30 @@ char * uids_2_str (sf_list *hd) { + uid_t uid; char *buf = (char *) xalloc (NULL, STRBUF + 1), - *buf2; + *buf2, + *uname; *buf = '\0'; if (hd) { + uid = *((uid_t *) (hd->el)); buf2 = uids_2_str (hd->next); + + /* try to get username */ + uname = uid2username (uid); + if (!uname) { + /* no username? print UID */ + uname = (char *) xalloc (NULL, STRBUF + 1); + snprintf (uname, STRBUF, "%d", uid); + } + if (*buf2) - snprintf (buf, STRBUF, "%d,%s", *((uid_t *) (hd->el)), buf2); + snprintf (buf, STRBUF, "%s,%s", uname, buf2); else - snprintf (buf, STRBUF, "%d", *((uid_t *) (hd->el))); + snprintf (buf, STRBUF, "%s ", uname); free (buf2); } return buf; } + Index: mainloop.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/mainloop.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- mainloop.c 4 Jun 2004 13:07:03 -0000 1.16 +++ mainloop.c 5 Jun 2004 12:49:40 -0000 1.17 @@ -26,6 +26,9 @@ #include "mainloop.h" #include "sys/processtitle.h" #include "sys/sighandlers.h" +#ifdef DEBUG +#include <syslog.h> +#endif int step = 10; @@ -43,9 +46,6 @@ signals_handling (SIGUNBLOCK); if (rule->hit) { -#ifdef DEBUG - printf ("Rule @%x hit.\n", (int) rule); -#endif /* first - log if neccessary */ if (rule->log != NULL) { if (! (rule->log->once && rule->prevhit)) { @@ -54,9 +54,6 @@ log_rulehit (rule); semaphore_post (semid); signals_handling (SIGUNBLOCK); -#ifdef DEBUG - printf ("rule logged\n"); -#endif } } @@ -66,14 +63,11 @@ setproctitle (RULE_PROCESS, STATE_EXEC, rule->name); system (rule->run->command); setproctitle (RULE_PROCESS, STATE_NORMAL, rule->name); -#ifdef DEBUG - printf ("executed '%s'\n", rule->run->command); -#endif } } } else { #ifdef DEBUG - printf ("Rule @%x NOT hit.\n", (int) rule); + syslog (LOG_DEBUG, "Rule @%x NOT hit.\n", (int) rule); #endif } Index: sysfence.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/sysfence.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- sysfence.c 4 Jun 2004 13:07:03 -0000 1.26 +++ sysfence.c 5 Jun 2004 12:49:40 -0000 1.27 @@ -55,10 +55,6 @@ int pid; -#ifdef DEBUG - sf_rule *rl; -#endif - if (argc < 2) bail_out (EXIT_NOCONF, NULL); log_start (); @@ -72,7 +68,9 @@ /* count rules */ rulecount = 0; - while (*(ruletab + rulecount) != NULL) rulecount ++; + while (*(ruletab + rulecount) != NULL) { + rulecount ++; + } syslog (LOG_INFO, "loaded %d rules", rulecount); /* open files for reading data and detach from console */ |