Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sun May 28, 2017 11:01 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Autom8 Rule Speed
PostPosted: Thu Jun 02, 2016 5:33 am 
Offline

Joined: Mon May 02, 2016 1:37 am
Posts: 6
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 * 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


Top
 Profile  
 
 Post subject: Re: Autom8 Rule Speed
PostPosted: Tue Dec 20, 2016 7:59 pm 
Offline
Cacti User
User avatar

Joined: Mon Jan 05, 2015 10:10 am
Posts: 289
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group