File: snmpdiff.php

package info (click to toggle)
netmrg 0.18.2-14
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,104 kB
  • ctags: 1,575
  • sloc: xml: 8,912; php: 7,389; sh: 4,019; cpp: 2,581; perl: 471; ansic: 338; makefile: 316; sql: 5
file content (33 lines) | stat: -rwxr-xr-x 730 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/php -q
<?
/*  snmpdiff.php
**
**  Usage:
**    snmpdiff.php <host> <community> <oid0> <oid1>
**
**  Descritpion:
**    Gets an oid1 and oid2 from a community@host and 
**    returns just the facts
*/

// no errors!
error_reporting(E_NONE);

// if less than 4 arguments, exit
if ($argc != 5) { exit; }

$snmp_result0 = snmpget($argv[1], $argv[2], $argv[3]);
$snmp_result1 = snmpget($argv[1], $argv[2], $argv[4]);

//if (!empty($snmp_result0) && !empty($snmp_result1)) {
	$snmp_parts0 = explode(" ", $snmp_result0);
	$snmp_parts1 = explode(" ", $snmp_result1);
	$diff = ($snmp_parts0[count($snmp_parts0)-1]+0) - ($snmp_parts1[count($snmp_parts1)-1]+0);
	echo "$diff\n";
//} else {
//	echo "U\n";
//} // end if

exit;
?>