Update of /cvsroot/sysfence/sysfence
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3222
Modified Files:
datastruct.c datastruct.h
Log Message:
+ display proc states as letters
Index: datastruct.h
===================================================================
RCS file: /cvsroot/sysfence/sysfence/datastruct.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- datastruct.h 9 Jun 2004 10:45:56 -0000 1.11
+++ datastruct.h 16 Jun 2004 09:23:08 -0000 1.12
@@ -34,6 +34,13 @@
#define STAT_MAX_ARGS 2
+#define _PR_RUN 0
+#define _PR_SLEEP 1
+#define _PR_STOP 2
+#define _PR_ZOMBIE 3
+#define _PR_UNINT 4
+#define _PR_UNKNOWN 5
+
#define PROC_RUN 1
#define PROC_SLEEP 2
#define PROC_STOP 4
@@ -202,6 +209,7 @@
int get_proc_num (sf_database *db, char statemask, uid_t *uid);
char * def_2_string (sf_stat_def *def);
char * uids_2_str (sf_list *hd);
+char * proc_states_2_str (int statemask);
int get_min_step (sf_rule **rule);
/* $Id$ */
Index: datastruct.c
===================================================================
RCS file: /cvsroot/sysfence/sysfence/datastruct.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- datastruct.c 9 Jun 2004 10:45:56 -0000 1.13
+++ datastruct.c 16 Jun 2004 09:23:08 -0000 1.14
@@ -221,6 +221,7 @@
char * def_2_string (sf_stat_def *def)
{
char *buf = (char *) xalloc (NULL, STRBUF + 1);
+ char *buf2;
*buf = '\0';
@@ -255,12 +256,22 @@
);
break;
case ST_PROC:
- snprintf (buf,
- STRBUF,
- "nproc %sstate: %d",
- uids_2_str (def->arg[0].uids),
- def->arg[1].procstates
- );
+ buf2 = proc_states_2_str (def->arg[1].procstates);
+ if (buf2) {
+ snprintf (buf,
+ STRBUF,
+ "nproc %sin state(s) %s",
+ uids_2_str (def->arg[0].uids),
+ buf2
+ );
+ free (buf2);
+ } else {
+ snprintf (buf,
+ STRBUF,
+ "nproc %s",
+ uids_2_str (def->arg[0].uids)
+ );
+ }
default:
break; // to avoid warnings
}
@@ -297,6 +308,26 @@
return buf;
}
+char * proc_states_2_str (int procmask)
+{
+ char *buf = (char *) xalloc (NULL, STRBUF + 1);
+ int pos = 0;
+ char state[_PR_UNKNOWN] = {'R', 'S', 'T', 'Z', 'D'};
+ int sta = 0;
+
+ if (procmask == PROC_ANY) return NULL;
+ while (sta < _PR_UNKNOWN) {
+ if (procmask & (1 << sta)) {
+ *(buf + pos) = state[sta];
+ pos ++;
+ }
+ sta ++;
+ }
+ *(buf + pos) = '\0';
+ return buf;
+}
+
+
int get_min_step (sf_rule **rule)
{
sf_rule *r;
|