[ previous ] [ next ] [ threads ]
 
 From:  "Mohammed Ismail" <m dot ismael at gmail dot com>
 To:  "'Adam Armstrong'" <lists at memetic dot org>
 Cc:  <m0n0wall at lists dot m0n0 dot ch>
 Subject:  RE: [m0n0wall] ng0 snmp could not read interface
 Date:  Wed, 6 May 2009 10:57:54 +0300
-----Original Message-----
From: Adam Armstrong [mailto:lists at memetic dot org] 
Sent: Monday, May 04, 2009 8:29 PM
To: Mohammed Ismail
Cc: m0n0wall at lists dot m0n0 dot ch
Subject: Re: [m0n0wall] ng0 snmp could not read interface
Please put :

$config['snmpbulkwalk'] = "/usr/bin/snmpbulkwalk";

Into config.php

Observer from 0.6 now uses snmpbulkwalk for walking interface tables.

> $cmd  = $config['snmpwalk'] . " -m IF-MIB -O nsq -" . $device['snmpver'] .
"
> -c " . $device['community'] . " " .
$device['hostname'].":".$device['port'];

#
I see only these interfaces via SNMP from m0n0 :

root@alpha:~# snmpwalk -v2c -c <THING> jersey.memetic.org ifDescr
IF-MIB::ifDescr.1 = STRING: vr0
IF-MIB::ifDescr.2 = STRING: vr1
IF-MIB::ifDescr.3 = STRING: vr2
IF-MIB::ifDescr.4 = STRING: lo0
IF-MIB::ifDescr.5 = STRING: enc0
IF-MIB::ifDescr.6 = STRING: ng0
IF-MIB::ifDescr.7 = STRING: gif0

What do you see on an snmpwalk? Can you show me your config.php?
adam.

>>>>>>>>>>>>>

server# snmpwalk -v2c -c community xxx.xxx.com ifDescr
IF-MIB::ifDescr.1 = STRING: fxp0
IF-MIB::ifDescr.2 = STRING: xl0
IF-MIB::ifDescr.3 = STRING: xl1
IF-MIB::ifDescr.4 = STRING: lo0
IF-MIB::ifDescr.5 = STRING: enc0
IF-MIB::ifDescr.6 = STRING: ng0

This is my output when I use the command>
Still cannot see ng0 in observer

This is my config.php
>>
<?php

### Database config
$config['db_host'] = "localhost";
$config['db_user'] = "xxx";
$config['db_pass'] = "xxx";
$config['db_name'] = "xxx";

### Installation Location
$config['install_dir'] 	= "/usr/local/www/observer";
$config['html_dir']	= $config['install_dir'] . "/html";
$config['rrd_dir'] 	= $config['install_dir'] . "/rrd";

### Default community
$config['community'] = "m0n0";

$config['base_url'] = "http://www.xxx.com";

### Location of executables

$config['sipcalc'] = "/usr/local/bin/sipcalc";
$config['rrdtool'] = "/usr/local/bin/rrdtool";
$config['fping'] = "/usr/local/sbin/fping";
$config['ipcalc'] = "/usr/local/bin/ipcalc";
$config['snmpwalk'] = "/usr/local/bin/snmpwalk";
$config['snmpget'] = "/usr/local/bin/snmpget";
$config['snmpbulkwalk'] = "/usr/local/bin/snmpbulkwalk";
$config['snmpset'] = "/usr/local/bin/snmpset";

### RRDGraph Settings

# Set the general colours and other settings for rrdtool graphs

$config['rrdgraph_defaults'] = array("-c", "BACK#FFFFFF", "-c",
"SHADEA#E5E5E5", "-c", "SHADEB#E5E5E5",
                                     "-c", "FONT#000000", "-c",
"CANVAS#FFFFFF", "-c", "GRID#aaaaaa",
                                     "-c", "MGRID#FFAAAA", "-c",
"FRAME#5e5e5e", "-c", "ARROW#5e5e5e",
                                     "-R", "normal");

$config['overlib_defaults'] = ",FGCOLOR,'#e5e5e5', BGCOLOR, '#e5e5e5'";


## List of networks to allow scanning-based discovery.
$config['nets'] =  array ("10.0.0.0/8", "172.22.0.0/16");

## Your local domain name and specifics
$config['mydomain'] = "xxx.com";
$config['page_title']  = "ObserverNMS";
$config['title_image'] = $config['base_url'] . "images/observer-logo.jpg";
$config['stylesheet']  = "css/styles.css"; 
$config['mono_font'] = $config['install_dir'] . "/fonts/DejaVuSansMono.ttf";
$config['favicon'] = "favicon.ico";
$config['header_color'] = "#1F334E";

$config['page_refresh'] = "90";  ## Refresh the page every xx seconds
$config['front_page'] = "pages/front/default.php";

$config['email_default']  = "m dot ismael at gmail dot com";
$config['email_from']     = "Observer <observer at xxx dot com>";
$config['email_headers']  = "From: " . $config['email_from'] . "\r\n";

### Which interface sections should we show?

$config['int_customers']       = 0;  # Enable Customer Port Parsing
$config['int_transit']         = 0;  # Enable Transit Types
$config['int_peering']         = 0;  # Enable Peering Types
$config['int_core']            = 0;  # Enable Core Port Types
$config['int_l2tp']            = 0;  # Enable L2TP Port Types

$config['show_locations']      = 1;  # Enable Locations on menu

### Which additional features should we enable?

$config['enable_bgp'] 		= 0; # Enable BGP session collection and
display
$config['enable_syslog'] 	= 0; # Enable Syslog
$config['enable_billing']	= 0; # Enable BGP session collection and
display
$config['enable_inventory']     = 1; # Enable Inventory
$config['enable_pseudowires']	= 0; # Enable Cisco Pseudowires

