Files
librenms-librenms/addhost.php
T

70 lines
1.5 KiB
PHP
Raw Normal View History

2010-09-03 18:26:59 +00:00
#!/usr/bin/env php
2009-09-07 11:07:59 +00:00
<?php
2008-03-12 20:01:46 +00:00
/* Observium Network Management and Monitoring System
* Copyright (C) 2006-2011, Observium Developers - http://www.observium.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* See COPYING for more details.
*/
include("includes/defaults.inc.php");
2011-03-16 09:29:46 +00:00
include("config.php");
2008-03-19 19:16:16 +00:00
include("includes/functions.php");
2007-04-03 14:10:23 +00:00
2011-03-14 18:53:48 +00:00
if (isset($argv[1]) && $argv[1])
2011-03-16 09:29:46 +00:00
{
2011-03-23 09:54:56 +00:00
$host = strtolower($argv[1]);
$community = $argv[2];
$snmpver = strtolower($argv[3]);
2011-03-14 18:56:26 +00:00
2011-03-23 09:54:56 +00:00
if (is_numeric($argv[4]))
{
$port = $argv[4];
}
else
{
$port = 161;
}
2011-03-23 09:54:56 +00:00
if (@!$argv[5])
{
$transport = 'udp';
}
else
{
$transport = $argv[5];
}
2011-03-15 16:12:44 +00:00
2011-03-23 09:54:56 +00:00
if (!$snmpver) $snmpver = "v2c";
if ($community)
{
unset($config['snmp']['community']);
$config['snmp']['community'][] = $community;
}
$device_id = addHost($host, $community, $snmpver, $port = '161', $transport = 'udp');
2011-03-15 16:12:44 +00:00
2011-09-20 15:48:12 +00:00
if ($device_id)
{
$device = device_by_id_cache($device_id);
echo("Added device ".$device['hostname']." (".$device['device_id'].")\n");
}
2011-03-23 09:54:56 +00:00
2011-09-20 09:55:11 +00:00
} else {
2011-03-22 20:27:39 +00:00
2011-09-20 15:48:12 +00:00
print Console_Color::convert("
Observium v".$config['version']." Add Host Tool
2011-03-22 20:27:39 +00:00
Usage: ./addhost.php <%Whostname%n> [community] [v1|v2c] [port] [" . join("|",$config['snmp']['transports']) . "]
2011-03-22 20:27:39 +00:00
2011-09-20 15:48:12 +00:00
%rRemember to run discovery for the host afterwards.%n
");
}
2007-04-03 14:10:23 +00:00
?>