A script to parse your RRD and import it into cacti
Moderators: Developers, Moderators
A script to parse your RRD and import it into cacti
http://www.birch.net/~spiegela/import_rrd_cacti
Right now what this script does is takes as argument your rrd filename(s) (without absolute path). Then it takes both the RRAs, and DSs using "rrdtool info" (well the perl libs anyway) into a hash.
Then checks for an existing RRA, if it doesn't exist inserts the new one.
Then checks for the existing DS, if it doesn't exist inserts the new one. Then RRD filename minus the ".rrd" is the parent DS, and the sources in the file are the children. It supports undefined Min/Max (after you change the field in the DB from *integer to char).
Then checks for existing links fromthe DS to the RRA, if they don't exist, it inserts them.
It doesn't, however, create the links from the RRA to the CFs, but I figure that's very little manual effort.
import_rrd_cacti is written in perl, and requires the following modules:
RRDs (from http://www.rrdtool.org)
DBI
DBD::mysql
It requires that you specify the username, password, and the directory in which the rrd files reside at the top of the script. Also it assumes that your database name is "cacti". If not you can change it where the script says $dbh->connect (near the bottom).
I haven't cleaned it up, or tested it thouroughly, but it works just fine on all of my rrds.
Anyway let me know what you think, or if you have any ideas/suggestions.
Aaron
Right now what this script does is takes as argument your rrd filename(s) (without absolute path). Then it takes both the RRAs, and DSs using "rrdtool info" (well the perl libs anyway) into a hash.
Then checks for an existing RRA, if it doesn't exist inserts the new one.
Then checks for the existing DS, if it doesn't exist inserts the new one. Then RRD filename minus the ".rrd" is the parent DS, and the sources in the file are the children. It supports undefined Min/Max (after you change the field in the DB from *integer to char).
Then checks for existing links fromthe DS to the RRA, if they don't exist, it inserts them.
It doesn't, however, create the links from the RRA to the CFs, but I figure that's very little manual effort.
import_rrd_cacti is written in perl, and requires the following modules:
RRDs (from http://www.rrdtool.org)
DBI
DBD::mysql
It requires that you specify the username, password, and the directory in which the rrd files reside at the top of the script. Also it assumes that your database name is "cacti". If not you can change it where the script says $dbh->connect (near the bottom).
I haven't cleaned it up, or tested it thouroughly, but it works just fine on all of my rrds.
Anyway let me know what you think, or if you have any ideas/suggestions.
Aaron
Last edited by yid on Wed May 01, 2002 5:18 pm, edited 1 time in total.
Sintaxis
Hi....
How run the script...?? how is the sintaxis..??
this i do:
perl clon.pl
and return the prompt.........
How run the script...?? how is the sintaxis..??
this i do:
perl clon.pl
and return the prompt.........
Define ternura...
Stpe errror
Hi...
i am triying this:
decadente# perl clon.pl igdew068_disco_c.rrd igdew069_disco_c.rrd
DBD::mysql::st execute failed: Column 'Step' cannot be null at clon.pl line 99.
Can't execute SQL statement: Column 'Step' cannot be null
any idea thanks
i am triying this:
decadente# perl clon.pl igdew068_disco_c.rrd igdew069_disco_c.rrd
DBD::mysql::st execute failed: Column 'Step' cannot be null at clon.pl line 99.
Can't execute SQL statement: Column 'Step' cannot be null
any idea thanks
Define ternura...
hmmm. Can't see why you would get that error.
I'm setting $step as a global variable in the "get_rrd_info" subroutine from the rrds::info hash (if that means anything to you).
I haven't been able to replicate it, and I know I was lazy using global vars and all.
Try this for me, please (if you don't mind):
You should have the Data::Dumper perl module installed, so try putting
at the end of the get_rrd_info subroutine, and send me the output (you can send that to me in email if you like, we don't need the whole world seeing your rrd info, spiegela@birch.net). To make it easy, you can put that line just before
I know my little script is clumsy, and pretty dorky. I promise I'll clean it up and put some gonads on it, but I must balance open source, a job, and even a family life (geez). Hopefully my boss'll give me more time to work on it later.
Send me that output, though, and we'll see why $step isn't getting through. Oh, also if you like, you can make the script even dorkier, and set $step right before the sth_ins_parent statement handle. Just insert
right before:
Let me know how it goes, whatever you decide to do. And let me know if this thing helps.
Aaron
I'm setting $step as a global variable in the "get_rrd_info" subroutine from the rrds::info hash (if that means anything to you).
I haven't been able to replicate it, and I know I was lazy using global vars and all.
Try this for me, please (if you don't mind):
You should have the Data::Dumper perl module installed, so try putting
Code: Select all
print Dumper($info);
Code: Select all
return(\%ds, \%rra);
Send me that output, though, and we'll see why $step isn't getting through. Oh, also if you like, you can make the script even dorkier, and set $step right before the sth_ins_parent statement handle. Just insert
Code: Select all
$step=<your step in secs>;
right before:
Code: Select all
my $sth_ins_parent = $dbh->prepare("
INSERT into rrd_ds
( `Name`, `Active`, `DSPath`, `Heartbeat`, `Step`, `IsParent` )
values ( " . $dbh->quote($rrdname) . ", 1, " . $dbh->quote($rrdpath) . ", 100, " . $dbh->quote($step) . ", 1 )
");
Aaron
Made some minor bug fixes. Haven't had time yet to dig in and make it more efficient, tho. Still there at:
http://www.birch.net/~spiegela/import_rrd_cacti
http://www.birch.net/~spiegela/import_rrd_cacti
Does anyone have a copy of import_rrd_cacti ?
I am looking for a script to migrate an existing MRTG/RRD installation to Cacti. This seems to have been done and posted at an extinct locatiion:
http://www.birch.net/~spiegela/import_rrd_cacti
Does anyone have this script? Can you attach it to this forum.
http://www.birch.net/~spiegela/import_rrd_cacti
Does anyone have this script? Can you attach it to this forum.
Who is online
Users browsing this forum: No registered users and 8 guests