http://zewaren.net/site/node/141
Playing with rrdtool counter resets
Fri, 2014-12-05 09:10 — ZeWaren
Now let's update it with some values.
Let's graph!
![Image](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_uuZ19IUnY2w57CVWOAo8znKN0TmEoBw2rsR0YfiYbeLJTG9_flyS0yzyDiBYbHWgn2CbnMkGkwSqcFjzNuLQqarZebN6Q9th3hx6hqjyDhHhF0CTVoLCwzq8345CoDcWbRn7pt5QlibOERjZDrXPUL-2M4BZKaDbZVo5lf=s0-d)
So far, so good.
The dreaded spike appears!
![Image](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_s7YJTOao42xz7jKwS-qkj2DQny9rgOLEXECRCC6Q519uK0b-sdKYX0RPxZt-s25PQnRseihQR6pHawurGeQ7ENT2qxd4ys2ZytktSmO2iIuOnEL3Sk_Ru5VfPRXKTIV4bCDU9wn2kC-S8EKhWt4m7-2oka5JGAFFwz98R08DmSoUxARw=s0-d)
Folder http://oss.oetiker.ch/rrdtool/pub/contrib/ contains many tools to remove spikes from rrd data files. My favorite one is spikekill (spikekill-1.1-1.tar.gz).
The spike is then replaced by a small innocent glitch.
![Image](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_vfNt2sTg5hpYnPpySeTRpKC2JY3Naeo_4Iw07T7975jsgxhCo9mxBbGiDmUogfNxFzu3q5y4i546h7cCJC1LUbxjAlQEiH5VF83W3ndRMMZHU-_3WQ0zrOTViJvmKrMwsmtpzrwDHUeiup5DLyHiU2sg-A9IIfavjXkQd4aRQeI7cVQZX7-ikIQMVO=s0-d)
To prevent counter reset spikes, you should use DERIVE instead of COUNTER. Tuning the rrd file solves the problem.
Not so frequently asked questions and stuff:
Creating and plotting some data normally
Let's create a standard rdd file, with a counter:
1
| rrdtool create test.rrd --start $start --step 60 DS:something:COUNTER:600:0:U RRA:AVERAGE:0.5:1:1440 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| #!/usr/bin/env perl -w use strict; use warnings; my $start = 1417392000; my $counter = 0; for my $x (1..60*24) { my $time = $start + 60* $x ; $counter += 1000+ int (250* sin (1/(48)* $x )); my $command = "rrdtool update test.rrd $time:$counter" ; system ( $command ); } |
1
2
3
| rrdtool graph test.png -a PNG --start 1417392000 --end 1417478400 -t "Sure looks like a sine" -v "avg potato per second" \ DEF:something=test.rrd:something:AVERAGE \ LINE1:something#111111:"My superb value" |
So far, so good.
Having a counter reset
Now, let's recreate the same data, but with a counter reset in the middle.
1
2
3
| if ( $x == 1000) { $counter = 0; } |
Folder http://oss.oetiker.ch/rrdtool/pub/contrib/ contains many tools to remove spikes from rrd data files. My favorite one is spikekill (spikekill-1.1-1.tar.gz).
1
| php removespikes.php -d -A=avg -M=variance -P=5000 -R=test.rrd |
To prevent counter reset spikes, you should use DERIVE instead of COUNTER. Tuning the rrd file solves the problem.
1
| rrdtool tune test.rrd --data-source-type something:DERIVE |
0 comentários:
Postar um comentário