richard-

it would be wonderful if you were to write a windows native gmond!

i had to make a lot of painful compromises in 3.x to get ganglia working on cygwin/windows (like not using any POSIX threads). having a windows-only code base would make things soooo much easier all around. i originally thought that having a single code base would be easier. i was wrong.

step 1.

i think step one in building the client is finding out all the OS calls necessary for collecting the system metrics. the current windows client uses the cygwin "/proc" filesystem. this filesystem is really just a directory with files that contain the current system configuration and status in the same format as linux. the problem with the cygwin proc filesystem is that is not complete and is emulated.

step 2.

once you have the code for collecting all the metrics, step 2 is to send those metric out via UDP in XDR format. unless things have changed, windows does not have a DLL with the Sun XDR api to format the data (of course.. why would microsoft support a portable data format that has been around for over 18 years). luckily, i have the code for XDR which should compile pretty painlessly on windows (and i'm attaching it to this email).

Attachment: xdr.tar.gz
Description: GNU Zip compressed data


you will want to use the xdrmem_create() call to encode your data into an XDR buffer and then shoot that buffer out over UDP using windows networking calls.

the good news is that if you get this xdr code running on windows you will be freed from the hassle of encoding and decoding the data. if you take a look in the distribution at ./lib/protocol.x, you will see the xdr protocol file for ganglia. running this file through rpcgen creates the ./lib/protocol_xdr.c and ./lib/protocol.h files that you see in the distribution.

if you use that protocol code in your windows client, you will have all the data structures and xdr calls necessary to do anything.

for example... if you look in ./lib/protocol.h you will see the data structure "struct Ganglia_gmetric_message". all you need to do to send a gmetric XDR message from windows is...

A. fill in this structure with data

Ganglia_gmetric_message gmetricData;
gmetricData.type = "myType";
gmetricData.name = "myName";
// etc etc

B. create an XDR handle

char msgBuf[1024];
XDR xdrHandle;
xdrmem_create(&xdrHandle, msgBuf, 1024, XDR_ENCODE);

C. fill the buffer with the Ganglia_gmetric_message structure...

xdr_Ganglia_gmetric_message(&xdrHandle, &gmetricData);

D. send the buffer using windows networking...

int bufLen = xdr_getpos(&xdrHandle);

i'm not a windows programmer so i have no clue what the call is to send a data buffer in windows. for example...

write( windowsSocket, msgBuf, bufLen )

that's it!

i think it's important that even though we have a complete separate code base, we all talk the same protocol. i think in the long run it'll make your life easier. all you need to do is collect data and then let the xdr protocol stub functions handle marshalling the data.

step 3.

listen to all the cheer from people who use windows

sending non-gmetric messages is just a simple... everything you need to know is in ./lib/protocol.h and ./lib/protocol_xdr.c. feel free to shoot questions to this list anytime you have a problem.

receiving XDR data...

if you want to have your client listen for data, the XDR stuff works exactly the same way but when you build the xdrHandle, you call

xdrmem_create(&xdrHandle, msgBuf, 1024, XDR_DECODE);
^^^^^^^^^^^^^^^
xdr_Ganglia_gmetric_message(&xdrHandle, &gmetricData);

now gmetricData is filled in with all the data in the buffer (the xdr library mallocs any data necessary to create the structure). after you are done saving the gmetricData... and you want to free it

xdr_free(xdr_Ganglia_gmetric_message, gmetricData);

i just thought of one potential problem... not sure if there is a windows malloc() call for getting memory. hmm.

well... let us know how it goes.  we're here to help.

good luck!
--
[EMAIL PROTECTED]
  http://massie.us



Reply via email to