function checkHost($host_id)
{
    global $config, $start, $seed, $key;
    // All time/dates will be stored in timestamps;
    // Get Collector Lastrun Information
    $storage_lastrun = read_config_option("mikrotik_storage_lastrun");
    $trees_lastrun = read_config_option("mikrotik_trees_lastrun");
    $users_lastrun = read_config_option("mikrotik_users_lastrun");
    $processor_lastrun = read_config_option("mikrotik_processor_lastrun");
    // Get Collection Frequencies (in seconds)
    $storage_freq = read_config_option("mikrotik_storage_freq");
    $trees_freq = read_config_option("mikrotik_trees_freq");
    $users_freq = read_config_option("mikrotik_users_freq");
    $processor_freq = read_config_option("mikrotik_processor_freq");
    /* remove the key process and insert the set a process lock */
    db_execute("DELETE FROM plugin_mikrotik_processes WHERE pid={$key}");
    db_execute("REPLACE INTO plugin_mikrotik_processes (pid, taskid) VALUES (" . getmypid() . ", {$seed})");
    /* obtain host information */
    $host = db_fetch_row("SELECT * FROM host WHERE id={$host_id}");
    // Run the collectors
    collect_system($host);
    if (runCollector($start, $trees_lastrun, $trees_freq)) {
        collect_trees($host);
    }
    if (runCollector($start, $users_lastrun, $users_freq)) {
        collect_users($host);
    }
    if (runCollector($start, $processor_lastrun, $processor_freq)) {
        collect_processor($host);
    }
    if (runCollector($start, $storage_lastrun, $storage_freq)) {
        collect_storage($host);
    }
    /* remove the process lock */
    db_execute("DELETE FROM plugin_mikrotik_processes WHERE pid=" . getmypid());
}
示例#2
0
function checkHost($host_id)
{
    global $config, $start, $seed, $key;
    // All time/dates will be stored in timestamps;
    // Get Collector Lastrun Information
    $hrDevices_lastrun = read_config_option("hmib_hrDevices_lastrun");
    $hrSWRun_lastrun = read_config_option("hmib_hrSWRun_lastrun");
    $hrSWRunPerf_lastrun = read_config_option("hmib_hrSWRunPerf_lastrun");
    $hrSWInstalled_lastrun = read_config_option("hmib_hrSWInstalled_lastrun");
    $hrStorage_lastrun = read_config_option("hmib_hrStorage_lastrun");
    $hrProcessor_lastrun = read_config_option("hmib_hrProcessor_lastrun");
    // Get Collection Frequencies (in seconds)
    $hrDevices_freq = read_config_option("hmib_hrDevices_freq");
    $hrSWRun_freq = read_config_option("hmib_hrSWRun_freq");
    $hrSWRunPerf_freq = read_config_option("hmib_hrSWRunPerf_freq");
    $hrSWInstalled_freq = read_config_option("hmib_hrSWInstalled_freq");
    $hrStorage_freq = read_config_option("hmib_hrStorage_freq");
    $hrProcessor_freq = read_config_option("hmib_hrProcessor_freq");
    /* remove the key process and insert the set a process lock */
    db_execute("DELETE FROM plugin_hmib_processes WHERE pid={$key}");
    db_execute("REPLACE INTO plugin_hmib_processes (pid, taskid) VALUES (" . getmypid() . ", {$seed})");
    /* obtain host information */
    $host = db_fetch_row("SELECT * FROM host WHERE id={$host_id}");
    // Run the collectors
    collect_hrSystem($host);
    if (runCollector($start, $hrDevices_lastrun, $hrDevices_freq)) {
        collect_hrDevices($host);
    }
    if (runCollector($start, $hrSWRun_lastrun, $hrSWRun_freq)) {
        collect_hrSWRun($host);
    }
    if (runCollector($start, $hrSWRunPerf_lastrun, $hrSWRunPerf_freq)) {
        collect_hrSWRunPerf($host);
    }
    if (runCollector($start, $hrSWInstalled_lastrun, $hrSWInstalled_freq)) {
        collect_hrSWInstalled($host);
    }
    if (runCollector($start, $hrStorage_lastrun, $hrStorage_freq)) {
        collect_hrStorage($host);
    }
    if (runCollector($start, $hrProcessor_lastrun, $hrProcessor_freq)) {
        collect_hrProcessor($host);
    }
    /* update the most recent table */
    db_execute("INSERT INTO plugin_hmib_hrSWRun_last_seen (host_id, name, total_time)\n\t\tSELECT DISTINCT host_id, name, " . read_config_option("hmib_hrSWRunPerf_freq") . " AS `total_time`\n\t\tFROM plugin_hmib_hrSWRun\n\t\tWHERE host_id=" . $host["id"] . "\n\t\tON DUPLICATE KEY UPDATE last_seen=NOW(),total_time=total_time+VALUES(total_time)");
    /* remove the process lock */
    db_execute("DELETE FROM plugin_hmib_processes WHERE pid=" . getmypid());
    /* remove odd entries */
    db_execute("DELETE FROM plugin_hmib_hrSWRun_last_seen WHERE name=''");
}
示例#3
0
function checkHost($host_id)
{
    global $config, $start, $seed, $key;
    // All time/dates will be stored in timestamps;
    // Get Collector Lastrun Information
    $storage_lastrun = read_config_option('mikrotik_storage_lastrun');
    $trees_lastrun = read_config_option('mikrotik_trees_lastrun');
    $users_lastrun = read_config_option('mikrotik_users_lastrun');
    $queues_lastrun = read_config_option('mikrotik_queues_lastrun');
    $interfaces_lastrun = read_config_option('mikrotik_interfaces_lastrun');
    $processor_lastrun = read_config_option('mikrotik_processor_lastrun');
    $wireless_aps_lastrun = read_config_option('mikrotik_wireless_aps_lastrun');
    $wireless_reg_lastrun = read_config_option('mikrotik_wireless_reg_lastrun');
    // Get Collection Frequencies (in seconds)
    $storage_freq = read_config_option('mikrotik_storage_freq');
    $trees_freq = read_config_option('mikrotik_trees_freq');
    $users_freq = read_config_option('mikrotik_users_freq');
    $queues_freq = read_config_option('mikrotik_queues_freq');
    $interfaces_freq = read_config_option('mikrotik_interfaces_freq');
    $processor_freq = read_config_option('mikrotik_processor_freq');
    $wireless_aps_freq = read_config_option('mikrotik_wireless_aps_freq');
    $wireless_reg_freq = read_config_option('mikrotik_wireless_reg_freq');
    /* remove the key process and insert the set a process lock */
    if (!empty($key)) {
        db_execute("DELETE FROM plugin_mikrotik_processes WHERE pid={$key}");
    }
    db_execute("REPLACE INTO plugin_mikrotik_processes (pid, taskid) VALUES (" . getmypid() . ", {$seed})");
    /* obtain host information */
    $host = db_fetch_row("SELECT * FROM host WHERE id={$host_id}");
    if (function_exists('snmp_read_mib')) {
        debug('Function snmp_read_mib() EXISTS!');
        snmp_read_mib($config['base_path'] . '/plugins/mikrotik/MIKROTIK-MIB.txt');
    } else {
        putenv('MIBS=all');
    }
    collect_system($host);
    if (runCollector($start, $users_lastrun, $users_freq)) {
        collect_users($host);
        // Remove old records
        db_execute_prepared('DELETE FROM plugin_mikrotik_users WHERE userType=0 AND name RLIKE "' . read_config_option('mikrotik_user_exclusion') . '" AND present = 0 AND host_id = ? AND last_seen < FROM_UNIXTIME(UNIX_TIMESTAMP()-' . read_config_option('mikrotik_user_exclusion_ttl') . ')', array($host['id']));
    }
    if (runCollector($start, $trees_lastrun, $trees_freq)) {
        collect_trees($host);
    }
    if (runCollector($start, $queues_lastrun, $queues_freq)) {
        collect_queues($host);
        collect_pppoe_users_api($host);
    }
    if (runCollector($start, $interfaces_lastrun, $interfaces_freq)) {
        collect_interfaces($host);
    }
    if (runCollector($start, $processor_lastrun, $processor_freq)) {
        collect_processor($host);
    }
    if (runCollector($start, $storage_lastrun, $storage_freq)) {
        collect_storage($host);
    }
    if (runCollector($start, $wireless_aps_lastrun, $wireless_aps_freq)) {
        collect_wireless_aps($host);
    }
    if (runCollector($start, $wireless_reg_lastrun, $wireless_reg_freq)) {
        collect_wireless_reg($host);
    }
    if (!function_exists('snmp_read_mib')) {
        putenv('MIBS=');
    }
    /* remove the process lock */
    db_execute('DELETE FROM plugin_mikrotik_processes WHERE pid=' . getmypid());
}