<rewrite_index> issue

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

Moderators: Developers, Moderators

Post Reply
jhonnyx
Cacti User
Posts: 87
Joined: Sun Feb 26, 2017 10:33 am

<rewrite_index> issue

Post by jhonnyx »

Hi Everyone,

I need to query a specific OID using the value from another input as index, I understand that <rewrite_index> is an option for this.

In my code I am calling up to CPUIndexcpuPhysIndex from cpuName

Code: Select all

<interface>
        <name>Cisco IOS XE cpu usage</name>
        <description>Get CPU usage for IOS XE stacks</description>
        <index_order_type>numeric</index_order_type>
        <oid_index>.1.3.6.1.4.1.9.9.109.1.1.1.1.2</oid_index>
        <oid_index_parse>OID/REGEXP:.*\.([0-9]+)$</oid_index_parse>

        <fields>
                <CPUIndexcpuPhysIndex>
                        <name>CPU Index</name>
                        <method>get</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.4.1.9.9.109.1.1.1.1.2</oid>
                </CPUIndexcpuPhysIndex>
                <cpuName>
                        <name>Switch Name</name>
                        <method>get</method>
                        <source>value</source>
                        <direction>input</direction>
                        <rewrite_index>|query_CPUIndexcpuPhysIndex|</rewrite_index>
                        <oid>.1.3.6.1.2.1.47.1.1.1.1.7</oid>
                </cpuName>
                <cpuFiveSec>
                        <name>CPU usage 5 sec</name>
                        <method>get</method>
                        <source>value</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.9.9.109.1.1.1.1.6</oid>
                </cpuFiveSec>
                <cpuOneMin>
                        <name>CPU usage 1 min</name>
                        <method>get</method>
                        <source>value</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.9.9.109.1.1.1.1.7</oid>
                </cpuOneMin>
                <cpuFiveMin>
                        <name>CPU usage 5 min</name>
                        <method>get</method>
                        <source>value</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.4.1.9.9.109.1.1.1.1.8</oid>
                </cpuFiveMin>
        </fields>
</interface>
This is the outcome :

Data Query Debug Information
Total: 0.000000, Delta: 0.000000, Running data query [15].
Total: 0.000000, Delta: 0.000000, Found type = '3' [SNMP Query].
Total: 0.000000, Delta: 0.000000, Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/cisco_xe_cpu.xml'
Total: 0.000000, Delta: 0.000000, XML file parsed ok.
Total: 0.000000, Delta: 0.000000, <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries
Total: 0.040000, Delta: 0.040000, Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.9.9.109.1.1.1.1.2' Index Count: 2
Total: 0.040000, Delta: 0.000000, Index found at OID: '.1.3.6.1.4.1.9.9.109.1.1.1.1.2.19' value: '1000'
Total: 0.040000, Delta: 0.000000, Index found at OID: '.1.3.6.1.4.1.9.9.109.1.1.1.1.2.20' value: '2000'
Total: 0.040000, Delta: 0.000000, index_parse at OID: '.1.3.6.1.4.1.9.9.109.1.1.1.1.2.19' results: '19'
Total: 0.040000, Delta: 0.000000, index_parse at OID: '.1.3.6.1.4.1.9.9.109.1.1.1.1.2.20' results: '20'
Total: 0.040000, Delta: 0.000000, Located input field 'CPUIndexcpuPhysIndex' [get]
Total: 0.080000, Delta: 0.040000, Executing SNMP get for data @ '.1.3.6.1.4.1.9.9.109.1.1.1.1.2.19' [value='1000']
Total: 0.110000, Delta: 0.040000, Executing SNMP get for data @ '.1.3.6.1.4.1.9.9.109.1.1.1.1.2.20' [value='2000']
Total: 0.110000, Delta: 0.000000, Located input field 'cpuName' [get]
Executing SNMP get for 2 oids
Got SNMP get result for data @ '.1.3.6.1.2.1.47.1.1.1.1.7.1000' [value=''] (index: 19)
Got SNMP get result for data @ '.1.3.6.1.2.1.47.1.1.1.1.7.2000' [value=''] (index: 20)

Total: 0.120000, Delta: 0.010000, Update data query sort cache complete
Total: 0.120000, Delta: 0.000000, Updated data query index ordering
Total: 0.160000, Delta: 0.040000, Update re-index cache complete
Total: 0.160000, Delta: 0.010000, Update graph data query cache complete
Total: 0.170000, Delta: 0.000000, Update data source data query cache complete
Total: 0.170000, Delta: 0.000000, Update data query cache complete
Total: 0.180000, Delta: 0.010000, Update poller cache from query complete
Total: 0.190000, Delta: 0.010000, Automation execute data query complete
Total: 0.190000, Delta: 0.000000, Plugin hooks complete

below the snmpget that should be the result of the query :

.1.3.6.1.2.1.47.1.1.1.1.7.1000 = STRING: "Switch 1"
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: <rewrite_index> issue

Post by netniV »

I've posted a reply on GitHub to your issue #1921 giving a brief breakdown on how the function works.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
jhonnyx
Cacti User
Posts: 87
Joined: Sun Feb 26, 2017 10:33 am

Re: <rewrite_index> issue

Post by jhonnyx »

thanks,

I also replied on Github, we can follow up there and update here in case at the end
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest