mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
reindent/reformat addhost and adduser
git-svn-id: http://www.observium.org/svn/observer/trunk@1831 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
13
addhost.php
13
addhost.php
@ -5,7 +5,8 @@ include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
if($argv[1]) {
|
||||
if (isset($argv[1]) && $argv[1])
|
||||
{
|
||||
$host = strtolower($argv[1]);
|
||||
$community = $argv[2];
|
||||
$snmpver = strtolower($argv[3]);
|
||||
@ -18,16 +19,16 @@ if($argv[1]) {
|
||||
if ($community) { unset($config['snmp']['community']); $config['snmp']['community'][] = $community; }
|
||||
|
||||
list($hostshort) = explode(".", $host);
|
||||
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) {
|
||||
if ( isDomainResolves($argv[1])){
|
||||
if ( isPingable($argv[1])) {
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) {
|
||||
if (isDomainResolves($argv[1])){
|
||||
if (isPingable($argv[1])) {
|
||||
# FIXME should be a foreach $config['snmp']['community'][0] as $community
|
||||
$community = $config['snmp']['community'][0];
|
||||
if ( isSNMPable($argv[1], $community, $snmpver, $port)) {
|
||||
if (isSNMPable($argv[1], $community, $snmpver, $port)) {
|
||||
$snmphost = trim(str_replace("\"", "", shell_exec($config['snmpget'] ." -m SNMPv2-MIB -Oqv -$snmpver -c ".$config['snmp']['community'][0]." $host:$port sysName.0")));
|
||||
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host))) {
|
||||
$return = createHost ($host, $community, $snmpver, $port);
|
||||
if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); }
|
||||
if ($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); }
|
||||
} else { echo("Given hostname does not match SNMP-read hostname ($snmphost)!\n"); }
|
||||
} else { echo("Could not reach $host with SNMP\n"); }
|
||||
} else { echo("Could not ping $host\n"); }
|
||||
|
@ -17,9 +17,9 @@ else
|
||||
|
||||
if (auth_usermanagement())
|
||||
{
|
||||
if($argv[1] && $argv[2] && $argv[3])
|
||||
if ($argv[1] && $argv[2] && $argv[3])
|
||||
{
|
||||
if(adduser($argv[1],$argv[2],$argv[3],$argv[4]))
|
||||
if (adduser($argv[1],$argv[2],$argv[3],$argv[4]))
|
||||
{
|
||||
echo("User ".$argv[1]." added successfully\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user