diff --git a/addhost.php b/addhost.php index 42371881c..1b0127882 100755 --- a/addhost.php +++ b/addhost.php @@ -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); diff --git a/adduser.php b/adduser.php index 5a68b365b..c6ac29575 100755 --- a/adduser.php +++ b/adduser.php @@ -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 \n"); + echo("Add User Tool\nUsage: ./adduser.php [email]\n"); } ?> diff --git a/includes/discovery/cisco-physical.php b/includes/discovery/cisco-physical.php index 9b47daafc..65ecf40d9 100755 --- a/includes/discovery/cisco-physical.php +++ b/includes/discovery/cisco-physical.php @@ -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`); diff --git a/includes/discovery/cisco-vrf.php b/includes/discovery/cisco-vrf.php index 317d971d0..6f5b78918 100755 --- a/includes/discovery/cisco-vrf.php +++ b/includes/discovery/cisco-vrf.php @@ -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(") "); - } } diff --git a/includes/discovery/interfaces.php b/includes/discovery/interfaces.php index 6ad37c1b9..cc469d9bd 100755 --- a/includes/discovery/interfaces.php +++ b/includes/discovery/interfaces.php @@ -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")) { diff --git a/includes/functions.php b/includes/functions.php index 6a4b4636c..b68db0800 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -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) { diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index d04cd0c6f..39dfbd012 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -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'] . "... ");