-#ifdef APCMAIN
-int main(int argc, char **argv)
-{
- /* we are not really going to use this */
- struct apc_detail_s apcups_detail;
-
- if (!*host || strcmp(host, "0.0.0.0") == 0)
- host = "localhost";
-
- do_pthreads_status(host, port, &apcups_detail);
-
- return 0;
-}
-#else
-static void apcups_init (void)
-{
- return;
-}
-
-static int apcups_config (char *key, char *value)
-{
- static char lhost[126];
-
- if (strcasecmp (key, "host") == 0)
- {
- lhost[0] = '\0';
- strcpy(lhost,key);
- host = lhost;
- }
- else if (strcasecmp (key, "Port") == 0)
- {
- int port_tmp = atoi (value);
- if(port_tmp < 1 || port_tmp > 65535) {
- syslog (LOG_WARNING, "apcups: `port' failed: %s",
- value);
- return (1);
- } else {
- port = port_tmp;
- }
- }
- else
- {
- return (-1);
- }
- return(0);
-}
-
-#define BUFSIZE 256
-static void apcups_submit (char *host,
- struct apc_detail_s *apcups_detail)
-{
- char buf[BUFSIZE];
-
- if (snprintf (buf, BUFSIZE, "%u:%f:%f",
- (unsigned int) curtime,
- apcups_detail->linev,
- apcups_detail->outputv) >= BUFSIZE)
- return;
-
- plugin_submit (MODULE_NAME, host, buf);
-}
-
-static void apc_bvolt_submit (char *host,
- struct apc_detail_s *apcups_detail)
-{
- char buf[BUFSIZE];
-
- if (snprintf (buf, BUFSIZE, "%u:%f",
- (unsigned int) curtime,
- apcups_detail->battv) >= BUFSIZE)
- return;
-
- plugin_submit ("apcups_bvolt", host, buf);
-}
-
-static void apc_load_submit (char *host,
- struct apc_detail_s *apcups_detail)
-{
- char buf[BUFSIZE];
-
- if (snprintf (buf, BUFSIZE, "%u:%f",
- (unsigned int) curtime,
- apcups_detail->loadpct) >= BUFSIZE)
- return;
-
- plugin_submit ("apcups_load", host, buf);
-}
-
-static void apc_charge_submit (char *host,
- struct apc_detail_s *apcups_detail)
-{
- char buf[BUFSIZE];
-
- if (snprintf (buf, BUFSIZE, "%u:%f",
- (unsigned int) curtime,
- apcups_detail->bcharge) >= BUFSIZE)
- return;
-
- plugin_submit ("apcups_charge", host, buf);
-}
-
-static void apc_temp_submit (char *host,
- struct apc_detail_s *apcups_detail)