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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<?
# IRM - The Information Resource Manager
# Copyright (C) 2000 Yann Ramin
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License (in file COPYING) for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Id: snmp.inc.php3,v 1.2.2.1 2000/06/16 21:37:02 atrus Exp $
#
################################################################################
# CHANGELOG #
################################################################################
# 1/1/00 - Yann Ramin: Started work on SNMP functions #
################################################################################
function SNMPgetComputerObject($computer, $object) {
global $cfg_snmp_rcommunity;
$db = new DB;
$query = "SELECT ip FROM computers WHERE ID = $computer";
$result = $db->query($query);
$ip = $db->result($result, 0, "ip");
if ($ip == "" OR $ip == "dhcp" OR $ip == "DHCP") {
return FALSE;
}
$mib = snmpget($ip, $cfg_snmp_rcommunity, $object);
return $mib;
}
function SNMPwalkComputer($computer, $object) {
global $cfg_snmp_rcommunity;
$db = new DB;
$query = "SELECT ip FROM computers WHERE ID = $computer";
$result = $db->query($query);
$ip = $db->result($result, 0, "ip");
if ($ip == "" OR $ip == "dhcp" OR $ip == "DHCP") {
return "Cannot talk to computer.";
}
$mib = snmpwalkoid($ip, $cfg_snmp_rcommunity, $object);
return $mib;
}
function SNMPwalkComputerData($computer, $object) {
global $cfg_snmp_rcommunity;
$db = new DB;
$query = "SELECT ip FROM computers WHERE ID = $computer";
$result = $db->query($query);
$ip = $db->result($result, 0, "ip");
if ($ip == "" OR $ip == "dhcp" OR $ip == "DHCP") {
return "Cannot talk to computer.";
}
$mib = snmpwalk($ip, $cfg_snmp_rcommunity, $object);
return $mib;
}
function SNMPHTMLping($computer) {
global $cfg_snmp_rcommunity;
$db = new DB;
$query = "SELECT ip FROM computers WHERE ID = $computer";
$result = $db->query($query);
$ip = $db->result($result, 0, "ip");
if ($ip != "" OR $ip != "DHCP" OR $ip != "dhcp") {
$out = exec(EscapeShellCmd("ping -c 1 -n -i 1 $ip"),$dummy_array, $ping_return);
}
if ($ping_return == 2) {
$hstatus = "<font color=red>DOWN</font>";
} else if ($ping_return == 0) {
$hstatus = "<font color=green>UP</font>";
} else {
$hstatus = "UNKNOWN ERROR";
}
return $hstatus;
}
?>
|