- toksaveptr = NULL;
- tokptr = strtok_r (recvline, " :\t", &toksaveptr);
- while (tokptr != NULL)
- {
- key = tokptr;
- if ((tokptr = strtok_r (NULL, " :\t", &toksaveptr)) == NULL)
- continue;
- value = atof (tokptr);
-
- PRINT_VALUE (key, value);
-
- if (strcmp ("LINEV", key) == 0)
- apcups_detail->linev = value;
- else if (strcmp ("BATTV", key) == 0)
- apcups_detail->battv = value;
- else if (strcmp ("ITEMP", key) == 0)
- apcups_detail->itemp = value;
- else if (strcmp ("LOADPCT", key) == 0)
- apcups_detail->loadpct = value;
- else if (strcmp ("BCHARGE", key) == 0)
- apcups_detail->bcharge = value;
- else if (strcmp ("OUTPUTV", key) == 0)
- apcups_detail->outputv = value;
- else if (strcmp ("LINEFREQ", key) == 0)
- apcups_detail->linefreq = value;
- else if (strcmp ("TIMELEFT", key) == 0)
- {
- /* Convert minutes to seconds if requested by
- * the user. */
- if (conf_report_seconds)
- value *= 60.0;
- apcups_detail->timeleft = value;
- }
-
- tokptr = strtok_r (NULL, ":", &toksaveptr);
- } /* while (tokptr != NULL) */
- }
- status = errno; /* save errno, net_shutdown() may re-set it. */
-
- if (!conf_persistent_conn)
- net_shutdown (&global_sockfd);
-
- if (n < 0)
- {
- char errbuf[1024];
- ERROR ("apcups plugin: Reading from socket failed: %s",
- sstrerror (status, errbuf, sizeof (errbuf)));
- return (-1);
- }
-
- return (0);
+ toksaveptr = NULL;
+ tokptr = strtok_r(recvline, " :\t", &toksaveptr);
+ while (tokptr != NULL) {
+ char *key = tokptr;
+ if ((tokptr = strtok_r(NULL, " :\t", &toksaveptr)) == NULL)
+ continue;
+
+ gauge_t value;
+ if (strtogauge(tokptr, &value) != 0)
+ continue;
+
+ PRINT_VALUE(key, value);
+
+ if (strcmp("LINEV", key) == 0)
+ apcups_detail->linev = value;
+ else if (strcmp("BATTV", key) == 0)
+ apcups_detail->battv = value;
+ else if (strcmp("ITEMP", key) == 0)
+ apcups_detail->itemp = value;
+ else if (strcmp("LOADPCT", key) == 0)
+ apcups_detail->loadpct = value;
+ else if (strcmp("BCHARGE", key) == 0)
+ apcups_detail->bcharge = value;
+ else if (strcmp("OUTPUTV", key) == 0)
+ apcups_detail->outputv = value;
+ else if (strcmp("LINEFREQ", key) == 0)
+ apcups_detail->linefreq = value;
+ else if (strcmp("TIMELEFT", key) == 0) {
+ /* Convert minutes to seconds if requested by
+ * the user. */
+ if (conf_report_seconds)
+ value *= 60.0;
+ apcups_detail->timeleft = value;
+ }
+
+ tokptr = strtok_r(NULL, ":", &toksaveptr);
+ } /* while (tokptr != NULL) */
+ }
+ status = errno; /* save errno, net_shutdown() may re-set it. */
+
+ if (!conf_persistent_conn)
+ net_shutdown(&global_sockfd);
+
+ if (n < 0) {
+ char errbuf[1024];
+ ERROR("apcups plugin: Reading from socket failed: %s",
+ sstrerror(status, errbuf, sizeof(errbuf)));
+ return (-1);
+ }
+
+ return (0);