Data Queries - Must the Index be numeric?

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

Moderators: Developers, Moderators

Post Reply
theiss
Posts: 9
Joined: Mon Dec 19, 2022 2:50 pm

Data Queries - Must the Index be numeric?

Post by theiss »

Hi Everyone,

This is my first Data Queries and am following a document on github "How-To-Script-Data-Queries".
I am curious if I can use a non-numeric index (ie: based on name, like associative array)?

What I'm trying to do:
I have a Cisco CallManager cluster, and I am trying to monitor my bandwidth for voice calls for each location by graphing them. So, location/site names does not have numerical index natively; if I use numerical index, a new location may cause re-indexing issue.

From following the document, I am at the stage of creating a graph from the "Management -> Device" page. And under the "Data Query" - the index column is empty (not filled in), but the description and other parameters are correctly listed.
If I create the graphs from the list, it will also keep the name of the first index for all of the graphs, ie: all graph names will contain CASS instead of inserting TESS.

Data Query
Index descr calls max avail used
CASS 0 0 0 0
TESS 0 0 0 0

Regards,
theiss
User avatar
TheWitness
Developer
Posts: 17047
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Data Queries - Must the Index be numeric?

Post by TheWitness »

Indexes can be both numeric and string based even if that string is a sequence of hex equivalent ASCII values like "aa.bb.fc.13...". The development of Data Queries can be very complex and often times involves re-writing the Index values to achieve the "actual" index. Knowledge of Regular Expressions is super important. So, if you start writing the heck out of these things, you will have to become familiar with REGEX.

There is a user contributed change in 1.2.23 that is going to make some of this easier. We've have several lightly documented enhancements in Data Query construction over the years, but sadly most of the Data Queries were never published.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
theiss
Posts: 9
Joined: Mon Dec 19, 2022 2:50 pm

Re: Data Queries - Must the Index be numeric?

Post by theiss »

Thank you for the response!

I think I have found my issue.
I am missing "query index" as an option in my script.

Cheers,
~Theiss
theiss
Posts: 9
Joined: Mon Dec 19, 2022 2:50 pm

Re: Data Queries - Must the Index be numeric?

Post by theiss »

I don't know how to close a "resolved question".

So, since this is still editable, I thought I'd include my finding to resolve my issue in this post.

I've solved my issue with regards to the index.
I followed the "Script Data Query Walkthrough" to create my index data query.
I found that I was missing the "query <indexname>" option.

I've now included the following notes in my script to remind me of future edits.

/* USAGE: */
/* script_name.php <hostname> 'index' */
/* script_name.php <hostname> 'index_count' */
/* script_name.php <hostname> 'get' <fieldname> <indexname> */
/* script_name.php <hostname> 'query' <fieldname> */
/* script_name.php <hostname> 'query' <indexname> */
/* <hostname>: hostname */
/* <fieldname>: index, descr, calls, max, avail, used */
/* <indexname>: location name */
/* NOTE: */
/* do not include newline (\n) when echoing 'get' or 'index_count' commands, */
/* but must have for 'index' or 'query' commands */

I hope this will help someone new to cacti like me.

Cheers,
~Theiss
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests