Пример #1
0
function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array(), $poller_group = '0', $port_assoc_mode = 'ifIndex')
{
    global $config;
    $host = trim(strtolower($host));
    $poller_group = getpollergroup($poller_group);
    /* Get port_assoc_mode id if neccessary
     * We can work with names of IDs here */
    if (!is_int($port_assoc_mode)) {
        $port_assoc_mode = get_port_assoc_mode_id($port_assoc_mode);
    }
    $device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver, 'poller_group' => $poller_group, 'status_reason' => '', 'port_association_mode' => $port_assoc_mode);
    $device = array_merge($device, $v3);
    $device['os'] = getHostOS($device);
    if ($device['os']) {
        if (host_exists($host) === false) {
            $device_id = dbInsert($device, 'devices');
            if ($device_id) {
                oxidized_reload_nodes();
                return $device_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        return FALSE;
    }
}
Пример #2
0
function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array(), $poller_group = '0')
{
    global $config;
    $host = trim(strtolower($host));
    $poller_group = getpollergroup($poller_group);
    $device = array('hostname' => $host, 'sysName' => $host, 'community' => $community, 'port' => $port, 'transport' => $transport, 'status' => '1', 'snmpver' => $snmpver, 'poller_group' => $poller_group, 'status_reason' => '');
    $device = array_merge($device, $v3);
    $device['os'] = getHostOS($device);
    if ($device['os']) {
        if (host_exists($host) === false) {
            $device_id = dbInsert($device, 'devices');
            if ($device_id) {
                oxidized_reload_nodes();
                return $device_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        return FALSE;
    }
}