SNMP Queries (index) - Limit/Ignore Rows
Moderators: Developers, Moderators
SNMP Queries (index) - Limit/Ignore Rows
Okay, so I'm working on a query for Canopy Access Units, these seem to return 255 values, regardless of how many current access units are attached.
I'm wondering if there is some way to have cacti "ignore" indexes with certain values...
There are like 255 entries here, most of which are empty, not to mention, I'd like it to sort (and query) on the ESN of the link, however, since all the empty results define the ESN as 0:0:0:0:0:0, its not detected as a "valid" index...
I'd like to some how ignore an entry with the ESN as 0:0:0:0:0:0.
Any pointers on this?
I'm wondering if there is some way to have cacti "ignore" indexes with certain values...
There are like 255 entries here, most of which are empty, not to mention, I'd like it to sort (and query) on the ESN of the link, however, since all the empty results define the ESN as 0:0:0:0:0:0, its not detected as a "valid" index...
I'd like to some how ignore an entry with the ESN as 0:0:0:0:0:0.
Any pointers on this?
- Attachments
-
- query.jpg (77.73 KiB) Viewed 7309 times
I just edited the PHP code...
I added a field to the definition of snmp_query's for this purpose...
I.E.
The <ignore> field is a regular expression....
I added a field to the definition of snmp_query's for this purpose...
I.E.
Code: Select all
<linkSessState>
<name>Session State</name>
<method>walk</method>
<source>value</source>
<direction>input</direction>
<ignore>/^6$/</ignore>
<oid>.1.3.6.1.4.1.161.19.3.1.4.1.19</oid>
</linkSessState>
Code: Select all
*** lib/data_query.php 2006-01-03 21:08:30.000000000 -0600
--- /var/www/html/cacti/lib/data_query.php 2006-10-11 19:59:11.000000000 -0500
*************** function query_snmp_host($host_id, $snmp
*** 177,183 ****
}
db_execute("delete from host_snmp_cache where host_id='$host_id' and snmp_query_id='$snmp_query_id'");
!
while (list($field_name, $field_array) = each($snmp_queries["fields"])) {
if ((!isset($field_array["oid"])) && ($field_array["source"] == "index")) {
for ($i=0; $i<sizeof($snmp_index); $i++) {
--- 177,183 ----
}
db_execute("delete from host_snmp_cache where host_id='$host_id' and snmp_query_id='$snmp_query_id'");
! $ignores = Array();
while (list($field_name, $field_array) = each($snmp_queries["fields"])) {
if ((!isset($field_array["oid"])) && ($field_array["source"] == "index")) {
for ($i=0; $i<sizeof($snmp_index); $i++) {
*************** function query_snmp_host($host_id, $snmp
*** 199,204 ****
--- 199,215 ----
debug_log_insert("data_query", "Executing SNMP get for data @ '$oid' [value='$value']");
+ $deleted = 0;
+ if (isset($field_array["ignore"])) {
+ if (preg_match($field_array["ignore"], $value)) {
+ db_execute("DELETE FROM host_snmp_cache WHERE
+ host_id='$host_id' AND snmp_index='$snmp_index'");
+ $deleted = 1;
+ debug_log_insert("data_query", "Inserting Ignore");
+ $ignores[$snmp_index] = 1;
+ }
+ }
+ if (!$deleted)
db_execute("replace into host_snmp_cache
(host_id,snmp_query_id,field_name,field_value,snmp_index,oid)
values ('$host_id','$snmp_query_id','$field_name','$value','" . $snmp_index[$i]["value"] . "','$oid')");
*************** function query_snmp_host($host_id, $snmp
*** 216,222 ****
if ($field_array["source"] == "value") {
for ($i=0; $i<sizeof($snmp_data); $i++) {
$snmp_index = ereg_replace($index_parse_regexp, "\\1", $snmp_data[$i]["oid"]);
!
$oid = $field_array["oid"] . ".$snmp_index";
if ($field_name == "ifOperStatus") {
--- 227,233 ----
if ($field_array["source"] == "value") {
for ($i=0; $i<sizeof($snmp_data); $i++) {
$snmp_index = ereg_replace($index_parse_regexp, "\\1", $snmp_data[$i]["oid"]);
! if (isset($ignores[$snmp_index])) continue;
$oid = $field_array["oid"] . ".$snmp_index";
if ($field_name == "ifOperStatus") {
*************** function query_snmp_host($host_id, $snmp
*** 226,231 ****
--- 237,253 ----
debug_log_insert("data_query", "Found item [$field_name='" . $snmp_data[$i]["value"] . "'] index: $snmp_index [from value]");
+ $deleted = 0;
+ if (isset($field_array["ignore"])) {
+ if (preg_match($field_array["ignore"], $snmp_data[$i]["value"])) {
+ db_execute("DELETE FROM host_snmp_cache WHERE
+ host_id='$host_id' AND snmp_index='$snmp_index'");
+ $deleted = 1;
+ debug_log_insert("data_query", "Inserting Ignore");
+ $ignores[$snmp_index] = 1;
+ }
+ }
+ if (!$deleted)
db_execute("replace into host_snmp_cache
(host_id,snmp_query_id,field_name,field_value,snmp_index,oid)
values ('$host_id','$snmp_query_id','$field_name','" . $snmp_data[$i]["value"] . "','$snmp_index','$oid')");
*************** function query_snmp_host($host_id, $snmp
*** 249,254 ****
--- 271,287 ----
$oid = $field_array["oid"] . "." . $value;
debug_log_insert("data_query", "Found item [$field_name='$value'] index: $snmp_index [from regexp oid parse]");
+ $deleted = 0;
+ if (isset($field_array["ignore"])) {
+ if (preg_match($field_array["ignore"], $snmp_data[$i]["value"])) {
+ db_execute("DELETE FROM host_snmp_cache WHERE
+ host_id='$host_id' AND snmp_index='$snmp_index'");
+ $deleted = 1;
+ debug_log_insert("data_query", "Inserting Ignore");
+ $ignores[$snmp_index] = 1;
+ }
+ }
+ if (!$deleted)
db_execute("replace into host_snmp_cache
(host_id,snmp_query_id,field_name,field_value,snmp_index,oid)
*************** function query_snmp_host($host_id, $snmp
*** 261,266 ****
--- 294,310 ----
$oid = $field_array["oid"] . "." . $value;
debug_log_insert("data_query", "Found item [$field_name='$value'] index: $snmp_index [from regexp value parse]");
+ $deleted = 0;
+ if (isset($field_array["ignore"])) {
+ if (preg_match($field_array["ignore"], $snmp_data[$i]["value"])) {
+ db_execute("DELETE FROM host_snmp_cache WHERE
+ host_id='$host_id' AND snmp_index='$snmp_index'");
+ $deleted = 1;
+ debug_log_insert("data_query", "Inserting Ignore");
+ $ignores[$snmp_index] = 1;
+ }
+ }
+ if (!$deleted)
db_execute("replace into host_snmp_cache
(host_id,snmp_query_id,field_name,field_value,snmp_index,oid)
Last edited by gnarf on Thu Oct 12, 2006 1:10 pm, edited 1 time in total.
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
Find feature request for this at http://bugs.cacti.net/view.php?id=836
Reinhard
Reinhard
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
I say this because I have to... But this is broken behavior on the part of the Canopy snmp implementation.
Plus, if this is associated SM, then you have a bigger problem, as they can move from AP to AP on the tower and disappear and reappear on the same AP.
Plus, if this is associated SM, then you have a bigger problem, as they can move from AP to AP on the tower and disappear and reappear on the same AP.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
Yeah, they can, however for the most part they are going to stay with the one AP. We have very little overlap in the signal of the canopy AU's we are using.
And I agree, it is broken SNMP implentation, however, the same issue might catch up other places. I really didn't feel like going through the overhead of setting up a Script Query for something that was entirely obtainable through SNMP
And I agree, it is broken SNMP implentation, however, the same issue might catch up other places. I really didn't feel like going through the overhead of setting up a Script Query for something that was entirely obtainable through SNMP
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
2 words, that I know you know like..
Script Query....
That way too, you can do a script query for a tower setup that defines the tower as one device in Cacti, instead of using each AP.
Now, if you use the PHP Script Server, you can use the Cacti snmp functions to get the values from the devices. This will not be as fast as native snmp in Cacti cmd.php or cactid, but it would be faster than a perl or shell script.
Script Query....
That way too, you can do a script query for a tower setup that defines the tower as one device in Cacti, instead of using each AP.
Now, if you use the PHP Script Server, you can use the Cacti snmp functions to get the values from the devices. This will not be as fast as native snmp in Cacti cmd.php or cactid, but it would be faster than a perl or shell script.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
Who is online
Users browsing this forum: No registered users and 5 guests