Global networks

At work, each network segment is classified with a color based on its access list. We have brown, green, red, purple, blue, orange, and firewalls all over the place. This has inspired...

The Network Connection

Why are there so many damn network colors,
And routers and firewalls?
Show them on pow'r point, but only to man'gers
And they will approve the change.
So we've been told and some choose to believe it
I know that I'll wait and see
Someday they'll make it
My Network Connection,
The cables, the VLANs, and me...

Who said that every server needs IP
A link to one thousand base T
Somebody thought of that, approving the purchase
Except for the cabling
A WAN so amazing, with OC-3's blazing
Sometimes the pings make it through.
Someday they'll make it,
A global connection,
The cables, the VLANS, and me...

All of us scanned by Nessus,
We know that it's probably magic

Have you been half-routed? Dropped by Rule Zero?
Lost packets silently
This is annoying, quit making changes
On Friday at end of the day.
Some of us do work, even on weekends, we need the network to flow.
Someday I'll have it
A working connection,
The cables, the VLANS and me...



Building stand-alone Collectd plugin - Part 2

Actually, this wasn't as difficult as I was expecting.

The only real challenge was in the fact that the ESX Guest SDK libraries are only distributed as a shared object, which means my plugin had to dlopen() the required library, rather than being able to link it in statically. Luckily, I was able to cannibalize some of the example guest SDK code for this.

Here's the basic idea:

// Function to get how much CPU time we've gotten
VMGuestLibError (*GuestLib_GetCpuUsedMs)(VMGuestLibHandle handle, uint64 *cpuUsedMs);

//In the plugin_init function, I dlopen("libvmGuestLib.so") and assign the function
GuestLib_GetCpuUsedMs = dlsym(dlHandle, "VMGuestLib_GetCpuUsedMs");
//And open the Guestlib handle. Each plugin_read loop, I
// GuestLib_UpdateInfo(glHandle); and then can get the latest data.
glError = GuestLib_GetCpuUsedMs(glHandle, &(CpuUsedMs));
values[0].counter = CpuUsedMs;
// and plugin_dispatch_values().

Then I copied the resulting .libs/esx_guest* and the libvmGuestLib.so into the ~collectd/lib/collectd/ directory (where it looks for plugin SOs) and fired it up. I also had to add entries to the types.db for my data sources.

From here, I get cool graphs for my Linux VMs like these.

I'll put this code up on my personal site when I get a chance, and contribute these documentation to the collectd project.



Building stand-alone Collectd plugin

I'm working on building a plugin for the collectd data collection system (www.collectd.org) that will gather stats on our ESX RedHat VMs through the VMware Guest API.

Here's what I've found so far...

unpack collectd, configure and make it.
In a separate directory, create the source files for the new plugin.

(minimal plugin code:

#include "collectd.h"
#include "common.h"
#include "plugin.h"

static int my_read(void) {
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;

values[0].counter = 0;

vl.values = values;
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "test1", sizeof (vl.plugin));
sstrncpy (vl.type, "counter", sizeof (vl.type));

plugin_dispatch_values (&vl);

return 0;

void module_register(void) {
plugin_register_read ("test1", my_read);

Then I use libtool to build the .o:
$ libtool --mode=compile gcc -DHAVE_CONFIG_H -I ../collectd-4.10.1/src -Wall -Werror -g -O2 -MT test1.lo -MD -MP -MF test1.Tpo -c -o test1.lo test1.c
and link it:
$ libtool --tag=CC --mode=link gcc -Wall -Werror -g -O2 -module -avoid-version -o test1.la -rpath /apps/collectd-4.10.1/lib/collectd -lpthread -ldl test1.lo

This generates the files in ./libs/test1.* which I copy into the $prefix/lib/collectd/ directory and enable it in my config.

So much for part 1... Up next, getting actual data.