X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fzone.c;h=bd51c55ec8b53374f2454e2031e4c2e02dd4b4e1;hb=04f27bdd38966e0b826b283d8790ce31fb467929;hp=0e9fee386f8c47749da5d320f407dfce4a56a545;hpb=7b64cc91d3307179557b25b6ece2349a088f4294;p=collectd.git diff --git a/src/zone.c b/src/zone.c index 0e9fee38..bd51c55e 100644 --- a/src/zone.c +++ b/src/zone.c @@ -31,11 +31,10 @@ #endif #include "collectd.h" + #include "common.h" #include "plugin.h" -#include -#include #include #include @@ -49,20 +48,12 @@ typedef struct zone_stats { ushort_t pctmem; } zone_stats_t; -static long pagesize; - -static int zone_init (void) -{ - pagesize = sysconf(_SC_PAGESIZE); - return (0); -} - static int -zone_compare(const zoneid_t *a, const zoneid_t *b) +zone_compare(const void *a, const void *b) { - if (*a == *b) + if (*(const zoneid_t *)a == *(const zoneid_t *)b) return(0); - if (*a < *b) + if (*(const zoneid_t *)a < *(const zoneid_t *)b) return(-1); return(1); } @@ -100,7 +91,6 @@ zone_submit_value(char *zone, gauge_t value) vl.values = values; vl.values_len = 1; /*STATIC_ARRAY_SIZE (values);*/ - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "zone", sizeof (vl.plugin)); sstrncpy (vl.type, "percent", sizeof (vl.type)); sstrncpy (vl.type_instance, zone, sizeof (vl.type_instance)); @@ -143,7 +133,7 @@ zone_submit_values(c_avl_tree_t *tree) while (c_avl_pick (tree, (void **)&zoneid, (void **)&stats) == 0) { if (getzonenamebyid(*zoneid, zonename, sizeof( zonename )) == -1) { - WARNING("zone plugin: error retreiving zonename"); + WARNING("zone plugin: error retrieving zonename"); } else { zone_submit_value(zonename, (gauge_t)FRC2PCT(stats->pctcpu)); } @@ -162,7 +152,7 @@ zone_scandir(DIR *procdir) c_avl_tree_t *tree; zone_stats_t *stats; - if (!(tree=c_avl_create((void *) zone_compare))) { + if (!(tree=c_avl_create(zone_compare))) { WARNING("zone plugin: Failed to create tree"); return(NULL); } @@ -210,6 +200,5 @@ static int zone_read (void) void module_register (void) { - plugin_register_init ("zone", zone_init); plugin_register_read ("zone", zone_read); } /* void module_register */