Carlo,

The permissions were the culprit!  Thanks for spotting that.  It appears
to have worked.  Here's the complete script, quick and dirty version.

#!/usr/bin/perl

# $oldxmlfile="cpu_pool_idle.xml";
# $oldrrdfile="cpu_pool_idle.rrd";
# $newrrdfile="cpu_pool_idle_new.rrd";
# $newxmlfile="cpu_pool_idle_new.xml";

$oldxmlfile="pkts_in.xml";
$oldrrdfile="pkts_in.rrd";
$newrrdfile="pkts_in_new.rrd";
$newxmlfile="pkts_in_new.xml";

$appendxmlfile="append.xml";

system("rrdtool dump $oldrrdfile > $oldxmlfile");

open OLDXML, ("< $oldxmlfile");
open NEWXML, ("> $newxmlfile");
open APPENDXML, ("< $appendxmlfile");

my(@oldxml) = <OLDXML>; # read file into list
my(@appxml) = <APPENDXML>;

for (@oldxml) {
  if (! /<\/rrd\>/) {
      print NEWXML $_;
   } else {
      for $appline (@appxml) {
          print NEWXML $appline;
      }
      print NEWXML $_;
      last;
   }
}

close (OLDXML);
close (NEWXML);
close (APPLENDXML);

system("rrdtool restore $newxmlfile $newrrdfile");

# Fix ownership and perms
system("chown nobody.system $newrrdfile");
system("chmod 666 $newrrdfile");

system("/etc/rc.d/init.d/gmetad stop");
system("cp -p $oldrrdfile $oldrrdfile.orig");
system("cp -p $newrrdfile $oldrrdfile");
system("/etc/rc.d/init.d/gmetad start");

David Wong
Senior Systems Engineer
Management Dynamics, Inc.
Phone: 201-804-6127
[EMAIL PROTECTED]
 
The information contained in this e-mail message, including any
attachments, constitutes proprietary and confidential information of
Management Dynamics, Inc. and is intended only for the personal and
confidential use of the recipient or recipients named above. If the
reader of this message is not the intended recipient, you are hereby
notified that you have received this message in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify the sender immediately by e-mail and delete the original
message.
-----Original Message-----
From: Carlo Marcelo Arenas Belon [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 30, 2008 9:52 PM
To: David Wong
Cc: [email protected]
Subject: Re: [Ganglia-general] HELP! Adding a new RRA to an RRD

On Wed, Jan 30, 2008 at 02:11:57PM -0500, David Wong wrote:

nice setup, but be sure gmetad is down when touching the rrd.

<SNIP>
> Can someone tell me what I'm doing wrong here?  Do you have a better
> suggestion?

little rough and untested but hopefully will help..

<SNIP>
> system("rrdtool restore $newxmlfile $newrrdfile");
> 
> system("cp -p $oldrrdfile $oldrrdfile.org");
> system("cp -p $newrrdfile $oldrrdfile");

system("chmod `stat -c'%a' $oldrrdfile` $newrrdfile");
system("chown `stat -c'%U:%G' $oldrrdfile` $newrrdfile");

Carlo

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ganglia-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-general

Reply via email to