On Thu, Jun 28, 2007 at 02:12:33PM -0400, Gary Baluha wrote:
I remember reading somewhere in the Hobbit documentation that when an extension script starts to do a lot of things, it should be coded in a compiled language such as C, instead of as a shell script. I have a custom script that takes a lot of data and converts it into NCV graphs, and I believe it is at the point where I should consider rewriting it in C.
It really depends on how much work it does, and how often it runs: Do you have 10 hosts calling into Hobbit with this kind of data, or 1000 ? Your system load will be much less with a compiled C program than with a shellscript or Perl program, but it should be considered against the amount of work needed to re-implement your script.
Before I get to far into it, is the hobbitd_sample.c something that I should look at for this? I'm not sure if I'm reading the documentation on it correctly, if it is a good example for an external script.
hobbitd_sample shows how your program is fed data from Hobbit. I'm not sure quite how your program currently works - does it run via the "--extra-script" option to hobbitd_rrd ? In that case it might be easier for you to just convert your current script into a C program and still run it via the extra-script option.
If you do decide that the extra-script method is too heavy, then modifying the hobbitd_rrd module is the easiest way to go. You'll have to create a new routine to parse the data - start with a simple one like hobbitd/rrd/do_bbtest.c, which just finds a single value in the "bbtest" status message, and updates and RRD file with it. Then you must add two lines to hobbitd/do_rrd.c: An "#include rrd/myfile.c" to pick up the parser routine you just wrote, and a line near the bottom of the file where you invoke your parser whenever the correct "status" or "data" message arrives.
Regards, Henrik