graphing cisco 4400 wireless controllers

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

shlotz
Posts: 3
Joined: Wed Aug 08, 2007 3:25 pm

Post by shlotz »

I've actually gotten most of this to work in 0.8.6i, querying in SNMPv2, against a Cisco WLC system!

Some changes were necessary. The APifType.php didn't account for changes in SNMP version and just didn't work anyways. The following works for me:

Code: Select all

<?php

/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD'])  || isset($_SERVER['REMOTE_ADDR'])) {
   die("<br><strong>This script is only meant to run at the command line.</strong>");
}

$no_http_headers = true;

include(dirname(__FILE__) . "/../include/config.php");
include(dirname(__FILE__) . "/../lib/snmp.php");

$hostname = $_SERVER["argv"][1];
$snmp_community = $_SERVER["argv"][2];
$snmp_version = $_SERVER["argv"][3];

$bsnAPIfType = ".1.3.6.1.4.1.14179.2.2.2.1.2";


$radiotypes = reindex(cacti_snmp_walk($hostname, $snmp_community, $bsnAPIfType, $snmp_version, "", "", 161, 1000));

$sorted = array_count_values($radiotypes);
$newfinalarray = array("APdot11a:"=>$sorted[2],"APdot11b:"=>$sorted[1]);
print "APdot11a:" . $sorted[2] . " APdot11b:" . $sorted[1] . "\n";

}

function reindex($arr) {
	$return_arr = array();
	
	for ($i=0;($i<sizeof($arr));$i++) {
		$return_arr[$i] = $arr[$i]["value"];
	}

	return $return_arr;
}
?>
I'm not, however, able to graph my APAssociations. The data is there in SMPWalks, but nothing I try results in output of anything but 0.

I can get

Code: Select all

# snmpwalk xxxxxxx -c public -v2c .1.3.6.1.4.1.14179.2.1.4.1.4 -O s
enterprises.14179.2.1.4.1.4.0.5.78.67.229.41 = Hex-STRING: 00 1B 2B A7 84 40
enterprises.14179.2.1.4.1.4.0.5.78.71.56.219 = Hex-STRING: 00 1B 2B A5 6F 60
enterprises.14179.2.1.4.1.4.0.5.78.74.45.21 = Hex-STRING: 00 1B 2B A7 90 30
enterprises.14179.2.1.4.1.4.0.5.78.74.46.35 = Hex-STRING: 00 1B 2B A7 90 30
And running "query Index" on the script returns, for example,
HEX-00:00:1B:2B:A5:6F:60!HEX-00:00:1B:2B:A5:6F:60
HEX-00:00:1B:2B:A7:67:C0!HEX-00:00:1B:2B:A7:67:C0
HEX-00:00:1B:2B:A7:84:40!HEX-00:00:1B:2B:A7:84:40
HEX-00:00:1B:2B:A7:90:30!HEX-00:00:1B:2B:A7:90:30
HEX-00:00:1B:2B:A7:91:E0!HEX-00:00:1B:2B:A7:91:E0
HEX-00:00:1B:2B:A7:97:A0!HEX-00:00:1B:2B:A7:97:A0

But trying php -q ./query_cisco4400_aps.php <IP> <comm> <ver> get apassoc HEX-00:00:1B:2B:A5:6F:60
Results in output of 0. As does any other permutation of an AP's MAC address that I've tried.

Any ideas? Maybe you can help me figure out what format the php needs to input for the APAssoc?

Thanks,

-Max
andys
Posts: 24
Joined: Fri Mar 23, 2007 8:06 am

Post by andys »

Max
cacti sends the mac address of the ap to the script in the format 00:1A:A2:FA:98:10 while query_cisco4400_aps.php queries the WLC for APs/assocs and stores them in an array in the format:

[ Hex: 00 1A A2 FA 98 10 ] => 1
[ Hex: 00 14 69 04 FD 00 ] => 1
[ Hex: 00 14 69 04 FC 50 ] => 2
[ Hex: 00 11 21 BF D3 C0 ] => 1

to match this mac accdress with any of the keys in the array, the script deletes the colons ":" and prepends the text "Hex: ". This is done by the following code:-

$test=" Hex: " . ereg_replace (":"," ",$index) . " ";

if the mac address is "00:1A:A2:FA:98:10" then query_cisco4400_aps.php will convert it to "Hex: 00 1A A2 FA 98 10".

from your example, you should try:-

php -q ./query_cisco4400_aps.php <IP> <comm> <ver> get apassoc 00:00:1B:2B:A5:6F:60

and this should return the number of assocs for that AP.

hope that helps
andy
shlotz
Posts: 3
Joined: Wed Aug 08, 2007 3:25 pm

Post by shlotz »

I think I got it now...
A couple of problems: First of all, the snmpwalk called in the script for the apassoc query only runs in v1. I've simply turned v1 on for now. This appears to be a "feature" of php-snmptools: http://us3.php.net/snmpwalk

