Re-Index Hosts

Re-Indexing is required only for SNMP/Script Data Queries. Remember, that whan applying a Data Query to a Host, a Re-Index Method has to be chosen. This reindex method governs the automatic re-indexing based on specific events.

Table 20-1. Re_Index Methods

Re-Index MethodDescription
Uptime Goes BackwardsRefers to a system reboot. Cacti will detect if the target has been rebootet by querying sysUptime (.1.3.6.1.2.1.1.3.0). If the current value for the uptime is lower than the previous one (uptime goes backwards), a reboot is assumed and a re-index is performed
Index Count ChangedRefers to a change of the number of indexed items, e.g. interfaces, without checking sysUptime. It is of particular interest in cases, where indexed entries may change without the need of a reboot. As modern operating systems seldom require reboots for system configuration changes, you may want to consider this setting for many cases (e.g. creating of a new filesystem without a reboot). The index to be considered is defined by the according XML file.
Verify All FieldsAll index fields of the according XML file are checked for changes. This is of particular interest e.g. in cases, where the index is non-numeric (e.g. a MAC address).

If you feel the need for manual re-indexing, you may run it from cli. Calling the script with the parameter --help yields

shell>php -q poller_reindex_hosts.php --help
Cacti Reindex Host Script 1.2, Copyright 2004-2013 - The Cacti Group

usage: poller_reindex_hosts.php --id=[host_id|All] [--qid=[ID|All]] [--host-descr=[description]]
                           [-d] [-h] [--help] [-v] [--version]

--id=host_id             - The host_id to have data queries reindexed or 'All' to reindex all hosts
--qid=query_id           - Only index on a specific data query id; defaults to 'All'
--host-descr=description - The host description to filter by (SQL filters acknowledged)
--debug                  - Display verbose output during execution
-v --version             - Display this help message
-h --help                - Display this help message

Running it in debug mode for the host with id=2 may yield

shell>php -q poller_reindex_hosts.php -id=2 -d
WARNING: Do not interrupt this script.  Reindexing can take quite some time
DEBUG: There are '1' data queries to run
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' starting
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' ending

A silent run for all devices is issued by

shell>php -q poller_reindex_hosts.php -id=All
WARNING: Do not interrupt this script.  Reindexing can take quite some time
.....shell>

You may run this script against a specific data query id using --qid=[data query id] like

shell>php -q poller_reindex_hosts.php --id=All --qid=1 -d
WARNING: Do not interrupt this script.  Reindexing can take quite some time
DEBUG: There are '3' data queries to run
DEBUG: Data query number '1' host: '1' SNMP Query Id: '1' starting
DEBUG: Data query number '1' host: '1' SNMP Query Id: '1' ending
DEBUG: Data query number '2' host: '2' SNMP Query Id: '1' starting
DEBUG: Data query number '2' host: '2' SNMP Query Id: '1' ending
DEBUG: Data query number '3' host: '15' SNMP Query Id: '1' starting
DEBUG: Data query number '3' host: '15' SNMP Query Id: '1' ending

It is possible, to select a host based on its host description using --host-descr=[host description]. It is allowed to apply an SQL filter expression for the description like --qid=some%descr. Use this parameter in conjunction with either --id=[host id] or --qid=[data query id] or both:

shell>php -q poller_reindex_hosts.php --id=All --qid=1 --host-descr=ga%f -d
WARNING: Do not interrupt this script.  Reindexing can take quite some time
DEBUG: There are '1' data queries to run
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' starting
DEBUG: Data query number '1' host: '2' SNMP Query Id: '1' ending

Stop the Poller during Re-Indexing

Re-Indexing interferes with the poller operation. Please make sure, that the poller is not running and will not start during a reindex operation