diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-14 16:44:14 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-01-14 16:44:14 +0000 |
commit | 6719b3de582b96d5760d696d35a977ad5e449e94 (patch) | |
tree | bb5bdd1dea9176c1fbe5ecf46f7536a3320c556c /src/sysmon | |
parent | aa61c135381eb883e4739620b23ccdd5969d3f16 (diff) | |
download | gnunet-6719b3de582b96d5760d696d35a977ad5e449e94.tar.gz gnunet-6719b3de582b96d5760d696d35a977ad5e449e94.zip |
gtop integration
Diffstat (limited to 'src/sysmon')
-rw-r--r-- | src/sysmon/gnunet-service-sysmon.c | 82 | ||||
-rw-r--r-- | src/sysmon/sysmon.conf.in | 4 |
2 files changed, 76 insertions, 10 deletions
diff --git a/src/sysmon/gnunet-service-sysmon.c b/src/sysmon/gnunet-service-sysmon.c index fc31ba4fb..8d9d63a80 100644 --- a/src/sysmon/gnunet-service-sysmon.c +++ b/src/sysmon/gnunet-service-sysmon.c | |||
@@ -26,6 +26,15 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_statistics_service.h" | 28 | #include "gnunet_statistics_service.h" |
29 | #if HAVE_LIBGTOP | ||
30 | #include <glibtop.h> | ||
31 | #include <glibtop/proclist.h> | ||
32 | #include <glibtop/procstate.h> | ||
33 | #include <glibtop/procargs.h> | ||
34 | #include <glibtop/procmem.h> | ||
35 | #include <glibtop/proctime.h> | ||
36 | #endif | ||
37 | |||
29 | 38 | ||
30 | enum operation | 39 | enum operation |
31 | { | 40 | { |
@@ -172,9 +181,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
172 | struct SysmonGtopProcProperty *gt_cur; | 181 | struct SysmonGtopProcProperty *gt_cur; |
173 | struct SysmonGtopProcProperty *gt_next; | 182 | struct SysmonGtopProcProperty *gt_next; |
174 | 183 | ||
175 | |||
176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n"); | 184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n"); |
177 | |||
178 | end_task = GNUNET_SCHEDULER_NO_TASK; | 185 | end_task = GNUNET_SCHEDULER_NO_TASK; |
179 | 186 | ||
180 | if (NULL != stats) | 187 | if (NULL != stats) |
@@ -209,6 +216,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
209 | GNUNET_free (gt_cur); | 216 | GNUNET_free (gt_cur); |
210 | } | 217 | } |
211 | 218 | ||
219 | #if HAVE_LIBGTOP | ||
220 | glibtop_close(); | ||
221 | #endif | ||
212 | } | 222 | } |
213 | 223 | ||
214 | static void | 224 | static void |
@@ -321,12 +331,67 @@ exec_cmd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
321 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' failed\n", sp->desc, sp->cmd); | 331 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s': command `%s' failed\n", sp->desc, sp->cmd); |
322 | } | 332 | } |
323 | 333 | ||
334 | #if HAVE_LIBGTOP | ||
324 | static void | 335 | static void |
325 | exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 336 | exec_gtop_proc_mon (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
326 | { | 337 | { |
327 | struct SysmonGtopProcProperty *sp = cls; | 338 | struct SysmonGtopProcProperty *sp = cls; |
328 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Property `%s'\n", sp->binary); | 339 | glibtop_proclist proc_list; |
340 | glibtop_proc_args proc_args; | ||
341 | glibtop_proc_mem proc_mem; | ||
342 | glibtop_proc_time proc_time; | ||
343 | pid_t *pids = NULL; | ||
344 | unsigned i; | ||
345 | char *argss; | ||
346 | |||
347 | /* get process list */ | ||
348 | pids = glibtop_get_proclist(&proc_list, GLIBTOP_KERN_PROC_ALL, 0); | ||
349 | if (NULL == pids) | ||
350 | { | ||
351 | fprintf (stderr, "Could not retrieve process list!\n"); | ||
352 | ret = 1; | ||
353 | return; | ||
354 | } | ||
355 | |||
356 | printf("Found %lu processes\n", (unsigned long) proc_list.number); | ||
357 | for (i = 0; i < proc_list.number; ++i) | ||
358 | { | ||
359 | //printf("PID %u:\n", pids[i]); | ||
360 | |||
361 | /* get process args */ | ||
362 | argss = glibtop_get_proc_args (&proc_args, pids[i], 1024); | ||
363 | if (NULL == argss) | ||
364 | { | ||
365 | fprintf (stderr, "Could not retrieve process args!\n"); | ||
366 | ret = 1; | ||
367 | return; | ||
368 | } | ||
369 | //printf ("\targument string: %s\n", argss); | ||
370 | if (NULL != strstr (argss, sp->binary)) | ||
371 | { | ||
372 | /* get memory info */ | ||
373 | glibtop_get_proc_mem (&proc_mem, pids[i]); | ||
374 | printf ("\tMemory information:\n"); | ||
375 | printf ("\t%-50s: %llu\n", "total # of pages of memory", (long long unsigned int) proc_mem.size); | ||
376 | printf ("\t%-50s: %llu\n", "number of pages of virtual memory", (long long unsigned int) proc_mem.vsize); | ||
377 | printf ("\t%-50s: %llu\n", "number of resident set", (long long unsigned int) proc_mem.resident); | ||
378 | printf ("\t%-50s: %llu\n", "number of pages of shared (mmap'd) memory", (long long unsigned int) proc_mem.share); | ||
379 | printf ("\t%-50s: %llu\n", "resident set size", (long long unsigned int) proc_mem.rss); | ||
380 | |||
381 | /* get time info */ | ||
382 | glibtop_get_proc_time (&proc_time, pids[i]); | ||
383 | printf ("\tTime information:\n"); | ||
384 | printf ("\t%-50s: %llu\n", "real time accumulated by process", (long long unsigned int) proc_time.rtime); | ||
385 | printf ("\t%-50s: %llu\n", "user-mode CPU time accumulated by process", (long long unsigned int) proc_time.utime); | ||
386 | printf ("\t%-50s: %llu\n", "kernel-mode CPU time accumulated by process", (long long unsigned int) proc_time.stime); | ||
387 | } | ||
388 | g_free (argss); | ||
389 | } | ||
390 | |||
391 | g_free(pids); | ||
392 | pids = NULL; | ||
329 | } | 393 | } |
394 | #endif | ||
330 | 395 | ||
331 | static void | 396 | static void |
332 | load_property (void *cls, | 397 | load_property (void *cls, |
@@ -553,7 +618,7 @@ load_gtop_properties (void) | |||
553 | sp->type = t_continous; | 618 | sp->type = t_continous; |
554 | sp->value_type = v_numeric; | 619 | sp->value_type = v_numeric; |
555 | sp->num_val = (uint64_t) 0; | 620 | sp->num_val = (uint64_t) 0; |
556 | sp->interval = GNUNET_TIME_UNIT_SECONDS; | 621 | sp->interval = GNUNET_TIME_UNIT_MINUTES; |
557 | sp->task_id = GNUNET_SCHEDULER_NO_TASK; | 622 | sp->task_id = GNUNET_SCHEDULER_NO_TASK; |
558 | sp->task = exec_gtop_proc_mon; | 623 | sp->task = exec_gtop_proc_mon; |
559 | sp->task_cls = pp; | 624 | sp->task_cls = pp; |
@@ -681,10 +746,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
681 | } | 746 | } |
682 | 747 | ||
683 | #if HAVE_LIBGTOP | 748 | #if HAVE_LIBGTOP |
684 | if (GNUNET_SYSERR == load_gtop_properties ()) | 749 | if (NULL != glibtop_init()) |
685 | { | 750 | if ( GNUNET_SYSERR == load_gtop_properties ()) |
686 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load gtop properties \n"); | 751 | { |
687 | } | 752 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load gtop properties \n"); |
753 | } | ||
688 | #endif | 754 | #endif |
689 | 755 | ||
690 | /* run properties */ | 756 | /* run properties */ |
diff --git a/src/sysmon/sysmon.conf.in b/src/sysmon/sysmon.conf.in index 208da1ae7..4f692faa2 100644 --- a/src/sysmon/sysmon.conf.in +++ b/src/sysmon/sysmon.conf.in | |||
@@ -3,7 +3,7 @@ AUTOSTART = YES | |||
3 | @UNIXONLY@ PORT = 2104 | 3 | @UNIXONLY@ PORT = 2104 |
4 | HOSTNAME = localhost | 4 | HOSTNAME = localhost |
5 | HOME = $SERVICEHOME | 5 | HOME = $SERVICEHOME |
6 | BINARY = gnunet-daemon-sysmon | 6 | BINARY = gnunet_service_sysmon |
7 | CFGFILE = sysmon-properties.conf | 7 | CFGFILE = sysmon-properties.conf |
8 | UNIXPATH = /tmp/gnunet-service-sysmon.sock | 8 | UNIXPATH = /tmp/gnunet-service-sysmon.sock |
9 | MONITOR_SERVICES = fs transport \ No newline at end of file | 9 | MONITOR_SERVICES = fs transport sysmon \ No newline at end of file |