[Orca-users] Re: runp mulitple graphs
Sean O'Neill
sean at seanoneill.info
Mon Aug 12 07:06:52 PDT 2002
I asked a similar question a couple of months ago. Joe Pawlicki was kind
enough to post a solution he has come up with for this issue.
Sean
At 03:01 AM 5/8/2002 +0000, pawlicja wrote:
>--- In orca-users at y..., Sean O'Neill <soneill at o...> wrote:
> > Just curious if anyone has beat up the multiple graph problem for
>disks
> > yet. I have a case right now where a system has 6 graphs for each
>type of
> > disk graph. Why? Because the system is being "tweaked" by the
> > administrator (e.g. mounting and ummounting file systems, etc etc).
> >
> > REALLY ugly. Just curious.
>
>
>Well, I've come up with a script that works for me. Basically, it
>assumes that your most recent orcallator data file is correct, and
>will rearrange/remove/add columns in old data files to be
>consistent. That way, when the rrd files and graphs are regenerated,
>duplicate plots are gone!
>
>Check it out. BTW - I know it's not the most elegant example of perl
>programming, but hey...
>
>
>#!/usr/local/bin/perl
>#
># orcafix.pl - Joe Pawlicki - May 2002
># Modify the orcallator data files, to prevent rrd files which
>result
># in multiple plots for disk space and inode usage. This
>situation
># arises because filesystems can change over time, and orca
>doesn't
># handle this well.
>#
># Step 1: Copy script to all orcallator clients
># Step 2: Backup orcallator data files
># Step 3: Stop orcallator process on client
># Step 4: Uncompress all orcallator data files on client
># Step 5: Run orcafix.pl on client; when prompted, enter the
>name of the
># most recent data file
># Step 6: Re-compress older data files (using gzip, bzip, etc.)
># Step 7: Start orcallator process on client
># Step 8: When orcafix has been run on all clients, remove the
>rrd files and
># web pages from the reporting host
># Step 9: Resync the client data files to the reporting host
>by your normal
># procedures, and run orca to regenerate rrd files and
>web pages
>#
>
>use File::Copy;
>
>print "orcafix.pl - This script will modify the orcallator data files
>in\n";
>print "the current directory, so that filesystem data is consistent
>with the\n";
>print "most recent data file. You must provide the name of the most
>recent\n";
>print "data file, and all data files in this directory must be
>uncompressed.\n";
>print "\nDo you want to continue?\n";
>
>$ANS = <STDIN>;
>if ( $ANS !~ /^[y|Y]/ ) {
> print "Exiting.\n";
> exit;
>}
>
>print "Enter the most recent data file name:\n";
>$newest = <STDIN>;
>chomp $newest;
>open CURRENT, "$newest" || die "Couldn't open data file $newest";
>
># Load the most current data file into a big array
>while (<CURRENT>) {
> @singleline = split /\s+/;
> push @CurrentData, [ @singleline ];
>}
>close CURRENT;
>
># Get the field headings from the first line of the data file
>$firstref = $CurrentData[0];
>for $x (0 .. $#{$firstref}) {
> $curfields[$x] = $firstref->[$x];
>}
>
># Get the list of all orcallator files in the current directory
>opendir THISDIR, ".";
>@filelist = readdir THISDIR;
>closedir THISDIR;
>chomp @filelist;
>
>### Main loop - repeat for every file in the current directory
>foreach $filename (@filelist) {
> if ( $filename =~ "orcallator-" && $filename ne $newest ) {
> print "Working on file: $filename\n";
> open THISFILE, "$filename" || die "Couldn't open data file
>$filename";
>
> # Load entire data file into array
> while (<THISFILE>) {
> @singleline = split /\s+/;
> push @OldData, [ @singleline ];
> }
> close THISFILE;
> rename "$filename", "$filename.sav" || die "Couldn't rename file
>$filename";
>
> # Get columns from the first line of the data file
> $firstref = $OldData[0];
> for $x (0 .. $#{$firstref}) {
> $oldfields[$x] = $firstref->[$x];
> }
>
> # Compare columns to the good headings to be preserved, add zero
>data
> # if column doesn't exist in old data file
> for $curposition ( 0 .. $#curfields ) {
> $match = 0;
> for $oldposition ( 0 .. $#oldfields ) {
> if ( $oldfields[$oldposition] eq $curfields[$curposition] ) {
> $match = 1; # Matching column found in old data file
> for $i ( 0 .. $#OldData ) {
> $ChangedData[$i][$curposition] = $OldData[$i]
>[$oldposition];
> }
> }
> }
> if ( $match == 0 ) { # No matching column found, insert zeroes
> $ChangedData[0][$curposition] = $curfields[$curposition];
> for $i ( 1 .. $#OldData ) {
> $ChangedData[$i][$curposition] = "0.0";
> }
> }
> }
>
> # Write out modified data file
> open OUT, ">$filename" || die "Couldn't create file $filename";
> for $j (0 .. $#ChangedData) {
> $ref = $ChangedData[$j];
> for $k (0 .. $#{$ref}) {
> print OUT "$ref->[$k] ";
> }
> print OUT "\n";
> }
> close OUT;
> undef @OldData;
> undef @oldfields;
> undef @ChangedData;
> undef @changedfields;
> }
>}
>### End main loop
>
>
>
>
>
>
>
--
........................................................
......... ..- -. .. -..- .-. ..- .-.. . ... ............
.-- .. -. -... .-.. --- .-- ... -.. .-. --- --- .-.. ...
Sean O'Neill
More information about the Orca-users
mailing list