tags:

views:

736

answers:

2

I have a separate application printing logs in every 10 seconds. I need to create RRD files from the log files. I need some Perl code to read the log files and create the RRD only without the graphs.

I have also gone through the available Perl module in CPAN, i.e. RRD::Simple and RRD::Simple::Examples, but I still need help.

+3  A: 

I'd start with RRD::Simple. There's some example code in the documentation. Since you don't need to create a graph, simply skip that section of the example.

Some of the examples read a single sample of data, call the update function once, and then exit. Those scripts are meant to be run periodically to collect data in real time. The example that's probably more pertinent to your needs is ApacheAccessLogActivity.pl, which reads an Apache log file, parses each line with a regular expression, does a bit of analysis to figure out what it just read, and then calls update, all in a loop. Note that that example uses the standalone functions rather than the object-oriented versions.

If you've already read the documentation for that module and need more information about how to use it, or if you've tried it and found that it has shortcomings that prevent you from using it, then please be more specific about what you need to do.

RRDTool::OO also looks promising.

Rob Kennedy
A: 

I'd recommend RRDTool::OO. Exerpt from the perldoc:

$rrd->create( ... ) Creates a new round robin database (RRD). A RRD consists of one or more data sources and one or more archives:

           $rrd->create(
                step        => 60,
                data_source => { name      => "mydatasource",
                                 type      => "GAUGE" },
                archive     => { rows      => 5 });
swissunix