## Uncomment this to enable display of rancid-collected configs
#$config['rancid_configs']      = '/var/lib/rancid/network/configs/';
$config['cdp_autocreate']       = false;    # Should we autocreate hosts we
see via CDP?
$config['snmp_autodiscovery']   = false;    # Should we scan for and
autocreate hosts via snmp?
                                            # SNMP autodiscovery is * NOT
WORKING *

## If a syslog entry contails these strings it is deleted from the database
$config['syslog_filter'] = array("last message repeated", "Connection from
UDP: [127.0.0.1]:"); 

$config['syslog_age']    = "1 month"; ## Time to keep syslog for in 
                                      ## MySQL DATE_SUB format (eg '1 day',
'1 month')

### Interface name strings to ignore
#$config['bad_if'] = array("null",  "unrouted", "eobc", "mpls", "sl0",
"lp0", "faith0",
#             "-atm layer", "-atm subif", "-shdsl", "-adsl", "-aal5",
"-atm", "stackport",
#             "async", "plip", "-physical", "-signalling", "control plane",
"stacksub",
#            "bri", "-bearer", "bluetooth", "isatap", "ras", "qos",
"miniport", "lo0", "enc0");
##
$config['bad_if_regexp'] = array("/serial[0-9]:/");

### Mountpoints to ignore

$config['ignore_mount'] = array("/kern", "/mnt/cdrom", "/dev", "/dev/pts",
"/proc/bus/usb");

### Style Options

$list_colour_a = "#ffffff";
$list_colour_b = "#eeeeee";

$warn_colour_a = "#ffeeee";
$warn_colour_b = "#ffcccc";

include("includes/static-config.php");

?>


And this is /includes/discovery/interfaces.php

<?

# Discover interfaces

  echo("Interfaces : ");
  $cmd  = $config['snmpwalk'] . " -m IF-MIB -O nsq -" . $device['snmpver'] .
"  -c " . $device['community'] . " " .
$device['hostname'].":".$device['port'];
  $cmd  = $config['snmpbulkwalk'] . " -m IF-MIB -O nsq -" .
$device['snmpver'] . " -c " . $device['community'] . " " .
$device['hostname'].":".$device['port'];
  $cmd .= " ifDescr";
  $interfaces = trim(shell_exec($cmd));
  $interfaces = str_replace("\"", "", $interfaces);
  $interfaces = str_replace("ifDescr.", "", $interfaces);
  $interfaces = str_replace(" ", "||", $interfaces);

  $interface_ignored = 0;
  $interface_added   = 0;

  foreach(explode("\n", $interfaces) as $entry){

    $entry = trim($entry);
    list($ifIndex, $ifDescr) = explode("||", $entry);

#    if($config['ifdescr'][$device['os']]) {
#      $ifDescr = shell_exec($config['snmpget'] . " -m IF-MIB -O qv -" .
$device['snmpver'] . " -c " . $device['community'] . " " .
$device['hostname'].":".$device['port'] . " ifDescr.$ifIndex");
#      $ifDescr = str_replace("No Such Object available on this agent at
this OID", "", $ifDescr);
#      $ifDescr = str_replace("No Such Instance currently exists at this
OID", "", $ifDescr);
#      $ifDescr = trim(str_replace("\"", "", $ifDescr));
#    } else { $ifDescr = trim(str_replace("\"", "", $ifName)); }


    if(!strstr($entry, "irtual")) {
      $if = trim(strtolower($ifDescr));
      $nullintf = 0;
      foreach($config['bad_if'] as $bi) {
      if (strstr($if, $bi)) {
          $nullintf = 1;
        }
      }
      $ifDescr = fixifName($ifDescr);
      if (preg_match('/serial[0-9]:/', $if)) { $nullintf = '1'; }
      if(!$config['allow_ng']) {
       if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = '1'; }
      }
      if ($nullintf == 0) {
        if(mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` WHERE
`device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) ==
'0') {
          mysql_query("INSERT INTO `interfaces`
(`device_id`,`ifIndex`,`ifDescr`) VALUES
('".$device['device_id']."','$ifIndex','$ifDescr')");
          # Add Interface
           echo("+");
        } else {
          mysql_query("UPDATE `interfaces` SET `deleted` = '0', `ifDescr` =
'$ifDescr' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` =
'$ifIndex'"); 
          if(mysql_affected_rows()) { 
            echo("*"); 
          } else {
            echo(".");
          }
        }
        $int_exists[] = "$ifIndex";
      } else { 
        # Ignored Interface
	#echo("$if \n");
	if(mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` WHERE
`device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) !=
'0') {
          mysql_query("UPDATE `interfaces` SET `deleted` = '1' WHERE
`device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
          # Delete Interface
          echo("-"); ## Deleted Interface
        } else {
          echo("X"); ## Ignored Interface
        }
      }
    } 
  }


  $sql = "SELECT * FROM `interfaces` WHERE `device_id`  =
'".$device['device_id']."' AND `deleted` = '0'";
  $query = mysql_query($sql);

  while ($test_if = mysql_fetch_array($query)) {
        unset($exists);
        $i = 0;
        while ($i < count($int_exists) && !$exists) {
            $this_if = $test_if['ifIndex'];
            if ($int_exists[$i] == $this_if) { $exists = 1; }
            $i++;
        }
        if(!$exists) {
          echo("-");
          mysql_query("UPDATE `interfaces` SET `deleted` = '1' WHERE
interface_id = '" . $test_if['interface_id'] . "'");
        }
  }

  unset($temp_exists);
  echo("\n");

?>