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()); }
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'); // 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'); /* 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}"); // 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, $queues_lastrun, $queues_freq)) { collect_queues($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); } /* remove the process lock */ db_execute('DELETE FROM plugin_mikrotik_processes WHERE pid=' . getmypid()); }