예제 #1
0
function is_custom_graph($type, $subtype, $device)
{
    if (is_mib_poller_enabled($device) && $device['os'] == 'ruckuswireless' && $type == 'device') {
        switch ($subtype) {
            case 'cpumem':
            case 'mempool':
            case 'processor':
                return true;
        }
    }
    return false;
}
예제 #2
0
function discover_device($device, $options = null)
{
    global $config, $valid;
    $valid = array();
    // Reset $valid array
    $attribs = get_dev_attribs($device['device_id']);
    $device['snmp_max_repeaters'] = $attribs['snmp_max_repeaters'];
    $device_start = microtime(true);
    // Start counting device poll time
    echo $device['hostname'] . ' ' . $device['device_id'] . ' ' . $device['os'] . ' ';
    if ($device['os'] == 'generic') {
        // verify if OS has changed from generic
        $device['os'] = getHostOS($device);
        if ($device['os'] != 'generic') {
            echo "\nDevice os was updated to " . $device['os'] . '!';
            dbUpdate(array('os' => $device['os']), 'devices', '`device_id` = ?', array($device['device_id']));
        }
    }
    // Set type to a predefined type for the OS if it's not already set
    if ($device['type'] == 'unknown' || $device['type'] == '') {
        if ($config['os'][$device['os']]['type']) {
            $device['type'] = $config['os'][$device['os']]['type'];
        }
    }
    if ($config['os'][$device['os']]['group']) {
        $device['os_group'] = $config['os'][$device['os']]['group'];
        echo ' (' . $device['os_group'] . ')';
    }
    echo "\n";
    // If we've specified modules, use them, else walk the modules array
    $force_module = false;
    if ($options['m']) {
        $config['discovery_modules'] = array();
        foreach (explode(',', $options['m']) as $module) {
            if (is_file("includes/discovery/{$module}.inc.php")) {
                $config['discovery_modules'][$module] = 1;
                $force_module = true;
            }
        }
    }
    foreach ($config['discovery_modules'] as $module => $module_status) {
        if ($force_module === true || $attribs['discover_' . $module] || $module_status && !isset($attribs['discover_' . $module])) {
            $module_start = microtime(true);
            echo "#### Load disco module {$module} ####\n";
            include "includes/discovery/{$module}.inc.php";
            $module_time = microtime(true) - $module_start;
            $module_time = substr($module_time, 0, 5);
            echo "\n>> Runtime for discovery module '{$module}': {$module_time} seconds\n";
            echo "#### Unload disco module {$module} ####\n\n";
        } elseif (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] == '0') {
            echo "Module [ {$module} ] disabled on host.\n\n";
        } else {
            echo "Module [ {$module} ] disabled globally.\n\n";
        }
    }
    if (is_mib_poller_enabled($device)) {
        $devicemib = array($device['sysObjectID'] => 'all');
        register_mibs($device, $devicemib, "includes/discovery/functions.inc.php");
    }
    $device_end = microtime(true);
    $device_run = $device_end - $device_start;
    $device_time = substr($device_run, 0, 5);
    dbUpdate(array('last_discovered' => array('NOW()'), 'type' => $device['type'], 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
    echo "Discovered in {$device_time} seconds\n";
    global $discovered_devices;
    echo "\n";
    $discovered_devices++;
}
예제 #3
0
function register_mibs($device, $mibs, $included_by)
{
    if (!is_mib_poller_enabled($device)) {
        return;
    }
    echo "MIB: registering\n";
    foreach ($mibs as $name => $module) {
        $translated = snmp_translate($name, $module);
        if ($translated) {
            $mod = $translated[0];
            $nam = $translated[1];
            echo "     {$mod}::{$nam}\n";
            if (snmp_mib_load($nam, $mod, $included_by) > 0) {
                // NOTE: `last_modified` omitted due to being automatically maintained by MySQL
                $columns = array('device_id', 'module', 'mib', 'included_by');
                $rows = array();
                $rows[] = array('device_id' => $device['device_id'], 'module' => $mod, 'mib' => $nam, 'included_by' => $included_by);
                update_db_table('device_mibs', $columns, 3, $rows);
            } else {
                echo "MIB: Could not load definition for {$mod}::{$nam}\n";
            }
        } else {
            echo "MIB: Could not find {$module}::{$name}\n";
        }
    }
    echo "\n";
}
예제 #4
0
         </a>
         </li>';
 }
 if (can_ping_device($attribs) === true) {
     echo '<li class="' . $select['performance'] . '">
         <a href="' . generate_device_url($device, array('tab' => 'performance')) . '">
         <img src="images/16/chart_line.png" align="absmiddle" border="0" /> Performance
         </a>
         </li>';
 }
 echo '<li class="' . $select['notes'] . '">
     <a href="' . generate_device_url($device, array('tab' => 'notes')) . '">
     <img src="images/16/page_white_text.png" align="absmiddle" border="0" /> Notes
     </a>
     </li>';
 if (device_permitted($device['device_id']) && is_mib_poller_enabled($device)) {
     echo '<li class="' . $select['mib'] . '">
         <a href="' . generate_device_url($device, array('tab' => 'mib')) . '">
         <i class="fa fa-file-text-o"></i> MIB
         </a>
         </li>';
 }
 echo '<div class="dropdown pull-right">
       <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><i class="fa fa-cog"></i>
       <span class="caret"></span></button>
       <ul class="dropdown-menu">
         <li><a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser to https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"> Launch</a></li>
         <li><a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"> SSH</a></li>
          <li><a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"> Telnet</a></li>';
 if (is_admin()) {
     echo '<li>