Second, that string parsing expression does not work for me for some reason. Output ends up looking like "Hex: 00:00:00:00:00" etc.
My script now reads:

Code: Select all

/*$test=" Hex: " . ereg_replace (":"," ",$index) . " "; */
		$pretest = "Hex-STRING: " . ereg_replace (":"," ",$index . " ");
		$test = ereg_replace ("HEX-00 ","",$pretest);
(No I obviously not an accomplished php coder...)

This outputs things properly for me and results in a successful query using the arguments that Cacti is passing - such as "HEX-00:00:1B:2B:A7:97:A0" (Note the extra 00: being passed by Cacti...dunno why that is).

Now to make that work for snmpv2...

-Max
cwahlin
Cacti User
Posts: 91
Joined: Fri Oct 10, 2003 7:23 am

Post by cwahlin »

love these scripts/templates!

Although I am not getting anything in my interface graphs. Also, not all interfaces show up in the query. I am running snmp v1.

Any updates? fixes?

/Carl
andys
Posts: 24
Joined: Fri Mar 23, 2007 8:06 am

Post by andys »

hi Carl
the interface query uses the interface name as the index - do all your interfaces have unique names? could you post the data query debug.
cheers
andys
cwahlin
Cacti User
Posts: 91
Joined: Fri Oct 10, 2003 7:23 am

Post by cwahlin »

Ok, here is a slightly messed up screenshot from the wireless server of all the configured interfaces (but you get the picture of lots of interfaces. We use AAA override so different users gets sent to their respective network) They all have different names:
screenshot

Here is the query:
+ Running data query [16].
+ Found type = '4 '[script query].
+ Found data query XML file at '/var/www/html/resource/script_queries/Cisco4400_Interfaces.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php -q /var/www/html/scripts/query_cisco4400_interfaces.php kn1-wc01a.stokab.net ******** 1 index'
+ Executing script query '/usr/bin/php -q /var/www/html/scripts/query_cisco4400_interfaces.php kn1-wc01a.stokab.net SPstokAB03 1 query index'
+ Found item [agentInterfaceName='allasdn'] index: allasdn
+ Found item [agentInterfaceName='ap-manager'] index: ap-manager
+ Found item [agentInterfaceName='edu'] index: edu
+ Executing script query '/usr/bin/php -q /var/www/html/scripts/query_cisco4400_interfaces.php kn1-wc01a.stokab.net SPstokAB03 1 query agentInterfaceVlanId'
+ Found item [agentInterfaceVlanId='78'] index: allasdn
+ Found item [agentInterfaceVlanId='62'] index: ap-manager
+ Found item [agentInterfaceVlanId='64'] index: edu
+ Executing script query '/usr/bin/php -q /var/www/html/scripts/query_cisco4400_interfaces.php kn1-wc01a.stokab.net SPstokAB03 1 query agentInterfaceIPAddress'
+ Found item [agentInterfaceIPAddress='172.18.240.2'] index: allasdn
+ Found item [agentInterfaceIPAddress='10.140.0.51'] index: ap-manager
+ Found item [agentInterfaceIPAddress='10.140.132.2'] index: edu
+ Found data query XML file at '/var/www/html/resource/script_queries/Cisco4400_Interfaces.xml'
+ Found data query XML file at '/var/www/html/resource/script_queries/Cisco4400_Interfaces.xml'
+ Found data query XML file at '/var/www/html/resource/script_queries/Cisco4400_Interfaces.xml'
It is only "finding" 3 of all those interfaces. And when I graph those, I am not seeing any registered clients.

Also just saw that my "AP radio Types" graphs are empty as well. Although I get all the AP:s in the "interface" list when I go to create graphs (not sure if they use the same data though).

/Carl
Last edited by cwahlin on Tue Oct 02, 2007 1:53 pm, edited 1 time in total.
andys
Posts: 24
Joined: Fri Mar 23, 2007 8:06 am

Post by andys »

Try running the attached script query_cisco4400_interfaces_test.php from the command line on your server. Save this script to your script folder. From your previous post, your command line would be:

/usr/bin/php -q /var/www/html/scripts/query_cisco4400_interfaces_test.php kn1-wc01a.stokab.net SPstokAB03 1

This script runs a simple snmpwalk of the 4400 controller and returns all the agentInterfaceName objects (oid 1.3.6.1.4.1.14179.1.2.13.1.1
)
the output should look something like this:-
Array
(
[0] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.10.97.112.45.109.97.110.97.103.101.114
[value] => ap-manager
)

[1] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.19.99.111.110.102.101.114.101.110.99.101.95.119.105.114.101.108.101.115.115
[value] => conference_wireless
)

[2] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.16.101.100.117.114.111.97.109.45.119.105.114.101.108.101.115.115
[value] => eduroam-wireless
)

[3] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.14.103.117.101.115.116.45.119.105.114.101.108.101.115.115
[value] => guest-wireless
)

