git-svn-id: http://www.observium.org/svn/observer/trunk@409 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong 2009-04-28 10:28:58 +00:00
parent dde365e30c
commit 1df7127d28
7 changed files with 37 additions and 21 deletions

View File

@ -17,7 +17,7 @@ if($argv[1] && $argv[2] && $argv[3]) {
if ( isDomainResolves($argv[1])){
if ( isPingable($argv[1])) {
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) {
$snmphost = trim(shell_exec($config['snmpget'] ." -m SNMPv2-MIB -Oqv -$snmpver -c $community $host:$port sysName.0 | sed s/\"//g`);
$snmphost = trim(shell_exec($config['snmpget'] ." -m SNMPv2-MIB -Oqv -$snmpver -c $community $host:$port sysName.0 | sed s/\"//g"));
# var_dump($snmphost);
if ($snmphost == $host || $hostshort = $host) {
$return = createHost ($host, $community, $snmpver, $port);

View File

@ -5,12 +5,16 @@ include("config.php");
include("includes/functions.php");
if($argv[1] && $argv[2] && $argv[3]) {
mysql_query("INSERT INTO `users` (`username`,`password`,`level`) VALUES ('".mres($argv[1])."',MD5('".$argv[2]."'),'".mres($argv[3])."')");
if($argv[4]) {
mysql_query("INSERT INTO `users` (`username`,`password`,`level`) VALUES ('".mres($argv[1])."',MD5('".$argv[2]."'),'".mres($argv[3])."'),'".mres($argv[4])."')");
} else {
mysql_query("INSERT INTO `users` (`username`,`password`,`level`) VALUES ('".mres($argv[1])."',MD5('".$argv[2]."'),'".mres($argv[3])."')");
}
if(mysql_affected_rows()) {
echo("User ".$argv[1]." added successfully\n");
}
} else {
echo("Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10>\n");
echo("Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10> [email]\n");
}
?>

View File

@ -4,7 +4,7 @@
if($config['enable_inventory']) {
$ents_cmd = $config['snmpwalk'] . " -m ENTITY-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['$port'] . " ";
$ents_cmd = $config['snmpbulkwalk'] . " -m ENTITY-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['$port'] . " ";
$ents_cmd .= "1.3.6.1.2.1.47.1.1.1.1.2 | sed s/.1.3.6.1.2.1.47.1.1.1.1.2.//g | cut -f 1 -d\" \"";
$ents = trim(`$ents_cmd | grep -v o`);

View File

@ -4,7 +4,8 @@
echo("VRF : ");
$oids = shell_exec($config['snmpwalk'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher");
$oid_cmd = $config['snmpwalk'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher";
$oids = shell_exec($oid_cmd);
$oids = str_replace(".1.3.6.1.3.118.1.2.2.1.3.", "", $oids);
$oids = str_replace(" \"", "||", $oids);
@ -14,7 +15,7 @@
foreach ( explode("\n", $oids) as $oid ) {
if($oid) {
list($vrf['oid'], $vrf['mplsVpnVrfRouteDistinguisher']) = explode("||", $oid);
$vrf['name'] = shell_exec($config['snmpget'] . " -m MPLS-VPN-MIB -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']);
$vrf['name'] = trim(shell_exec($config['snmpget'] . " -m MPLS-VPN-MIB -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']));
list(,$vrf['name'],, $vrf['mplsVpnVrfRouteDistinguisher']) = explode("\"", $vrf['name']);
$vrf['mplsVpnVrfDescription'] = trim(shell_exec($config['snmpget'] . " -m MPLS-VPN-MIB -Ln -Osqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfDescription.".$vrf['oid']));
@ -28,8 +29,8 @@
$insert_query .= "VALUES ('".$vrf['oid']."','".$vrf['name']."','".$vrf['mplsVpnVrfRouteDistinguisher']."','".$vrf['mplsVpnVrfDescription']."','".$device['device_id']."')";
mysql_query($insert_query);
}
$vrf_id = mysql_result(mysql_query("SELECT vrf_id FROM vrfs WHERE `device_id` = '".$device['device_id']."' AND `vrf_oid`='".$vrf['oid']."'"),0);
echo("\nRD:".$vrf['mplsVpnVrfRouteDistinguisher']." Id: ($vrf_id) Descr: ".$vrf['mplsVpnVrfDescription']." ");
$vrf_id = @mysql_result(mysql_query("SELECT vrf_id FROM vrfs WHERE `device_id` = '".$device['device_id']."' AND `vrf_oid`='".$vrf['oid']."'"),0);
echo("\nRD:".$vrf['mplsVpnVrfRouteDistinguisher']." ".$vrf['mplsVpnVrfDescription']." ");
$interfaces_oid = ".1.3.6.1.3.118.1.2.1.1.2." . $vrf['oid'];
$interfaces = shell_exec($config['snmpwalk'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $interfaces_oid");
$interfaces = trim(str_replace($interfaces_oid . ".", "", $interfaces));
@ -37,12 +38,10 @@
echo(" ( ");
foreach (explode("\n", $interfaces) as $if_id) {
$interface = mysql_fetch_array(mysql_query("SELECT * FROM interfaces WHERE ifIndex = '$if_id' AND device_id = '" . $device['device_id'] . "'"));
echo($interface['ifDescr'] . " ");
echo(makeshortif($interface['ifDescr']) . " ");
mysql_query("UPDATE interfaces SET ifVrf = '".$vrf_id."' WHERE interface_id = '".$interface['interface_id']."'");
}
echo(") ");
}
}

View File

@ -4,8 +4,8 @@
echo("Interfaces : ");
$cmd = $config['snmpwalk'] . " -m IF-MIB -O nsq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$cmd .= " .1.3.6.1.2.1.2.2.1.2";
$cmd = $config['snmpbulkwalk'] . " -m IF-MIB -O nsq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$cmd .= " ifDescr";
$interfaces = trim(shell_exec($cmd));
$interfaces = str_replace("\"", "", $interfaces);
$interfaces = str_replace("ifDescr.", "", $interfaces);
@ -17,14 +17,14 @@
foreach(explode("\n", $interfaces) as $entry){
$entry = trim($entry);
list($ifIndex, $ifName) = explode("||", $entry);
list($ifIndex, $ifDescr) = explode("||", $entry);
if($config['ifdescr'][$device['os']]) {
$ifDescr = shell_exec($config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifDescr.$ifIndex");
$ifDescr = str_replace("No Such Object available on this agent at this OID", "", $ifDescr);
$ifDescr = str_replace("No Such Instance currently exists at this OID", "", $ifDescr);
$ifDescr = trim(str_replace("\"", "", $ifDescr));
} else { $ifDescr = trim(str_replace("\"", "", $ifName)); }
# if($config['ifdescr'][$device['os']]) {
# $ifDescr = shell_exec($config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifDescr.$ifIndex");
# $ifDescr = str_replace("No Such Object available on this agent at this OID", "", $ifDescr);
# $ifDescr = str_replace("No Such Instance currently exists at this OID", "", $ifDescr);
# $ifDescr = trim(str_replace("\"", "", $ifDescr));
# } else { $ifDescr = trim(str_replace("\"", "", $ifName)); }
if(!strstr($entry, "irtual")) {

View File

@ -238,6 +238,19 @@ function interface_errors ($rrd_file) // Returns the last in/out errors value in
return $errors;
}
function interface_packets ($rrd_file) // Returns the last in/out pps value in RRD
{
global $config;
#$rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
$cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrd_file AVERAGE | grep : | cut -d\" \" -f 6,7";
$data = trim(shell_exec($cmd));
foreach( explode("\n", $data) as $entry) {
list($in, $out) = explode(" ", $entry);
}
$packets['in'] = round($in);
$packets['out'] = round($out);
return $packets;
}
function geteventicon ($message)
{

View File

@ -4,7 +4,7 @@ $query = "SELECT * FROM temperature WHERE temp_host = '" . $device['device_id']
$temp_data = mysql_query($query);
while($temperature = mysql_fetch_array($temp_data)) {
$temp_cmd = $config['snmpget'] . " -m SNMPv2-MIB-O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['temp_oid'];
$temp_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['temp_oid'];
$temp = shell_exec($temp_cmd);
echo("Checking temp " . $temperature['temp_descr'] . "... ");