#include "plugin.h"
#include <dirent.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <syslog.h>
#include <sys/types.h>
-#include <unistd.h>
#define BUFSIZE 512
DIR *proc;
struct dirent *dent; /* 42 */
- static complain_t complain_obj;
-
errno = 0;
if (NULL == (proc = opendir (PROCDIR)))
{
- plugin_complain (LOG_ERR, &complain_obj, "vserver plugin: "
- "fopen (%s) failed: %s", PROCDIR, strerror (errno));
+ char errbuf[1024];
+ ERROR ("vserver plugin: fopen (%s): %s", PROCDIR,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
- plugin_relief (LOG_NOTICE, &complain_obj, "vserver plugin: "
- "fopen (%s) succeeded.", PROCDIR);
while (NULL != (dent = readdir (proc)))
{
continue;
if (NULL == (fh = fopen (file, "r")))
- syslog (LOG_ERR, "Cannot open '%s': %s", file, strerror (errno));
+ {
+ char errbuf[1024];
+ ERROR ("Cannot open '%s': %s", file,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
continue;
if (NULL == (fh = fopen (file, "r")))
- syslog (LOG_ERR, "Cannot open '%s': %s", file, strerror (errno));
+ {
+ char errbuf[1024];
+ ERROR ("Cannot open '%s': %s", file,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
continue;
if (NULL == (fh = fopen (file, "r")))
- syslog (LOG_ERR, "Cannot open '%s': %s", file, strerror (errno));
+ {
+ char errbuf[1024];
+ ERROR ("Cannot open '%s': %s", file,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
} /* int vserver_read */
#endif /* VSERVER_HAVE_READ */
-void module_register (void)
+void module_register (modreg_e load)
{
- plugin_register_data_set (&octets_ds);
- plugin_register_data_set (&load_ds);
- plugin_register_data_set (&threads_ds);
- plugin_register_data_set (&processes_ds);
- plugin_register_data_set (&memory_ds);
+ if (load & MR_DATASETS)
+ {
+ plugin_register_data_set (&octets_ds);
+ plugin_register_data_set (&load_ds);
+ plugin_register_data_set (&threads_ds);
+ plugin_register_data_set (&processes_ds);
+ plugin_register_data_set (&memory_ds);
+ }
#if VSERVER_HAVE_READ
- plugin_register_init ("vserver", vserver_init);
- plugin_register_read ("vserver", vserver_read);
+ if (load & MR_READ)
+ {
+ plugin_register_init ("vserver", vserver_init);
+ plugin_register_read ("vserver", vserver_read);
+ }
#endif /* VSERVER_HAVE_READ */
} /* void module_register(void) */