sysfence-commit Mailing List for sysfence (Page 6)
Status: Alpha
Brought to you by:
emes
You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
(2) |
Apr
(3) |
May
(99) |
Jun
(45) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: mkoperto <mko...@us...> - 2004-05-22 16:47:02
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24744 Modified Files: communication.c Log Message: change: key -> IPC_PRIVATE for IPC resources Index: communication.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/communication.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- communication.c 20 May 2004 14:50:47 -0000 1.1 +++ communication.c 22 May 2004 16:46:51 -0000 1.2 @@ -39,16 +39,12 @@ int semaphore_init (int val) { - key_t key; int semid; union semun argument; unsigned short values[1]; - /* semaphore unique key */ - key = ftok (".", 's'); - /* create semaphore */ - semid = semget (key, 1, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); + semid = semget (IPC_PRIVATE, 1, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); values[0] = val; argument.array = values; @@ -68,14 +64,8 @@ int shared_mem_init (int memsize) { - key_t key; - - /* shared memory unique key */ - key = ftok (".", 'm'); - /* allocate shared memory */ - return shmget (key, memsize, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); - + return shmget (IPC_PRIVATE, memsize, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); } void *shared_mem_attach (int shmid) |
|
From: mkoperto <mko...@us...> - 2004-05-22 16:45:18
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24339 Modified Files: sysfence.c Log Message: goes to backgroud... Index: sysfence.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/sysfence.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- sysfence.c 20 May 2004 16:17:34 -0000 1.14 +++ sysfence.c 22 May 2004 16:45:08 -0000 1.15 @@ -125,7 +125,7 @@ /* open files for reading data and detach from console */ open_files (); - //if (daemon (0, 0) != 0) bail_out (EXIT_IO, "daemon()"); + if (daemon (0, 0) != 0) bail_out (EXIT_IO, "daemon()"); /* initialize semaphore */ semid = semaphore_init (SEMAPHORE_SET); @@ -172,10 +172,7 @@ /* one child process one ruleset */ rule_watch_loop (*(ruleshm + i)); } else /* parent */ - { - /* go background */ - daemon (1,0); - + { /* start handling signals */ signal_init (); |
|
From: Michal S. <em...@us...> - 2004-05-20 16:17:50
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11335 Modified Files: sysfence.c Log Message: + parent process goes to background Index: sysfence.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/sysfence.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- sysfence.c 20 May 2004 14:29:28 -0000 1.13 +++ sysfence.c 20 May 2004 16:17:34 -0000 1.14 @@ -173,6 +173,9 @@ rule_watch_loop (*(ruleshm + i)); } else /* parent */ { + /* go background */ + daemon (1,0); + /* start handling signals */ signal_init (); |
|
From: Michal S. <em...@us...> - 2004-05-20 15:57:24
|
Update of /cvsroot/sysfence/sysfence/parseopt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6896 Modified Files: parse.c Log Message: * automatic substitution sucks ;) Index: parse.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/parseopt/parse.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- parse.c 10 May 2004 13:57:52 -0000 1.11 +++ parse.c 20 May 2004 15:57:09 -0000 1.12 @@ -18,7 +18,7 @@ #include "../exit.h" #include "../xalloc.h" #include "../getstats.h" -#include "../expressions.h" +#include "../conditions.h" #include "parse.h" #include <stdio.h> #include <stdlib.h> |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:51:01
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26068 Added Files: communication.c Log Message: IPC communication --- NEW FILE: communication.c --- /* copyright (c) 2004, Mirek Kopertowski <m.k...@po...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation (see file COPYING for details). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/types.h> union semun { int val; struct semid_ds *buf; unsigned short int *array; struct seminfo *__buf; }; int semaphore_op (int semid, int sem_op) { static struct sembuf operation[1]; operation[0].sem_num = 0; operation[0].sem_op = sem_op; operation[0].sem_flg = SEM_UNDO; return semop (semid, operation, 1); } int semaphore_init (int val) { key_t key; int semid; union semun argument; unsigned short values[1]; /* semaphore unique key */ key = ftok (".", 's'); /* create semaphore */ semid = semget (key, 1, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); values[0] = val; argument.array = values; /* set semaphore value */ semctl (semid, 0, SETALL, argument); return semid; } int semaphore_del (int semid) { union semun ignored_argument; /* delete semaphore - last process */ return semctl (semid, 1, IPC_RMID, ignored_argument); } int shared_mem_init (int memsize) { key_t key; /* shared memory unique key */ key = ftok (".", 'm'); /* allocate shared memory */ return shmget (key, memsize, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); } void *shared_mem_attach (int shmid) { return shmat (shmid, NULL, 0); } void shared_mem_detach (void *shm) { shmdt (shm); } void shared_mem_del (int shmid) { shmctl (shmid, IPC_RMID, NULL); } |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:50:07
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25747 Added Files: communication.h Log Message: IPC communication: shared memory, semaphore --- NEW FILE: communication.h --- /* copyright (c) 2004, Mirek Kopertowski <m.k...@po...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation (see file COPYING for details). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define SEMAPHORE_SET 1 #define SEMAPHORE_RESET 0 int semaphore_init (int val); int semaphore_op (int semid, int sem_op); int semaphore_del (int semid); #define semaphore_wait(S) semaphore_op (S, -1) #define semaphore_post(S) semaphore_op (S, 1) int shared_mem_init (int memsize); void *shared_mem_attach (int shmid); void shared_mem_detach (void *shm); void shared_mem_del (int shmid); |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:49:08
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25563 Added Files: cp2memory.h Log Message: copy rule to memory buffer --- NEW FILE: cp2memory.h --- /* copyright (c) 2004, Mirek Kopertowski <m.k...@po...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation (see file COPYING for details). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ int get_rule_size (ruleset *rule); void *cp_rule (void **buf, ruleset *rule); |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:48:03
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25212 Added Files: cp2memory.c Log Message: copy rule to memory bufor --- NEW FILE: cp2memory.c --- /* copyright (c) 2004, Mirek Kopertowski <m.k...@po...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation (see file COPYING for details). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <string.h> #include "parseopt/lex.h" #include "getstats.h" #include "conditions.h" int get_expression_size (expression *expr) { int size=0; atomic *a; switch (expr->type) { case ATOMIC: a = (atomic *)expr->arg1; if (a->type == DOUBLE) { size += sizeof(double); } else { size += sizeof(long int); } size += sizeof (atomic); size += sizeof (expression); return size ; case RELATION: /* copy expression */ size += get_expression_size ((expression *)expr->arg1); size += get_expression_size ((expression *)expr->arg2); size += sizeof (expression); return size; default: return 0; } } int get_rundata_size (rundata *run) { int size=0; size += sizeof (rundata); if (run->runcmd) size += (int)strlen (run->runcmd) + 1; return size; } int get_logdata_size (logdata *log) { return sizeof (logdata); } int get_rule_size (ruleset *rule) { int size=0; size += sizeof (ruleset); if (rule->name) size += (int)strlen (rule->name) + 1; /* expression size */ size += get_expression_size (rule->expr); /* rundata size */ if (rule->run) size += get_rundata_size (rule->run); /* logdata size*/ if (rule->log) size += get_logdata_size (rule->log); return size; } void *cp_expression (void **buf, expression *expr) { void *b1, *b2; atomic *a; expression *e; b1 = *buf; switch (expr->type) { case ATOMIC: /* copy thresh */ a = (atomic *)expr->arg1; if (a->type == DOUBLE) { memcpy (*buf, (void *)a->thresh, sizeof (double)); *buf += sizeof(double); } else { memcpy (*buf, (void *)a->thresh, sizeof (long int)); *buf += sizeof(long int); } /* copy atomic */ memcpy (*buf, (void *)a, sizeof(atomic)); a = (atomic *) *buf; a->thresh = b1; *buf += sizeof (atomic); /* copy expression */ memcpy (*buf, (void *)expr, sizeof(expression)); e = (expression *) *buf; e->arg1 = (void *)a; *buf += sizeof (expression); return (void *)e ; case RELATION: /* copy expression */ b1 = cp_expression (buf, (expression *)expr->arg1); b2 = cp_expression (buf, (expression *)expr->arg2); memcpy (*buf, (void *)expr, sizeof (expression)); e = (expression *) *buf; e->arg1 = b1; e->arg2 = b2; *buf += sizeof (expression); return (void *)e; default: return 0; } } void *cp_rundata (void **buf, rundata *run) { rundata *r; /* copy rundata */ memcpy (*buf, (void *)run, sizeof (rundata)); r = (rundata *) *buf; *buf += sizeof (rundata); /* copy runcmd */ if (run->runcmd) { strcpy (*buf, run->runcmd); r->runcmd = (char *) *buf; *buf += (int)strlen (run->runcmd) + 1; } return (void *)r; } void *cp_logdata (void **buf, logdata *log) { void *b; /* copy logdata */ memcpy (*buf, (void *)log, sizeof (logdata)); b = *buf; *buf += sizeof (logdata); return b; } void *cp_rule (void **buf, ruleset *rule) { ruleset *r; /* copy rule */ memcpy (*buf, (void *)rule, sizeof (ruleset)); r = (ruleset *) *buf; *buf += sizeof (ruleset); /* copy name*/ if (rule->name) { strcpy (*buf, rule->name); r->name = (char *) *buf; *buf += (int)strlen (rule->name) + 1; } /* copy expression */ r->expr = (expression *) cp_expression (buf, rule->expr); /* copy rundata */ if (r->run) r->run = (rundata *) cp_rundata (buf, rule->run); /* copy logdata */ if (r->log) r->log = (logdata *) cp_logdata (buf, rule->log); return (void *)r; } |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:46:03
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24931/sysfence Modified Files: xalloc.c Log Message: + removed compilation warning Index: xalloc.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/xalloc.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- xalloc.c 29 Mar 2004 13:47:55 -0000 1.3 +++ xalloc.c 20 May 2004 14:45:53 -0000 1.4 @@ -23,9 +23,11 @@ void *res; res = (void *) realloc (ptr, size); - if (res != NULL) return res; + if (!res) + bail_out (EXIT_MEM, NULL); + + return res; - bail_out (EXIT_MEM, NULL); } /* $Id$ */ |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:43:31
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24499 Added Files: sighandlers.c Log Message: works only for SIGTERM --- NEW FILE: sighandlers.c --- /* copyright (c) 2004, Mirek Kopertowski <m.k...@po...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation (see file COPYING for details). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <signal.h> #include <sys/types.h> #include <sys/wait.h> #include <string.h> #include "exit.h" #include "parseopt/lex.h" #include "getstats.h" #include "conditions.h" #include "mainloop.h" #include "communication.h" #include <stdlib.h> struct sigaction schildact, stermact; void schild_action (int snumber); void sterm_action (int snumber); void signal_init () { memset (&schildact, 0, sizeof(schildact)); schildact.sa_handler = &schild_action; sigaction (SIGCHLD, &schildact, NULL); memset (&stermact, 0, sizeof(stermact)); stermact.sa_handler = &sterm_action; sigaction (SIGTERM, &stermact, NULL); } /* local functions ------------------------------------------------------------*/ void schild_action (int snumber) { int exitstatus, pid, i=0; pid = (int)wait (&exitstatus); while (*(ruleprocesses + i)!=pid) i++; *(ruleprocesses + i) = 0; } void sterm_action (int snumber) { int i; /* deactive handling SIGCHLD */ memset (&schildact, 0, sizeof(schildact)); schildact.sa_handler = SIG_IGN; sigaction (SIGCHLD, &schildact, NULL); /* terminate child processes */ for (i=0; i<rulecount; i++) if (*(ruleprocesses + i)) kill ((pid_t)*(ruleprocesses + i), SIGTERM); /* detach, deallocate shared memory */ shared_mem_detach ((void *)stat); shared_mem_del (shmid); /* deallocate semaphore */ semaphore_del (semid); bail_out (EXIT_OK, NULL); } |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:42:21
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24276 Added Files: sighandlers.h Log Message: module for handling signals --- NEW FILE: sighandlers.h --- /* copyright (c) 2004, Mirek Kopertowski <m.k...@po...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation (see file COPYING for details). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void signal_init (); |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:39:53
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23552/sysfence Modified Files: mainloop.h Log Message: + add global id's for shared memory, semaphore, ruleset Index: mainloop.h =================================================================== RCS file: /cvsroot/sysfence/sysfence/mainloop.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mainloop.h 10 Feb 2004 00:41:45 -0000 1.2 +++ mainloop.h 20 May 2004 14:39:43 -0000 1.3 @@ -14,10 +14,12 @@ /* $Id$ */ -pthread_mutex_t changing_data; +int semid; +int shmid; +int *ruleprocesses; +int rulecount; void rule_watch_loop (ruleset *rule); void res_probe_loop (); - /* $Id$ */ |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:37:47
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23246/sysfence Modified Files: mainloop.c Log Message: change: mutex -> semaphore Index: mainloop.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/mainloop.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mainloop.c 1 Mar 2004 17:28:10 -0000 1.7 +++ mainloop.c 20 May 2004 14:37:37 -0000 1.8 @@ -17,13 +17,13 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <pthread.h> #include "parseopt/lex.h" #include "getstats.h" #include "conditions.h" #include "log.h" +#include "communication.h" +#include "mainloop.h" -pthread_mutex_t changing_data; int step = 10; void rule_watch_loop (ruleset *rule) @@ -32,10 +32,10 @@ /* save result of this and previous hit */ rule->prevhit = rule->hit; - /* lock mutex while checking data */ - pthread_mutex_lock (&changing_data); + /* set semaphore while checking data */ + semaphore_wait (semid); rule->hit = check_expression (rule->expr); - pthread_mutex_unlock (&changing_data); + semaphore_post (semid); if (rule->hit) { #ifdef DEBUG @@ -75,11 +75,11 @@ { while (1) { - /* lock mutex while changing data */ - pthread_mutex_lock (&changing_data); + /* set semaphore while changing data */ + semaphore_wait (semid); fetch_la (); fetch_mem (); - pthread_mutex_unlock (&changing_data); + semaphore_post (semid); sleep (step); } |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:36:26
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22913/sysfence Modified Files: getstats.c Log Message: + stat_init (...) Index: getstats.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/getstats.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- getstats.c 18 Apr 2004 17:25:36 -0000 1.8 +++ getstats.c 20 May 2004 14:36:12 -0000 1.9 @@ -20,19 +20,9 @@ #include <stdlib.h> #include <unistd.h> #include <fcntl.h> -#include <strings.h> +#include <string.h> #include <sys/vfs.h> -statval stat [STA_LAST] = { - [STA_LA1] = { "la1", DOUBLE, {0} }, - [STA_LA5] = { "la5", DOUBLE, {0} }, - [STA_LA15] = { "la15", DOUBLE, {0} }, - [STA_MFREE] = { "memfree", SIZE, {0} }, - [STA_MUSED] = { "memused", SIZE, {0} }, - [STA_SFREE] = { "swapfree", SIZE, {0} }, - [STA_SUSED] = { "swapused", SIZE, {0} } -}; - const char *lafile = "/proc/loadavg"; int lafha; const char *memfile = "/proc/meminfo"; @@ -41,6 +31,18 @@ char fbuf[ BUFSIZE ]; +void stat_init (statval *stat) +{ + strcpy (stat[STA_LA1].label, "la1"); stat[STA_LA1].type = DOUBLE; stat[STA_LA1].val.dbl = 0.0; + strcpy (stat[STA_LA5].label, "la5"); stat[STA_LA5].type = DOUBLE; stat[STA_LA5].val.dbl = 0.0; + strcpy (stat[STA_LA15].label, "la15"); stat[STA_LA15].type = DOUBLE; stat[STA_LA15].val.dbl = 0.0; + + strcpy (stat[STA_MFREE].label, "memfree"); stat[STA_MFREE].type = SIZE; stat[STA_MFREE].val.siz = 0; + strcpy (stat[STA_MUSED].label, "memused"); stat[STA_MUSED].type = SIZE; stat[STA_MUSED].val.siz = 0; + strcpy (stat[STA_SFREE].label, "swapfree"); stat[STA_SFREE].type = SIZE; stat[STA_SFREE].val.siz = 0; + strcpy (stat[STA_SUSED].label, "swapused"); stat[STA_SUSED].type = SIZE; stat[STA_SUSED].val.siz = 0; +} + void fetch_la () { char *one, *two, *three; |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:34:44
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22628/sysfence Modified Files: getstats.h Log Message: stat -> pointer Index: getstats.h =================================================================== RCS file: /cvsroot/sysfence/sysfence/getstats.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- getstats.h 17 Apr 2004 16:54:35 -0000 1.5 +++ getstats.h 20 May 2004 14:34:33 -0000 1.6 @@ -30,8 +30,10 @@ SIZE } vartype; +#define MAX_LABEL 10 + typedef struct { - char *label; + char label[MAX_LABEL]; vartype type; union { @@ -47,7 +49,9 @@ } pathspaceval; -statval stat [STA_LAST]; +statval *stat; + +void stat_init (statval *stat); void fetch_la (); void fetch_mem (); |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:32:50
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22269/sysfence Modified Files: exit.c Log Message: + now works when EXIT_OK Index: exit.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/exit.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- exit.c 1 Mar 2004 17:28:10 -0000 1.4 +++ exit.c 20 May 2004 14:32:35 -0000 1.5 @@ -28,7 +28,9 @@ [EXIT_PARSE] = "Parse error: %s", [EXIT_VALUE] = "Invalid value: %s", - [EXIT_OPTION] = "Invalid option: %s" + [EXIT_OPTION] = "Invalid option: %s", + [EXIT_SHM] = "Shared memory exists", + [EXIT_SEM] = "Semaphore exists" }; extern char *usage; @@ -38,6 +40,8 @@ #ifdef DEBUG fprintf (stderr, "bail_out() exit code %d\n", excode); #endif + if (excode == EXIT_OK) exit (EXIT_OK); + if (details != NULL) fprintf (stderr, errormessage[excode], details); else |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:31:45
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22032/sysfence Modified Files: exit.h Log Message: + IPC errors Index: exit.h =================================================================== RCS file: /cvsroot/sysfence/sysfence/exit.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- exit.h 1 Mar 2004 17:32:39 -0000 1.4 +++ exit.h 20 May 2004 14:31:35 -0000 1.5 @@ -26,6 +26,9 @@ #define EXIT_VALUE 22 #define EXIT_OPTION 23 +#define EXIT_SHM 31 +#define EXIT_SEM 32 + void bail_out (int excode, const char *details); /* $Id$ */ |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:29:38
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21551/sysfence Modified Files: sysfence.c Log Message: change threads -> processes Index: sysfence.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/sysfence.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- sysfence.c 1 Mar 2004 17:28:10 -0000 1.12 +++ sysfence.c 20 May 2004 14:29:28 -0000 1.13 @@ -15,9 +15,12 @@ /* $Id$ */ #include <stdio.h> +#include <stdlib.h> #include <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <assert.h> #include "xalloc.h" -#include <pthread.h> #include "exit.h" #include "parseopt/lex.h" #include "getstats.h" @@ -26,6 +29,9 @@ #include "parseopt/confread.h" #include "mainloop.h" #include "log.h" +#include "communication.h" +#include "sighandlers.h" +#include "cp2memory.h" const char *usage = "sysfence v0.11, 01-03-2004\n" @@ -65,12 +71,14 @@ int main (int argc, char *argv[]) { - ruleset **ruletab; - int rulecount = 0; + ruleset **ruletab, **ruleshm; int i; + int ruletabsize; + + int pid; + + void *shm; - pthread_t *threads; - #ifdef DEBUG ruleset *rl; #endif @@ -82,15 +90,18 @@ if (*ruletab == NULL) bail_out (EXIT_NORULE, NULL); /* count rules */ + rulecount = 0; while (*(ruletab + rulecount) != NULL) rulecount ++; log_start (rulecount); #ifdef DEBUG + printf ("read %d rules.\n", rulecount); i = 0; rl = *(ruletab + i); + while (rl != NULL) { printf ("\nRULESET %d:\n", i); print_expr (rl->expr); @@ -113,27 +124,64 @@ /* open files for reading data and detach from console */ open_files (); - if (daemon (0, 0) != 0) bail_out (EXIT_IO, "daemon()"); - pthread_mutex_init (&changing_data, NULL); + //if (daemon (0, 0) != 0) bail_out (EXIT_IO, "daemon()"); - /* rule-watching threads start before data provider, so we must get fresh - * stats before starting them */ + /* initialize semaphore */ + semid = semaphore_init (SEMAPHORE_SET); + if (semid < 0) bail_out (EXIT_SEM, NULL); + + /* count ruletab size */ + ruletabsize = 0; + for (i=0; i<rulecount; i++) + ruletabsize += get_rule_size (*(ruletab+i)); + + /* initialize shared memory */ + shmid = shared_mem_init (STA_LAST * sizeof(statval) + + ruletabsize + + rulecount * sizeof (void *)); + if (shmid < 0) bail_out (EXIT_SHM, NULL); + shm = shared_mem_attach (shmid); + + stat = (statval *)shm; + + /* copy ruletab to shared memory */ + ruleshm = (ruleset **)(shm + STA_LAST * sizeof (statval)); + shm = (void *)(ruleshm + rulecount * sizeof (void *)); + + for (i=0; i<rulecount ;i++) { + *(ruleshm + i) = (ruleset *)cp_rule (&shm, *(ruletab + i)); + } + + /* rule-watching processes start before data provider, so we must get fresh + * stats before starting them */ fetch_la (); fetch_mem (); - /* one child for every ruleset */ - threads = (pthread_t *) xalloc (NULL, sizeof (pthread_t) * rulecount); - for (i = 0; i < rulecount; i ++) - pthread_create ( - threads + i, - NULL, - (void *) rule_watch_loop, - (void *) *(ruletab + i) - ); - - /* parent goes into data-providing loop */ - res_probe_loop (); + assert (rulecount); + ruleprocesses = (int *)xalloc (NULL, rulecount*sizeof(int)); + i = rulecount; + do { + pid = (int)fork (); + i--; + if (pid) *(ruleprocesses + i) = pid; + } while ((pid !=0) && (i!=0)); + + /* child */ + if (pid == 0) { + /* one child process one ruleset */ + rule_watch_loop (*(ruleshm + i)); + } else /* parent */ + { + /* start handling signals */ + signal_init (); + + /* parent goes into data-providing loop */ + res_probe_loop (); + } + + /* remove compilation warning */ + return 0; } /* $Id$ */ |
|
From: mkoperto <mko...@us...> - 2004-05-20 14:28:07
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21056/sysfence Modified Files: Makefile Log Message: + new modules Index: Makefile =================================================================== RCS file: /cvsroot/sysfence/sysfence/Makefile,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Makefile 1 Mar 2004 17:28:10 -0000 1.18 +++ Makefile 20 May 2004 14:27:58 -0000 1.19 @@ -1,7 +1,8 @@ CC=gcc -LDFLAGS=-lpthread -CFLAGS=-Wall -objects=exit.o conditions.o xalloc.o getstats.o mainloop.o log.o sysfence.o +LDFLAGS= +CFLAGS=-Wall -O2 +objects=exit.o conditions.o xalloc.o getstats.o mainloop.o log.o communication.o \ + sighandlers.o sysfence.o cp2memory.o parseopt=parseopt/{confread,lex,parse}.o %.o: %.c @@ -21,10 +22,14 @@ gcc -DDEBUG -ggdb -c getstats.c -o getstats.o make -C parseopt/ debug gcc -DDEBUG -ggdb -c mainloop.c -o mainloop.o - gcc -DDEBIG -ggdb -c log.c -o log.o + gcc -DDEBUG -ggdb -c log.c -o log.o + gcc -DDEBUG -ggdb -c communication.c -o communication.o + gcc -DDEBUG -ggdb -c sighandlers.c -o sighandlers.o + gcc -DDEBUG -ggdb -c cp2memory.c -o cp2memory.o gcc -DDEBUG -ggdb -c sysfence.c -o sysfence.o gcc -ggdb sysfence.o exit.o xalloc.o getstats.o conditions.o mainloop.o log.o \ - parseopt/lex.o parseopt/parse.o parseopt/confread.o -lpthread \ + communication.o sighandlers.o cp2memory.o \ + parseopt/lex.o parseopt/parse.o parseopt/confread.o \ -o sysfence clean: make -C parseopt/ clean |
|
From: Michal S. <em...@us...> - 2004-05-17 15:36:46
|
Update of /cvsroot/sysfence/sysfence/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19634/doc Modified Files: Tag: get_stat_value_function example.conf Log Message: * rules without name are not allowed Index: example.conf =================================================================== RCS file: /cvsroot/sysfence/sysfence/doc/example.conf,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- example.conf 27 Feb 2004 11:16:52 -0000 1.5 +++ example.conf 17 May 2004 15:36:33 -0000 1.5.2.1 @@ -15,7 +15,7 @@ # Here is an example: # -if { +rule "example" { la1 >= 5.0 and { { la5 > 3.0 and la5 < 5.0 } @@ -47,7 +47,7 @@ # usedswap - used swap # -when { +when "example 2" { freemem < 128M or swapused > 256M |
|
From: Michal S. <em...@us...> - 2004-05-17 15:32:52
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18568 Modified Files: Tag: get_stat_value_function conditions.c conditions.h exit.c exit.h getstats.c getstats.h log.c Log Message: + introducing get_stat_value function. this won't work yet - stat value logging is now disabled; needs to be rewritten Index: conditions.h =================================================================== RCS file: /cvsroot/sysfence/sysfence/conditions.h,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -d -r1.8 -r1.8.2.1 --- conditions.h 27 Feb 2004 11:16:07 -0000 1.8 +++ conditions.h 17 May 2004 15:32:35 -0000 1.8.2.1 @@ -29,9 +29,10 @@ } expression; typedef struct { - vartype type; - int val_id; - void *thresh; + stattype label; + statarg arg1; + statarg arg2; + statval thresh; token op; } atomic; @@ -54,10 +55,6 @@ // indicate if expression was true after this check and previous one int hit, prevhit; - - // bool vector that shows which stats are used within this rule. - // used by logging functions to report only important values - int showstat[STA_LAST]; } ruleset; /* Index: log.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/log.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -d -r1.6 -r1.6.2.1 --- log.c 1 Mar 2004 17:28:10 -0000 1.6 +++ log.c 17 May 2004 15:32:35 -0000 1.6.2.1 @@ -24,6 +24,7 @@ #include "conditions.h" #include "log.h" +#if 0 char * stats2str (int *sta) { char *res = xalloc (NULL, LOGLINEBUF); @@ -67,6 +68,7 @@ return res; } +#endif void log_start (int rules) { @@ -79,50 +81,7 @@ void log_rulehit (ruleset *rule) { - char *stattxt = stats2str (&(rule->showstat[0])); - - if (rule->name != NULL) - syslog (LOG_WARNING, - "%s: %s", - rule->name, - stattxt - ); - else - syslog (LOG_WARNING, - "rule hit: %s", - stattxt - ); - - free (stattxt); - - /* - if (rule->name != NULL) { - syslog (LOG_WARNING, - "%s: %s=%0.2f %s=%0.2f %s=%0.2f, " - "%s=%d %s=%d, %s=%d %s=%d", - rule->name, - stat[STA_LA1].label, stat[STA_LA1].val.dbl, - stat[STA_LA5].label, stat[STA_LA5].val.dbl, - stat[STA_LA15].label, stat[STA_LA15].val.dbl, - stat[STA_MFREE].label, stat[STA_MFREE].val.siz, - stat[STA_MUSED].label, stat[STA_MUSED].val.siz, - stat[STA_SFREE].label, stat[STA_SFREE].val.siz, - stat[STA_SUSED].label, stat[STA_SUSED].val.siz - ); - } else { - syslog (LOG_WARNING, - "rule hit: %s=%0.2f %s=%0.2f %s=%0.2f, " - "%s=%d %s=%d, %s=%d %s=%d", - stat[STA_LA1].label, stat[STA_LA1].val.dbl, - stat[STA_LA5].label, stat[STA_LA5].val.dbl, - stat[STA_LA15].label, stat[STA_LA15].val.dbl, - stat[STA_MFREE].label, stat[STA_MFREE].val.siz, - stat[STA_MUSED].label, stat[STA_MUSED].val.siz, - stat[STA_SFREE].label, stat[STA_SFREE].val.siz, - stat[STA_SUSED].label, stat[STA_SUSED].val.siz - ); - } - */ + syslog (LOG_WARNING, "rule %s hit", rule->name); } void log_end () Index: exit.h =================================================================== RCS file: /cvsroot/sysfence/sysfence/exit.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- exit.h 1 Mar 2004 17:32:39 -0000 1.4 +++ exit.h 17 May 2004 15:32:35 -0000 1.4.2.1 @@ -26,6 +26,8 @@ #define EXIT_VALUE 22 #define EXIT_OPTION 23 +#define EXIT_BUG 101 + void bail_out (int excode, const char *details); /* $Id$ */ Index: getstats.h =================================================================== RCS file: /cvsroot/sysfence/sysfence/getstats.h,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- getstats.h 17 Apr 2004 16:54:35 -0000 1.5 +++ getstats.h 17 May 2004 15:32:35 -0000 1.5.2.1 @@ -16,14 +16,28 @@ #define BUFSIZE 512 -#define STA_LA1 0 -#define STA_LA5 1 -#define STA_LA15 2 -#define STA_MFREE 3 -#define STA_MUSED 4 -#define STA_SFREE 5 -#define STA_SUSED 6 -#define STA_LAST 7 +typedef enum { + STA_LOAD, + STA_MEMORY, + STA_SWAP, + STA_FILESYS, + STA_PROC +} stattype; + +typedef enum { + ARG_MIN1, + ARG_MIN5, + ARG_MIN15, + ARG_TOTAL, + ARG_USED, + ARG_FREE, + ARG_AVAIL +} arg_simple; + +typedef union { + arg_simple simple; + void *ptr; +} statarg; typedef enum { DOUBLE, @@ -31,23 +45,19 @@ } vartype; typedef struct { - char *label; - vartype type; - + vartype type; union { - double dbl; - long int siz; + long int intval; + double dblval; } val; - } statval; typedef struct { char *path; long int total, used, free; - } pathspaceval; -statval stat [STA_LAST]; +statval *get_stat_value (stattype label, statarg arg1, statarg arg2); void fetch_la (); void fetch_mem (); Index: conditions.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/conditions.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- conditions.c 26 Feb 2004 20:11:09 -0000 1.4 +++ conditions.c 17 May 2004 15:32:35 -0000 1.4.2.1 @@ -14,6 +14,7 @@ */ #include <stdio.h> +#include "exit.h" #include "parseopt/lex.h" #include "getstats.h" #include "conditions.h" @@ -52,24 +53,24 @@ int check_atomic (atomic *at) { - double dv = stat[at->val_id].val.dbl, - *dt = (double *) at->thresh; - long int iv = stat[at->val_id].val.siz, - *it = (long int *) at->thresh; + statval *stval = get_stat_value (at->label, at->arg1, at->arg2); + + if (at->thresh.type != stval->type) + bail_out (EXIT_BUG, "incompatible stat value and threshold types"); - switch (at->type) { + switch (stval->type) { case DOUBLE: return ordcmp ( - (dv < *dt), - (dv == *dt), - (dv > *dt), + (stval->val.dblval < at->thresh.val.dblval), + (stval->val.dblval == at->thresh.val.dblval), + (stval->val.dblval > at->thresh.val.dblval), at->op ); case SIZE: return ordcmp ( - (iv < *it), - (iv == *it), - (iv > *it), + (stval->val.intval < at->thresh.val.intval), + (stval->val.intval == at->thresh.val.intval), + (stval->val.intval > at->thresh.val.intval), at->op ); default: Index: getstats.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/getstats.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -d -r1.8 -r1.8.2.1 --- getstats.c 18 Apr 2004 17:25:36 -0000 1.8 +++ getstats.c 17 May 2004 15:32:35 -0000 1.8.2.1 @@ -14,24 +14,26 @@ /* $Id$ */ -#include "exit.h" -#include "getstats.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <strings.h> #include <sys/vfs.h> +#include "xalloc.h" +#include "exit.h" +#include "getstats.h" -statval stat [STA_LAST] = { - [STA_LA1] = { "la1", DOUBLE, {0} }, - [STA_LA5] = { "la5", DOUBLE, {0} }, - [STA_LA15] = { "la15", DOUBLE, {0} }, - [STA_MFREE] = { "memfree", SIZE, {0} }, - [STA_MUSED] = { "memused", SIZE, {0} }, - [STA_SFREE] = { "swapfree", SIZE, {0} }, - [STA_SUSED] = { "swapused", SIZE, {0} } -}; +statval *get_stat_value (stattype label, statarg arg1, statarg arg2) +{ + /* This function brings stat value from shared memory */ + + statval *s = (statval *) xalloc (NULL, sizeof (statval)); + + s->type = SIZE; + s->val.intval = 1; + return s; +} const char *lafile = "/proc/loadavg"; int lafha; @@ -43,6 +45,7 @@ void fetch_la () { +#if 0 char *one, *two, *three; lseek (lafha, 0, SEEK_SET); @@ -60,10 +63,13 @@ printf ("fetch_la(): la1=%0.2f la5=%0.2f la15=%0.2f\n", stat[STA_LA1], stat[STA_LA5], stat[STA_LA15]); #endif + +#endif } void fetch_mem () { +#if 0 char *ptr; long int vmtot, vmused, vmbuf, vmcache; @@ -115,6 +121,8 @@ stat[STA_SUSED].val.siz ); #endif + +#endif } void open_files () Index: exit.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/exit.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- exit.c 1 Mar 2004 17:28:10 -0000 1.4 +++ exit.c 17 May 2004 15:32:35 -0000 1.4.2.1 @@ -28,7 +28,9 @@ [EXIT_PARSE] = "Parse error: %s", [EXIT_VALUE] = "Invalid value: %s", - [EXIT_OPTION] = "Invalid option: %s" + [EXIT_OPTION] = "Invalid option: %s", + + [EXIT_BUG] = "Internal bug: %s" }; extern char *usage; |
|
From: Michal S. <em...@us...> - 2004-05-17 15:32:46
|
Update of /cvsroot/sysfence/sysfence/parseopt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18568/parseopt Modified Files: Tag: get_stat_value_function parse.c Log Message: + introducing get_stat_value function. this won't work yet - stat value logging is now disabled; needs to be rewritten Index: parse.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/parseopt/parse.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -d -r1.11 -r1.11.2.1 --- parse.c 10 May 2004 13:57:52 -0000 1.11 +++ parse.c 17 May 2004 15:32:36 -0000 1.11.2.1 @@ -18,7 +18,7 @@ #include "../exit.h" #include "../xalloc.h" #include "../getstats.h" -#include "../expressions.h" +#include "../conditions.h" #include "parse.h" #include <stdio.h> #include <stdlib.h> @@ -55,16 +55,6 @@ bail_out (EXIT_PARSE, buf); } -void collect_stats (expression *ex, int *tab) -{ - if (ex->type == ATOMIC) { - *(tab + ((atomic *) ex->arg1)->val_id) = 1; - } else { - collect_stats ((expression *) ex->arg1, tab); - collect_stats ((expression *) ex->arg2, tab); - } -} - parserdata * get_logdata (tokdata *tok) { /* grammar: @@ -255,39 +245,46 @@ switch (var->type) { case ID_LA1: - at->type = DOUBLE; - at->op = op->type; - at->val_id = STA_LA1; + at->thresh.type = DOUBLE; + at->op = op->type; + at->label = STA_LOAD; + at->arg1.simple = ARG_MIN1; break; case ID_LA5: - at->type = DOUBLE; - at->op = op->type; - at->val_id = STA_LA5; + at->thresh.type = DOUBLE; + at->op = op->type; + at->label = STA_LOAD; + at->arg1.simple = ARG_MIN5; break; case ID_LA15: - at->type = DOUBLE; - at->op = op->type; - at->val_id = STA_LA15; + at->thresh.type = DOUBLE; + at->op = op->type; + at->label = STA_LOAD; + at->arg1.simple = ARG_MIN15; break; case ID_MFREE: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_MFREE; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_MEMORY; + at->arg1.simple = ARG_FREE; break; case ID_MUSED: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_MUSED; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_MEMORY; + at->arg1.simple = ARG_USED; break; case ID_SFREE: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_SFREE; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_SWAP; + at->arg1.simple = ARG_FREE; break; case ID_SUSED: - at->type = SIZE; - at->op = op->type; - at->val_id = STA_SUSED; + at->thresh.type = SIZE; + at->op = op->type; + at->label = STA_SWAP; + at->arg1.simple = ARG_USED; break; default: return NULL; @@ -313,8 +310,8 @@ /* check value type */ if (val->type == VA_INT) { /* this is integer. convert it to type required by label */ - if (at->type == SIZE) val->type = VA_SIZ; - else if (at->type == DOUBLE) { + if (at->thresh.type == SIZE) val->type = VA_SIZ; + else if (at->thresh.type == DOUBLE) { /* long int 2 double */ val->type = VA_DBL; tmp = xalloc (NULL, sizeof (double)); @@ -324,8 +321,8 @@ } } - if (((at->type == SIZE) && (val->type != VA_SIZ)) || - ((at->type == DOUBLE) && (val->type != VA_DBL))) + if (((at->thresh.type == SIZE) && (val->type != VA_SIZ)) || + ((at->thresh.type == DOUBLE) && (val->type != VA_DBL))) #ifdef DEBUG parse_error (val, thisfuncname, "type mismatch"); #else @@ -333,7 +330,8 @@ #endif /* copy threshold value */ - at->thresh = val->val; + if (at->thresh.type == SIZE) at->thresh.val.intval = (long int) *((long int *) val->val); + else if (at->thresh.type == DOUBLE) at->thresh.val.dblval = (double) *((long int *) val->val); res = (parserdata *) xalloc (NULL, sizeof (parserdata)); res->ptr = tok; @@ -420,8 +418,6 @@ rlst->log = NULL; rlst->hit = 0; rlst->prevhit = 0; - for (i = 0; i < STA_LAST; i++) - rlst->showstat[i] = 0; /* ruleset begins with IF */ if (tok->type != KW_IF) @@ -432,11 +428,14 @@ #endif else tok ++; - /* then we may find an optional rule name. */ - if (tok->type == VA_STR) { - rlst->name = tok->val; - tok ++; - } + /* then we should find rule name. */ + if (tok->type == VA_STR) rlst->name = tok->val; +#ifdef DEBUG + else parse_error (tok, thisfuncname, "no rule name"); +#else + else parse_error (tok); +#endif + tok ++; /* next should be expression in block */ tmp = get_block_expression (tok); @@ -490,9 +489,6 @@ tok = tmp->ptr; rlst->step = *((unsigned int *) tmp->parsed); - /* search expression tree for used stats */ - collect_stats (rlst->expr, &(rlst->showstat[0])); - /* ok, now we got full ruleset structure. * we need only to skip to next token. */ |
|
From: Michal S. <em...@us...> - 2004-05-10 14:07:53
|
Update of /cvsroot/sysfence/sysfence/parseopt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30521 Added Files: grammar.txt Log Message: + grammar overview --- NEW FILE: grammar.txt --- Grammar overview (informal): ruleset := rule [<string>] <block_expression> <rundata> [<logdata>] [<stepdata>] | rule [<string>] <block_expression> <logdata> [<rundata>] [<stepdata>] block_expression := { <expression> } expression := <atomic> [<log_op> <expression>] | <block_expression> [<log_op> <expression>] logdata := log [once] rundata := run [once] "command" stepdata := step <integer> atomic := <stat> <comp_op> <threshold> stat := la1 | la5 | la15 | memfree | memused | swapfree | swapused | <fs_cond> | <proc_cond> fs_cond := spacefree "path" | spaceavail "path" | spaceused "path" proc_cond := nproc [<user_list>] [<state_list>] user_list := <uid> [, <user_list>] | <username> [, <user_list>] state_list := <state> [, <state_list>] state := sleeping | running | stopped | uninterruptible | zombie log_op := && | || comp_op := = | < | > | <= | >= | != |
|
From: Michal S. <em...@us...> - 2004-05-10 13:58:16
|
Update of /cvsroot/sysfence/sysfence/parseopt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28153 Modified Files: parse.c Log Message: * consistent names in grammar Index: parse.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/parseopt/parse.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- parse.c 27 Feb 2004 11:16:07 -0000 1.10 +++ parse.c 10 May 2004 13:57:52 -0000 1.11 @@ -18,7 +18,7 @@ #include "../exit.h" #include "../xalloc.h" #include "../getstats.h" -#include "../conditions.h" +#include "../expressions.h" #include "parse.h" #include <stdio.h> #include <stdlib.h> @@ -215,7 +215,7 @@ { /* grammar: * - * condition := <atomic> [<op> <expression>] + * expression := <atomic> [<op> <expression>] * | <block_expression> [<op> <expression>] */ #ifdef DEBUG @@ -393,8 +393,8 @@ { /* grammar: * - * ruleset := 'if' [<string>] <block_condition> <rundata> [<logdata>] - * | 'if' [<string>] <block_condition> <logdata> [<rundata>] + * ruleset := 'if' [<string>] <block_expression> <rundata> [<logdata>] + * | 'if' [<string>] <block_expression> <logdata> [<rundata>] */ #ifdef DEBUG |
|
From: Michal S. <em...@us...> - 2004-05-10 13:53:26
|
Update of /cvsroot/sysfence/sysfence/parseopt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27040/parseopt Modified Files: lex.c lex.h Log Message: + added new tokens for fs and processes Index: lex.h =================================================================== RCS file: /cvsroot/sysfence/sysfence/parseopt/lex.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- lex.h 27 Feb 2004 11:16:07 -0000 1.5 +++ lex.h 10 May 2004 13:53:17 -0000 1.6 @@ -25,6 +25,8 @@ CO_EQ, CO_NEQ, CO_LE, CO_LT, CO_GE, CO_GT, /* logical operators */ LO_OR, LO_AND, + /* list separator */ + LI_SEP, /* keywords */ KW_IF, KW_RUN, KW_LOG, KW_ONCE, KW_STEP, /* block beginning/end */ @@ -33,6 +35,10 @@ ID_LA1, ID_LA5, ID_LA15, ID_MFREE, ID_MUSED, ID_SFREE, ID_SUSED, + ID_FSFREE, ID_FSAVAIL, ID_FSUSED, + ID_NPROC, + /* process states */ + PR_RUN, PR_STOP, PR_SLEEP, PR_UNINT, PR_ZOMBIE, /* values */ VA_INT, VA_SIZ, VA_DBL, VA_STR, /* special token, must be last */ Index: lex.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/parseopt/lex.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- lex.c 27 Feb 2004 11:16:07 -0000 1.8 +++ lex.c 10 May 2004 13:53:17 -0000 1.9 @@ -27,29 +27,41 @@ literal toktrans[] = { /* Tokens table. To extend it, modify MAXREP in lex.h */ - { CO_NEQ, {"!=", "<>", NULL, NULL } }, - { CO_LE, {"<=", "=<", NULL, NULL } }, - { CO_LT, {"<", NULL, NULL, NULL } }, - { CO_GE, {">=", "=>", NULL, NULL } }, - { CO_GT, {">", NULL, NULL, NULL } }, - { CO_EQ, {"=", "==", NULL, NULL } }, - { LO_OR, {"or", "orelse", "||", NULL } }, - { LO_AND, {"and", "andalso", "&&", NULL } }, - { KW_IF, {"if", "when", "on", "rule" } }, - { KW_RUN, {"run", "exec", "execute", "invoke"} }, - { KW_LOG, {"log", NULL, NULL, NULL } }, - { KW_ONCE, {"once", "onlyonce", NULL, NULL } }, - { KW_STEP, {"step", "stepping", NULL, NULL } }, - { BL_BEGIN, {"{", NULL, NULL, NULL } }, - { BL_END, {"}", NULL, NULL, NULL } }, - { ID_LA15, {"la15", "load15", "loadavg15", NULL } }, - { ID_LA5, {"la5", "load5", "loadavg5", NULL } }, - { ID_LA1, {"la1", "load1", "loadavg1", NULL } }, - { ID_MFREE, {"memfree", "freemem", "freememory", NULL } }, - { ID_MUSED, {"memused", "usedmem", "usedmemory", NULL } }, - { ID_SFREE, {"swapfree", "freeswap", NULL, NULL } }, - { ID_SUSED, {"swapused", "usedswap", NULL, NULL } }, - { END, {"\0", NULL, NULL, NULL } } + { CO_NEQ, {"!=", "<>", NULL, NULL } }, + { CO_LE, {"<=", "=<", NULL, NULL } }, + { CO_LT, {"<", NULL, NULL, NULL } }, + { CO_GE, {">=", "=>", NULL, NULL } }, + { CO_GT, {">", NULL, NULL, NULL } }, + { CO_EQ, {"=", "==", NULL, NULL } }, + { LO_OR, {"or", "orelse", "||", NULL } }, + { LO_AND, {"and", "andalso", "&&", NULL } }, + { LI_SEP, {",", "|", NULL, NULL } }, + { KW_IF, {"if", "when", "on", "rule" } }, + { KW_RUN, {"run", "exec", "execute", "invoke" } }, + { KW_LOG, {"log", NULL, NULL, NULL } }, + { KW_ONCE, {"once", "onlyonce", NULL, NULL } }, + { KW_STEP, {"step", "stepping", NULL, NULL } }, + { BL_BEGIN, {"{", NULL, NULL, NULL } }, + { BL_END, {"}", NULL, NULL, NULL } }, + { ID_LA15, {"la15", "load15", "loadavg15", NULL } }, + { ID_LA5, {"la5", "load5", "loadavg5", NULL } }, + { ID_LA1, {"la1", "load1", "loadavg1", NULL } }, + { ID_MFREE, {"memfree", "freemem", "freememory", NULL } }, + { ID_MUSED, {"memused", "usedmem", "usedmemory", NULL } }, + { ID_SFREE, {"swapfree", "freeswap", NULL, NULL } }, + { ID_SUSED, {"swapused", "usedswap", NULL, NULL } }, + { ID_FSFREE, {"spacefree", "freespace", NULL, NULL } }, + { ID_FSAVAIL, {"spaceavail", "availspace", "spaceavailable", "availablespace" } }, + { ID_FSUSED, {"spaceused", "usedspace", NULL, NULL } }, + { ID_NPROC, {"nproc", "numproc", "procnum", "processes" } }, + { PR_RUN, {"run", "running", NULL, NULL } }, + { PR_STOP, {"stop", "stopped", "traced", NULL } }, + { PR_SLEEP, {"sleep", "sleeping", NULL, NULL } }, + { PR_UNINT, {"unint", "io", "uninterruptible", NULL } }, + { PR_ZOMBIE, {"zombie", "defunct", NULL, NULL } }, + { PR_RUN, {"run", "running", NULL, NULL } }, + { PR_RUN, {"run", "running", NULL, NULL } }, + { END, {"\0", NULL, NULL, NULL } } }; unsigned int linenum = 1; @@ -58,33 +70,43 @@ char * tok2string (token t) { switch (t) { - case CO_EQ: return "="; - case CO_NEQ: return "!="; - case CO_LE: return "<="; - case CO_LT: return "<"; - case CO_GE: return ">="; - case CO_GT: return ">"; - case LO_OR: return "or"; - case LO_AND: return "and"; - case KW_IF: return "if"; - case KW_RUN: return "run"; - case KW_LOG: return "log"; - case KW_ONCE: return "once"; - case KW_STEP: return "step"; - case BL_BEGIN: return "{"; - case BL_END: return "}"; - case ID_LA1: return "LA1"; - case ID_LA5: return "LA5"; - case ID_LA15: return "LA15"; - case ID_MFREE: return "MEMFREE"; - case ID_MUSED: return "MEMUSED"; - case ID_SFREE: return "SWAPFREE"; - case ID_SUSED: return "SWAPUSED"; - case VA_INT: return "VA_INT"; - case VA_SIZ: return "VA_SIZ"; - case VA_DBL: return "VA_DBL"; - case VA_STR: return "VA_STR"; - case END: return "END"; + case CO_EQ: return "="; + case CO_NEQ: return "!="; + case CO_LE: return "<="; + case CO_LT: return "<"; + case CO_GE: return ">="; + case CO_GT: return ">"; + case LO_OR: return "or"; + case LO_AND: return "and"; + case LI_SEP: return ","; + case KW_IF: return "if"; + case KW_RUN: return "run"; + case KW_LOG: return "log"; + case KW_ONCE: return "once"; + case KW_STEP: return "step"; + case BL_BEGIN: return "{"; + case BL_END: return "}"; + case ID_LA1: return "LA1"; + case ID_LA5: return "LA5"; + case ID_LA15: return "LA15"; + case ID_MFREE: return "MEMFREE"; + case ID_MUSED: return "MEMUSED"; + case ID_SFREE: return "SWAPFREE"; + case ID_SUSED: return "SWAPUSED"; + case ID_FSFREE: return "SPACEFREE"; + case ID_FSAVAIL: return "SPACEAVAILABLE"; + case ID_FSUSED: return "SPACEUSED"; + case ID_NPROC: return "NPROC"; + case PR_RUN: return "R"; + case PR_STOP: return "T"; + case PR_SLEEP: return "S"; + case PR_UNINT: return "U"; + case PR_ZOMBIE: return "Z"; + case VA_INT: return "VA_INT"; + case VA_SIZ: return "VA_SIZ"; + case VA_DBL: return "VA_DBL"; + case VA_STR: return "VA_STR"; + case END: return "END"; } } #endif |