[mrtg-developers] Running cfgmaker from a PERL script

Charles Johnson Johnson-C at MSSU.EDU
Thu Jul 31 23:06:00 MEST 2003


I figure one of you PERL hackers out there will be able to answer this
one pretty easily. I can't get the cfgmaker command to work from within
my PERL script using the system() function. I'm setting up a pretty
large site by looping through a series of files (the name of the file
identifies the OS or device type) and sublooping through the lines in
each file to get the IP address and device name. Withing my script the
command looks something like this:

***************************************************

@command=("cfgmaker",
                      "--global Workdir: $pathPrefix{html}/$catagory",
                      "--global Options[_]: growright,bits",
                      "--no-down",
                      "--show-op-down",
                      "--noreversedns",
                      "$community@$address >
$pathPrefix{mrtg}/$catagory/$name.cfg");

system(@command);
************************************************

It doesn't work. I get an "unknown option" error from cfgmaker for the
Options[_] element of the array, and depending upon how I try to escape
quotes, other similar errors.

I know I have my loops and variables set properly because when I call a
bash shell script to run the command for me it works. Here is the
command to call the bash shell script that contains the cfgmaker
command:

*******************************************
@command=("$pathPrefix{helpers}/basic_cfg",
          "$pathPrefix{html}/$catagory",
          "$community", 
          "$address",
          "$pathPrefix{mrtg}/$catagory", 
          "$name");
system(@command) == 0;
#I really don't understand why I need the "== 0" part.
*******************************************

And finally, here is the script I call:

*******************************************
#!/bin/bash

# Run the basic mrtg config command.

`cfgmaker --global "Workdir: $1" \
          --global "Options[_]: growright,bits" \
          --no-down \
          --show-op-down \
          --noreversedns \
          "$2"@"$3" > "$4"/"$5".cfg`
**************************************************

This is just the basic setup command that I'll use for every OS and
device type. There is a lot of other OS/device specific processing and
adjustments to be made to the .cfg files as I progress through the
setup. 

I know it's probably a nit-picky kind of thing to worry about, but I
really shouldn't have to call another script to do this.

In case anyone is wondering, I had this system up and running using
bash as the original scripting tool for setup. The system was up for
about a year monitoring NetWare 5 & 6 servers, W2k servers, Cisco
routers and switches, Dell switches, Cajun switches, and a variety of
other things we want to keep an eye on. About 100 individual devices and
probably 10 times as many individual ports on some of the switch stacks.
The setup script also generated the overall site with a menu for
navigation and several custom pages with information gleaned from the
MRTG output. The whole thing ran on a 10 minute cycle (half every 5) and
kept dual PII 450's with .5 Gig RAM running at > 99% for 2 out of every
5 minutes. The box was a hand me down, but it worked like a champ until
it died the other day. Now I have to do it all over again, but this time
I'm using PERL vs bash, RH9 vs RH7.3, all the latest for MRTG, rrdtool,
etc. I haven't used rrdtool yet but that's part of the plan this time.
And, get this, the machine  is a HP NetServer LXe Pro with quad PPro
200's. If I make this work they'll probably give me a real machine.

Anyway, thanks in advance for any help.


Ed Johnson 
eflashj at swbell.net
johnson-c at mail.mssc.edu

--
Unsubscribe mailto:mrtg-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:mrtg-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/mrtg-developers



More information about the mrtg-developers mailing list