summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2007-08-10 05:07:14 +0000
committerHisham Muhammad <hisham@gobolinux.org>2007-08-10 05:07:14 +0000
commit4c51ad0e3549a12215c98e8fa011557fc6889b65 (patch)
treec074c69432b324827825a25bdc7710f7406b42c7
parentd357c677178f173575ac09d70f84a3e0c19e4329 (diff)
OpenVZ support, contributed by Sergey Lychko
-rw-r--r--ChangeLog6
-rw-r--r--Process.c30
-rw-r--r--Process.h10
-rw-r--r--ProcessList.c22
-rw-r--r--configure.ac5
5 files changed, 70 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ed1be0a..7e642ba0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+What's new in version 0.6.7
+
+* OpenVZ support, enabled at compile-time with
+ the --enable-openvz flag.
+ (thanks to Sergey Lychko)
+
What's new in version 0.6.6
* Add support of NLWP field
diff --git a/Process.c b/Process.c
index e9d05dbe..71840f4f 100644
--- a/Process.c
+++ b/Process.c
@@ -41,7 +41,11 @@ typedef enum ProcessField_ {
STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
- USER, TIME, NLWP, LAST_PROCESSFIELD
+ USER, TIME, NLWP,
+ #ifdef HAVE_OPENVZ
+ VEID, VPID,
+ #endif
+ LAST_PROCESSFIELD
} ProcessField;
struct ProcessList_;
@@ -108,6 +112,10 @@ typedef struct Process_ {
float percent_cpu;
float percent_mem;
char* user;
+ #ifdef HAVE_OPENVZ
+ unsigned int veid;
+ unsigned int vpid;
+ #endif
} Process;
}*/
@@ -119,7 +127,11 @@ char* PROCESS_CLASS = "Process";
#endif
char *Process_fieldNames[] = {
- "", "PID", "Command", "STATE", "PPID", "PGRP", "SESSION", "TTY_NR", "TPGID", "FLAGS", "MINFLT", "CMINFLT", "MAJFLT", "CMAJFLT", "UTIME", "STIME", "CUTIME", "CSTIME", "PRIORITY", "NICE", "ITREALVALUE", "STARTTIME", "VSIZE", "RSS", "RLIM", "STARTCODE", "ENDCODE", "STARTSTACK", "KSTKESP", "KSTKEIP", "SIGNAL", "BLOCKED", "SIGIGNORE", "SIGCATCH", "WCHAN", "NSWAP", "CNSWAP", "EXIT_SIGNAL", "PROCESSOR", "M_SIZE", "M_RESIDENT", "M_SHARE", "M_TRS", "M_DRS", "M_LRS", "M_DT", "ST_UID", "PERCENT_CPU", "PERCENT_MEM", "USER", "TIME", "NLWP", "*** report bug! ***"
+ "", "PID", "Command", "STATE", "PPID", "PGRP", "SESSION", "TTY_NR", "TPGID", "FLAGS", "MINFLT", "CMINFLT", "MAJFLT", "CMAJFLT", "UTIME", "STIME", "CUTIME", "CSTIME", "PRIORITY", "NICE", "ITREALVALUE", "STARTTIME", "VSIZE", "RSS", "RLIM", "STARTCODE", "ENDCODE", "STARTSTACK", "KSTKESP", "KSTKEIP", "SIGNAL", "BLOCKED", "SIGIGNORE", "SIGCATCH", "WCHAN", "NSWAP", "CNSWAP", "EXIT_SIGNAL", "PROCESSOR", "M_SIZE", "M_RESIDENT", "M_SHARE", "M_TRS", "M_DRS", "M_LRS", "M_DT", "ST_UID", "PERCENT_CPU", "PERCENT_MEM", "USER", "TIME", "NLWP",
+#ifdef HAVE_OPENVZ
+"VEID", "VPID",
+#endif
+"*** report bug! ***"
};
static int Process_getuid = -1;
@@ -363,6 +375,10 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) {
}
break;
}
+ #ifdef HAVE_OPENVZ
+ case VEID: snprintf(buffer, n, "%5u ", this->veid); break;
+ case VPID: snprintf(buffer, n, "%5u ", this->vpid); break;
+ #endif
default:
snprintf(buffer, n, "- ");
}
@@ -427,6 +443,12 @@ int Process_compare(const void* v1, const void* v2) {
return strcmp(p1->comm, p2->comm);
case NLWP:
return (p1->nlwp - p2->nlwp);
+ #ifdef HAVE_OPENVZ
+ case VEID:
+ return (p1->veid - p2->veid);
+ case VPID:
+ return (p1->vpid - p2->vpid);
+ #endif
default:
return (p1->pid - p2->pid);
}
@@ -461,6 +483,10 @@ char* Process_printField(ProcessField field) {
case PERCENT_MEM: return "MEM% ";
case PROCESSOR: return "CPU ";
case NLWP: return "NLWP ";
+ #ifdef HAVE_OPENVZ
+ case VEID: return " VEID ";
+ case VPID: return " VPID ";
+ #endif
default: return "- ";
}
}
diff --git a/Process.h b/Process.h
index 79ccc5ee..37a20cb9 100644
--- a/Process.h
+++ b/Process.h
@@ -43,7 +43,11 @@ typedef enum ProcessField_ {
STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
- USER, TIME, NLWP, LAST_PROCESSFIELD
+ USER, TIME, NLWP,
+ #ifdef HAVE_OPENVZ
+ VEID, VPID,
+ #endif
+ LAST_PROCESSFIELD
} ProcessField;
struct ProcessList_;
@@ -110,6 +114,10 @@ typedef struct Process_ {
float percent_cpu;
float percent_mem;
char* user;
+ #ifdef HAVE_OPENVZ
+ unsigned int veid;
+ unsigned int vpid;
+ #endif
} Process;
diff --git a/ProcessList.c b/ProcessList.c
index 0b02d6aa..fa550cb5 100644
--- a/ProcessList.c
+++ b/ProcessList.c
@@ -580,6 +580,28 @@ void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, fl
if(!existingProcess) {
process->user = UsersTable_getRef(this->usersTable, process->st_uid);
+
+ #ifdef HAVE_OPENVZ
+ if (access("/proc/vz", R_OK) != 0) {
+ process->vpid = process->pid;
+ process->veid = 0;
+ } else {
+ snprintf(statusfilename, MAX_NAME, "%s/%s/stat", dirname, name);
+ status = ProcessList_fopen(this, statusfilename, "r");
+ if (status == NULL)
+ goto errorReadingProcess;
+ num = ProcessList_fread(this, status,
+ "%*u %*s %*c %*u %*u %*u %*u %*u %*u %*u "
+ "%*u %*u %*u %*u %*u %*u %*u %*u "
+ "%*u %*u %*u %*u %*u %*u %*u %*u "
+ "%*u %*u %*u %*u %*u %*u %*u %*u "
+ "%*u %*u %*u %*u %*u %*u %*u %*u "
+ "%*u %*u %*u %*u %*u %*u %*u "
+ "%u %u",
+ &process->vpid, &process->veid);
+ fclose(status);
+ }
+ #endif
snprintf(statusfilename, MAX_NAME, "%s/%s/cmdline", dirname, name);
status = ProcessList_fopen(this, statusfilename, "r");
diff --git a/configure.ac b/configure.ac
index 24f67f1c..038343a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,11 @@ AC_ARG_WITH(proc, [ --with-proc=DIR Location of a Linux-compatible proc fi
fi,
AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
+AC_ARG_ENABLE(openvz, [AC_HELP_STRING([--enable-openvz], [enable OpenVZ support])], ,enable_openvz="no")
+if test "x$enable_openvz" = xyes; then
+ AC_DEFINE(HAVE_OPENVZ, 1, [Define if openvz support enabled.])
+fi
+
AC_CHECK_FILE($PROCDIR/stat,,AC_MSG_ERROR(Cannot find /proc/stat. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.))
AC_CHECK_FILE($PROCDIR/meminfo,,AC_MSG_ERROR(Cannot find /proc/meminfo. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.))

© 2014-2024 Faster IT GmbH | imprint | privacy policy