projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sensors plugin: Reload lm_sensors' configuration when changed
[collectd.git]
/
src
/
serial.c
diff --git
a/src/serial.c
b/src/serial.c
index
9d41fde
..
0c6050d
100644
(file)
--- a/
src/serial.c
+++ b/
src/serial.c
@@
-1,6
+1,6
@@
/**
* collectd - src/serial.c
/**
* collectd - src/serial.c
- * Copyright (C) 2005 David Bacher
+ * Copyright (C) 2005
,2006
David Bacher
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@
-21,29
+21,34
@@
* Florian octo Forster <octo at verplant.org>
**/
* Florian octo Forster <octo at verplant.org>
**/
-#include "serial.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
-#if COLLECT_SERIAL
#define MODULE_NAME "serial"
#define MODULE_NAME "serial"
-#include "plugin.h"
-#include "common.h"
+#if defined(KERNEL_LINUX)
+# define SERIAL_HAVE_READ 1
+#else
+# define SERIAL_HAVE_READ 0
+#endif
static char *serial_filename_template = "serial-%s.rrd";
static char *ds_def[] =
{
static char *serial_filename_template = "serial-%s.rrd";
static char *ds_def[] =
{
- "DS:incoming:COUNTER:
25
:0:U",
- "DS:outgoing:COUNTER:
25
:0:U",
+ "DS:incoming:COUNTER:
"COLLECTD_HEARTBEAT"
:0:U",
+ "DS:outgoing:COUNTER:
"COLLECTD_HEARTBEAT"
:0:U",
NULL
};
static int ds_num = 2;
NULL
};
static int ds_num = 2;
-void serial_init (void)
+
static
void serial_init (void)
{
{
+ return;
}
}
-void serial_write (char *host, char *inst, char *val)
+
static
void serial_write (char *host, char *inst, char *val)
{
char file[512];
int status;
{
char file[512];
int status;
@@
-57,13
+62,13
@@
void serial_write (char *host, char *inst, char *val)
rrd_update_file (host, file, val, ds_def, ds_num);
}
rrd_update_file (host, file, val, ds_def, ds_num);
}
+#if SERIAL_HAVE_READ
#define BUFSIZE 512
#define BUFSIZE 512
-void serial_submit (char *device,
+
static
void serial_submit (char *device,
unsigned long long incoming,
unsigned long long outgoing)
{
char buf[BUFSIZE];
unsigned long long incoming,
unsigned long long outgoing)
{
char buf[BUFSIZE];
- time_t curtime = time(NULL);
if (snprintf (buf, BUFSIZE, "%u:%llu:%llu", (unsigned int) curtime,
incoming, outgoing) >= BUFSIZE)
if (snprintf (buf, BUFSIZE, "%u:%llu:%llu", (unsigned int) curtime,
incoming, outgoing) >= BUFSIZE)
@@
-73,7
+78,7
@@
void serial_submit (char *device,
}
#undef BUFSIZE
}
#undef BUFSIZE
-void serial_read (void)
+
static
void serial_read (void)
{
#ifdef KERNEL_LINUX
{
#ifdef KERNEL_LINUX
@@
-97,6
+102,13
@@
void serial_read (void)
{
int have_rx = 0, have_tx = 0;
{
int have_rx = 0, have_tx = 0;
+ /* stupid compiler:
+ * serial.c:87: warning: 'incoming' may be used uninitialized in this function
+ * serial.c:87: warning: 'outgoing' may be used uninitialized in this function
+ */
+ incoming = 0ULL;
+ outgoing = 0ULL;
+
numfields = strsplit (buffer, fields, 16);
if (numfields < 6)
numfields = strsplit (buffer, fields, 16);
if (numfields < 6)
@@
-140,6
+152,9
@@
void serial_read (void)
fclose (fh);
#endif /* KERNEL_LINUX */
}
fclose (fh);
#endif /* KERNEL_LINUX */
}
+#else
+# define serial_read NULL
+#endif /* SERIAL_HAVE_READ */
void module_register (void)
{
void module_register (void)
{
@@
-147,4
+162,3
@@
void module_register (void)
}
#undef MODULE_NAME
}
#undef MODULE_NAME
-#endif /* COLLECT_SERIAL */