summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2794e70)
raw | patch | inline | side by side (parent: 2794e70)
author | Patrik Weiskircher <weiskircher@inqnet.at> | |
Thu, 1 Oct 2009 11:57:11 +0000 (13:57 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Fri, 2 Oct 2009 06:52:25 +0000 (08:52 +0200) |
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/processes.c | patch | blob | history | |
src/types.db | patch | blob | history |
diff --git a/src/processes.c b/src/processes.c
index 4f515184ed85a66f38f17400f9f08dbca112fdb5..3623f73f9683c68e90af4e03404518588918be80 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
}
return buf;
} /* char *ps_get_cmdline (...) */
+
+static unsigned long read_fork_rate ()
+{
+ FILE *proc_stat;
+ char buf[1024];
+ unsigned long result = 0;
+ int numfields;
+ char *fields[2];
+
+ proc_stat = fopen("/proc/stat", "r");
+ if (proc_stat == NULL) {
+ char errbuf[1024];
+ ERROR ("processes plugin: fopen (/proc/stat) failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return 0;
+ }
+
+ while (fgets (buf, sizeof(buf), proc_stat) != NULL)
+ {
+ if (strncmp (buf, "processes", 9))
+ continue;
+ numfields = strsplit(buf, fields, 2);
+ if (numfields != 2) {
+ ERROR ("processes plugin: processes in /proc/stat contain more than 2 fields.");
+ break;
+ }
+
+ result = strtoul(fields[1], NULL, 10);
+ if (errno == ERANGE && result == ULONG_MAX) {
+ ERROR ("processes plugin: processes value in /proc/stat overflows.");
+ break;
+ }
+
+ break;
+ }
+
+ fclose(proc_stat);
+
+ return result;
+}
+
+static void ps_submit_fork_rate (unsigned long value)
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ values[0].derive = value;
+
+ vl.values = values;
+ vl.values_len = 1;
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "processes", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, "fork_rate", sizeof (vl.type));
+ sstrncpy (vl.type_instance, "", sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+}
+
#endif /* KERNEL_LINUX */
#if HAVE_THREAD_INFO
procstat_entry_t pse;
char state;
+ unsigned long fork_rate;
+
procstat_t *ps_ptr;
running = sleeping = zombies = stopped = paging = blocked = 0;
for (ps_ptr = list_head_g; ps_ptr != NULL; ps_ptr = ps_ptr->next)
ps_submit_proc_list (ps_ptr);
+
+ fork_rate = read_fork_rate();
+ ps_submit_fork_rate(fork_rate);
/* #endif KERNEL_LINUX */
#elif HAVE_LIBKVM_GETPROCS && HAVE_STRUCT_KINFO_PROC_FREEBSD
diff --git a/src/types.db b/src/types.db
index 10e15974b630f5487d040a853bbbc2526090b86b..399dbd23949654a28a99cd570f8d71848ef243ca 100644 (file)
--- a/src/types.db
+++ b/src/types.db
frequency frequency:GAUGE:0:U
frequency_offset ppm:GAUGE:-1000000:1000000
fscache_stat value:COUNTER:0:4294967295
+fork_rate value:DERIVE:0:U
gauge value:GAUGE:U:U
http_request_methods count:COUNTER:0:134217728
http_requests count:COUNTER:0:134217728