[rrd-users] RRDs::tune zeroing values

Tobias Oetiker tobi at oetiker.ch
Thu Apr 17 07:33:59 CEST 2008


Hi William,

the reason for this behaviour is, that when you reset the DS-type,
rrdtool will also reset the last_ds value which prevents it from
doing building the difference between the current and the last
counter value ... the following patch makes rrdtune NOT do this
unless the data-source-type is actually changed.

Index: src/rrd_tune.c
===================================================================
--- src/rrd_tune.c      (revision 1323)
+++ src/rrd_tune.c      (working copy)
@@ -197,15 +197,17 @@
                 rrd_close(rrd_file);
                 return -1;
             }
-            strncpy(rrd.ds_def[ds].dst, dst, DST_SIZE - 1);
-            rrd.ds_def[ds].dst[DST_SIZE - 1] = '\0';
+            /* only reset when something is changed */
+            if (strncmp(rrd.ds_def[ds].dst, dst, DST_SIZE - 1) != 0) {
+                strncpy(rrd.ds_def[ds].dst, dst, DST_SIZE - 1);
+                rrd.ds_def[ds].dst[DST_SIZE - 1] = '\0';

-            rrd.pdp_prep[ds].last_ds[0] = 'U';
-            rrd.pdp_prep[ds].last_ds[1] = 'N';
-            rrd.pdp_prep[ds].last_ds[2] = 'K';
-            rrd.pdp_prep[ds].last_ds[3] = 'N';
-            rrd.pdp_prep[ds].last_ds[4] = '\0';
-
+                rrd.pdp_prep[ds].last_ds[0] = 'U';
+                rrd.pdp_prep[ds].last_ds[1] = 'N';
+                rrd.pdp_prep[ds].last_ds[2] = 'K';
+                rrd.pdp_prep[ds].last_ds[3] = 'N';
+                rrd.pdp_prep[ds].last_ds[4] = '\0';
+            }
             break;
         case 'r':
             if ((matches =

cheers
tobi

Yesterday William Cassis wrote:

> Hello,
>
> I'm running MRTG on Fedora Core 8 with RRDTool and am having problems
> with MRTG updating rrd files with correct values.
>
> MRTG version 2.15.1 (package 2.15.1-6.fc8)
> RRDTool says it's version 1.2.99907080300 when I run rrdtool --help, but
> the package is 1.3-0.6.beta3.fc8.
>
> When MRTG runs, it seems that the 'tune' step is zeroing out the most
> recent values in the rrd files.  Commenting out the section of the MRTG
> perl executable that calls the RRDs::tune command has temporarily fixed
> things, but that's probably not a good long-term fix ;).
>
> Here's a snippet from my mrtg config file:
>
> ********
> ### Interface 11 >> Descr: 'FastEthernet0/10' | Name: 'Fa0/10' | Ip: ''
> | Eth: '00-03-e3-36-20-0a' ###
>
> Target[FastEthernet0_10]: \FastEthernet0/10:mrtg at office-sw01:::::2
> SetEnv[FastEthernet0_10]: MRTG_INT_IP=""
> MRTG_INT_DESCR="FastEthernet0/10"
> MaxBytes[FastEthernet0_10]: 12500000
> Title[FastEthernet0_10]: Traffic Analysis for FastEthernet0/10 --
> office-sw01
> PageTop[FastEthernet0_10]: <h1>Traffic Analysis for FastEthernet0/10 --
> office-sw01</h1>
>                <div id="sysdetails">
>                        <table>
>                                <tr>
>                                        <td>System:</td>
>                                        <td>office-sw01</td>
>                                </tr>
>                                <tr>
>                                        <td>Description:</td>
>                                        <td>FastEthernet0/10 Test </td>
>                                </tr>
>                                <tr>
>                                        <td>ifType:</td>
>                                        <td>ethernetCsmacd</td>
>                                </tr>
>                                <tr>
>                                        <td>Max Speed:</td>
>                                        <td>100.0 Mbits/s</td>
>                                </tr>
>                        </table>
>                </div>
>
> ********
>
> When I run MRTG with --debug="log", I get output that looks like this:
>
> Creating the rrd:
> --log: RRDs::create(/usr/local/mrtg/office-sw01/fastethernet0_10.rrd -b
> 1208374325 -s 300 DS:ds0:COUNTER:600:0:12500000
> DS:ds1:COUNTER:600:0:12500000 RRA:AVERAGE:0.5:1:800
> RRA:AVERAGE:0.5:6:800 RRA:AVERAGE:0.5:24:800 RRA:AVERAGE:0.5:288:800
> RRA:MAX:0.5:1:800 RRA:MAX:0.5:6:800 RRA:MAX:0.5:24:800
> RRA:MAX:0.5:288:800)
> --log: RRDs::update(/usr/local/mrtg/office-sw01/fastethernet0_10.rrd,
> '1208374335:172812857:450899955')
> --log:  got: ???/???
>
> Updating the rrd with values:
> --log: RRDs::tune(/usr/local/mrtg/office-sw01/fastethernet0_10.rrd -a
> ds0:12500000 -a ds1:12500000 -d ds0:COUNTER -d ds1:COUNTER)
> --log: RRDs::update(/usr/local/mrtg/office-sw01/fastethernet0_10.rrd,
> '1208377525:186981022:466737759')
> --log:  got: ???/???
>
> However, the rrd records 'NaN' values for that interval:
> <!-- 2008-04-16 13:20:00 PDT / 1208377200 --> <row><v> NaN </v><v> NaN
> </v></row>
> <!-- 2008-04-16 13:25:00 PDT / 1208377500 --> <row><v> NaN </v><v> NaN
> </v></row>
> <!-- 2008-04-16 13:30:00 PDT / 1208377800 --> <row><v> NaN </v><v> NaN
> </v></row>
>
> After commenting out 'RRDs::tune(@args);' in the mrtg executable, the
> rrds are updating with correct values.
>
> I figured that this might be par for the course since I'm running a beta
> version of rrdtool, but unfortunately yum doesn't give me an option to
> install a stable version of rrdtool and I have quite a few other
> packages that are dependencies on the version of rrdtool that the system
> has installed.
>
> Is this a known bug?
>
> Any help is appreciated!
>
> Thanks,
> Will Cassis
>
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten
http://it.oetiker.ch tobi at oetiker.ch ++41 62 213 9902



More information about the rrd-users mailing list