Пример #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
    if ($update_message) {
        print_error($update_message);
    }
}
$max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters');
echo "\n    <form id='edit' name='edit' method='post' action='' role='form' class='form-horizontal'>\n    <input type=hidden name='editing' value='yes'>\n    <div class='form-group'>\n    <label for='snmpver' class='col-sm-2 control-label'>SNMP Details</label>\n    <div class='col-sm-1'>\n    <select id='snmpver' name='snmpver' class='form-control input-sm' onChange='changeForm();'>\n    <option value='v1'>v1</option>\n    <option value='v2c' " . ($device['snmpver'] == 'v2c' ? 'selected' : '') . ">v2c</option>\n    <option value='v3' " . ($device['snmpver'] == 'v3' ? 'selected' : '') . ">v3</option>\n    </select>\n    </div>\n    <div class='col-sm-2'>\n    <input type='text' name='port' placeholder='port' class='form-control input-sm' value='" . ($device['port'] == $config['snmp']['port'] ? "" : $device['port']) . "'>\n    </div>\n    <div class='col-sm-1'>\n    <select name='transport' id='transport' class='form-control input-sm'>";
foreach ($config['snmp']['transports'] as $transport) {
    echo "<option value='" . $transport . "'";
    if ($transport == $device['transport']) {
        echo " selected='selected'";
    }
    echo '>' . $transport . '</option>';
}
echo "      </select>\n    </div>\n    </div>\n    <div class='form-group'>\n    <div class='col-sm-2'>\n    </div>\n    <div class='col-sm-1'>\n    <input id='timeout' name='timeout' class='form-control input-sm' value='" . ($device['timeout'] ? $device['timeout'] : '') . "' placeholder='seconds' />\n    </div>\n    <div class='col-sm-1'>\n    <input id='retries' name='retries' class='form-control input-sm' value='" . ($device['timeout'] ? $device['retries'] : '') . "' placeholder='retries' />\n    </div>\n    </div>\n    <div class='form-group'>\n      <label for='port_assoc_mode' class='col-sm-2 control-label'>Port Association Mode</label>\n      <div class='col-sm-1'>\n        <select name='port_assoc_mode' id='port_assoc_mode' class='form-control input-sm'>\n";
foreach (get_port_assoc_modes() as $pam) {
    $pam_id = get_port_assoc_mode_id($pam);
    echo "           <option value='{$pam_id}'";
    if ($pam_id == $device['port_association_mode']) {
        echo " selected='selected'";
    }
    echo ">{$pam}</option>\n";
}
echo "        </select>\n      </div>\n    </div>\n    <div class='form-group'>\n        <label for='max_repeaters' class='col-sm-2 control-label'>Max Repeaters</label>\n        <div class='col-sm-1'>\n            <input id='max_repeaters' name='max_repeaters' class='form-control input-sm' value='" . $max_repeaters . "' placeholder='max rep' />\n        </div>\n    </div>\n    <div id='snmpv1_2'>\n    <div class='form-group'>\n    <label class='col-sm-3 control-label text-left'><h4><strong>SNMPv1/v2c Configuration</strong></h4></label>\n    </div>\n    <div class='form-group'>\n    <label for='community' class='col-sm-2 control-label'>SNMP Community</label>\n    <div class='col-sm-4'>\n    <input id='community' class='form-control' name='community' value='" . $device['community'] . "'/>\n    </div>\n    </div>\n    </div>\n    <div id='snmpv3'>\n    <div class='form-group'>\n    <label class='col-sm-3 control-label'><h4><strong>SNMPv3 Configuration</strong></h4></label>\n    </div>\n    <div class='form-group'>\n    <label for='authlevel' class='col-sm-2 control-label'>Auth Level</label>\n    <div class='col-sm-4'>\n    <select id='authlevel' name='authlevel' class='form-control'>\n    <option value='noAuthNoPriv'>noAuthNoPriv</option>\n    <option value='authNoPriv' " . ($device['authlevel'] == 'authNoPriv' ? 'selected' : '') . ">authNoPriv</option>\n    <option value='authPriv' " . ($device['authlevel'] == 'authPriv' ? 'selected' : '') . ">authPriv</option>\n    </select>\n    </div>\n    </div>\n    <div class='form-group'>\n    <label for='authname' class='col-sm-2 control-label'>Auth User Name</label>\n    <div class='col-sm-4'>\n    <input type='text' id='authname' name='authname' class='form-control' value='" . $device['authname'] . "'>\n    </div>\n    </div>\n    <div class='form-group'>\n    <label for='authpass' class='col-sm-2 control-label'>Auth Password</label>\n    <div class='col-sm-4'>\n    <input type='password' id='authpass' name='authpass' class='form-control' value='" . $device['authpass'] . "'>\n    </div>\n    </div>\n    <div class='form-group'>\n    <label for='authalgo' class='col-sm-2 control-label'>Auth Algorithm</label>\n    <div class='col-sm-4'>\n    <select id='authalgo' name='authalgo' class='form-control'>\n    <option value='MD5'>MD5</option>\n    <option value='SHA' " . ($device['authalgo'] === 'SHA' ? 'selected' : '') . ">SHA</option>\n    </select>\n    </div>\n    </div>\n    <div class='form-group'>\n    <label for='cryptopass' class='col-sm-2 control-label'>Crypto Password</label>\n    <div class='col-sm-4'>\n    <input type='password' id='cryptopass' name='cryptopass' class='form-control' value='" . $device['cryptopass'] . "'>\n    </div>\n    </div>\n    <div class='form-group'>\n    <label for='cryptoalgo' class='col-sm-2 control-label'>Crypto Algorithm</label>\n    <div class='col-sm-4'>\n    <select id='cryptoalgo' name='cryptoalgo' class='form-control'>\n    <option value='AES'>AES</option>\n    <option value='DES' " . ($device['cryptoalgo'] === 'DES' ? 'selected' : '') . ">DES</option>\n    </select>\n    </div>\n    </div>\n    </div>";
if ($config['distributed_poller'] === true) {
    echo '
        <div class="form-group">
        <label for="poller_group" class="col-sm-2 control-label">Poller Group</label>
        <div class="col-sm-4">
        <select name="poller_group" id="poller_group" class="form-control input-sm">
        <option value="0"> Default poller group</option>
        ';
Пример #3
0
function deviceArray($host, $community, $snmpver, $port = 161, $transport = 'udp', $v3, $port_assoc_mode = 'ifIndex')
{
    $device = array();
    $device['hostname'] = $host;
    $device['port'] = $port;
    $device['transport'] = $transport;
    /* 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['port_association_mode'] = $port_assoc_mode;
    $device['snmpver'] = $snmpver;
    if ($snmpver === "v2c" or $snmpver === "v1") {
        $device['community'] = $community;
    } elseif ($snmpver === "v3") {
        $device['authlevel'] = $v3['authlevel'];
        $device['authname'] = $v3['authname'];
        $device['authpass'] = $v3['authpass'];
        $device['authalgo'] = $v3['authalgo'];
        $device['cryptopass'] = $v3['cryptopass'];
        $device['cryptoalgo'] = $v3['cryptoalgo'];
    }
    return $device;
}