Note: This article is about features in a version of Weathermap that is not yet released. It is aimed at those who are testing the new version, prior to it's release. Feel free to help with that testing process, but 0.96 is not a finished or fully tested release yet.
There have been quite a few changes to the RRDtool datasource plugin for 0.96 - some of them are related specifically to the Cacti integration, and poller_output support, and others are more general. I'll cover the general ones here, and the Cacti-related stuff in another article about Cacti-related new features.
First of all, there are some convenience features, especially if you don't use Cacti. These SET commands are map-global, so they should appear in the top section of you map config file, before any nodes or links:
- You can define a default 'base directory' where the RRD DS will look for .rrd files, if there isn't a full path in the TARGET. This makes your config files much easier to read.
SET rrd_default_path /usr/local/mrtg/var
- You can also change the default 'in' and 'out' DS names from traffic_in and traffic_out to something more useful for your environment. For MRTG, this would be
SET rrd_default_in_ds DS0 SET rrd_default_out_ds DS1
and for Cricket, ds0/ds1.
Next up is a completely different mode for reading RRD files. Normally, weathermap fetches the last 12 minutes' data from each RRD file, and then picks the newest non-NaN line to use as the 'current' data. Of course, RRDtool's big strength is that it keeps historical data too. You have been able define rrd_start and rrd_period for quite a while now to get a historical map using RRD data - although the results 'soften' as RRDtool aggregates older data into averages over larger periods of time. It still presents data from a single point in time though.
In 0.96, you can also get data which is the average, minimum, maximum etc over a given period. So you can make a weekly maximum, or a monthly 95th percentile map. This is done with very few changes to the map config, so you can also do this without having a second config file - much less maintenance to do!
To use the aggregate functions, you need to define a few map-global SET variables. You can do this either in the map config, or using the --define command-line parameter if you use the command-line tool, or from within the Cacti plugin interface, if you use that. The last two mean you can use the same map config file for an instantaneous map, and also for 'reporting' maps.
The SET variables are:
SET rrd_start now-1month SET rrd_period 2592000 SET rrd_aggregate_function AVERAGE
The first two define which period in time to collect data from, while the last defines what to do with it. Valid aggregation functions currently include: MINIMUM, MAXIMUM, AVERAGE and PERCENT (PERCENT also requires a percentage, like '95,PERCENT'). This feature uses the 'PRINT' rrdtool graph command and VDEF feature, so as new functions are added there, they will work here. rrd_period is a timespan in seconds (30 days here) - this will likely change to allow more friendly period descriptions.
Add another cron job, and you can easily get weekly or monthly reports without managing another map.
August 19, 2008 - 10:09pm
I have a problem with the following command line:
/usr/bin/php5 weathermap --config configs/mymap.cfg --define rrd_period=120 --define rrd_start=1212962400 --define rrd_aggregate_function= MAXIMUM --output output/mymap_1212962400.png
the last two options get cut. So the result ist just a mymap.png (set as IMAGEOUTPUTFILE in mymap.cfg) in the weathermap folder with the AVERAGES and not the MAX values.
the same with debug:
/srv/www/cacti/plugins/weathermap # /usr/bin/php5 weathermap --debug --config configs/mymap.cfg --define rrd_period=120 --define rrd_start=1212962400 --define rrd_aggregate_function= MAXIMUM --output output/mymap_1212962400.png
DEBUG: [@weathermap:141] >> rrd_period = '120'
DEBUG: [@weathermap:141] >> rrd_start = '1212962400'
DEBUG: [@weathermap:141] >> rrd_aggregate_function = ''
...............
DEBUG: [wmrrd_read_from_real_rrdtool@WeatherMapDataSource_rrd.php:292] configs/mymap.cfg: RRD ReadData: traditional style
DEBUG: [wmrrd_read_from_real_rrdtool@WeatherMapDataSource_rrd.php:307] configs/mymap.cfg: RRD ReadData: Running: /usr/bin/rrdtool fetch /srv/www/cacti/rra/node1_traffic_in_1004.rrd AVERAGE --start 1212962400 --end start+120
DEBUG: [wmrrd_read_from_real_rrdtool@WeatherMapDataSource_rrd.php:327] configs/mymap.cfg: > 1212962460: 9.9756328170e+05 4.1407558058e+06
DEBUG: [wmrrd_read_from_real_rrdtool@WeatherMapDataSource_rrd.php:327] configs/mymap.cfg: > 1212962520: 1.5138245172e+06 4.3269857117e+06
DEBUG: [wmrrd_read_from_real_rrdtool@WeatherMapDataSource_rrd.php:327] configs/mymap.cfg: > DEBUG: [wmrrd_read_from_real_rrdtool@WeatherMapDataSource_rrd.php:335] configs/mymap.cfg: RRD ReadData: Read 3 lines from rrdtool
DEBUG: [wmrrd_read_from_real_rrdtool@WeatherMapDataSource_rrd.php:336] configs/mymap.cfg: RRD ReadData: Headings are: traffic_in traffic_out
...............
DEBUG: [DrawMap@Weathermap.class.php:2696] configs/mymap.cfg: Writing PNG file to mymap.png
DEBUG: [@weathermap:240] configs/mymap.cfg: Writing HTML to mymap.html
I have large rrd files with 90 days/1min rra´s.
July 22, 2008 - 11:06pm
I just edited the aggregation example to show the correct syntax, since I played with this for the first time in a while today for our live Cacti server.
August 6, 2008 - 6:35pm
It's not clear to me how the second cron job should look in order to pick up the new feature and build a different map from the same config file. Can you elaborate?
My apologies if this should be obvious, I just started using php-weathermap the day before yesterday. :)
--
Garry
August 7, 2008 - 10:42pm
Sure. You would do something like:
php weathermap --config my-map-config.cfg
normally.
So for the summary map, you can do
php weathermap --config my-map-config.cfg --define rrd_aggregate_function=95,PERCENT --define rrd_period= 2592000 --define rrd_start=now-1month
instead, to get a monthly 95th-percentile version of the same map. Make sense?
If you are using Cacti, you can do a similar thing, but in the web UI - add a second copy of the same map, and define the same 3 extra variables by clicking on the column that probably says 'standard' in the management screen.
August 6, 2008 - 11:43pm
Also, I think I may have found a bug. But it could just be that I'm not sure yet how the conf file directives all work together...
If I set the rrd_default_path, then later need to change something to use guage:, 'TARGET guage:example.rrd' will not work, due to 'guage:' being inserted in the path.
Easy way around this?
August 7, 2008 - 10:37pm
gauge: is spelt 'gauge' - it's not picking it up, so it assumes it's part of the filename.