How-to use scripts to create cacti templates
June 25, 2012 Leave a comment
If you have ever created a cacti templates from scratch, you would know it’s a very tedious work. I am very lucky to find this site. Later it moved to this new place. There are plenty of documents to let us know how it works while I will just share my experience of creating an MongoDB template.
First, create a definition file.
It can be copied from an existing one and change it. Referenceand.
You may need to unique the hash value using this script.
tools/unique-hashes.pl mongodb_definitions_tmp.pl > mongodb_definitions.pl tools/unique-hashes.pl --refresh mongodb_definitions_tmp.pl > mongodb_definitions.pl
Secondly, generate the cacti template.
make-template.pl --mpds port2 --script /export/home/cacti/scripts/ss_get_mongo_stats.php mongodb_definitions.pl > mongo.xml
Here are the source files(you need to change the file extension name back after download):
mongodb_definitions.pl : this one need to be created manually. It’s not so difficult if you know the structure.
make-template.pl : I added the support of “friend name” to it.
ss_get_mongo_stats.php : this one is changed from ss_get_by_ssh.php. One of the outstanding changes is the change to the map array as follows:
<pre>$keys_map = array( 'MONGODB_connected_clients' => array('short' => 'ma', 'source' => 'Connections'), 'MONGODB_active_sessions' => array('short' => 'mb', 'source' => 'Active'), 'MONGODB_used_resident_memory' => array('short' => 'mc', 'source' => 'residentMem'), 'MONGODB_used_mapped_memory' => array('short' => 'md', 'source' => 'mappedMem'), ...
The performance data is from a webpage like:
opInsert=36868243 opQuery=4290620 opUpdate=20708814 opDelete=608893 opGetmore=255241 opCommand=22943868 ...
As always, it’s just an example to help you get started. You can change whatever you like once you know it.