[collectd] tcp connection stats on freebsd 7x (specifically 7.2)

Brett Hawn brett.hawn at gmail.com
Wed Jun 10 04:27:47 CEST 2009


Has anyone gotten tcpconns module working for freebsd 7x?  I've mucked 
around with a bit but so far have had no luck
figuring out what's going on but so far I'm still coming up with no joy.

Here's the rather simplistic config:

LoadPlugin tcpconns

<Plugin "tcpconns">
  ListeningPorts false
  RemotePort "80"
  LocalPort "80"
</Plugin>


Below is how I changed tcpconn.c to try and figure out what's going on, 
but it's not actually failing, just not giving stats either, I'm being 
sent 0.00 every time



static int conn_read (void)
{
  char *buffer;
  size_t buffer_len;

  struct xinpgen *in_orig;
  struct xinpgen *in_ptr;

  conn_reset_port_entry ();

  buffer_len = 8192;

  buffer = (char *) malloc (buffer_len);
  if (buffer == NULL)
  {
    ERROR ("tcpconns plugin: malloc failed.");
    return (-1);
  }

  if ( sysctlbyname ("net.inet.tcp.pcblist", buffer, &buffer_len, NULL, 
0) ==  0) {
     ERROR ("tcpconns plugin: Failed fetching pcblist");
     sfree (buffer);
     if ( errno == ENOENT ) {
       ERROR ("tcpconns plugin: no entry");
     }
     if ( errno == ENOMEM ) {
       ERROR ("tcpconns plugin: not enough memory");
     }
     if ( errno == EFAULT ) {
       ERROR ("tcpconns plugin: bad address");
     }
     if ( errno == EINVAL ) {
       ERROR ("tcpconns plugin: non-null newp");
     }
     return (-1);
  }

  if (buffer_len <= sizeof (struct xinpgen))
  {
    ERROR ("tcpconns plugin: (buffer_len <= sizeof (struct xinpgen))");
    sfree (buffer);
    return (-1);
  }




More information about the collectd mailing list