summaryrefslogtreecommitdiff
path: root/src/libvmon/vmon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libvmon/vmon.h')
-rw-r--r--src/libvmon/vmon.h34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/libvmon/vmon.h b/src/libvmon/vmon.h
index cefcb43..4f17d12 100644
--- a/src/libvmon/vmon.h
+++ b/src/libvmon/vmon.h
@@ -4,12 +4,13 @@
#include <sys/types.h>
#include <dirent.h>
#include <stdint.h>
+#include <stdio.h> /* just for vmon_dump_procs() */
#include <string.h> /* I use strcmp() in the type comparator definitions */
#include "bitmap.h"
#include "list.h"
-#define VMON_HTAB_SIZE 128 /* number of buckets in the processes hash table */
+#define VMON_HTAB_SIZE 1024 /* number of buckets in the processes hash table */
#define VMON_ARRAY_GROWBY 5 /* number of elements to grow the processes array */
typedef enum _vmon_flags_t {
@@ -17,6 +18,9 @@ typedef enum _vmon_flags_t {
VMON_FLAG_PROC_ARRAY = 1L, /* maintain a process array (useful if you need to do things like implement top(1) */
VMON_FLAG_PROC_ALL = 1L << 1, /* monitor all the processes in the system (XXX this has some follow_children implications...) */
VMON_FLAG_2PASS = 1L << 2, /* perform all sampling/wants in a first pass, then invoke all callbacks in second in vmon_sample(), important if your callbacks are layout-sensitive (vwm) */
+ VMON_FLAG_NEGLECT_THREADS = 1L << 3, /* only actually sample processes, even if we're following threads
+ * (for situations where you still want to monitor children of threads, but don't care about per-thread monitoring)
+ */
} vmon_flags_t;
/* store ids, used as indices into the stores array, and shift offsets for the wants mask */
@@ -49,14 +53,14 @@ typedef enum _vmon_proc_wants_t {
/* we add some new complex types */
typedef struct _vmon_char_array_t {
char *array;
- int len;
- int alloc_len;
+ size_t len;
+ size_t alloc_len;
} vmon_char_array_t;
typedef struct _vmon_str_array_t {
char **array;
- int len;
- int alloc_len;
+ size_t len;
+ size_t alloc_len;
} vmon_str_array_t;
@@ -228,6 +232,7 @@ typedef struct _vmon_proc_t {
list_head_t children; /* head of the children of this process, empty when no children */
list_head_t siblings; /* node in siblings list */
list_head_t threads; /* head or node for the threads list, empty when process has no threads */
+ unsigned n_current_threads; /* count of non-stale nodes in the threads list */
struct _vmon_proc_t *parent; /* reference to the parent */
@@ -246,11 +251,12 @@ typedef struct _vmon_proc_t {
list_head_t sample_callbacks; /* list of callbacks to invoke sample_cb on behalf of (and supply as parameteres to) */
void *foo; /* another per-process hook for whatever per-process uses the caller may have, but not managed by the api */
- int children_changed:1; /* gets set when any of my immediate children have had is_new or is_stale set in the last sample */
- int threads_changed:1; /* gets set when any of my threads have had is_new or is_stale set in the last sample */
- int is_new:1; /* process is new in the most recent sample, automatically cleared on subsequent sample */
- int is_stale:1; /* process became stale in the most recent sample, automatically cleared on subsequent sample (process will be discarded) */
- int is_thread:1; /* process is a thread belonging to parent */
+ unsigned children_changed:1; /* gets set when any of my immediate children have had is_new or is_stale set in the last sample */
+ unsigned threads_changed:1; /* gets set when any of my threads have had is_new or is_stale set in the last sample */
+ unsigned is_new:1; /* process is new in the most recent sample, automatically cleared on subsequent sample */
+ unsigned is_stale:1; /* process became stale in the most recent sample, automatically cleared on subsequent sample (process will be discarded) */
+ unsigned is_thread:1; /* process is a thread belonging to parent */
+ unsigned is_threaded:1; /* gets set when any of my immediate children are/have been threads */
} vmon_proc_t;
@@ -265,9 +271,9 @@ typedef struct _vmon_t {
int array_hint_free; /* hint for a free element in the list */
list_head_t htab[VMON_HTAB_SIZE]; /* hash table for quickly finding processes being monitored */
- list_head_t processes; /* top of the processes heirarchy */
+ list_head_t processes; /* top of the processes hierarchy */
list_head_t orphans; /* ephemeral list of processes orphaned this sample, orphans wind up becoming top-level processes */
- int processes_changed:1; /* flag set when the toplevel processes list changes */
+ unsigned processes_changed:1; /* flag set when the toplevel processes list changes */
list_head_t fobjects; /* XXX TODO: temporary single fobjects table, in the future this will be an array of type-indexed
* fobject hash tables */
@@ -277,6 +283,7 @@ typedef struct _vmon_t {
vmon_sys_wants_t sys_wants; /* system-wide wants mask */
vmon_proc_wants_t proc_wants; /* inherited per-process wants mask */
long ticks_per_sec; /* sysconf(_SC_CLK_TCK) */
+ long num_cpus; /* sysconf(_SC_NPROCESSORS_ONLN) */
/* function tables for mapping of wants bits to functions (sys-wide and per-process) */
int (*sys_funcs[VMON_STORE_SYS_NR])(struct _vmon_t *, void **);
@@ -303,8 +310,9 @@ typedef struct _vmon_t {
int vmon_init(vmon_t *, vmon_flags_t, vmon_sys_wants_t, vmon_proc_wants_t);
void vmon_destroy(vmon_t *);
-vmon_proc_t * vmon_proc_monitor(vmon_t *, vmon_proc_t *, int, vmon_proc_wants_t, void (*)(vmon_t *, void *, vmon_proc_t *, void *), void *);
+vmon_proc_t * vmon_proc_monitor(vmon_t *, int, vmon_proc_wants_t, void (*)(vmon_t *, void *, vmon_proc_t *, void *), void *);
void vmon_proc_unmonitor(vmon_t *, vmon_proc_t *, void (*)(vmon_t *, void *, vmon_proc_t *, void *), void *);
int vmon_sample(vmon_t *);
+void vmon_dump_procs(vmon_t *vmon, FILE *out);
#endif
© All Rights Reserved