50e6fe830348647bbb2818ceb380ecf35e6649e6
1 /*
2 * Copyright (C) 2000-2004 Kern Sibbald
3 * Copyright (C) 1996-99 Andre M. Hedrick <andre@suse.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General
7 * Public License as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
17 * MA 02111-1307, USA.
18 */
20 # include <stdio.h>
21 # include <stdlib.h>
22 # include <stdarg.h>
23 # include <unistd.h>
24 #include <string.h>
25 #include <strings.h>
26 #include <signal.h>
27 #include <ctype.h>
28 #include <syslog.h>
29 #include <limits.h>
30 #include <pwd.h>
31 #include <time.h>
32 #include <errno.h>
33 #include <fcntl.h>
34 #include <setjmp.h>
35 #include <termios.h>
36 #include <netdb.h>
37 #include <sys/ioctl.h>
38 # include <sys/ipc.h>
39 # include <sys/sem.h>
40 # include <sys/shm.h>
41 # include <sys/socket.h>
42 # include <sys/types.h>
43 # include <sys/time.h>
44 # include <time.h>
45 # include <sys/wait.h>
46 #include <netinet/in.h>
47 #include <arpa/inet.h>
49 #include "collectd.h"
50 #include "common.h" /* rrd_update_file */
51 #include "plugin.h" /* plugin_register, plugin_submit */
52 #include "configfile.h" /* cf_register */
54 #define NISPORT 3551
55 #define _(String) (String)
56 #define N_(String) (String)
57 #define MAXSTRING 256
58 #define Error_abort0(fmd) error_out(__FILE__, __LINE__, fmd)
59 #define MODULE_NAME "apcups"
62 /* Prototypes */
63 void generic_error_out(const char *, int , const char *, ...);
65 /* Default values for contacting daemon */
66 static char *host = "localhost";
67 static int port = NISPORT;
69 char argvalue[MAXSTRING];
71 struct sockaddr_in tcp_serv_addr; /* socket information */
72 int net_errno = 0; /* error number -- not yet implemented */
73 char *net_errmsg = NULL; /* pointer to error message */
74 char net_errbuf[256]; /* error message buffer for messages */
76 void (*error_out) (const char *file, int line, const char *fmt, ...) = generic_error_out;
77 void (*error_cleanup) (void) = NULL;
79 /*
80 * The following are only if not compiled to test the module with
81 * its own main.
82 */
83 #ifndef APCMAIN
84 static char *volt_file_template = "apcups_volt-%s.rrd";
85 static char *volt_ds_def[] =
86 {
87 "DS:linev:GAUGE:"COLLECTD_HEARTBEAT":0:250",
88 "DS:outputv:GAUGE:"COLLECTD_HEARTBEAT":0:250",
89 NULL
90 };
91 static int volt_ds_num = 2;
93 static char *bvolt_file_template = "apcups_bvolt-%s.rrd";
94 static char *bvolt_ds_def[] =
95 {
96 "DS:battv:GAUGE:"COLLECTD_HEARTBEAT":0:100",
97 };
98 static int bvolt_ds_num = 1;
100 static char *load_file_template = "apcups_load-%s.rrd";
101 static char *load_ds_def[] =
102 {
103 "DS:loadpct:GAUGE:"COLLECTD_HEARTBEAT":0:120",
104 };
105 static int load_ds_num = 1;
107 static char *charge_file_template = "apcups_charge-%s.rrd";
108 static char *charge_ds_def[] =
109 {
110 "DS:bcharge:GAUGE:"COLLECTD_HEARTBEAT":0:100",
111 };
112 static int charge_ds_num = 1;
114 static char *time_file_template = "apcups_time-%s.rrd";
115 static char *time_ds_def[] =
116 {
117 "DS:timeleft:GAUGE:"COLLECTD_HEARTBEAT":0:100",
118 };
119 static int time_ds_num = 1;
121 static char *temp_file_template = "apcups_temp-%s.rrd";
122 static char *temp_ds_def[] =
123 {
124 "DS:itemp:GAUGE:"COLLECTD_HEARTBEAT":0:100",
125 };
126 static int temp_ds_num = 1;
128 static char *freq_file_template = "apcups_freq-%s.rrd";
129 static char *freq_ds_def[] =
130 {
131 "DS:linefreq:GAUGE:"COLLECTD_HEARTBEAT":0:65",
132 };
133 static int freq_ds_num = 1;
135 static char *config_keys[] =
136 {
137 "Host",
138 "Port",
139 NULL
140 };
141 static int config_keys_num = 2;
143 #endif /* ifndef APCMAIN */
145 struct apc_detail_s {
146 float linev;
147 float loadpct;
148 float bcharge;
149 float timeleft;
150 float outputv;
151 float itemp;
152 float battv;
153 float linefreq;
154 };
156 /* Guarantee that the string is properly terminated */
157 char *astrncpy(char *dest, const char *src, int maxlen)
158 {
159 strncpy(dest, src, maxlen - 1);
160 dest[maxlen - 1] = 0;
161 return dest;
162 }
165 #define BIG_BUF 5000
167 /* Implement snprintf */
168 int asnprintf(char *str, size_t size, const char *fmt, ...)
169 {
170 #ifdef HAVE_VSNPRINTF
171 va_list arg_ptr;
172 int len;
174 va_start(arg_ptr, fmt);
175 len = vsnprintf(str, size, fmt, arg_ptr);
176 va_end(arg_ptr);
178 str[size - 1] = 0;
179 return len;
181 #else
183 va_list arg_ptr;
184 int len;
185 char *buf;
187 buf = (char *)malloc(BIG_BUF);
189 va_start(arg_ptr, fmt);
190 len = vsprintf(buf, fmt, arg_ptr);
191 va_end(arg_ptr);
193 if (len >= BIG_BUF)
194 Error_abort0(_("Buffer overflow.\n"));
196 memcpy(str, buf, size);
197 str[size - 1] = 0;
199 free(buf);
200 return len;
201 #endif
202 }
204 /* Implement vsnprintf() */
205 int avsnprintf(char *str, size_t size, const char *format, va_list ap)
206 {
207 #ifdef HAVE_VSNPRINTF
208 int len;
210 len = vsnprintf(str, size, format, ap);
211 str[size - 1] = 0;
213 return len;
215 #else
217 int len;
218 char *buf;
220 buf = (char *)malloc(BIG_BUF);
222 len = vsprintf(buf, format, ap);
223 if (len >= BIG_BUF)
224 Error_abort0(_("Buffer overflow.\n"));
226 memcpy(str, buf, size);
227 str[size - 1] = 0;
229 free(buf);
230 return len;
231 #endif
232 }
234 /*
235 * Subroutine normally called by macro error_abort() to print
236 * FATAL ERROR message and supplied error message
237 */
238 void generic_error_out(const char *file, int line, const char *fmt, ...)
239 {
240 char buf[256];
241 va_list arg_ptr;
242 int i;
244 asnprintf(buf, sizeof(buf), _("FATAL ERROR in %s at line %d\n"), file, line);
245 i = strlen(buf);
246 va_start(arg_ptr, fmt);
247 avsnprintf((char *)&buf[i], sizeof(buf) - i, (char *)fmt, arg_ptr);
248 va_end(arg_ptr);
249 fprintf(stdout, "%s", buf);
251 if (error_cleanup)
252 error_cleanup();
254 exit(1);
255 }
257 /*
258 * Read nbytes from the network.
259 * It is possible that the total bytes require in several
260 * read requests
261 */
262 static int read_nbytes(int fd, char *ptr, int nbytes)
263 {
264 int nleft, nread;
267 nleft = nbytes;
269 while (nleft > 0) {
270 do {
271 nread = read(fd, ptr, nleft);
272 } while (nread == -1 && (errno == EINTR || errno == EAGAIN));
274 if (nread <= 0) {
275 net_errno = errno;
276 return (nread); /* error, or EOF */
277 }
279 nleft -= nread;
280 ptr += nread;
281 }
283 return (nbytes - nleft); /* return >= 0 */
284 }
287 /*
288 * Write nbytes to the network.
289 * It may require several writes.
290 */
291 static int write_nbytes(int fd, char *ptr, int nbytes)
292 {
293 int nleft, nwritten;
295 nleft = nbytes;
296 while (nleft > 0) {
297 nwritten = write(fd, ptr, nleft);
299 if (nwritten <= 0) {
300 net_errno = errno;
301 return (nwritten); /* error */
302 }
304 nleft -= nwritten;
305 ptr += nwritten;
306 }
308 return (nbytes - nleft);
309 }
312 /* Close the network connection */
313 void net_close(int sockfd)
314 {
315 short pktsiz = 0;
317 /* send EOF sentinel */
318 write_nbytes(sockfd, (char *)&pktsiz, sizeof(short));
319 close(sockfd);
320 }
323 /*
324 * Open a TCP connection to the UPS network server
325 * Returns -1 on error
326 * Returns socket file descriptor otherwise
327 */
328 int net_open(char *host, char *service, int port)
329 {
330 int sockfd;
331 struct hostent *hp;
332 unsigned int inaddr; /* Careful here to use unsigned int for */
333 /* compatibility with Alpha */
335 /*
336 * Fill in the structure serv_addr with the address of
337 * the server that we want to connect with.
338 */
339 memset((char *)&tcp_serv_addr, 0, sizeof(tcp_serv_addr));
340 tcp_serv_addr.sin_family = AF_INET;
341 tcp_serv_addr.sin_port = htons(port);
343 if ((inaddr = inet_addr(host)) != INADDR_NONE) {
344 tcp_serv_addr.sin_addr.s_addr = inaddr;
345 } else {
346 if ((hp = gethostbyname(host)) == NULL) {
347 net_errmsg = "tcp_open: hostname error\n";
348 return -1;
349 }
351 if (hp->h_length != sizeof(inaddr) || hp->h_addrtype != AF_INET) {
352 net_errmsg = "tcp_open: funny gethostbyname value\n";
353 return -1;
354 }
356 tcp_serv_addr.sin_addr.s_addr = *(unsigned int *)hp->h_addr;
357 }
360 /* Open a TCP socket */
361 if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
362 net_errmsg = "tcp_open: cannot open stream socket\n";
363 return -1;
364 }
366 /* connect to server */
367 #if defined HAVE_OPENBSD_OS || defined HAVE_FREEBSD_OS
368 /*
369 * Work around a bug in OpenBSD & FreeBSD userspace pthreads
370 * implementations. Rationale is the same as described above.
371 */
372 fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL));
373 #endif
375 if (connect(sockfd, (struct sockaddr *)&tcp_serv_addr, sizeof(tcp_serv_addr)) < 0) {
376 asnprintf(net_errbuf, sizeof(net_errbuf),
377 _("tcp_open: cannot connect to server %s on port %d.\n"
378 "ERR=%s\n"), host, port, strerror(errno));
379 net_errmsg = net_errbuf;
380 close(sockfd);
381 return -1;
382 }
384 return sockfd;
385 }
389 /*
390 * Receive a message from the other end. Each message consists of
391 * two packets. The first is a header that contains the size
392 * of the data that follows in the second packet.
393 * Returns number of bytes read
394 * Returns 0 on end of file
395 * Returns -1 on hard end of file (i.e. network connection close)
396 * Returns -2 on error
397 */
398 int net_recv(int sockfd, char *buff, int maxlen)
399 {
400 int nbytes;
401 short pktsiz;
403 /* get data size -- in short */
404 if ((nbytes = read_nbytes(sockfd, (char *)&pktsiz, sizeof(short))) <= 0) {
405 /* probably pipe broken because client died */
406 return -1; /* assume hard EOF received */
407 }
408 if (nbytes != sizeof(short))
409 return -2;
411 pktsiz = ntohs(pktsiz); /* decode no. of bytes that follow */
412 if (pktsiz > maxlen) {
413 net_errmsg = "net_recv: record length too large\n";
414 return -2;
415 }
416 if (pktsiz == 0)
417 return 0; /* soft EOF */
419 /* now read the actual data */
420 if ((nbytes = read_nbytes(sockfd, buff, pktsiz)) <= 0) {
421 net_errmsg = "net_recv: read_nbytes error\n";
422 return -2;
423 }
424 if (nbytes != pktsiz) {
425 net_errmsg = "net_recv: error in read_nbytes\n";
426 return -2;
427 }
429 return (nbytes); /* return actual length of message */
430 }
432 /*
433 * Send a message over the network. The send consists of
434 * two network packets. The first is sends a short containing
435 * the length of the data packet which follows.
436 * Returns number of bytes sent
437 * Returns -1 on error
438 */
439 int net_send(int sockfd, char *buff, int len)
440 {
441 int rc;
442 short pktsiz;
444 /* send short containing size of data packet */
445 pktsiz = htons((short)len);
446 rc = write_nbytes(sockfd, (char *)&pktsiz, sizeof(short));
447 if (rc != sizeof(short)) {
448 net_errmsg = "net_send: write_nbytes error of length prefix\n";
449 return -1;
450 }
452 /* send data packet */
453 rc = write_nbytes(sockfd, buff, len);
454 if (rc != len) {
455 net_errmsg = "net_send: write_nbytes error\n";
456 return -1;
457 }
459 return rc;
460 }
463 /* Get and print status from apcupsd NIS server */
464 static void do_pthreads_status(char *host, int port, struct apc_detail_s *apcups_detail)
465 {
466 int sockfd, n;
467 char recvline[MAXSTRING + 1];
468 char *tokptr;
470 if ((sockfd = net_open(host, NULL, port)) < 0)
471 Error_abort0(net_errmsg);
473 net_send(sockfd, "status", 6);
475 while ((n = net_recv(sockfd, recvline, sizeof(recvline))) > 0) {
476 recvline[n] = 0;
477 #ifdef APCMAIN
478 fputs(recvline, stdout);
479 int printit = 1;
480 #else
481 int printit = 0;
482 #endif /* ifdef APCMAIN */
484 tokptr = strtok(recvline,":");
485 while(tokptr != NULL) {
486 /* Look for Limit_Add */
487 if(strncmp("LINEV",tokptr,5) == 0) {
488 if(printit) fprintf(stdout," Found LINEV.\n");
489 tokptr = strtok(NULL," \t");
490 if(tokptr == NULL) continue;
491 if(printit) fprintf(stdout," Value %s.\n",tokptr);
492 apcups_detail->linev = atof (tokptr);
493 }else if(strncmp("BATTV",tokptr,5) == 0) {
494 if(printit) fprintf(stdout," Found BATTV.\n");
495 tokptr = strtok(NULL," \t");
496 if(tokptr == NULL) continue;
497 if(printit) fprintf(stdout," Value %s.\n",tokptr);
498 apcups_detail->battv = atof (tokptr);
499 }else if(strncmp("ITEMP",tokptr,5) == 0) {
500 if(printit) fprintf(stdout," Found ITEMP.\n");
501 tokptr = strtok(NULL," \t");
502 if(tokptr == NULL) continue;
503 if(printit) fprintf(stdout," Value %s.\n",tokptr);
504 apcups_detail->itemp = atof (tokptr);
505 }else if(strncmp("LOADPCT",tokptr,7) == 0) {
506 if(printit) fprintf(stdout," Found LOADPCT.\n");
507 tokptr = strtok(NULL," \t");
508 if(tokptr == NULL) continue;
509 if(printit) fprintf(stdout," Value %s.\n",tokptr);
510 apcups_detail->loadpct = atof (tokptr);
511 }else if(strncmp("BCHARGE",tokptr,7) == 0) {
512 if(printit) fprintf(stdout," Found BCHARGE.\n");
513 tokptr = strtok(NULL," \t");
514 if(tokptr == NULL) continue;
515 if(printit) fprintf(stdout," Value %s.\n",tokptr);
516 apcups_detail->bcharge = atof (tokptr);
517 }else if(strncmp("OUTPUTV",tokptr,7) == 0) {
518 if(printit) fprintf(stdout," Found OUTPUTV.\n");
519 tokptr = strtok(NULL," \t");
520 if(tokptr == NULL) continue;
521 if(printit) fprintf(stdout," Value %s.\n",tokptr);
522 apcups_detail->outputv = atof (tokptr);
523 }else if(strncmp("LINEFREQ",tokptr,8) == 0) {
524 if(printit) fprintf(stdout," Found LINEFREQ.\n");
525 tokptr = strtok(NULL," \t");
526 if(tokptr == NULL) continue;
527 if(printit) fprintf(stdout," Value %s.\n",tokptr);
528 apcups_detail->linefreq = atof (tokptr);
529 }else if(strncmp("TIMELEFT",tokptr,8) == 0) {
530 if(printit) fprintf(stdout," Found TIMELEFT.\n");
531 tokptr = strtok(NULL," \t");
532 if(tokptr == NULL) continue;
533 if(printit) fprintf(stdout," Value %s.\n",tokptr);
534 apcups_detail->timeleft = atof (tokptr);
535 } /* */
536 tokptr = strtok(NULL,":");
537 }
538 }
540 if (n < 0)
541 Error_abort0(net_errmsg);
543 net_close(sockfd);
544 }
546 #ifdef APCMAIN
547 int main(int argc, char **argv)
548 {
549 /* we are not really going to use this */
550 struct apc_detail_s apcups_detail;
552 if (!*host || strcmp(host, "0.0.0.0") == 0)
553 host = "localhost";
555 do_pthreads_status(host, port, &apcups_detail);
557 return 0;
558 }
559 #else
560 static void apcups_init (void)
561 {
562 return;
563 }
565 static int apcups_config (char *key, char *value)
566 {
567 static char lhost[126];
569 if (strcasecmp (key, "host") == 0)
570 {
571 lhost[0] = '\0';
572 strcpy(lhost,key);
573 host = lhost;
574 }
575 else if (strcasecmp (key, "Port") == 0)
576 {
577 int port_tmp = atoi (value);
578 if(port_tmp < 1 || port_tmp > 65535) {
579 syslog (LOG_WARNING, "apcups: `port' failed: %s",
580 value);
581 return (1);
582 } else {
583 port = port_tmp;
584 }
585 }
586 else
587 {
588 return (-1);
589 }
590 return(0);
591 }
593 #define BUFSIZE 256
594 static void apcups_submit (char *host,
595 struct apc_detail_s *apcups_detail)
596 {
597 char buf[BUFSIZE];
599 if (snprintf (buf, BUFSIZE, "%u:%f:%f",
600 (unsigned int) curtime,
601 apcups_detail->linev,
602 apcups_detail->outputv) >= BUFSIZE)
603 return;
605 plugin_submit (MODULE_NAME, host, buf);
606 }
608 static void apc_bvolt_submit (char *host,
609 struct apc_detail_s *apcups_detail)
610 {
611 char buf[BUFSIZE];
613 if (snprintf (buf, BUFSIZE, "%u:%f",
614 (unsigned int) curtime,
615 apcups_detail->battv) >= BUFSIZE)
616 return;
618 plugin_submit ("apcups_bvolt", host, buf);
619 }
621 static void apc_load_submit (char *host,
622 struct apc_detail_s *apcups_detail)
623 {
624 char buf[BUFSIZE];
626 if (snprintf (buf, BUFSIZE, "%u:%f",
627 (unsigned int) curtime,
628 apcups_detail->loadpct) >= BUFSIZE)
629 return;
631 plugin_submit ("apcups_load", host, buf);
632 }
634 static void apc_charge_submit (char *host,
635 struct apc_detail_s *apcups_detail)
636 {
637 char buf[BUFSIZE];
639 if (snprintf (buf, BUFSIZE, "%u:%f",
640 (unsigned int) curtime,
641 apcups_detail->bcharge) >= BUFSIZE)
642 return;
644 plugin_submit ("apcups_charge", host, buf);
645 }
647 static void apc_temp_submit (char *host,
648 struct apc_detail_s *apcups_detail)
649 {
650 char buf[BUFSIZE];
652 if (snprintf (buf, BUFSIZE, "%u:%f",
653 (unsigned int) curtime,
654 apcups_detail->itemp) >= BUFSIZE)
655 return;
657 plugin_submit ("apcups_temp", host, buf);
658 }
660 static void apc_time_submit (char *host,
661 struct apc_detail_s *apcups_detail)
662 {
663 char buf[BUFSIZE];
665 if (snprintf (buf, BUFSIZE, "%u:%f",
666 (unsigned int) curtime,
667 apcups_detail->timeleft) >= BUFSIZE)
668 return;
670 plugin_submit ("apcups_time", host, buf);
671 }
673 static void apc_freq_submit (char *host,
674 struct apc_detail_s *apcups_detail)
675 {
676 char buf[BUFSIZE];
678 if (snprintf (buf, BUFSIZE, "%u:%f",
679 (unsigned int) curtime,
680 apcups_detail->linefreq) >= BUFSIZE)
681 return;
683 plugin_submit ("apcups_freq", host, buf);
684 }
685 #undef BUFSIZE
687 static void apcups_read (void)
688 {
689 struct apc_detail_s apcups_detail;
691 apcups_detail.linev = 0.0;
692 apcups_detail.loadpct = 0.0;
693 apcups_detail.bcharge = 0.0;
694 apcups_detail.timeleft = 0.0;
695 apcups_detail.outputv = 0.0;
696 apcups_detail.itemp = 0.0;
697 apcups_detail.battv = 0.0;
698 apcups_detail.linefreq = 0.0;
701 if (!*host || strcmp(host, "0.0.0.0") == 0)
702 host = "localhost";
704 do_pthreads_status(host, port, &apcups_detail);
706 apcups_submit (host, &apcups_detail);
707 apc_bvolt_submit (host, &apcups_detail);
708 apc_load_submit (host, &apcups_detail);
709 apc_charge_submit (host, &apcups_detail);
710 apc_temp_submit (host, &apcups_detail);
711 apc_time_submit (host, &apcups_detail);
712 apc_freq_submit (host, &apcups_detail);
713 }
716 static void apcups_write (char *host, char *inst, char *val)
717 {
718 char file[512];
719 int status;
721 status = snprintf (file, 512, volt_file_template, inst);
722 if (status < 1)
723 return;
724 else if (status >= 512)
725 return;
727 rrd_update_file (host, file, val, volt_ds_def, volt_ds_num);
728 }
730 static void apc_bvolt_write (char *host, char *inst, char *val)
731 {
732 char file[512];
733 int status;
735 status = snprintf (file, 512, bvolt_file_template, inst);
736 if (status < 1)
737 return;
738 else if (status >= 512)
739 return;
741 rrd_update_file (host, file, val, bvolt_ds_def, bvolt_ds_num);
742 }
744 static void apc_load_write (char *host, char *inst, char *val)
745 {
746 char file[512];
747 int status;
749 status = snprintf (file, 512, load_file_template, inst);
750 if (status < 1)
751 return;
752 else if (status >= 512)
753 return;
755 rrd_update_file (host, file, val, load_ds_def, load_ds_num);
756 }
758 static void apc_charge_write (char *host, char *inst, char *val)
759 {
760 char file[512];
761 int status;
763 status = snprintf (file, 512, charge_file_template, inst);
764 if (status < 1)
765 return;
766 else if (status >= 512)
767 return;
769 rrd_update_file (host, file, val, charge_ds_def, charge_ds_num);
770 }
772 static void apc_temp_write (char *host, char *inst, char *val)
773 {
774 char file[512];
775 int status;
777 status = snprintf (file, 512, temp_file_template, inst);
778 if (status < 1)
779 return;
780 else if (status >= 512)
781 return;
783 rrd_update_file (host, file, val, temp_ds_def, temp_ds_num);
784 }
786 static void apc_time_write (char *host, char *inst, char *val)
787 {
788 char file[512];
789 int status;
791 status = snprintf (file, 512, time_file_template, inst);
792 if (status < 1)
793 return;
794 else if (status >= 512)
795 return;
797 rrd_update_file (host, file, val, time_ds_def, time_ds_num);
798 }
800 static void apc_freq_write (char *host, char *inst, char *val)
801 {
802 char file[512];
803 int status;
805 status = snprintf (file, 512, freq_file_template, inst);
806 if (status < 1)
807 return;
808 else if (status >= 512)
809 return;
811 rrd_update_file (host, file, val, freq_ds_def, freq_ds_num);
812 }
814 void module_register (void)
815 {
816 plugin_register (MODULE_NAME, apcups_init, apcups_read, apcups_write);
817 plugin_register ("apcups_bvolt", NULL, NULL, apc_bvolt_write);
818 plugin_register ("apcups_load", NULL, NULL, apc_load_write);
819 plugin_register ("apcups_charge", NULL, NULL, apc_charge_write);
820 plugin_register ("apcups_temp", NULL, NULL, apc_temp_write);
821 plugin_register ("apcups_time", NULL, NULL, apc_time_write);
822 plugin_register ("apcups_freq", NULL, NULL, apc_freq_write);
823 cf_register (MODULE_NAME, apcups_config, config_keys, config_keys_num);
824 }
826 #endif /* ifdef APCMAIN */
827 #undef MODULE_NAME