ping_switch.php

As of FreeNAC v3.0 we introduced the ping_switch.php script. The purpose of this script is to determine the status of the switch ports which are part of a FreeNAC system.

The status of a port is determined via SNMP, retrieving the IfAdminStatus object (OID: 1.3.6.1.2.1.2.2.1.7) from the switch. The states defined for this object are as follows:

  1. up
  2. down
  3. testing

The testing state indicates that no operational packages can be passed.

Since this script makes extensive use of SNMP, make sure you adjust your SNMP communities in the etc/config.inc file.

ping_switch.php takes the list of switches to query from the FreeNAC database whose scan flag is set to 1. Then it performs two SNMP queries per switch in order to know if a port is up. The first query retrieves the list of ports available on the switch, and the second one retrieves their current status. Then, such a status is stored in the database to be later seen through the Windows GUI.

Also, the list of switches to query can be fed to ping_switch.php through the command line. To ping certain switches (assuming those switches exist in the FreeNAC database) do the following:

ping_switch.php switch1 switch2 ... 

Where switchN can be the switch's name (as defined in the FreeNAC database) or the switch's IP.

The optional switches for ping_switch.php are the following:

OPTIONS:
-h Display this help screen
-s Supress messages to standard output and redirect them to syslog
-d Activate debugging

Timing measurements in tests conducted showed that for small switches (8 ports) it takes about one second to retrieve ports' status and in large switches (48 ports) it took aproximately 5 seconds.

This script can also be run from crontab. You should adapt the frequency to run this script taking into account how loaded your network is. The following crontab entry is an example, which runs this script every 10 minutes:

*/10 * * * *    /opt/nac/bin/ping_switch.php -s

Bugs and comments, please discuss them in the forums .

Syndicate content