'Delete', 2 => 'Enable', 3 => 'Disable', 4 => 'Change SNMP Options', 5 => 'Clear Statistics', 6 => 'Change Availability Options', 7 => 'Apply Automation Rules' ); $device_actions = api_plugin_hook_function('device_action_array', $device_actions); /* set default action */ set_default_action(); switch (get_request_var('action')) { case 'save': form_save(); break; case 'actions': form_actions(); break; case 'gt_add': get_filter_request_var('host_id'); host_add_gt(); header('Location: host.php?header=false&action=edit&id=' . get_request_var('host_id')); break; case 'gt_remove': get_filter_request_var('host_id'); host_remove_gt(); header('Location: host.php?header=false&action=edit&id=' . get_request_var('host_id')); break; case 'query_add': get_filter_request_var('host_id'); host_add_query(); header('Location: host.php?header=false&action=edit&id=' . get_request_var('host_id')); break; case 'query_remove': get_filter_request_var('host_id'); host_remove_query(); header('Location: host.php?header=false&action=edit&id=' . get_request_var('host_id')); break; case 'query_reload': get_filter_request_var('host_id'); host_reload_query(); header('Location: host.php?header=false&action=edit&id=' . get_request_var('host_id')); break; case 'query_verbose': get_filter_request_var('host_id'); host_reload_query(); header('Location: host.php?header=' . (isset_request_var('header') && get_nfilter_request_var('header') == 'true' ? 'true':'false') . '&action=edit&id=' . get_request_var('host_id') . '&display_dq_details=true#dqdbg'); break; case 'edit': top_header(); host_edit(); bottom_footer(); break; case 'ping_host': ping_host(); break; default: top_header(); host(); bottom_footer(); break; } /* -------------------------- Global Form Functions -------------------------- */ function add_tree_names_to_actions_array() { global $device_actions; /* add a list of tree names to the actions dropdown */ $trees = db_fetch_assoc('SELECT id, name FROM graph_tree ORDER BY name'); if (sizeof($trees)) { foreach ($trees as $tree) { $device_actions{'tr_' . $tree['id']} = 'Place on a Tree (' . $tree['name'] . ')'; } } } /* -------------------------- The Save Function -------------------------- */ function form_save() { if (isset_request_var('save_component_host')) { if (get_nfilter_request_var('snmp_version') == 3 && (get_nfilter_request_var('snmp_password') != get_nfilter_request_var('snmp_password_confirm'))) { raise_message(4); }else{ get_filter_request_var('id'); get_filter_request_var('host_template_id'); $host_id = api_device_save(get_nfilter_request_var('id'), get_nfilter_request_var('host_template_id'), get_nfilter_request_var('description'), trim(get_nfilter_request_var('hostname')), get_nfilter_request_var('snmp_community'), get_nfilter_request_var('snmp_version'), get_nfilter_request_var('snmp_username'), get_nfilter_request_var('snmp_password'), get_nfilter_request_var('snmp_port'), get_nfilter_request_var('snmp_timeout'), (isset_request_var('disabled') ? get_nfilter_request_var('disabled') : ''), get_nfilter_request_var('availability_method'), get_nfilter_request_var('ping_method'), get_nfilter_request_var('ping_port'), get_nfilter_request_var('ping_timeout'), get_nfilter_request_var('ping_retries'), get_nfilter_request_var('notes'), get_nfilter_request_var('snmp_auth_protocol'), get_nfilter_request_var('snmp_priv_passphrase'), get_nfilter_request_var('snmp_priv_protocol'), get_nfilter_request_var('snmp_context'), get_nfilter_request_var('max_oids'), get_nfilter_request_var('device_threads')); } header('Location: host.php?header=false&action=edit&id=' . (empty($host_id) ? get_nfilter_request_var('id') : $host_id)); } } /* ------------------------ The "actions" function ------------------------ */ function form_actions() { global $device_actions, $fields_host_edit; /* ================= input validation ================= */ get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/'))); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_nfilter_request_var('drp_action') == '2') { /* Enable Selected Devices */ for ($i=0;($i'; $host_array[$i] = $matches[1]; $i++; } } top_header(); /* add a list of tree names to the actions dropdown */ add_tree_names_to_actions_array(); form_start('host.php'); html_start_box($device_actions[get_nfilter_request_var('drp_action')], '60%', '', '3', 'center', ''); if (isset($host_array) && sizeof($host_array)) { if (get_nfilter_request_var('drp_action') == '2') { /* Enable Devices */ print "

Click 'Continue' to enable the following Device(s).

\n"; $save_html = " "; }elseif (get_nfilter_request_var('drp_action') == '3') { /* Disable Devices */ print "

Click 'Continue' to disable the following Device(s).

\n"; $save_html = " "; }elseif (get_nfilter_request_var('drp_action') == '4') { /* change snmp options */ print "

Click 'Continue' to change SNMP parameters for the following Device(s). Please check the box next to the fields you want to update, and then fill in the new value.

\n"; $form_array = array(); while (list($field_name, $field_array) = each($fields_host_edit)) { if ((preg_match('/^snmp_/', $field_name)) || ($field_name == 'max_oids')) { $form_array += array($field_name => $fields_host_edit[$field_name]); $form_array[$field_name]['value'] = ''; $form_array[$field_name]['description'] = ''; $form_array[$field_name]['form_id'] = 0; $form_array[$field_name]['sub_checkbox'] = array( 'name' => 't_' . $field_name, 'friendly_name' => 'Update this Field', 'value' => '' ); } } draw_edit_form( array( 'config' => array('no_form_tag' => true), 'fields' => $form_array ) ); $save_html = " "; }elseif (get_nfilter_request_var('drp_action') == '6') { /* change availability options */ print "

Click 'Continue' to change Availability parameters for the following Device(s). Please check the box next to the fields you want to update, then fill in the new value.

\n"; $form_array = array(); while (list($field_name, $field_array) = each($fields_host_edit)) { if (preg_match('/(availability_method|ping_method|ping_port)/', $field_name)) { $form_array += array($field_name => $fields_host_edit[$field_name]); $form_array[$field_name]['value'] = ''; $form_array[$field_name]['description'] = ''; $form_array[$field_name]['form_id'] = 0; $form_array[$field_name]['sub_checkbox'] = array( 'name' => 't_' . $field_name, 'friendly_name' => 'Update this Field', 'value' => '' ); } } draw_edit_form( array( 'config' => array('no_form_tag' => true), 'fields' => $form_array ) ); $save_html = " "; }elseif (get_nfilter_request_var('drp_action') == '5') { /* Clear Statisitics for Selected Devices */ print "

Click 'Continue' to clear the counters for the following Device(s).

\n"; $save_html = " "; }elseif (get_nfilter_request_var('drp_action') == '1') { /* delete */ print "

Click 'Continue' to delete the following Device(s).

\n"; form_radio_button('delete_type', '2', '1', 'Leave all Graph(s) and Data Source(s) untouched. Data Source(s) will be disabled however.', '1'); print '
'; form_radio_button('delete_type', '2', '2', 'Delete all associated Graph(s) and Data Source(s).', '1'); print '
'; print " \n"; $save_html = " "; }elseif (preg_match('/^tr_([0-9]+)$/', get_nfilter_request_var('drp_action'), $matches)) { /* place on tree */ print "

Click 'Continue' to place the following Device(s) under the branch selected below.

Destination Branch:
\n"; grow_dropdown_tree($matches[1], '0', 'tree_item_id', '0'); print "

\n"; $save_html = " "; }elseif (get_nfilter_request_var('drp_action') == 7) { /* automation */ print "

Click 'Continue' to apply Automation Rules to the following Devices(s)

\n"; $save_html = " "; } else { $save['drp_action'] = get_nfilter_request_var('drp_action'); $save['host_list'] = $host_list; $save['host_array'] = (isset($host_array)? $host_array : array()); api_plugin_hook_function('device_action_prepare', $save); $save_html = " "; } }else{ print "You must select at least one device.\n"; $save_html = ""; } print " $save_html \n"; html_end_box(); form_end(); bottom_footer(); } /* ------------------- Data Query Functions ------------------- */ function host_add_query() { /* ================= input validation ================= */ get_filter_request_var('host_id'); get_filter_request_var('snmp_query_id'); get_filter_request_var('reindex_method'); /* ==================================================== */ db_execute_prepared('REPLACE INTO host_snmp_query (host_id, snmp_query_id, reindex_method) VALUES (?, ?, ?)', array(get_nfilter_request_var('host_id'), get_nfilter_request_var('snmp_query_id'), get_nfilter_request_var('reindex_method'))); /* recache snmp data */ run_data_query(get_nfilter_request_var('host_id'), get_nfilter_request_var('snmp_query_id')); } function host_reload_query() { /* ================= input validation ================= */ get_filter_request_var('id'); get_filter_request_var('host_id'); /* ==================================================== */ run_data_query(get_request_var('host_id'), get_request_var('id')); } function host_remove_query() { /* ================= input validation ================= */ get_filter_request_var('id'); get_filter_request_var('host_id'); /* ==================================================== */ api_device_dq_remove(get_request_var('host_id'), get_request_var('id')); } function host_add_gt() { /* ================= input validation ================= */ get_filter_request_var('host_id'); get_filter_request_var('graph_template_id'); /* ==================================================== */ db_execute_prepared('REPLACE INTO host_graph (host_id, graph_template_id) VALUES (?, ?)', array(get_nfilter_request_var('host_id'), get_nfilter_request_var('graph_template_id'))); automation_hook_graph_template(get_nfilter_request_var('host_id'), get_nfilter_request_var('graph_template_id')); api_plugin_hook_function('add_graph_template_to_host', array('host_id' => get_nfilter_request_var('host_id'), 'graph_template_id' => get_nfilter_request_var('graph_template_id'))); } function host_remove_gt() { /* ================= input validation ================= */ get_filter_request_var('id'); get_filter_request_var('host_id'); /* ==================================================== */ api_device_gt_remove(get_request_var('host_id'), get_request_var('id')); } /* --------------------- Device Functions --------------------- */ function host_remove() { global $config; /* ================= input validation ================= */ get_filter_request_var('id'); /* ==================================================== */ if ((read_config_option('deletion_verification') == 'on') && (!isset_request_var('confirm'))) { top_header(); form_confirm('Are You Sure?', "Are you sure you want to delete the host '" . htmlspecialchars(db_fetch_cell_prepared('SELECT description FROM host WHERE id = ?', array(get_request_var('id')))) . "'?", htmlspecialchars('host.php'), htmlspecialchars('host.php?action=remove&id=' . get_request_var('id'))); bottom_footer(); exit; } if ((read_config_option('deletion_verification') == '') || (isset_request_var('confirm'))) { api_device_remove(get_request_var('id')); } } function ping_host() { get_filter_request_var('id'); if (isempty_request_var('id')) { return ""; } $host = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array(get_request_var('id'))); $am = $host['availability_method']; $anym = false; if ($am == AVAIL_SNMP || $am == AVAIL_SNMP_GET_NEXT || $am == AVAIL_SNMP_GET_SYSDESC || $am == AVAIL_SNMP_AND_PING || $am == AVAIL_SNMP_OR_PING) { $anym = true; print "SNMP Information
\n"; print "\n"; if (($host['snmp_community'] == '' && $host['snmp_username'] == '') || $host['snmp_version'] == 0) { print "SNMP not in use\n"; }else{ $snmp_system = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.1.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'),SNMP_WEBUI); /* modify for some system descriptions */ /* 0000937: System output in host.php poor for Alcatel */ if (substr_count($snmp_system, '00:')) { $snmp_system = str_replace('00:', '', $snmp_system); $snmp_system = str_replace(':', ' ', $snmp_system); } if ($snmp_system == '') { print "SNMP error\n"; }else{ $snmp_uptime = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.3.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI); $snmp_hostname = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.5.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI); $snmp_location = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.6.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI); $snmp_contact = cacti_snmp_get($host['hostname'], $host['snmp_community'], '.1.3.6.1.2.1.1.4.0', $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_auth_protocol'], $host['snmp_priv_passphrase'], $host['snmp_priv_protocol'], $host['snmp_context'], $host['snmp_port'], $host['snmp_timeout'], read_config_option('snmp_retries'), SNMP_WEBUI); print 'System:' . html_split_string($snmp_system) . "
\n"; $days = intval($snmp_uptime / (60*60*24*100)); $remainder = $snmp_uptime % (60*60*24*100); $hours = intval($remainder / (60*60*100)); $remainder = $remainder % (60*60*100); $minutes = intval($remainder / (60*100)); print "Uptime: $snmp_uptime"; print " ($days days, $hours hours, $minutes minutes)
\n"; print "Hostname: $snmp_hostname
\n"; print "Location: $snmp_location
\n"; print "Contact: $snmp_contact
\n"; } } print "
\n"; } if ($am == AVAIL_PING || $am == AVAIL_SNMP_AND_PING || $am == AVAIL_SNMP_OR_PING) { $anym = true; /* create new ping socket for host pinging */ $ping = new Net_Ping; $ping->host = $host; $ping->port = $host['ping_port']; /* perform the appropriate ping check of the host */ $ping_results = $ping->ping(AVAIL_PING, $host['ping_method'], $host['ping_timeout'], $host['ping_retries']); if ($ping_results == true) { $host_down = false; $class = 'hostUp'; }else{ $host_down = true; $class = 'hostDown'; } print "Ping Results
\n"; print "" . $ping->ping_response . "\n"; } if ($anym == false) { print "No Ping or SNMP Availability Check In Use

\n"; } } function host_edit() { global $fields_host_edit, $reindex_types; /* ================= input validation ================= */ get_filter_request_var('id'); /* ==================================================== */ api_plugin_hook('host_edit_top'); if (!isempty_request_var('id')) { $host = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array(get_request_var('id'))); $header_label = '[edit: ' . htmlspecialchars($host['description']) . ']'; }else{ $header_label = '[new]'; } if (!empty($host['id'])) { ?>
() *'>Create Graphs for this Device
*'>Data Source List
*'>Graph List
Contacting Device 

array('no_form_tag' => true), 'fields' => inject_form_variables($fields_host_edit, (isset($host) ? $host : array())) )); html_end_box(); ?> \n"; print "\n"; print "\n"; print "
Data Query Debug InformationHide
\n"; print "\n"; print ""; print "
" . debug_log_return('data_query') . "
\n"; print "\n"; } if (!empty($host['id'])) { html_start_box('Associated Graph Templates', '100%', '', '3', 'center', ''); html_header(array('Graph Template Name', 'Status'), 2); $selected_graph_templates = db_fetch_assoc_prepared('SELECT graph_templates.id, graph_templates.name FROM (graph_templates, host_graph) WHERE graph_templates.id = host_graph.graph_template_id AND host_graph.host_id = ? ORDER BY graph_templates.name', array(get_request_var('id'))); $available_graph_templates = db_fetch_assoc_prepared('SELECT graph_templates.id, graph_templates.name FROM snmp_query_graph RIGHT JOIN graph_templates ON snmp_query_graph.graph_template_id = graph_templates.id WHERE snmp_query_graph.name IS NULL AND graph_templates.id NOT IN (SELECT graph_template_id FROM host_graph WHERE host_id = ?) ORDER BY graph_templates.name', array(get_request_var('id'))); $i = 0; if (sizeof($selected_graph_templates)) { foreach ($selected_graph_templates as $item) { $i++; form_alternate_row("gt$i", true); /* get status information for this graph template */ $is_being_graphed = (sizeof(db_fetch_assoc_prepared('SELECT id FROM graph_local WHERE graph_template_id = ? AND host_id = ?', array($item['id'], get_request_var('id')))) > 0) ? true : false; ?> ) Is Being Graphed (Edit)" : "Not Being Graphed");?> ' data-id=''> No associated graph templates."; } ?>
Add Graph Template
0) { /* do nothing */ } else { array_push($keeper, $item); } } } $available_data_queries = $keeper; $i = 0; if (sizeof($selected_data_queries)) { foreach ($selected_data_queries as $item) { $i++; form_alternate_row("dg$i", true); /* get status information for this data query */ $num_dq_items = sizeof(db_fetch_assoc_prepared('SELECT snmp_index FROM host_snmp_cache WHERE host_id = ? AND snmp_query_id = ?', array(get_request_var('id'), $item['id']))); $num_dq_rows = sizeof(db_fetch_assoc_prepared('SELECT snmp_index FROM host_snmp_cache WHERE host_id = ? AND snmp_query_id = ? GROUP BY snmp_index', array(get_request_var('id'), $item['id']))); $status = 'success'; ?> ) (' class='linkEditMain' data-id=''>Verbose Query) Success" : "Fail");?> [ Item, Row] ' data-id=''> ' data-id=''> No associated data queries."; } ?>
Add Data Query Re-Index Method
array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_config_option('num_rows_table') ), 'page' => array( 'filter' => FILTER_VALIDATE_INT, 'default' => '1' ), 'filter' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string') ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'description', 'options' => array('options' => 'sanitize_search_string') ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string') ), 'host_status' => array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' ), 'host_template_id' => array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' ) ); validate_store_request_vars($filters, 'sess_host'); /* ================= input validation ================= */ /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') == -1) { $rows = read_config_option('num_rows_table'); }else{ $rows = get_request_var('rows'); } ?>
Search ' onChange='applyFilter()'> Template Status Devices
'>
array('display' => 'Device Description', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The name by which this Device will be referred to.'), 'hostname' => array('display' => 'Hostname', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'Either an IP address, or hostname. If a hostname, it must be resolvable by either DNS, or from your hosts file.'), 'id' => array('display' => 'ID', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The internal database ID for this Device. Useful when performing automation or debugging.'), 'graphs' => array('display' => 'Graphs', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The total number of Graphs generated from this Device.'), 'data_sources' => array('display' => 'Data Sources', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The total number of Data Sources generated from this Device.'), 'status' => array('display' => 'Status', 'align' => 'center', 'sort' => 'ASC', 'tip' => 'The monitoring status of the Device based upon ping results. If this Device is a special type Device, by using the hostname "localhost", or due to the setting to not perform an Availability Check, it will always remain Up. When using cmd.php data collector, a Device with no Graphs, is not pinged by the data collector and will remain in an "Unknown" state.'), 'status_rec_date' => array('display' => 'In State', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The amount of time that this Device has been in its current state.'), 'snmp_sysUpTimeInstance' => array('display' => 'Uptime', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The current amount of time that the host has been up.'), 'polling_time' => array('display' => 'Poll Time', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The the amount of time it takes to collect data from this Device.'), 'cur_time' => array('display' => 'Current (ms)', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The current ping time in milliseconds to reach the Device.'), 'avg_time' => array('display' => 'Average (ms)', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The average ping time in milliseconds to reach the Device since the counters were cleared for this Device.'), 'availability' => array('display' => 'Availability', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The availability percentage based upon ping results insce the counters were cleared for this Device.')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false); $i = 0; if (sizeof($hosts)) { foreach ($hosts as $host) { if ($host['disabled'] == '' && ($host['status'] == HOST_RECOVERING || $host['status'] == HOST_UP) && ($host['availability_method'] != AVAIL_NONE && $host['availability_method'] != AVAIL_PING)) { $snmp_uptime = $host['snmp_sysUpTimeInstance']; $days = intval($snmp_uptime / (60*60*24*100)); $remainder = $snmp_uptime % (60*60*24*100); $hours = intval($remainder / (60*60*100)); $remainder = $remainder % (60*60*100); $minutes = intval($remainder / (60*100)); $uptime = "$days:$hours:$minutes"; }else{ $uptime = "N/A"; } form_alternate_row('line' . $host['id'], true); form_selectable_cell("" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter'), '/') . ')/i', "\\1", htmlspecialchars($host['description'])) : htmlspecialchars($host['description'])) . '', $host['id']); form_selectable_cell((strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter'), '/') . ')/i', "\\1", htmlspecialchars($host['hostname'])) : htmlspecialchars($host['hostname'])), $host['id']); form_selectable_cell($host['id'], $host['id'], '', 'text-align:right'); form_selectable_cell(number_format($host['graphs']), $host['id'], '', 'text-align:right'); form_selectable_cell(number_format($host['data_sources']), $host['id'], '', 'text-align:right'); form_selectable_cell(get_colored_device_status(($host['disabled'] == 'on' ? true : false), $host['status']), $host['id'], '', 'text-align:center'); form_selectable_cell(get_timeinstate($host), $host['id'], '', 'text-align:right'); form_selectable_cell($uptime, $host['id'], '', 'text-align:right'); form_selectable_cell(round($host['polling_time'],2), $host['id'], '', 'text-align:right'); form_selectable_cell(round(($host['cur_time']), 2), $host['id'], '', 'text-align:right'); form_selectable_cell(round(($host['avg_time']), 2), $host['id'], '', 'text-align:right'); form_selectable_cell(round($host['availability'], 2) . ' %', $host['id'], '', 'text-align:right'); form_checkbox_cell($host['description'], $host['id']); form_end_row(); } /* put the nav bar on the bottom as well */ print $nav; }else{ print "No Devices"; } html_end_box(false); /* add a list of tree names to the actions dropdown */ add_tree_names_to_actions_array(); /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($device_actions); form_end(); } function get_timeinstate($host) { $interval = read_config_option('poller_interval'); if ($host['status_event_count'] > 0) { $time = $host['status_event_count'] * $interval; }elseif (strtotime($host['status_rec_date']) > 943916400) { $time = time() - strtotime($host['status_rec_date']); }else{ return '-'; } if ($time > 86400) { $days = floor($time/86400); $time %= 86400; }else{ $days = 0; } if ($time > 3600) { $hours = floor($time/3600); $time %= 3600; }else{ $hours = 0; } $minutes = floor($time/60); return $days . ':' . $hours . ':' . $minutes; }