Send Netdot-devel mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."


Today's Topics:

   1. [SCM] Netdot branch netdot-1.0 updated.
      netdot-1.0.4-90-g08e39d0 ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Thu, 15 Aug 2013 07:41:50 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
        netdot-1.0.4-90-g08e39d0
To: [email protected]
Message-ID: <[email protected]>

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".

The branch, netdot-1.0 has been updated
       via  08e39d0ea869577440a53827c1ed412d78fa3a70 (commit)
      from  b56ec672bd51b52286fb6054da62d4dc77591af0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 08e39d0ea869577440a53827c1ed412d78fa3a70
Author: Carlos Vicente <[email protected]>
Date:   Thu Aug 15 10:39:44 2013 -0400

    Include option to ignore interfaces when populating Cacti, given name 
patterns

diff --git a/export/cacti/netdot_to_cacti.php b/export/cacti/netdot_to_cacti.php
index 4ee1536..ab52efe 100644
--- a/export/cacti/netdot_to_cacti.php
+++ b/export/cacti/netdot_to_cacti.php
@@ -394,6 +394,7 @@ foreach ($groups as $group => $hosts){
        $GraphAttr["hostTemplateId"] = $template_id;
        $GraphAttr["hostId"]         = $hostId;
        $GraphAttr["description"]    = $description;
+       $GraphAttr["ignoreIntsLike"] = $ignoreIntsLike;
        debug("$description: Creating ds graphs: $descr");
        $dsGraphsCreated = create_ds_graphs($GraphAttr);
        if ( $dsGraphsCreated ){
@@ -448,6 +449,7 @@ function create_ds_graphs($args) {
   $description     = $args["description"];
   $queryTypeIds    = $args["queryTypeIds"];
   $snmpQueryId     = $args["snmpQueryId"];
+  $ignoreIntsLike  = $args["ignoreIntsLike"];
 
   if (!isset($hostId) || !isset($description) || !isset($queryTypeIds) || 
!isset($snmpQueryId)){
     echo "ERROR: create_ds_graph: Missing required arguments\n";
@@ -490,10 +492,55 @@ function create_ds_graphs($args) {
    if (isset($args["snmpCriteria"]) && $args["snmpCriteria"] != ""){
      $indexes_query .= " AND ". $args["snmpCriteria"];
    }
-   
+
    $snmpIndexes = db_fetch_assoc($indexes_query);
+
+   // Interfaces to ignore
+
+   if($snmpQueryId == 1 && count($snmpIndexes) && 
+      isset($ignoreIntsLike) && count($ignoreIntsLike)){
+     $ignQuery = "SELECT snmp_index
+                  FROM   host_snmp_cache
+                  WHERE  host_id='$hostId'
+                    AND  snmp_query_id=1
+                    AND  field_name='ifDescr'";
+     
+     $patts = array();
+     foreach ($ignoreIntsLike as $patt){
+       array_push($patts, "field_value LIKE '$patt'");
+     }
+
+     $crit = implode(' OR ', $patts);
+     $ignQuery .= " AND ($crit)";
+
+     debug('$ignQuery is: '.$ignQuery);
+     $ignIndexes = db_fetch_assoc($ignQuery);
+
+     // Make into an associative array for faster lookups
+     $ignHash = array();
+     foreach ($ignIndexes as $row){
+       $ignHash[$row["snmp_index"]] = TRUE;
+     }
+
+     debug('$ignHash has: ');
+     debug(var_export($ignHash));
+     
+     if (count($ignHash)){
+       // Now exclude the indexes that matched the ignore patterns
+       $temparr = array();
+       foreach ($snmpIndexes as $row){
+        if (!isset($ignHash[$row["snmp_index"]])) {
+          array_push($temparr, $row);
+        }
+       }
+       $snmpIndexes = $temparr;
+     }
+   }
+
+   debug('$snmpIndexes has: '); 
+   debug(var_export($snmpIndexes));
    
-   if (sizeof($snmpIndexes)) {
+   if (count($snmpIndexes)) {
     $graphsCreated = 0;
     $graphs = db_fetch_assoc("SELECT id, snmp_index, graph_template_id
                               FROM   graph_local
diff --git a/export/cacti/netdot_to_cacti_config.php 
b/export/cacti/netdot_to_cacti_config.php
index d23dea4..75fdbac 100644
--- a/export/cacti/netdot_to_cacti_config.php
+++ b/export/cacti/netdot_to_cacti_config.php
@@ -102,6 +102,11 @@ $dsGraphs["any"]["Interface Statistics"]["queryTypeIds"] = 
array(2  => 22,  // I
                                                                 4  => 23,  // 
In/Out Unicast Packets
                                                                 13 => 2,   // 
In/Out Bits
                                                                 );
+
+// Ignore interfaces matching these patterns in their names
+// Notice that we use the '%' wildcard for SQL
+$ignoreIntsLike = array('lo%', 'ipfw%', 'usbus%', 'plip%', 'dwdm%', 
'127.0.0.%');
+
 /* Host MIB Mounted Partitions Stats */
 $dsGraphs["3"]["Mounted Partitions"]["snmpQueryId"]  = 8;
 $dsGraphs["3"]["Mounted Partitions"]["snmpCriteria"] = 
"field_name='hrStorageIndex'";

-----------------------------------------------------------------------

Summary of changes:
 export/cacti/netdot_to_cacti.php        |   51 +++++++++++++++++++++++++++++-
 export/cacti/netdot_to_cacti_config.php |    5 +++
 2 files changed, 54 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
Netdot


------------------------------

_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel


End of Netdot-devel Digest, Vol 77, Issue 8
*******************************************

Reply via email to