File/bin/snmp_defs.inc.php

Description

/opt/nac/contrib/snmp_defs.inc

Long description for file:

  • Specific SNMP queries
  • Some functions for snmp scripts
  • tested on the following switches:
      • 3550
      • 3750
      Further reading: http://www.cisco.com/public/sw-center/netmgmt/cmtk/mibs.shtml The "getif" tool for exploring MIBs.

      PHP version 5

      LICENSE: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation.

      Functions
      callback (line 89)

      This function is called for any errors or

      messages sent to stdout/err. The idea is to catch all such messages and send them to syslog, this this is a daemon normally detached from the console

      void callback ( $buffer)
      • $buffer
      detect_hub (line 244)

      Detect if a hub is attached to a certain port If a hub is detected, suggest another vlan to avoid port flapping.

      So far it is only an adaptation from the old algorithm It hasn't been tested yet

      void detect_hub ( $REQUEST)
      • $REQUEST
      format_snmpmac (line 932)
      void format_snmpmac ( $mac)
      • $mac
      get_cisco_info (line 883)
      void get_cisco_info ( $switch,  $snmp_ro)
      • $switch
      • $snmp_ro
      get_snmp_index (line 485)
      void get_snmp_index ( $what,  $where)
      • $what
      • $where
      get_snmp_port_index (line 104)

      Get the snmp port index

      • return: Port index if found, false otherwise
      mixed get_snmp_port_index (mixed $switch, mixed $port)
      • mixed $port: Port name to look for.
      • mixed $switch: Switch to ask
      get_vlanid (line 862)
      void get_vlanid ( $default_id)
      • $default_id
      iface_exist (line 819)
      void iface_exist ( $switchid,  $portname)
      • $switchid
      • $portname
      is_mac_on_port (line 368)

      Tell whether a MAC address is on a certain port using SNMP

      • return: True if MAC found on that port, false otherwise
      boolean is_mac_on_port (mixed $mac, mixed $switch, mixed $port, mixed $vlan)
      • mixed $mac: MAC to look for
      • mixed $switch: Switch to look on
      • mixed $port: Switch port to look on
      • mixed $vlan: Vlan we'll use to look for that MAC address
      is_port_vmps (line 613)
      void is_port_vmps ( $myiface)
      • $myiface
      mac_exist (line 797)
      void mac_exist ( $mac)
      • $mac
      ping_mac2 (line 226)

      Ping a MAC address on a specific switch port

      • return: True if MAC has been found on the switch port
      boolean ping_mac2 (mixed $mac, mixed $switch, mixed $port, mixed $vlan)
      • mixed $mac: MAC address to ping
      • mixed $switch: Switch we want to query
      • mixed $port: switch port we want to query
      • mixed $vlan: VLAN to use to perform the query
      ports_on_switch (line 412)
      void ports_on_switch ( $switch)
      • $switch
      remove_type (line 210)

      Remove the type of one element and leave only the value.

      This function is to be used when performing SNMP operations Example: INTEGER:33

      • return: Value without type
      mixed remove_type (mixed $element)
      • mixed $element: Element to remove type from
      set_port_as_dynamic (line 500)
      void set_port_as_dynamic ( $switch,  $port, [ $snmp_port_index = false])
      • $switch
      • $port
      • $snmp_port_index
      set_port_as_static (line 544)
      void set_port_as_static ( $switch,  $port,  $vlan, [ $snmp_port_index = false])
      • $switch
      • $port
      • $vlan
      • $snmp_port_index
      snmp_restart_port (line 322)

      Wrapper around the restart_port script.

      Restart a switch port

      void snmp_restart_port (mixed $port, mixed $switch)
      • mixed $port: Port name
      • mixed $switch: Switch
      snmp_restart_port_id (line 341)

      Wrapper around snmp_restart_port

      void snmp_restart_port_id (integer $port_id)
      • integer $port_id: ID of the port we want to restart
      switch_exist (line 841)
      void switch_exist ( $name,  $value)
      • $name
      • $value
      turn_off_port (line 170)

      Turn off a determined port identified by its index.

      • return: True if port was successfully switched off, false otherwise
      boolean turn_off_port ( $switch,  $port, [mixed $port_index = false])
      • mixed $port_index: Port index according to SNMP
      • $switch
      • $port
      turn_on_port (line 132)

      Turn on a determined port identified by its index.

      • return: True if port was successfully switched on, false otherwise
      boolean turn_on_port ( $switch,  $port, [mixed $port_index = false])
      • mixed $port_index: Port index according to SNMP
      • $switch
      • $port
      vlans_on_switch (line 462)
      void vlans_on_switch ( $switch)
      • $switch
      vm_type (line 439)
      void vm_type ( $switch)
      • $switch
      walk_macs (line 942)
      void walk_macs ( $switch,  $vlanid,  $snmp_ro)
      • $switch
      • $vlanid
      • $snmp_ro
      walk_ports (line 635)
      void walk_ports ( $switch,  $snmp_ro)
      • $switch
      • $snmp_ro
      walk_switchhw (line 1060)
      void walk_switchhw ( $switch,  $snmp_ro)
      • $switch
      • $snmp_ro
      walk_switchsw (line 1080)
      void walk_switchsw ( $switch,  $snmp_ro)
      • $switch
      • $snmp_ro
      walk_vlans (line 1029)
      void walk_vlans ( $switch,  $snmp_ro)
      • $switch
      • $snmp_ro

      Documentation generated on Mon, 13 Oct 2008 01:10:44 +0200 by phpDocumentor 1.4.0