X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fascent.c;h=e0b6ba2db7d586c46058a26833f0a2709eba0f01;hb=a019b6c8144745db63c599680bd693ac02f11666;hp=b63f73e9539d9d8120825ecf9502712860b7263a;hpb=f499e159c3bb073650ca23bda44b3342466e4c6f;p=collectd.git diff --git a/src/ascent.c b/src/ascent.c index b63f73e9..e0b6ba2d 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -30,23 +30,6 @@ static char *races_list[] = /* {{{ */ { NULL, - "Warrior", /* 1 */ - "Paladin", /* 2 */ - "Hunter", /* 3 */ - "Rogue", /* 4 */ - "Priest", /* 5 */ - NULL, - "Shaman", /* 7 */ - "Mage", /* 8 */ - "Warlock", /* 9 */ - NULL, - "Druid" /* 11 */ -}; /* }}} */ -#define RACES_LIST_LENGTH STATIC_ARRAY_SIZE (races_list) - -static char *classes_list[] = /* {{{ */ -{ - NULL, "Human", /* 1 */ "Orc", /* 2 */ "Dwarf", /* 3 */ @@ -59,6 +42,23 @@ static char *classes_list[] = /* {{{ */ "Bloodelf", /* 10 */ "Draenei" /* 11 */ }; /* }}} */ +#define RACES_LIST_LENGTH STATIC_ARRAY_SIZE (races_list) + +static char *classes_list[] = /* {{{ */ +{ + NULL, + "Warrior", /* 1 */ + "Paladin", /* 2 */ + "Hunter", /* 3 */ + "Rogue", /* 4 */ + "Priest", /* 5 */ + NULL, + "Shaman", /* 7 */ + "Mage", /* 8 */ + "Warlock", /* 9 */ + NULL, + "Druid" /* 11 */ +}; /* }}} */ #define CLASSES_LIST_LENGTH STATIC_ARRAY_SIZE (classes_list) static char *genders_list[] = /* {{{ */ @@ -123,8 +123,8 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */ vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ascent"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "ascent", sizeof (vl.plugin)); if (plugin_instance != NULL) sstrncpy (vl.plugin_instance, plugin_instance, @@ -193,11 +193,12 @@ static int ascent_submit_players (player_stats_t *ps) /* {{{ */ value = ((double) ps->level_sum) / ((double) ps->level_num); ascent_submit_gauge (NULL, "gauge", "avg-level", value); + /* Latency is in ms, but we store seconds. */ if (ps->latency_num <= 0) value = NAN; else - value = ((double) ps->latency_sum) / ((double) ps->latency_num); - ascent_submit_gauge (NULL, "gauge", "avg-latency", value); + value = ((double) ps->latency_sum) / (1000.0 * ((double) ps->latency_num)); + ascent_submit_gauge (NULL, "latency", "average", value); return (0); } /* }}} int ascent_submit_players */ @@ -270,10 +271,12 @@ static int ascent_xml_submit_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */ value = strtod (str_ptr, &end_ptr); if (str_ptr == end_ptr) { + xmlFree(str_ptr); ERROR ("ascent plugin: ascent_xml_submit_gauge: strtod failed."); return (-1); } } + xmlFree(str_ptr); return (ascent_submit_gauge (plugin_instance, type, type_instance, value)); } /* }}} int ascent_xml_submit_gauge */ @@ -299,10 +302,12 @@ static int ascent_xml_read_int (xmlDoc *doc, xmlNode *node, /* {{{ */ value = strtol (str_ptr, &end_ptr, 0); if (str_ptr == end_ptr) { + xmlFree(str_ptr); ERROR ("ascent plugin: ascent_xml_read_int: strtol failed."); return (-1); } } + xmlFree(str_ptr); *ret_value = value; return (0); @@ -392,6 +397,22 @@ static int ascent_xml_status (xmlDoc *doc, xmlNode *node) /* {{{ */ ascent_xml_submit_gauge (doc, child, NULL, "players", "horde"); else if (xmlStrcmp ((const xmlChar *) "qplayers", child->name) == 0) ascent_xml_submit_gauge (doc, child, NULL, "players", "queued"); + else if ((xmlStrcmp ((const xmlChar *) "acceptedconns", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "avglat", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "cdbquerysize", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "cpu", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "fthreads", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "gmcount", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "lastupdate", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "ontime", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "oplayers", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "peakcount", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "platform", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "ram", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "threads", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "uptime", child->name) == 0) + || (xmlStrcmp ((const xmlChar *) "wdbquerysize", child->name) == 0)) + /* ignore */; else { WARNING ("ascent plugin: ascent_xml_status: Unknown tag: %s", child->name);