Percona Cacti templates with MAX consolidation & custom port

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
brianpcurran
Posts: 2
Joined: Wed Jul 20, 2016 1:11 pm

Percona Cacti templates with MAX consolidation & custom port

Post by brianpcurran »

I wanted my historical graphs to display maximum/peak values instead of averages for the time periods, so I had to modify the consolidation function that the Percona templates use. I also used the --mpds option to one of the Percona scripts to force a custom port specification every time a new graph is added to host. It's a bit tedious specifying the port for every single graph, but it's the best solution I could come up with. I'll paste the steps I used below. If anyone sees any issues or I'm not doing something right (I'm fairly new to Cacti and RRDtool) let me know!

Code: Select all

# PREREQUISITES
#
# This assumes you've already installed the templates from Percona.
# Steps to do this are documented here:
# https://www.percona.com/doc/percona-monitoring-plugins/LATEST/cacti/index.html
#
# PROBLEM
#
# The Cacti graph templates from Percona use the AVERAGE consolidation
# function. This means that on the Weekly (30 Minute Average) graph,
# for example, the average result over thirty minute periods is
# displayed as the maximum value in the graph (and in the legend below
# the graph). The Weekly (30 Minute Average) Round Robin Archive has
# both the AVERAGE and MAX consolidation functions selected by default,
# so it's possible to modify the Percona graph templates to pull MAX
# data from the RRD files. 
#
# SOLUTION
#
# First generate a new definition file with unique hashes. This will
# prevent overwriting the default Percona host, data, and graph
# templates if you've already imported them.

/usr/share/cacti/resource/percona/bin/pmp-cacti-make-hashes --refresh /usr/share/cacti/resource/percona/definitions/mysql.def > /usr/share/cacti/resource/percona/definitions/mysql-MAX.def

# If you also want to be able to define a port per graph template
# (useful if you have multiple MySQL servers that listen on different
# ports, or customize the size of the graphs (the default Cacti graphs
# are pretty small), use the --mpds, --graph_height, and --graph_width
# options. More details are here: 
# https://www.percona.com/doc/percona-monitoring-plugins/LATEST/cacti/installing-templates.html
#
# If you don't want to require a port for each graph template or don't
# want to change the size of the graphs, just remove the options from
# the command.

/usr/share/cacti/resource/percona/bin/pmp-cacti-template --script /usr/share/cacti/scripts/ss_get_mysql_stats.php /usr/share/cacti/resource/percona/definitions/mysql-MAX.def --mpds port --graph_height 240 --graph_width 1100 > /usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_MAX_0.8.6i-sver1.1.6.xml

# This will replace the default AVERAGE (id 1) consolidation function
# on all graph template items of types LINE1, LINE2, LINE3, AREA, and
# STACK with MAX (id 3) and rename the new template.

sed -i ':a;N;$!ba;s/<graph_type_id>\([4-8]\)<\/graph_type_id>\n\t\t\t\t<consolidation_function_id>1<\/consolidation_function_id>/<graph_type_id>\1<\/graph_type_id>\n\t\t\t\t<consolidation_function_id>3<\/consolidation_function_id>/g' /usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_MAX_0.8.6i-sver1.1.6.xml

# Rename the host template, data templates, and graph templates to
# clarify their purpose.

sed -i 's/Percona MySQL Server HT/Percona MySQL Server HT MAX/g' /usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_MAX_0.8.6i-sver1.1.6.xml
sed -i 's/GT/GT MAX/g' /usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_MAX_0.8.6i-sver1.1.6.xml
sed -i 's/DT/DT MAX/g' /usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_MAX_0.8.6i-sver1.1.6.xml

# Import the template into Cacti.

php /usr/share/cacti/cli/import_template.php --filename=/usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_MAX_0.8.6i-sver1.1.6.xml --with-user-rras='1:2:3:4'

# Now navigate to your Cacti web UI, open the Graph Templates page, and
# click on any of the Percona graph templates. You should see "MAX" in
# the CF Type column on each graph. Now your graphs will display peak
# values for sample periods instead of averages.
#
# You may want to go to Data Sources/RRAs and rename the RRAs to reflect
# this change. For example, change "Weekly (30 Minute Average)" to
# "Weekly (30 Minute Peak)".
Last edited by brianpcurran on Fri Jan 05, 2018 3:36 pm, edited 1 time in total.
brianpcurran
Posts: 2
Joined: Wed Jul 20, 2016 1:11 pm

Re: Percona Cacti templates with MAX consolidation & custom

Post by brianpcurran »

Just a quick update that this is working great! I've attached a screenshot demonstrating that the peak values are displayed in the graphs.
Attachments
2016-08-09 12_21_43-Graphs -_ Tree Mode - InnoDB I_O.png
2016-08-09 12_21_43-Graphs -_ Tree Mode - InnoDB I_O.png (312.36 KiB) Viewed 1547 times
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests