Problem with script query and Index Count Changed re-index

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

Moderators: Developers, Moderators

Post Reply
youlzz
Posts: 14
Joined: Wed May 06, 2009 8:21 am

Problem with script query and Index Count Changed re-index

Post by youlzz »

Hello,
I need some help to understand the syntax for the script file and the xml file for script queries with Index Count Changed re-index method. Indeed, after reading the documentation, many messages on the forum and the examples given with Cacti installation, it is not clear for me.

For the re-index method Index Count Changed to work, there must be a field <arg_num_indexes> in the xml file. The value of this field (num_indexes in the example for Get Unix Mounted Partitions) is used by Cacti as an argument for the script file to retrieve the value of the index (a number of partitions for instance). I imagine Cacti will launched a command such as "perl xx.pl num_indexes" and if the return value is different from the previous one, the re-indexation will be performed. Am I right ?

I have 2 questions :
- why is there no "function" num_indexes in the corresponding script file query_unix_partitions.pl ?
- how is the re-indexation performed ? where should that function be ?

Thanks

Kevin
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Problem with script query and Index Count Changed re-ind

Post by BSOD2600 »

youlzz wrote:I imagine Cacti will launched a command such as "perl xx.pl num_indexes" and if the return value is different from the previous one, the re-indexation will be performed. Am I right ?
Basically, yes.
youlzz wrote:- why is there no "function" num_indexes in the corresponding script file query_unix_partitions.pl ?
Because disk/partitions counts typically don't change often between reboots?
youlzz wrote:- how is the re-indexation performed ? where should that function be ?
If the previous index count is different from the current, then a reindex is performed. For example, \cacti\resource\snmp_queries\interface.xml contains oid_num_indexes. So does my 'monitor processes' script. When cacti detects the process count has changed, one sees something like the following in the log:

Code: Select all

CMDPHP: Poller[0] ASSERT: '52=51' failed. Recaching host 'quad', data query #14 
youlzz
Posts: 14
Joined: Wed May 06, 2009 8:21 am

Post by youlzz »

- why is there no "function" num_indexes in the corresponding script file query_unix_partitions.pl ?

Because disk/partitions counts typically don't change often between reboots?
Maybe I did not choose the best example...

Imagine a router that never reboots with many interfaces, SNMP deactivated but another way retrieve the indexes, the data and the number of indexes by a script (perl, bash, ...).
Interfaces can be added or deleted without reboot so that the Index Count Changed re-index method seems the best ?
In that case, how is Cacti doing the re-indexation ? do I have to code it ?
If I have to code it : where ? how ?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

I'm not a programmer and in the code, but if the oid_num_indexes field is present in the XML script file, cacti stores the index count for that data query in the db. Then on the next polling pass, it compares the previous to the current index counts. If they're different, it'll issue a reindex for that data query (as shown in my previous post excerpt).

Looking through the existing cacti scripts and documentation, I'm not sure any script besides the SNMP XML ones can use the reindex logic from cacti. I think they leave it up to the script writer to do it...
youlzz
Posts: 14
Joined: Wed May 06, 2009 8:21 am

Post by youlzz »

There is a surprising thing in Cacti database : the table host_snmp_cache does not contain only SNMP queries cache values but also script queries cache values !!!

Indeed BSOD2600, the table poller_reindex contains the number of indexes used for the re-index method Index Count Changed.

It seems difficult to write a method to do the re-indexation and I could not find any example except the one here http://docs.cacti.net/manual:087:3a_adv ... alkthrough but that script query uses SNMP (function cacti_snmp_walk) for the re-indexation !!!
Does someone know where I can find examples of re-indexation scripts which do not require SNMP ?

Thanks

Kevin
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest