File: old-cisco-dev-props.php

package info (click to toggle)
netmrg 0.20-7
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,896 kB
  • ctags: 2,012
  • sloc: php: 9,401; sh: 4,791; cpp: 2,898; perl: 621; ansic: 381; makefile: 337; xml: 92; sql: 71; sed: 16
file content (39 lines) | stat: -rwxr-xr-x 968 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/php -q
<?
/*  old-cisco-dev-props.php
**
**  Usage:
**    old-cisco-dev-props.php <host> <community> <model|version>
**
**  Descritpion:
**    Returns either the model number (actually closer to "family" than model),
**    and the IOS version.  Designed for use on 2900XL and 3500XL switches with 
**    older IOS versions that do not support MIBs containing these values separately.
*/

// no errors!
error_reporting(E_ALL);

// if less than 3 arguments, exit
if ($argc != 4) { print "U\nnot enough args"; exit; }

$snmp_result = snmpget($argv[1], $argv[2], "sysDescr.0");

//print($snmp_result);

$model = preg_replace("/.* \(tm\) /s", "", $snmp_result);
$model = preg_replace("/ .*/s", "", $model);
$model = "WS-" . $model; 

$version = preg_replace("/.* Version /s", "", $snmp_result);
$version = preg_replace("/,.*/s", "", $version);

switch ($argv[3])
{
	case "version":	echo("$version\n"); break;
	case "model":	echo("$model\n");	break;
}

exit;
?>