src/utils_cmd_flush.c: Add the `identifier' option.
[collectd.git] / src / ascent.c
index 75d5cb6..6b4f21f 100644 (file)
@@ -130,10 +130,12 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */
     sstrncpy (vl.plugin_instance, plugin_instance,
         sizeof (vl.plugin_instance));
 
+  sstrncpy (vl.type, type, sizeof (vl.type));
+
   if (type_instance != NULL)
     sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
-  plugin_dispatch_values (type, &vl);
+  plugin_dispatch_values (&vl);
   return (0);
 } /* }}} int ascent_submit_gauge */
 
@@ -193,11 +195,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 */
@@ -533,7 +536,7 @@ static int ascent_init (void) /* {{{ */
   {
     int status;
 
-    status = snprintf (credentials, sizeof (credentials), "%s:%s",
+    status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
         user, (pass == NULL) ? "" : pass);
     if (status >= sizeof (credentials))
     {
@@ -541,7 +544,6 @@ static int ascent_init (void) /* {{{ */
           "credentials have been truncated.");
       return (-1);
     }
-    credentials[sizeof (credentials) - 1] = '\0';
 
     curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
   }