Re: Cacti script_server index invocation
Nitzan Zaifman <[email protected]> Thu, 18 Jun 2015 18:37:08 +0000
| Newsgroups | gmane.network.cacti.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks you very much,
Quote:
'
"Index Count Changed" == Cacti _always_ gets the number of indexes
'
Does this mean that cacti_always_gets the index count and if I happen to choose: "index count changed" then a full re-index will occur if that number is changed?
Or it means that ONLY had I choose this "index count changed" method, then *and only then* will cacti_always_gets this num_indexes? If I choose something else, then cacti won't get num_indexes nor the whole indexes.
In <some of my> scripts the cost of "index" and "num_index" is the same and very high compared to specific data asked. I want to avoid num_indexes and index queries as much as possible.
Can data queries (<input>) generate index queries?
I use script server scripts as a mean to "cache" results of other scripts, with the add benefit of allowing GUI access to choose interested stats with "queries", the data itself (results of other scripts) is saved in static array variables thus filled only once and read for whatever's needed.
Some of those underlying scripts can be very expensive.
BTW, IMHO this technique is very elegant and affective for those kind of things and should go to some FAQ or a new manual in the future, but NM that now.
BTW2, I use the same technique on full PHP script_server scripts (i.e. not running underlying scripts), and there I can granularly add stuff to my static data structures on first access - if it interests anyone on the list I'll provide an example.
Sorry for the lengthy mail and hope that that clarifies what I'm after.
If you need an example, this is part of a script server that runs expansive underlying scripts (the relevant cmd part):
switch ($cmd) {
case "index":
/*************/
# we have to have the whole bunch for index, I hope Cacti is smart enough not to ask this too much (only when asked with run query)... :/
if (!isset($statsArr[$host][$pythonScript])) {
$statsArr[$host][$pythonScript] = ss_runPythonCmd_init($pythonScript, $host);
}
foreach (array_keys($statsArr[$host][$pythonScript]) as $key) {
$returnStr .= $key.PHP_EOL;
}
break;
case "num_indexes":
/*******************/
# we have to have the whole bunch for num_indexes, I hope Cacti is smart enough not to ask this too much (only when asked with run query)... :/
if (!isset($statsArr[$host][$pythonScript])) {
$statsArr[$host][$pythonScript] = ss_runPythonCmd_init($pythonScript, $host);
}
$returnStr = count($statsArr[$host][$pythonScript]).PHP_EOL;
break;
case "query":
/*************/
# we have to have the whole bunch for query, I hope Cacti is smart enough not to ask this too much (i.e. not every poll, only when asked with run query)... :/
if (!isset($statsArr[$host][$pythonScript])) {
$statsArr[$host][$pythonScript] = ss_runPythonCmd_init($pythonScript, $host);
}
# support asking for services and service1, service2, ... queries (Cacti var |query_service2| for ex.)
foreach (array_keys($statsArr[$host][$pythonScript]) as $key) {
if ($property == 'services') {
$returnStr .= $key.':'.$key.PHP_EOL;
} elseif (preg_match("/^service(\d+)$/", $property, $matches)) {
$serviceArr=explode('.', $key);
$returnStr .= $key.':'.$serviceArr[$matches[1]-1].PHP_EOL;
} else {
$returnStr .= $key.':'.$statsArr[$host][$pythonScript][$key][$property].PHP_EOL;
}
}
break;
case "get":
/***********/
....
Thank you very much again.
-----Original Message-----
From: Gandalf [mailto:[email protected]]
Sent: Thursday, June 18, 2015 8:06 PM
To: Support requests/questions about cacti
Subject: Re: [cacti-user] Cacti script_server index invocation
This depends on the "re-index setting".
"Uptime goes backwards" == Cacti tracks system uptime. If current value is lower than resent value (remembered by Cacti), Cacti will assume a rebbot and perform a reindex operation.
"Index Count Changed" == Cacti _always_ gets the number of indexes present (this is _not_ a full reindex operation). If previous count <> current count, a full reindex is done
Counting the index is done the following way:
- in case there is an OID that represents the index count, this single OID is fetched
- in case of a (server) script query, the script is called with the "index"
operator. Depending on the script, the related action is performed
Reinhard
Am 10.06.2015 um 11:30 schrieb Nitzan Zaifman:
> Hi,
>
> I've tried the same question in the forums (http://forums.cacti.net/viewtopic.php?f=21&t=54713) for the last couple of days with no reply, I hope someone can pick it up here.
>
> I don't recall encountering this in the docs nor the FAQs, if it's there please enlighten me and if not IMHO it belongs there.
>
> I have a very expensive script server "index" query, one I want to do as seldom as possible.
> When does an index query called? once? whenever num_indexes change? can I set it up to only manually as num_indexes is equally as expensive.
>
> Thanks, Bye, Nitzan.
>
> ----------------------------------------------------------------------
> -------- _______________________________________________
> cacti-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cacti-user
>
------------------------------------------------------------------------------
_______________________________________________
cacti-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cacti-user
************************************************************************************
This footnote confirms that this email message has been scanned by PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************
------------------------------------------------------------------------------