[4] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.10.109.97.110.97.103.101.109.101.110.116
[value] => management
)

[5] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.12.115.101.114.118.105.99.101.45.112.111.114.116
[value] => service-port
)

[6] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.14.115.116.97.102.102.45.119.105.114.101.108.101.115.115
[value] => staff-wireless
)

[7] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.16.115.116.117.100.101.110.116.45.119.105.114.101.108.101.115.115
[value] => student-wireless
)

[8] => Array
(
[oid] => enterprises.14179.1.2.13.1.1.7.118.105.114.116.117.97.108
[value] => virtual
)
Can you see all your interfaces in the output? Also what Cacti version are you using? I'm running 0.8.6j
Attachments
query_cisco4400_interfaces_test.zip
(578 Bytes) Downloaded 443 times
cwahlin
Cacti User
Posts: 91
Joined: Fri Oct 10, 2003 7:23 am

Post by cwahlin »

Here is the output. I removed the community this time ;) But I only get 3 interfaces. Maybe it's just a software bug in the WLC? I am running 4.0.206.0. Just saw there is a 4.1.185.0 version out. What version are you running?
[root@cacti scripts]# /usr/bin/php -q /var/www/html/scripts/query_cisco4400_interfaces_test.php kn1-wc01a.stokab.net ******** 1
Error: OID not increasing: .1.3.6.1.4.1.14179.1.2.13.1.1.10.97.112.45.109.97.110.97.103.101.114
>= .1.3.6.1.4.1.14179.1.2.13.1.1.3.101.100.117

Array
(
[0] => Array
(
[oid] => .1.3.6.1.4.1.14179.1.2.13.1.1.7.97.108.108.97.115.100.110
[value] => allasdn
)

[1] => Array
(
[oid] => .1.3.6.1.4.1.14179.1.2.13.1.1.10.97.112.45.109.97.110.97.103.101.114
[value] => ap-manager
)

[2] => Array
(
[oid] => .1.3.6.1.4.1.14179.1.2.13.1.1.3.101.100.117
[value] => edu
)

)
andys
Posts: 24
Joined: Fri Mar 23, 2007 8:06 am

Post by andys »

our 4404 is running 4.1.171.0 - what is your cacti rev?
andys
cwahlin
Cacti User
Posts: 91
Joined: Fri Oct 10, 2003 7:23 am

Post by cwahlin »

0.8.6j running on a linux box.

/Carl
andys
Posts: 24
Joined: Fri Mar 23, 2007 8:06 am

Post by andys »

i haven't tried theses scripts on any cisco WLC software other than 4.1.X. Has anyone else had similar problems with 4.0.X?
andys
cwahlin
Cacti User
Posts: 91
Joined: Fri Oct 10, 2003 7:23 am

Post by cwahlin »

I will try uppgrading one of our controllers and check if your scripts work with the newer version.

/Carl
cwahlin
Cacti User
Posts: 91
Joined: Fri Oct 10, 2003 7:23 am

Post by cwahlin »

I just upgraded one of our controllers (4.1.185), but I still get the same error as before - "Error: OID not increasing: .1.3.6.1.4.1.14179.1.2.13.1.1.10.97.112.45.109.97.110.97.103.101.114"

and still only 3 interfaces.

Also getting an error in the "query_4400_APifType.php" script:
PHP Fatal error: Call to undefined function snmpwalk() in /var/www/html/scripts/query_4400_APifType.php on line 19
And that's just weird, because snmpwalk works in the other script. Going to do some more digging.

/Carl
mia1dolfan
Posts: 18
Joined: Tue Oct 02, 2007 3:19 pm

Update for php scripts for SNMP 2c and 0.8.7 support

Post by mia1dolfan »

Update for php scripts for SNMP 2c and 0.8.7 support

Id like to thank the original author for the time and effort put into this, it is greatly appreciated! :D

When I first imported the xml files, the scripts could not be found. I believe this was because they were originally created it on a Microsoft system, which is not case sensitive, hence it worked for him, so if you have problems, first check the paths under "Collection Methods" in Cacti for case sensitivity.

* Compatible with 0.8.7beta4, (still works for me on 0.8.6j).
* Works with SNMP version 2c.

Replace these scripts in your <CACTI_ROOT>/scripts directory if you are having difficulties.
Attachments
scripts.zip
(7.89 KiB) Downloaded 1231 times
cwahlin
Cacti User
Posts: 91
Joined: Fri Oct 10, 2003 7:23 am

Post by cwahlin »

For me, almost everything works now with v2c. I now get all the interfaces listed. But associations/interface does not give an accurate number. If I look at the number of associations per ssid, I get roughly 300 (which seems about right). But all my interfaces (8-10 interfaces) all show over 200 associations.

Another problem still remaining is that the query_4400_APifType.php script thinks snmpwalk is an unknown function. Not sure why, since it works in the other scripts?

Any ideas?

/Carl
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests