projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
network plugin: Use `memcpy' when parsing packages, too.
[collectd.git]
/
src
/
tcpconns.c
diff --git
a/src/tcpconns.c
b/src/tcpconns.c
index
74874ae
..
fdf7ec1
100644
(file)
--- a/
src/tcpconns.c
+++ b/
src/tcpconns.c
@@
-33,6
+33,19
@@
#elif HAVE_SYSCTLBYNAME
# include <sys/socketvar.h>
# include <sys/sysctl.h>
#elif HAVE_SYSCTLBYNAME
# include <sys/socketvar.h>
# include <sys/sysctl.h>
+
+/* Some includes needed for compiling on FreeBSD */
+#include <sys/time.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+
# include <net/route.h>
# include <netinet/in.h>
# include <netinet/in_systm.h>
# include <net/route.h>
# include <netinet/in.h>
# include <netinet/in_systm.h>
@@
-336,12
+349,7
@@
static int conn_read_file (const char *file)
fh = fopen (file, "r");
if (fh == NULL)
fh = fopen (file, "r");
if (fh == NULL)
- {
- char errbuf[1024];
- ERROR ("tcpconns plugin: fopen (%s) failed: %s",
- file, sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
return (-1);
- }
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
@@
-411,12
+419,25
@@
static int conn_init (void)
static int conn_read (void)
{
static int conn_read (void)
{
+ int errors_num = 0;
+
conn_reset_port_entry ();
conn_reset_port_entry ();
- conn_read_file ("/proc/net/tcp");
- conn_read_file ("/proc/net/tcp6");
+ if (conn_read_file ("/proc/net/tcp") != 0)
+ errors_num++;
+ if (conn_read_file ("/proc/net/tcp6") != 0)
+ errors_num++;
- conn_submit_all ();
+ if (errors_num < 2)
+ {
+ conn_submit_all ();
+ }
+ else
+ {
+ ERROR ("tcpconns plugin: Neither /proc/net/tcp nor /proc/net/tcp6 "
+ "coult be read.");
+ return (-1);
+ }
return (0);
} /* int conn_read */
return (0);
} /* int conn_read */