*
* 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
*
* $collectd: parts of tcpconns.c, 2008/08/08 03:48:30 Michael Stapelberg $
* $OpenBSD: inet.c,v 1.100 2007/06/19 05:28:30 ray Exp $
*
* $collectd: parts of tcpconns.c, 2008/08/08 03:48:30 Michael Stapelberg $
* $OpenBSD: inet.c,v 1.100 2007/06/19 05:28:30 ray Exp $
-#if !KERNEL_LINUX && !HAVE_SYSCTLBYNAME && !__OpenBSD__
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+#undef HAVE_SYSCTLBYNAME /* force HAVE_LIBKVM_NLIST path */
+#endif
+
+#if !KERNEL_LINUX && !HAVE_SYSCTLBYNAME && !HAVE_LIBKVM_NLIST
# include <netinet/in_pcb.h>
# include <netinet/tcp.h>
# include <netinet/tcp_timer.h>
# include <netinet/in_pcb.h>
# include <netinet/tcp.h>
# include <netinet/tcp_timer.h>
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "tcpconns", sizeof (vl.plugin));
sstrncpy (vl.type, "tcp_connections", sizeof (vl.type));
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "tcpconns", sizeof (vl.plugin));
sstrncpy (vl.type, "tcp_connections", sizeof (vl.type));
|| (pe->flags & PORT_COLLECT_LOCAL))
{
ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
|| (pe->flags & PORT_COLLECT_LOCAL))
{
ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
if (pe->flags & PORT_COLLECT_REMOTE)
{
ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
if (pe->flags & PORT_COLLECT_REMOTE)
{
ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
port_local, port_remote, tcp_state[state]);
pe = conn_get_port_entry (port_local, 0 /* no create */);
port_local, port_remote, tcp_state[state]);
pe = conn_get_port_entry (port_local, 0 /* no create */);
static int conn_config (const char *key, const char *value)
{
if (strcasecmp (key, "ListeningPorts") == 0)
{
static int conn_config (const char *key, const char *value)
{
if (strcasecmp (key, "ListeningPorts") == 0)
{
- if ((strcasecmp (value, "Yes") == 0)
- || (strcasecmp (value, "True") == 0)
- || (strcasecmp (value, "On") == 0))
if (!(inpcb.inp_flags & INP_IPV6)
&& (inet_lnaof(inpcb.inp_laddr) == INADDR_ANY))
continue;
if ((inpcb.inp_flags & INP_IPV6)
&& IN6_IS_ADDR_UNSPECIFIED (&inpcb.inp_laddr6))
continue;
if (!(inpcb.inp_flags & INP_IPV6)
&& (inet_lnaof(inpcb.inp_laddr) == INADDR_ANY))
continue;
if ((inpcb.inp_flags & INP_IPV6)
&& IN6_IS_ADDR_UNSPECIFIED (&inpcb.inp_laddr6))
continue;
kread ((u_long) inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb));
conn_handle_ports (ntohs(inpcb.inp_lport), ntohs(inpcb.inp_fport), tcpcb.t_state);
kread ((u_long) inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb));
conn_handle_ports (ntohs(inpcb.inp_lport), ntohs(inpcb.inp_fport), tcpcb.t_state);
plugin_register_init ("tcpconns", conn_init);
#endif
plugin_register_read ("tcpconns", conn_read);
plugin_register_init ("tcpconns", conn_init);
#endif
plugin_register_read ("tcpconns", conn_read);