#include "common.h"
#include "plugin.h"
-#if defined(KERNEL_LINUX)
-# define SERIAL_HAVE_READ 1
-#else
-# define SERIAL_HAVE_READ 0
+#if !KERNEL_LINUX
+# error "No applicable input method."
#endif
-static data_source_t octets_dsrc[2] =
-{
- {"rx", DS_TYPE_COUNTER, 0, 4294967295.0},
- {"tx", DS_TYPE_COUNTER, 0, 4294967295.0}
-};
-
-static data_set_t octets_ds =
-{
- "serial_octets", 2, octets_dsrc
-};
-
-#if SERIAL_HAVE_READ
static void serial_submit (const char *type_instance,
counter_t rx, counter_t tx)
{
vl.values = values;
vl.values_len = 2;
- vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "serial");
- strncpy (vl.type_instance, type_instance,
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "serial", sizeof (vl.plugin));
+ sstrncpy (vl.type, "serial_octets", sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance,
sizeof (vl.type_instance));
- plugin_dispatch_values ("serial_octets", &vl);
+ plugin_dispatch_values (&vl);
}
static int serial_read (void)
{
-#ifdef KERNEL_LINUX
FILE *fh;
char buffer[1024];
fclose (fh);
return (0);
-#endif /* KERNEL_LINUX */
} /* int serial_read */
-#endif /* SERIAL_HAVE_READ */
-void module_register (modreg_e load)
+void module_register (void)
{
- if (load & MR_DATASETS)
- plugin_register_data_set (&octets_ds);
-
-#if SERIAL_HAVE_READ
- if (load & MR_READ)
- plugin_register_read ("serial", serial_read);
-#endif /* SERIAL_HAVE_READ */
+ plugin_register_read ("serial", serial_read);
} /* void module_register */