Autom8 Rule Speed

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

Post Reply
Seratio
Posts: 6
Joined: Mon May 02, 2016 1:37 am

Autom8 Rule Speed

Post by Seratio »

Hi everyone,

currently im creating a lot of automate rules for our entire equipment. Unfortunately adding a host to cacti, will be very slow if there is a large amount of rules.

Is it possible to deactivate running the rules on adding or editing a host? The best would be, if the rules are run by poller only or once a day.

Additionaly what is the best practice for rules? Large REGEX or a lot of conditions in a rule?

For example i created the following regex to fetch all important interfaces on cisco, juniper and brocade devices, which ends up in over 11000 up interfaces

^((xe|ge|et|fe)-[0-9]+\/[0-9]+\/[0-9]+|((lag|ae|me|vme|fxp|st|reth)[0-9]+)|(ethernet[0-9]+\/[0-9]+\/[0-9]+)|(Gigabit|Fast)Ethernet[0-9]+\/[0-9]+)$

Using a basic rule with this regex creates the following SQL:

Code: Select all

SELECT * FROM (SELECT host.hostname AS autom8_host, host_id, host.disabled, host.status, snmp_query_id, snmp_index , MAX(CASE WHEN field_name='ifAlias' THEN field_value ELSE NULL END) AS 'ifAlias', MAX(CASE WHEN field_name='ifDescr' THEN field_value ELSE NULL END) AS 'ifDescr', MAX(CASE WHEN field_name='ifHighSpeed' THEN field_value ELSE NULL END) AS 'ifHighSpeed', MAX(CASE WHEN field_name='ifHwAddr' THEN field_value ELSE NULL END) AS 'ifHwAddr', MAX(CASE WHEN field_name='ifIndex' THEN field_value ELSE NULL END) AS 'ifIndex', MAX(CASE WHEN field_name='ifIP' THEN field_value ELSE NULL END) AS 'ifIP', MAX(CASE WHEN field_name='ifName' THEN field_value ELSE NULL END) AS 'ifName', MAX(CASE WHEN field_name='ifOperStatus' THEN field_value ELSE NULL END) AS 'ifOperStatus', MAX(CASE WHEN field_name='ifSpeed' THEN field_value ELSE NULL END) AS 'ifSpeed', MAX(CASE WHEN field_name='ifType' THEN field_value ELSE NULL END) AS 'ifType' FROM host_snmp_cache LEFT JOIN host ON (host_snmp_cache.host_id=host.id) LEFT JOIN host_template ON (host.host_template_id=host_template.id) WHERE snmp_query_id=1 AND (  host_template.name REGEXP '(Juniper|Brocade|Cisco)')  GROUP BY host_id, snmp_query_id, snmp_index  ORDER BY autom8_host, CAST(snmp_index AS unsigned)) AS a WHERE (  a.ifOperStatus <=> 'Up' AND a.ifName REGEXP '^((xe|ge|et|fe)-[0-9]+\\/[0-9]+\\/[0-9]+|((lag|ae|me|vme|fxp|st|reth)[0-9]+)|(ethernet[0-9]+\\/[0-9]+\\/[0-9]+)|(Gigabit|Fast)Ethernet[0-9]+\\/[0-9]+)$');
Which takes over 11 seconds..


Regards
Alex
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Autom8 Rule Speed

Post by Osiris »

You should run an explain query on that rule to see if adding an index will help.
Before history, there was a paradise, now dust.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests