コード例 #1
0
ファイル: tab.php プロジェクト: Cacti/plugin_thold
function thold_show_tab()
{
    global $config;
    if (api_user_realm_auth('thold_graph.php')) {
        $cp = false;
        if (basename($_SERVER['PHP_SELF']) == 'thold_graph.php' || basename($_SERVER['PHP_SELF']) == 'thold_view_failures.php' || basename($_SERVER['PHP_SELF']) == 'thold_view_normal.php') {
            $cp = true;
        }
        print '<a href="' . $config['url_path'] . 'plugins/thold/thold_graph.php"><img src="' . $config['url_path'] . 'plugins/thold/images/tab_thold' . ($cp ? '_down' : '') . '.gif" alt="thold" align="absmiddle" border="0"></a>';
    }
}
コード例 #2
0
ファイル: tabs.php プロジェクト: tinchobsas/cacti-gpsmaps
function gpsmap_show_tab()
{
    global $config;
    if (api_user_realm_auth('gpsmap.php')) {
        $cp = false;
        if (basename($_SERVER['PHP_SELF']) == 'gpsmap.php') {
            $cp = true;
        }
        print '<a href="' . $config['url_path'] . 'plugins/gpsmap/gpsmap.php"><img src="' . $config['url_path'] . 'plugins/gpsmap/images/tab_gpsmap' . ($cp ? '_down' : '') . '.gif" alt="GPS Map" align="absmiddle" border="0"></a>';
    }
}
コード例 #3
0
ファイル: tab.php プロジェクト: n00badmin/mirage
function mirage_show_tab()
{
    global $config;
    if (api_user_realm_auth('mirage_graph.php')) {
        $cp = false;
        if (basename($_SERVER['PHP_SELF']) == 'mirage_graph.php') {
            $cp = true;
        }
        print '<a href="' . $config['url_path'] . 'plugins/mirage/mirage_graph.php"><img src="' . $config['url_path'] . 'plugins/mirage/images/tab_mirage' . ($cp ? '_down' : '') . '.gif" alt="mirage" align="absmiddle" border="0"></a>';
    }
}
コード例 #4
0
ファイル: setup.php プロジェクト: Cacti/plugin_flowview
function flowview_show_tab()
{
    global $config;
    if (api_user_realm_auth('flowview.php')) {
        if (substr_count($_SERVER['REQUEST_URI'], 'flowview')) {
            print '<a href="' . htmlspecialchars($config['url_path'] . 'plugins/flowview/flowview.php') . '"><img src="' . $config['url_path'] . 'plugins/flowview/images/tab_flows_down.gif" alt="FlowView" align="absmiddle" border="0"></a>';
        } else {
            print '<a href="' . htmlspecialchars($config['url_path'] . 'plugins/flowview/flowview.php') . '"><img src="' . $config['url_path'] . 'plugins/flowview/images/tab_flows.gif" alt="FlowView" align="absmiddle" border="0"></a>';
        }
    }
}
コード例 #5
0
ファイル: setup.php プロジェクト: teddywen/cacti
function monitor_show_tab()
{
    global $config;
    if (api_user_realm_auth('monitor.php')) {
        if (substr_count($_SERVER["REQUEST_URI"], "monitor.php")) {
            print '<a href="' . $config['url_path'] . 'plugins/monitor/monitor.php"><img src="' . $config['url_path'] . 'plugins/monitor/images/tab_monitor_down.gif" alt="monitor" align="absmiddle" border="0"></a>';
        } else {
            print '<a href="' . $config['url_path'] . 'plugins/monitor/monitor.php"><img src="' . $config['url_path'] . 'plugins/monitor/images/tab_monitor.gif" alt="monitor" align="absmiddle" border="0"></a>';
        }
    }
    monitor_setup_table();
}
コード例 #6
0
ファイル: functions.php プロジェクト: Cacti/plugin_flowview
function display_tabs()
{
    /* purge old flows if they exist */
    purgeFlows();
    /* draw the categories tabs on the top of the page */
    $tab = get_nfilter_request_var('tab');
    if ($tab == '') {
        if (isset($_SESSION['flowview_current_tab'])) {
            $tab = $_SESSION['flowview_current_tab'];
        } else {
            $tab = 'filters';
            $_SESSION['flowview_current_tab'] = 'filters';
        }
    }
    print "<div class='tabs' style='float:left;'><nav><ul>\n";
    print "<li><a class='pic " . ($tab == 'filters' ? ' selected' : '') . "' title='Flow Filters' href='flowview.php?tab=filters'>Filters</a></li>\n";
    if (api_user_realm_auth('flowview_devices.php')) {
        print "<li><a class='pic " . ($tab == 'listeners' ? ' selected' : '') . "' title='Manage Listeners' href='flowview_devices.php?tab=listeners'>Listeners</a></li>\n";
    }
    if (api_user_realm_auth('flowview_schedules.php')) {
        print "<li><a class='pic " . ($tab == 'sched' ? ' selected' : '') . "' title='Manage Schedules' href='flowview_schedules.php?tab=sched'>Schedules</a></li>\n";
    }
    if (isset($_SESSION['flowview_flows']) && is_array($_SESSION['flowview_flows']) && sizeof($_SESSION['flowview_flows'])) {
        foreach ($_SESSION['flowview_flows'] as $sessionid => $data) {
            if (!isset($data['title'])) {
                $_SESSION['flowview_flows'][$sessionid]['title'] = $data['title'] = "Unknown";
            }
            print "<li><a class='pic " . ($tab == $sessionid ? 'selected' : '') . "' title='View Flow' href='flowview.php?action=view&tab={$sessionid}'>" . $data['title'] . "</a><a class='pic' href='flowview.php?action=killsession&session={$sessionid}' title='Remove Flow Cache'><span class='fa fa-remove deviceDown'></span></a></li>\n";
        }
    }
    print "</ul></nav></div>\n";
}
コード例 #7
0
ファイル: setup.php プロジェクト: Cacti/plugin_mactrack
function mactrack_show_tab()
{
    global $config, $user_auth_realm_filenames;
    if (api_user_realm_auth('mactrack_view_macs.php')) {
        if (substr_count($_SERVER['REQUEST_URI'], 'mactrack_view_')) {
            print '<a href="' . $config['url_path'] . 'plugins/mactrack/mactrack_view_macs.php"><img src="' . $config['url_path'] . 'plugins/mactrack/images/tab_mactrack_down.png" alt="' . __('MacTrack') . '" align="absmiddle" border="0"></a>';
        } else {
            print '<a href="' . $config['url_path'] . 'plugins/mactrack/mactrack_view_macs.php"><img src="' . $config['url_path'] . 'plugins/mactrack/images/tab_mactrack.png" alt="' . __('MacTrack') . '" align="absmiddle" border="0"></a>';
        }
    }
}
コード例 #8
0
function mactrack_view_sites()
{
    global $title, $config, $item_rows;
    mactrack_sites_request_validation();
    if (get_request_var('rows') == -1) {
        $row_limit = read_config_option('num_rows_table');
    } elseif (get_request_var('rows') == -2) {
        $row_limit = 999999;
    } else {
        $row_limit = get_request_var('rows');
    }
    $webroot = $config['url_path'] . '/plugins/mactrack/';
    mactrack_tabs();
    html_start_box($title, '100%', '', '3', 'center', '');
    mactrack_site_filter('mactrack_view_sites.php');
    html_end_box();
    $sql_where = '';
    $sites = mactrack_view_get_site_records($sql_where, $row_limit);
    if (get_request_var('detail') == 'false') {
        $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(mac_track_sites.site_id)\n\t\t\tFROM mac_track_sites\n\t\t\t{$sql_where}");
    } else {
        $total_rows = sizeof(db_fetch_assoc("SELECT\n\t\t\tmac_track_device_types.device_type_id, mac_track_sites.site_name\n\t\t\tFROM (mac_track_device_types\n\t\t\tRIGHT JOIN mac_track_devices ON (mac_track_device_types.device_type_id = mac_track_devices.device_type_id))\n\t\t\tRIGHT JOIN mac_track_sites ON (mac_track_devices.site_id = mac_track_sites.site_id)\n\t\t\t{$sql_where}\n\t\t\tGROUP BY mac_track_sites.site_name, mac_track_device_types.device_type_id"));
    }
    $nav = html_nav_bar('mactrack_view_sites.php', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 11, __('Sites'));
    print $nav;
    html_start_box('', '100%', '', '3', 'center', '');
    if (get_request_var('detail') == 'false') {
        $display_text = array('nosort' => array(__('Actions'), ''), 'site_name' => array(__('Site Name'), 'ASC'), 'total_devices' => array(__('Devices'), 'DESC'), 'total_ips' => array(__('Total IP\'s'), 'DESC'), 'total_user_ports' => array(__('User Ports'), 'DESC'), 'total_oper_ports' => array(__('User Ports Up'), 'DESC'), 'total_macs' => array(__('MACS Found'), 'DESC'), 'total_device_errors' => array(__('Device Errors'), 'DESC'));
        html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
        if (sizeof($sites) > 0) {
            foreach ($sites as $site) {
                form_alternate_row('row_' . $site['site_id'], true);
                ?>
					<td width=140>
						<?php 
                if (api_user_realm_auth('mactrack_sites.php')) {
                    echo "<a href='" . htmlspecialchars($webroot . 'mactrack_sites.php?action=edit&site_id=' . $site['site_id']) . "' title='" . __('Edit Site') . "'><img border='0' src='" . $webroot . "images/edit_object.png'></a>";
                    echo "<a href='#'><img id='r_" . $site['site_id'] . "' src='" . $webroot . "images/rescan_site.gif' alt='' onClick='site_scan(" . $site['site_id'] . ")' title='" . __('Rescan Site') . "' border='0'></a>";
                }
                ?>
						<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_devices.php?report=devices&reset&site_id=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View Devices');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_devices.gif'></a>
						<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_ips.php?report=ips&reset&site_id=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View IP Ranges');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_networks.gif'></a>
						<a href='<?php 
                print htmlspecialchars($webroot . 'plugins/mactrack/mactrack_view_arp.php?report=arp&reset&site_id=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View IP Addresses');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_ipaddresses.gif'></a>
						<a href='<?php 
                print htmlspecialchars($webroot . 'plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View MAC Addresses');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_macs.gif'></a>
						<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_interfaces.php?report=interfaces&reset&site=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View Interfaces');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_interfaces.gif'></a>
					</td>
					<td class='hyperLink'>
						<?php 
                print filter_value($site['site_name'], get_request_var('filter'));
                ?>
					</td>
					<td><?php 
                print number_format_i18n($site['total_devices']);
                ?>
</td>
					<td><?php 
                print number_format_i18n($site['total_ips']);
                ?>
</td>
					<td><?php 
                print number_format_i18n($site['total_user_ports']);
                ?>
</td>
					<td><?php 
                print number_format_i18n($site['total_oper_ports']);
                ?>
</td>
					<td><?php 
                print number_format_i18n($site['total_macs']);
                ?>
</td>
					<td><?php 
                print $site['total_device_errors'];
                ?>
</td>
				</tr>
				<?php 
            }
        } else {
            print '<tr><td colspan="10"><em>' . __('No MacTrack Sites') . '</em></td></tr>';
        }
        html_end_box(false);
        if (sizeof($sites)) {
            print $nav;
            mactrack_display_stats();
        }
    } else {
        $display_text = array('nosort' => array(__('Actions'), ''), 'site_name' => array(__('Site Name'), 'ASC'), 'vendor' => array(__('Vendor'), 'ASC'), 'description' => array(__('Device Type'), 'DESC'), 'total_devices' => array(__('Total Devices'), 'DESC'), 'sum_ips_total' => array(__('Total IP\'s'), 'DESC'), 'sum_ports_total' => array(__('Total User Ports'), 'DESC'), 'sum_ports_active' => array(__('Total Oper Ports'), 'DESC'), 'sum_ports_trunk' => array(__('Total Trunks'), 'DESC'), 'sum_macs_active' => array(__('MACS Found'), 'DESC'));
        html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
        if (sizeof($sites)) {
            foreach ($sites as $site) {
                form_alternate_row();
                ?>
					<td width=100>
						<?php 
                if (api_user_realm_auth('mactrack_sites.php')) {
                    echo "<a href='" . htmlspecialchars($webroot . 'mactrack_sites.php?action=edit&site_id=' . $site['site_id']) . "' title='" . __('Edit Site') . "'><img border='0' src='" . $webroot . "images/edit_object.png'></a>";
                }
                ?>
						<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_devices.php?report=devices&site_id=' . $site['site_id'] . '&device_type_id=' . $site['device_type_id'] . '&type_id=-1&status=-1&filter=');
                ?>
' title='<?php 
                print __('View Devices');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_devices.gif'></a>
						<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_ips.php?report=ips&reset&site_id=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View IP Ranges');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_networks.gif'></a>
						<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View MAC Addresses');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_macs.gif'></a>
						<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_interfaces.php?report=interfaces&reset&site=' . $site['site_id']);
                ?>
' title='<?php 
                print __('View Interfaces');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_interfaces.gif'></a>
					</td>
					<td class='hyperLink'>
						<?php 
                print filter_value($site['site_name'], get_request_var('filter'));
                ?>
					</td>
					<td><?php 
                print filter_value($site['vendor'], get_request_var('filter'));
                ?>
					<td><?php 
                print filter_value($site['description'], get_request_var('filter'));
                ?>
					<td><?php 
                print number_format_i18n($site['total_devices']);
                ?>
</td>
					<td><?php 
                print $site['device_type'] == '1' ? __('N/A') : number_format_i18n($site['sum_ips_total']);
                ?>
</td>
					<td><?php 
                print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_ports_total']);
                ?>
</td>
					<td><?php 
                print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_ports_active']);
                ?>
</td>
					<td><?php 
                print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_ports_trunk']);
                ?>
</td>
					<td><?php 
                print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_macs_active']);
                ?>
</td>
				</tr>
				<?php 
            }
        } else {
            print '<tr><td colspan="10"><em>' . __('No MacTrack Sites') . '</em></td></tr>';
        }
        html_end_box(false);
        if (sizeof($sites)) {
            print $nav;
            mactrack_display_stats();
        }
    }
    print '<div id="response"></div>';
}
コード例 #9
0
ファイル: thold_graph.php プロジェクト: Cacti/plugin_thold
function hosts()
{
    global $config, $device_actions, $item_rows;
    /* ================= input validation and session storage ================= */
    $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), '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_template_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host_status' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-4'));
    validate_store_request_vars($filters, 'sess_thold_hstatus');
    /* ================= 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');
    }
    html_start_box(__('Device Status'), '100%', '', '3', 'center', '');
    form_host_filter();
    html_end_box();
    /* form the 'where' clause for our main sql query */
    $sql_where = '';
    if (get_request_var('filter') != '') {
        $sql_where = "((h.hostname LIKE '%" . get_request_var('filter') . "%' OR h.description LIKE '%" . get_request_var('filter') . "%')";
    }
    if (get_request_var('host_status') == '-1') {
        /* Show all items */
    } elseif (get_request_var('host_status') == '-2') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.disabled='on'";
    } elseif (get_request_var('host_status') == '-3') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.disabled=''";
    } elseif (get_request_var('host_status') == '-4') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.status!='3' OR h.disabled='on')";
    } elseif (get_request_var('host_status') == '-5') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.availability_method=0)";
    } elseif (get_request_var('host_status') == '3') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.availability_method!=0 AND h.status=3 AND h.disabled='')";
    } else {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.status=" . get_request_var('host_status') . " AND h.disabled = '')";
    }
    if (get_request_var('host_template_id') == '-1') {
        /* Show all items */
    } elseif (get_request_var('host_template_id') == '0') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.host_template_id=0'";
    } elseif (!isempty_request_var('host_template_id')) {
        $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.host_template_id=" . get_request_var('host_template_id');
    }
    $sql_where .= strlen($sql_where) ? ')' : '';
    $sortby = get_request_var('sort_column');
    if ($sortby == 'hostname') {
        $sortby = 'INET_ATON(hostname)';
    }
    $host_graphs = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id'), 'host_id', 'graphs');
    $host_data_sources = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id'), 'host_id', 'data_sources');
    $hosts = get_allowed_devices($sql_where, $sortby . ' ' . get_request_var('sort_direction'), $rows * (get_request_var('page') - 1) . ',' . $rows, $total_rows);
    $nav = html_nav_bar('thold_graph.php?action=hoststat', MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 12, __('Devices'), 'page', 'main');
    print $nav;
    html_start_box('', '100%', '', '3', 'center', '');
    $display_text = array('nosort' => array('display' => __('Actions'), 'align' => 'left', 'sort' => '', 'tip' => __('Hover over icons for help')), 'description' => array('display' => __('Description'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('A description for the Device')), 'id' => array('display' => __('ID'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('A Cacti unique identifier for the Device')), 'nosort1' => array('display' => __('Graphs'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The number of Graphs for this Device')), 'nosort2' => array('display' => __('Data Sources'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The number of Data Sources for this Device')), 'status' => array('display' => __('Status'), 'align' => 'center', 'sort' => 'ASC', 'tip' => __('The status for this Device as of the last time it was polled')), 'nosort3' => array('display' => __('In State'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The last time Cacti found an issues with this Device.  It can be higher than the Uptime for the the Device, if it was rebooted between Cacti polling cycles')), 'snmp_sysUpTimeInstance' => array('display' => __('Uptime'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The official uptime of the Device as reported by SNMP')), 'hostname' => array('display' => __('Hostname'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The official hostname for this Device')), 'cur_time' => array('display' => __('Current (ms)'), 'align' => 'right', 'sort' => 'DESC', 'tip' => __('The current response time for the Cacti Availability check')), 'avg_time' => array('display' => __('Average (ms)'), 'align' => 'right', 'sort' => 'DESC', 'tip' => __('The average response time for the Cacti Availability check')), 'availability' => array('display' => __('Availability'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The overall Availability of this Device since the last counter reset in Cacti')));
    html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'thold_graph.php?action=hoststat');
    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 . 'd:' . substr('00' . $hours, -2) . 'h:' . substr('00' . $minutes, -2) . 'm';
            } else {
                $uptime = __('N/A');
            }
            if (isset($host_graphs[$host['id']])) {
                $graphs = $host_graphs[$host['id']];
            } else {
                $graphs = 0;
            }
            if (isset($host_data_sources[$host['id']])) {
                $ds = $host_data_sources[$host['id']];
            } else {
                $ds = 0;
            }
            if ($host['availability_method'] != 0) {
                form_host_status_row_color($host['status'], $host['disabled']);
                print "<td width='1%' class='nowrap'>";
                if (api_user_realm_auth('host.php')) {
                    print '<a href="' . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $host['id']) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="' . __('Edit Device') . '"></a>';
                }
                print "<a href='" . htmlspecialchars($config['url_path'] . 'graph_view.php?action=preview&graph_template_id=0&filter=&host_id=' . $host['id']) . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='" . __('View Graphs') . "'></a>";
                print '</td>';
                ?>
				<td style='text-align:left'>
					<?php 
                print filter_value($host['description'], get_request_var('filter'));
                ?>
				</td>
				<td style='text-align:right'><?php 
                print round($host['id'], 2);
                ?>
</td>
				<td style='text-align:right'><i><?php 
                print number_format_i18n($graphs);
                ?>
</i></td>
				<td style='text-align:right'><i><?php 
                print number_format_i18n($ds);
                ?>
</i></td>
				<td style='text-align:center'><?php 
                print get_uncolored_device_status($host['disabled'] == 'on' ? true : false, $host['status']);
                ?>
</td>
				<td style='text-align:right'><?php 
                print get_timeinstate($host);
                ?>
</td>
				<td style='text-align:right'><?php 
                print $uptime;
                ?>
</td>
				<td style='text-align:right'><?php 
                print filter_value($host['hostname'], get_request_var('filter'));
                ?>
</td>
				<td style='text-align:right'><?php 
                print round($host['cur_time'], 2);
                ?>
</td>
				<td style='text-align:right'><?php 
                print round($host['avg_time'], 2);
                ?>
</td>
				<td style='text-align:right'><?php 
                print round($host['availability'], 2);
                ?>
 %</td>
				<?php 
            } else {
                print "<tr class='deviceNotMonFull'>\n";
                print "<td width='1%' class='nowrap'>\n";
                if (api_user_realm_auth('host.php')) {
                    print '<a href="' . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $host["id"]) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="' . __('Edit Device') . '"></a>';
                }
                print "<a href='" . htmlspecialchars($config['url_path'] . "graph_view.php?action=preview&graph_template_id=0&filter=&host_id=" . $host["id"]) . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='" . __('View Graphs') . "'></a>";
                print "</td>";
                ?>
				<td style='text-align:left'>
					<?php 
                print filter_value($host['description'], get_request_var('filter'));
                ?>
				</td>
				<td style='text-align:right'><?php 
                print $host['id'];
                ?>
</td>
				<td style='text-align:right'><i><?php 
                print number_format_i18n($graphs);
                ?>
</i></td>
				<td style='text-align:right'><i><?php 
                print number_format_i18n($ds);
                ?>
</i></td>
				<td style='text-align:center'><?php 
                print 'Not Monitored';
                ?>
</td>
				<td style='text-align:right'><?php 
                print 'N/A';
                ?>
</td>
				<td style='text-align:right'><?php 
                print $uptime;
                ?>
</td>
				<td style='text-align:right'><?php 
                print filter_value($host['hostname'], get_request_var('filter'));
                ?>
</td>
				<td style='text-align:right'><?php 
                print 'N/A';
                ?>
</td>
				<td style='text-align:right'><?php 
                print 'N/A';
                ?>
</td>
				<td style='text-align:right'><?php 
                print 'N/A';
                ?>
</td>
				<?php 
            }
            form_end_row();
        }
    } else {
        print '<tr><td class="center" colspan="12">' . __('No Devices') . '</td></tr>';
    }
    html_end_box(false);
    if (sizeof($hosts)) {
        print $nav;
    }
    host_legend();
    //thold_display_rusage();
}
コード例 #10
0
function mactrack_view_devices()
{
    global $title, $report, $mactrack_search_types, $mactrack_device_types, $rows_selector, $config, $item_rows;
    mactrack_device_request_validation();
    if (get_request_var('rows') == -1) {
        $row_limit = read_config_option('num_rows_table');
    } elseif (get_request_var('rows') == -2) {
        $row_limit = 999999;
    } else {
        $row_limit = get_request_var('rows');
    }
    $webroot = $config['url_path'] . '/plugins/mactrack/';
    mactrack_tabs();
    html_start_box($title, '100%', '', '3', 'center', '');
    mactrack_device_filter2();
    html_end_box();
    $sql_where = '';
    $devices = mactrack_view_get_device_records($sql_where, $row_limit);
    $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(mac_track_devices.device_id)\n\t\tFROM mac_track_sites\n\t\tRIGHT JOIN mac_track_devices ON mac_track_devices.site_id = mac_track_sites.site_id\n\t\tLEFT JOIN mac_track_device_types ON (mac_track_device_types.device_type_id=mac_track_devices.device_type_id)\n\t\t{$sql_where}");
    $nav = html_nav_bar('mactrack_view_devices.php?report=devices', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 13, __('Devices'));
    print $nav;
    html_start_box('', '100%', '', '3', 'center', '');
    $display_text = array('nosort' => array(__('Actions'), ''), 'device_name' => array(__('Device Name'), 'ASC'), 'site_name' => array(__('Site Name'), 'ASC'), 'snmp_status' => array(__('Status'), 'ASC'), 'hostname' => array(__('Hostname'), 'ASC'), 'device_type' => array(__('Device Type'), 'ASC'), 'ips_total' => array(__('Total IP\'s'), 'DESC'), 'ports_total' => array(__('User Ports'), 'DESC'), 'ports_active' => array(__('User Ports Up'), 'DESC'), 'ports_trunk' => array(__('Trunk Ports'), 'DESC'), 'macs_active' => array(__('Active Macs'), 'DESC'), 'vlans_total' => array(__('Total VLAN\'s'), 'DESC'), 'last_runduration' => array(__('Last Duration'), 'DESC'));
    html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
    $i = 0;
    if (sizeof($devices) > 0) {
        foreach ($devices as $device) {
            $hostinfo['hostname'] = $device['hostname'];
            $hostinfo['user'] = $device['user_name'];
            switch ($device['term_type']) {
                case 0:
                    $hostinfo['transport'] = 'none';
                    break;
                case 1:
                    $hostinfo['transport'] = 'telnet';
                    break;
                case 2:
                    $hostinfo['transport'] = 'ssh';
                    break;
                case 3:
                    $hostinfo['transport'] = 'http';
                    break;
                case 4:
                    $hostinfo['transport'] = 'https';
                    break;
            }
            form_alternate_row();
            ?>
				<td width=100>
					<?php 
            if (api_user_realm_auth('mactrack_sites.php')) {
                ?>
					<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_devices.php?action=edit&device_id=' . $device['device_id']);
                ?>
' title='<?php 
                print __('Edit Device');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/edit_object.png'></a>
					<?php 
                api_plugin_hook_function('remote_link', $hostinfo);
            }
            ?>
					<?php 
            if ($device['host_id'] > 0) {
                ?>
					<a href='<?php 
                print htmlspecialchars($webroot . 'mactrack_view_graphs.php?action=preview&report=graphs&style=selective&graph_list=&host=' . $device['host_id'] . '&graph_template_id=0&filter=');
                ?>
' title='<?php 
                print __('View Graphs');
                ?>
'><img border='0' src='<?php 
                print $webroot;
                ?>
images/view_graphs.gif'></a>
					<?php 
            } else {
                ?>
					<img title='<?php 
                print __('Device Not Mapped to Cacti Device');
                ?>
' border='0' src='<?php 
                print $webroot;
                ?>
images/view_graphs_disabled.gif'>
					<?php 
            }
            ?>
					<a href='<?php 
            print htmlspecialchars($webroot . 'mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=' . get_request_var('site_id') . '&device_id=' . $device['device_id']);
            ?>
' title='<?php 
            print __('View MAC Addresses');
            ?>
'><img border='0' src='<?php 
            print $webroot;
            ?>
images/view_macs.gif'></a>
					<a href='<?php 
            print htmlspecialchars($webroot . 'mactrack_view_interfaces.php?report=interfaces&reset&site=' . get_request_var('site_id') . '&device=' . $device['device_id']);
            ?>
' title='<?php 
            print __('View Interfaces');
            ?>
'><img border='0' src='<?php 
            print $webroot;
            ?>
images/view_interfaces.gif'></a>
				</td>
				<td class='hyperLink'>
					<?php 
            print filter_value($device['device_name'], get_request_var('filter'));
            ?>
				</td>
				<td><?php 
            print filter_value($device['site_name'], get_request_var('filter'));
            ?>
				<td><?php 
            print get_colored_device_status($device['disabled'] == 'on' ? true : false, $device['snmp_status']);
            ?>
</td>
				<td><?php 
            print filter_value($device['hostname'], get_request_var('filter'));
            ?>
				<td><?php 
            print $device['device_type'];
            ?>
</td)>
				<td><?php 
            print $device['scan_type'] == '1' ? __('N/A') : number_format_i18n($device['ips_total']);
            ?>
</td>
				<td><?php 
            print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_total']);
            ?>
</td>
				<td><?php 
            print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_active']);
            ?>
</td>
				<td><?php 
            print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_trunk']);
            ?>
</td>
				<td><?php 
            print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['macs_active']);
            ?>
</td>
				<td><?php 
            print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['vlans_total']);
            ?>
</td>
				<td><?php 
            print number_format($device['last_runduration'], 1);
            ?>
</td>
			</tr>
			<?php 
        }
    } else {
        print '<tr><td colspan="10"><em>' . __('No MacTrack Devices') . '</em></td></tr>';
    }
    html_end_box(false);
    if (sizeof($devices)) {
        print $nav;
        mactrack_display_stats();
    }
}
コード例 #11
0
ファイル: setup.php プロジェクト: Cacti/plugin_mikrotik
function mikrotik_show_tab()
{
    global $config;
    if (api_user_realm_auth('mikrotik.php')) {
        if (substr_count($_SERVER['REQUEST_URI'], 'mikrotik.php')) {
            print '<a href="' . $config['url_path'] . 'plugins/mikrotik/mikrotik.php"><img src="' . $config['url_path'] . 'plugins/mikrotik/images/tab_mikrotik_down.gif" alt="' . __('MikroTik') . '" border="0"></a>';
        } else {
            print '<a href="' . $config['url_path'] . 'plugins/mikrotik/mikrotik.php"><img src="' . $config['url_path'] . 'plugins/mikrotik/images/tab_mikrotik.gif" alt="' . __('MikroTik') . '" border="0"></a>';
        }
    }
}
コード例 #12
0
ファイル: setup.php プロジェクト: beiyehou/2D-CPA-platform
function predict_show_tab()
{
    global $config;
    if (api_user_realm_auth('predict.php')) {
        if (!isset($_SERVER['REQUEST_URI'])) {
            $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 0);
            if (isset($_SERVER['QUERY_STRING']) and $_SERVER['QUERY_STRING'] != "") {
                $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
            }
        }
        if (substr_count($_SERVER["REQUEST_URI"], "predict")) {
            print '<a href="' . $config['url_path'] . 'plugins/predict/predict.php"><img src="' . $config['url_path'] . 'plugins/predict/images/tab_predict_down.png" alt="predict" align="absmiddle" border="0"></a>';
        } else {
            print '<a href="' . $config['url_path'] . 'plugins/predict/predict.php"><img src="' . $config['url_path'] . 'plugins/predict/images/tab_predict.png" alt="predict" align="absmiddle" border="0"></a>';
        }
    }
}
コード例 #13
0
ファイル: flowview.php プロジェクト: avillaverdec/cacti
function flowview_display_form()
{
    global $config, $colors;
    include $config['base_path'] . '/plugins/flowview/variables.php';
    include $config['base_path'] . '/plugins/flowview/arrays.php';
    print '<form id="flowview" action="' . $config['url_path'] . 'plugins/flowview/flowview.php" method="post" name="flowview">';
    display_tabs();
    html_start_box("<strong>Flow Filter Constraints</strong>", "100%", $colors["header"], "3", "center", "");
    ?>
	<tr>
		<td>
			<table border='0' cellspacing='0' cellpadding='1' width='100%' style='white-space:nowrap;'>
				<tr>
					<td>Saved Query:</td>
					<td><?php 
    draw_edit_control("query", $query_name_field);
    ?>
</td>
					<td>Listener:</td>
					<td><?php 
    draw_edit_control("device_name", $device_name_field);
    ?>
</td>
				</tr>
				<tr>
					<td>Start Date:</td>
					<td><input type='text' size='10' name='start_date' value='<?php 
    echo $start_date;
    ?>
'></td>
					<td>Start Time:</td><td><input type='text' size='8' name='start_time' value='<?php 
    echo $start_time;
    ?>
'></td>
					<td>TOS Fields:</td>
					<td><input type='text' size='10' name='tos_fields' value='<?php 
    echo $tos_fields;
    ?>
'></td>
					<td colspan=2>(e.g., -0x0b/0x0F)</td>
				</tr>
				<tr>
					<td>End Date:</td>
					<td><input type='text' size='10' name='end_date' value='<?php 
    echo $end_date;
    ?>
'></td>
					<td>End Time:</td>
					<td><input type='text' size='8' name='end_time' value='<?php 
    echo $end_time;
    ?>
'></td>
					<td>TCP Flags:</td>
					<td><input type='text' size='10' name='tcp_flags' value='<?php 
    echo $tcp_flags;
    ?>
'></td>
					<td>Protocols:</td>
					<td><?php 
    draw_edit_control("protocols", $ip_protocol_field);
    ?>
</td>
				</tr>
				<tr>
					<td>Source IP:</td>
					<td><input type='text' size='19' name='source_address' value='<?php 
    echo $source_address;
    ?>
'></td>
					<td>Source Port(s):</td>
					<td><input type='text' size='20' name='source_port' value='<?php 
    echo $source_port;
    ?>
'></td>
					<td>Source Interface:</td>
					<td><input type='text' size='2' name='source_if' value='<?php 
    echo $source_if;
    ?>
'></td>
					<td>Source AS:</td>
					<td><input type='text' size='6' name='source_as' value='<?php 
    echo $source_as;
    ?>
'></td>
				</tr>
				<tr>
					<td>Dest IP:</td>
					<td><input type='text' size='19' name='dest_address' value='<?php 
    echo $dest_address;
    ?>
'></td>
					<td>Dest Port(s):</td>
					<td><input type='text' size='20' name='dest_port' value='<?php 
    echo $dest_port;
    ?>
'></td>
					<td>Dest Interface:</td>
					<td><input type='text' size='2' name='dest_if' value='<?php 
    echo $dest_if;
    ?>
'></td>
					<td>Dest AS:</td>
					<td><input type='text' size='6' name='dest_as' value='<?php 
    echo $dest_as;
    ?>
'></td>
				</tr>
				<tr>
					<td colspan='9'>
						<hr size='2'>
						<center><strong>Note:</strong> Multiple field entries, separated by commas, are permitted in the fields above. A minus sign (-) will negate an entry (e.g. -80 for Port, would mean any Port but 80)</center>
						<hr size='2'>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php 
    html_end_box(false);
    ?>
	<?php 
    html_start_box("<strong>Report Parameters</strong>", "100%", $colors["header"], "3", "center", "");
    ?>
	<tr>
		<td>
			<table cellpadding='1' cellspacing='0' border='0' width='100%' style='white-space:nowrap;'>
				<tr id='rsettings'>
					<td>Statistics:</td>
					<td><?php 
    draw_edit_control("stat_report", $stat_report_field);
    ?>
</td>
					<td>Printed:</td>
					<td><?php 
    draw_edit_control("print_report", $print_report_field);
    ?>
</td>
					<td>Include if:</td>
					<td><?php 
    draw_edit_control("flow_select", $flow_select_field);
    ?>
</td>
					<td>Resolve Addresses:</td>
					<td><?php 
    draw_edit_control("resolve_addresses", $resolve_addresses_field);
    ?>
</td>
				</tr>
				<tr id='rlimits'>
					<td class='sortfield'>Sort Field:</td>
					<td class='sortfield'><select id='sort_field' name='sort_field'></select></td>
					<td>Max Flows:</td>
					<td><?php 
    draw_edit_control("cutoff_lines", $cutoff_lines_field);
    ?>
</td>
					<td>Minimum Bytes:</td>
					<td><?php 
    draw_edit_control("cutoff_octets", $cutoff_octets_field);
    ?>
</td>
				</tr>
				<tr>
			</table>
		</td>
	</tr>
		<td colspan='9'><hr size='2'></td>
	</tr>
	<tr>
		<td colspan='9'>
			<input type='hidden' id='action' name='action' value='view'>
			<input type='hidden' id='new_query' name='new_query' value=''>
			<input type='hidden' id='changed' name='changed' value='0'>
			<center>
				<input id='view' type='button' name='view' value='View'>
				<input id='defaults' type='button' value='Defaults'>
				<input id='save' type='button' name='save' value='Save'>
				<input id='saveas' type='button' name='saveas' value='Save As'>
				<input id='delete' type='button' name='delete' value='Delete'>
			</center>
		</td>
	</tr>
	<?php 
    html_end_box();
    ?>
	</table></td></tr>
	<?php 
    print '</form>';
    ?>
	<script type="text/javascript">
	<!--
	function statSelect() {
		statval = $('#stat_report').val();
		setStatOption(statval);
		if (statval > 0) {
			$('#print_report').attr('value', 0);
			$('#print_report').attr('disabled', 'disabled');
			$('#rlimits').children('.sortfield').show();
		}else{
			$('#print_report').attr('disabled', '');
		}
		if (statval == 99 || statval < 1) {
			$('#rlimits').hide();
		} else {
			$('#rlimits').show();
		}

		if (statval == 0 && $('#print_report').val() == 0) {
			$('#view').attr('disabled','disabled');
			$('#save').attr('disabled','disabled');
			$('#saveas').attr('disabled','disabled');
		}else{
			$('#view').attr('disabled','');
			$('#save').attr('disabled','');
			$('#saveas').attr('disabled','');
		}
	}

	function printSelect() {
		statval = $('#print_report').val();
		if (statval > 0) {
			$('#stat_report').attr('value',0);
			$('#stat_report').attr('disabled', 'disabled');
			$('#sort_field').removeAttr('disabled');
			$('#rlimits').hide();
			$('#rlimits').children('.sortfield').hide();
		} else {
			$('#rlimits').show();
			$('#cutoff_lines').removeAttr('disabled');
			$('#cutoff_octets').removeAttr('disabled');
			if ($('#stat_report').val() == 0) {
				$('#stat_report').attr('value', 10);
			}
			$('#stat_report').removeAttr('disabled');
			statSelect();
			return;
		}
		if (statval == 4 || statval == 5) {
			$('#cutoff_lines').removeAttr('disabled');
			$('#cutoff_octets').removeAttr('disabled');
			$('#rlimits').show();
		} else {
			$('#cutoff_lines').attr('disabled','disabled');
			$('#cutoff_octets').attr('disabled','disabled');
			$('#rlimits').hide();
		}

		if (statval == 0 && $('#stat_report').val() == 0) {
			$('#view').attr('disabled','disabled');
			$('#save').attr('disabled','disabled');
			$('#saveas').attr('disabled','disabled');
		}else{
			$('#view').attr('disabled','');
			$('#save').attr('disabled','');
			$('#saveas').attr('disabled','');
		}
	}

	$('#device_name').change(function () {
		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($(this).val() == 0) {
			$('#view').attr('disabled', 'disabled');
			$('#save').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
			$('#save').removeAttr('disabled');
		}
		<?php 
    } else {
        ?>
		if ($(this).val() == 0) {
			$('#view').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
		}
		<?php 
    }
    ?>
	});

	$().ready(function () {
		$('#saveas').hide();
		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#query').val() == 0) {
			$('#delete').hide();
		}else{
			$('#save').attr('value', 'Update');
			$('#saveas').show();
		}
		<?php 
    } else {
        ?>
		$('#delete').hide();
		$('#save').hide();
		<?php 
    }
    ?>

		$('#query').change(function() {
			window.location="flowview.php?action=loadquery&query="+$('#query').val();
		});

		$('#flowview').change(function() {
			$('#changed').attr('value', '1');
		});

		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').attr('disabled', 'disabled');
			$('#save').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
			$('#save').removeAttr('disabled');
		}
		<?php 
    } else {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').attr('disabled', 'disabled');
		}else{
			$('#view').removeAttr('disabled');
		}
		<?php 
    }
    ?>

		$('#stat_report').change(function() {
			statSelect();
		});

		$('#print_report').change(function() {
			printSelect();
		});

		statSelect();
		printSelect();

		$("#fdialog").dialog({
			autoOpen: false,
			width: 320,
			height: 90,
			resizable: false,
			modal: true
		});
	});

	$('#view').click(function() {
		$('#action').attr('value', 'view');
		document.flowview.submit();
	});

	$('#saveas').click(function() {
		$('#squery').attr('value', $('#query>option:selected').text()+' (New)');
		$('#fdialog').dialog('open');
		$('#qcancel').click(function() {
			$('#fdialog').dialog('close');
		});
		$('#qsave').click(function() {
			$('#new_query').attr('value', $('#squery').val());
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize(), function(data) {
				if (data!="error") {
					$('#query').append("<option value='"+data+"'>"+$('#new_query').val()+"</option>");
					$('#query').attr('value', data);
				}
			});
			$('#fdialog').dialog('close');
		});
	});

	$('#save').click(function() {
		if ($('#query').val() == 0) {
			$('#fdialog').dialog('open');
			$('#qcancel').click(function() {
				$('#fdialog').dialog('close');
			});
			$('#qsave').click(function() {
				$('#new_query').attr('value', $('#squery').val());
				$('#action').attr('value', 'save');
				$.post('flowview.php', $('#flowview').serialize(), function(data) {
					if (data!="error") {
						$('#query').append("<option value='"+data+"'>"+$('#new_query').val()+"</option>");
						$('#query').attr('value', data);
					}
				});
				$('#fdialog').dialog('close');
			});
		}else{
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize());
		}
	});

	$('#delete').click(function() {
		document.location="flowview.php?action=delete&query="+$('#query').val();
	});

	$('#defaults').click(function() {
		setDefaults();
	});

	function setDefaults() {
		// Flow Filter Settings
		$('#device').attr('value',0);
		$('#start_date').attr('value', '');
		$('#start_time').attr('value','-8 HOURS');
		$('#end_date').attr('value','');
		$('#end_time').attr('value','NOW');
		$('#source_address').attr('value','');
		$('#source_port').attr('value','');
		$('#source_if').attr('value','');
		$('#source_as').attr('value','');
		$('#dest_address').attr('value','');
		$('#dest_port').attr('value','');
		$('#dest_if').attr('value','');
		$('#dest_as').attr('value','');
		$('#protocols').attr('value',0);
		$('#tos_fields').attr('value','');
		$('#tcp_flags').attr('value','');
		// Report Settings
		$('#stat_report').attr('value',10);
		$('#print_report').attr('value',0);
		$('#flow_select').attr('value',1);
		$('#sort_field').attr('value',4);
		$('#cutoff_lines').attr('value','100');
		$('#cutoff_octets').attr('value', '');
		$('#resolve_addresses').attr('value',0);
		statSelect();
	}

	function setStatOption(choose) {
		stat = document.flowview.sort_field;
		stat.options.length = 0;
		defsort = 1;
		if (choose == 10) {
			stat.options[stat.options.length] = new Option('Source IP', '1');
			stat.options[stat.options.length] = new Option('Destination IP', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 5 || choose == 6 || choose == 7) {
			stat.options[stat.options.length] = new Option('Port', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 8 || choose == 9 || choose == 11) {
			stat.options[stat.options.length] = new Option('IP', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 12) {
			stat.options[stat.options.length] = new Option('Protocol', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 17 || choose == 18) {
			stat.options[stat.options.length] = new Option('Interface', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 23) {
			stat.options[stat.options.length] = new Option('Input Interface', '1');
			stat.options[stat.options.length] = new Option('Output Interface', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 19 || choose == 20) {
			stat.options[stat.options.length] = new Option('AS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 21) {
			stat.options[stat.options.length] = new Option('Source AS', '1');
			stat.options[stat.options.length] = new Option('Destination AS', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 22) {
			stat.options[stat.options.length] = new Option('TOS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 24 || choose == 25) {
			stat.options[stat.options.length] = new Option('Prefix', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 26) {
			stat.options[stat.options.length] = new Option('Source Prefix', '1');
			stat.options[stat.options.length] = new Option('Destination Prefix', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else {

		}

		if (statreport == choose) {
			stat.value = sortfield;
		} else {
			stat.value = defsort;
		}
	}

	var sortfield='<?php 
    echo $sort_field;
    ?>
';
	var statreport='<?php 
    echo $stat_report > 0 ? $stat_report : 0;
    ?>
';

	-->
	</script>

	<?php 
}
コード例 #14
0
ファイル: setup.php プロジェクト: Cacti/plugin_thold
function thold_graph_button($data)
{
    global $config;
    $local_graph_id = $data[1]['local_graph_id'];
    $rra_id = $data[1]['rra'];
    if (isset_request_var('view_type') && !isempty_request_var('view_type')) {
        $view_type = get_request_var('view_type');
    } else {
        set_request_var('view_type', '');
        $view_type = read_config_option('dataquery_type');
    }
    if (isset_request_var('graph_start') && !isempty_request_var('graph_start')) {
        $start = get_request_var('graph_start');
    } else {
        set_request_var('graph_start', '');
        $start = time() - 3600;
    }
    if (isset_request_var('graph_end') && !isempty_request_var('graph_end')) {
        $end = get_request_var('graph_end');
    } else {
        set_request_var('graph_end', '');
        $end = time();
    }
    if (!isset($_SESSION['sess_config_array']['thold_draw_vrules'])) {
        $_SESSION['sess_config_array']['thold_draw_vrules'] = 'off';
    }
    $url = $_SERVER['REQUEST_URI'];
    $url = str_replace('&thold_vrule=on', '', $url);
    $url = str_replace('&thold_vrule=off', '', $url);
    if (!substr_count($url, '?')) {
        $separator = '?';
    } else {
        $separator = '&';
    }
    if (api_user_realm_auth('thold_graph.php')) {
        print '<a class="hyperLink" href="' . $url . $separator . 'thold_vrule=' . ($_SESSION['sess_config_array']['thold_draw_vrules'] == 'on' ? 'off' : 'on') . '"><img src="' . $config['url_path'] . 'plugins/thold/images/reddot.png" border="0" alt="" title="' . __('Toggle Threshold VRULES %s', $_SESSION['sess_config_array']['thold_draw_vrules'] == 'on' ? __('Off') : __('On')) . '" style="padding: 3px;"></a><br>';
    }
    // Add Threshold Creation button
    if (api_user_realm_auth('thold.php')) {
        if (isset_request_var('tree_id')) {
            get_filter_request_var('tree_id');
        }
        if (isset_request_var('leaf_id')) {
            get_filter_request_var('leaf_id');
        }
        print '<a class="hyperLink" href="' . htmlspecialchars($config['url_path'] . 'plugins/thold/thold.php?action=add' . '&usetemplate=1&local_graph_id=' . $local_graph_id) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="' . __('Create Threshold') . '" style="padding: 3px;"></a><br>';
    }
}
コード例 #15
0
ファイル: flowview.php プロジェクト: Cacti/plugin_flowview
function flowview_display_form()
{
    global $config, $graph_timespans;
    include $config['base_path'] . '/plugins/flowview/variables.php';
    include $config['base_path'] . '/plugins/flowview/arrays.php';
    display_tabs();
    form_start('flowview.php', 'flowview');
    html_start_box('Flow Filter Constraints  <span id="text"></span>', '100%', '', '3', 'center', '');
    ?>
	<tr class='even center'>
		<td style='text-align:center'>
			<table class='filterTable' width='100%'>
				<tr>
					<td>
						Filter
					</td>
					<td>
						<?php 
    draw_edit_control('query', $query_name_field);
    ?>
					</td>
					<td>
						Listener
					</td>
					<td>
						<?php 
    draw_edit_control('device_name', $device_name_field);
    ?>
					</td>
				</tr>
				<tr>
					<td>
                        Presets
					</td>
					<td>
						<select id='predefined_timespan' name='predefined_timespan' onChange='applyTimespan()'>
							<?php 
    if ($timespan == 0) {
        $graph_timespans[GT_CUSTOM] = 'Custom';
        $start_val = 0;
        $end_val = sizeof($graph_timespans);
    } else {
        if (isset($graph_timespans[GT_CUSTOM])) {
            asort($graph_timespans);
            array_shift($graph_timespans);
        }
        $start_val = 1;
        $end_val = sizeof($graph_timespans) + 1;
    }
    if (sizeof($graph_timespans) > 0) {
        for ($value = $start_val; $value < $end_val; $value++) {
            print "<option value='{$value}'";
            if ($timespan == $value) {
                print ' selected';
            }
            print '>' . title_trim($graph_timespans[$value], 40) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>

					<td>
						Start Date
					</td>
					<td class='nowrap'>
						<input type='text' size='15' id='date1' value='<?php 
    echo $date1;
    ?>
'>
						<i id='startDate' class='calendar fa fa-calendar' title='Start Date Selector'></i>
					</td>
					<td>
						End Date
					</td>
					<td>
						<input type='text' size='15' id='date2' value='<?php 
    echo $date2;
    ?>
'>
						<i id='endDate' class='calendar fa fa-calendar' title='End Date Selector'></i>
					</td>
				</tr>
				<tr>
					<td colspan='9'><hr size='2'></td>
				</tr>
				<tr>
					<td>
						Protocols
					</td>
					<td>
						<?php 
    draw_edit_control('protocols', $ip_protocol_field);
    ?>
					</td>
					<td>
						TCP Flags
					</td>
					<td>
						<input type='text' size='10' name='tcp_flags' value='<?php 
    echo $tcp_flags;
    ?>
'>
					</td>
					<td>
						TOS Fields
					</td>
					<td>
						<input type='text' size='10' name='tos_fields' value='<?php 
    echo $tos_fields;
    ?>
'>
					</td>
					<td colspan=2>
						(e.g., -0x0b/0x0F)
					</td>
				</tr>
				<tr>
					<td>
						Source IP
					</td>
					<td>
						<input type='text' size='19' name='source_address' value='<?php 
    echo $source_address;
    ?>
'>
					</td>
					<td>
						Source Port(s)
					</td>
					<td>
						<input type='text' size='20' name='source_port' value='<?php 
    echo $source_port;
    ?>
'>
					</td>
					<td>
						Source Interface
					</td>
					<td>
						<input type='text' size='2' name='source_if' value='<?php 
    echo $source_if;
    ?>
'>
					</td>
					<td>
						Source AS
					</td>
					<td>
						<input type='text' size='6' name='source_as' value='<?php 
    echo $source_as;
    ?>
'>
					</td>
				</tr>
				<tr>
					<td>
						Dest IP
					</td>
					<td>
						<input type='text' size='19' name='dest_address' value='<?php 
    echo $dest_address;
    ?>
'></td>
					<td>
						Dest Port(s)
					</td>
					<td>
						<input type='text' size='20' name='dest_port' value='<?php 
    echo $dest_port;
    ?>
'>
					</td>
					<td>
						Dest Interface
					</td>
					<td>
						<input type='text' size='2' name='dest_if' value='<?php 
    echo $dest_if;
    ?>
'>
					</td>
					<td>
						Dest AS
					</td>
					<td>
						<input type='text' size='6' name='dest_as' value='<?php 
    echo $dest_as;
    ?>
'>
						<input type='hidden' name='header' value='false'>
					</td>
				</tr>
				<tr>
					<td colspan='9'>
						<hr size='2'>
						<center><strong>Note:</strong> Multiple field entries, separated by commas, are permitted in the fields above. A minus sign (-) will negate an entry (e.g. -80 for Port, would mean any Port but 80)</center>
						<hr size='2'>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php 
    html_end_box(false);
    ?>

	<?php 
    html_start_box('Report Parameters', '100%', '', '3', 'center', '');
    ?>
	<tr class='even'>
		<td>
			<table class='filterTable'>
				<tr id='rsettings'>
					<td>Statistics:</td>
					<td><?php 
    draw_edit_control('stat_report', $stat_report_field);
    ?>
</td>
					<td>Printed:</td>
					<td><?php 
    draw_edit_control('print_report', $print_report_field);
    ?>
</td>
					<td>Include if:</td>
					<td><?php 
    draw_edit_control('flow_select', $flow_select_field);
    ?>
</td>
					<td>Resolve Addresses:</td>
					<td><?php 
    draw_edit_control('resolve_addresses', $resolve_addresses_field);
    ?>
</td>
				</tr>
				<tr id='rlimits'>
					<td class='sortfield'>Sort Field:</td>
					<td class='sortfield'><select id='sort_field' name='sort_field'></select></td>
					<td>Max Flows:</td>
					<td><?php 
    draw_edit_control('cutoff_lines', $cutoff_lines_field);
    ?>
</td>
					<td>Minimum Bytes:</td>
					<td><?php 
    draw_edit_control('cutoff_octets', $cutoff_octets_field);
    ?>
</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colspan='9'><hr size='2'></td>
	</tr>
	<tr>
		<td colspan='9'>
			<input type='hidden' id='action' name='action' value='view'>
			<input type='hidden' id='new_query' name='new_query' value=''>
			<input type='hidden' id='changed' name='changed' value='0'>
			<center>
				<input id='view' type='button' name='view' value='View'>
				<input id='defaults' type='button' value='Defaults'>
				<input id='save' type='button' name='save' value='Save'>
				<input id='saveas' type='button' name='saveas' value='Save As'>
				<input id='delete' type='button' name='delete' value='Delete'>
			</center>
		</td>
	</tr>
	<?php 
    html_end_box();
    form_end();
    ?>
	<script type='text/javascript'>

	var date1Open = false;
	var date2Open = false;

	function applyTimespan() {
		$.getJSON('flowview.php?action=gettimespan&timespan='+$('#predefined_timespan').val(), function(data) {
			$('#date1').val(data['current_value_date1']);
			$('#date2').val(data['current_value_date2']);
		});
	}

	function applyFilter() {
		loadPageNoHeader('flowview.php?action=loadquery&tab=filters&header=false&query='+$('#query').val());
	}

	function statSelect() {
		statval = $('#stat_report').val();
		setStatOption(statval);

		if (statval > 0) {
			$('#print_report').attr('value', 0);
			$('#print_report').prop('disabled', true);
			$('#rlimits').children('.sortfield').show();
		}else{
			$('#print_report').prop('disabled', false);
		}

		if (statval == 99 || statval < 1) {
			$('#rlimits').hide();
		} else {
			$('#rlimits').show();
		}

		if (statval == 0 && $('#print_report').val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
			$('#saveas').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
			$('#saveas').prop('disabled', false);
		}
	}

	function printSelect() {
		statval = $('#print_report').val();

		if (statval > 0) {
			$('#stat_report').attr('value',0);
			$('#stat_report').prop('disabled', false);
			$('#sort_field').prop('disabled', false);
			$('#rlimits').hide();
			$('#rlimits').children('.sortfield').hide();
		} else {
			$('#rlimits').show();
			$('#cutoff_lines').prop('disabled', false);
			$('#cutoff_octets').prop('disabled', false);

			if ($('#stat_report').val() == 0) {
				$('#stat_report').attr('value', 10);
			}

			$('#stat_report').prop('disabled', false);
			statSelect();
			return;
		}
		if (statval == 4 || statval == 5) {
			$('#cutoff_lines').prop('disabled', false);
			$('#cutoff_octets').prop('disabled', false);
			$('#rlimits').show();
		} else {
			$('#cutoff_lines').prop('disabled', true);
			$('#cutoff_octets').prop('disabled', true);
			$('#rlimits').hide();
		}

		if (statval == 0 && $('#stat_report').val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
			$('#saveas').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
			$('#saveas').prop('disabled', false);
		}
	}

	$('#device_name').change(function () {
		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($(this).val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
		}
		<?php 
    } else {
        ?>
		if ($(this).val() == 0) {
			$('#view').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
		}
		<?php 
    }
    ?>
	});

	$('#date1, #date2').change(function() {
		if ($('#predefined_timespan option').length == 28) {
			$('#predefined_timespan').prepend("<option value='0' selected='selected'>Custom</option>");
			$('#predefined_timespan').val('0');
			<?php 
    if (get_selected_theme() != 'classic') {
        ?>
			$('#predefined_timespan').selectmenu('refresh');
			<?php 
    }
    ?>
		}
	});

	$(function() {
		$('#startDate').click(function() {
			if (date1Open) {
				date1Open = false;
				$('#date1').datetimepicker('hide');
			}else{
				date1Open = true;
				$('#date1').datetimepicker('show');
			}
		});

		$('#endDate').click(function() {
			if (date2Open) {
				date2Open = false;
				$('#date2').datetimepicker('hide');
			}else{
				date2Open = true;
				$('#date2').datetimepicker('show');
			}
		});

		$('#date1').datetimepicker({
			minuteGrid: 10,
			stepMinute: 1,
			showAnim: 'slideDown',
			numberOfMonths: 1,
			timeFormat: 'HH:mm',
			dateFormat: 'yy-mm-dd',
			showButtonPanel: false
		});

		$('#date2').datetimepicker({
			minuteGrid: 10,
			stepMinute: 1,
			showAnim: 'slideDown',
			numberOfMonths: 1,
			timeFormat: 'HH:mm',
			dateFormat: 'yy-mm-dd',
			showButtonPanel: false
		});

		$('#saveas').hide();

		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#query').val() == 0) {
			$('#delete').hide();
		}else{
			$('#save').attr('value', 'Update');
			$('#saveas').show();
		}
		<?php 
    } else {
        ?>
		$('#delete').hide();
		$('#save').hide();
		<?php 
    }
    ?>

		$('#flowview').change(function() {
			$('#changed').attr('value', '1');
		});

		<?php 
    if (api_user_realm_auth('flowview_devices.php')) {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').prop('disabled', true);
			$('#save').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
			$('#save').prop('disabled', false);
		}
		<?php 
    } else {
        ?>
		if ($('#device_name').val() == 0) {
			$('#view').prop('disabled', true);
		}else{
			$('#view').prop('disabled', false);
		}
		<?php 
    }
    ?>

		$('#stat_report').change(function() {
			statSelect();
		});

		$('#print_report').change(function() {
			printSelect();
		});

		statSelect();
		printSelect();

		$('#fdialog').dialog({
			autoOpen: false,
			width: 380,
			height: 120,
			resizable: false,
			modal: true
		});
	});

	$('#view').click(function() {
		$('#action').attr('value', 'view');
		$.post('flowview.php', $('input, select, textarea').serialize(), function(data) {
			$('#main').html(data);
			applySkin();
		});
	});

	$('#saveas').click(function() {
		console.log('This is saveas');
		$('#squery').attr('value', $('#query>option:selected').text()+' (New)');
		$('#fdialog').dialog('open');
		$('#qcancel').click(function() {
			$('#fdialog').dialog('close');
		});
		$('#qsave').click(function() {
			$('#new_query').attr('value', $('#squery').val());
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize(), function(data) {
				if (data!='error') {
					$('#text').show().text('Filter Saved').fadeOut(2000);
					$('#query').append("<option value='"+data+"'>"+$('#new_query').val()+"</option>");
					$('#query').attr('value', data);
				}
			});
			$('#fdialog').dialog('close');
		});
	});

	$('#save').click(function() {
		if ($('#query').val() == 0) {
			$('#fdialog').dialog('open');
			$('#qcancel').click(function() {
				$('#fdialog').dialog('close');
			});
			$('#qsave').click(function() {
				$('#new_query').attr('value', $('#squery').val());
				$('#action').attr('value', 'save');
				$.post('flowview.php', $('#flowview').serialize(), function(data) {
					if (data!='error') {
						loadPageNoHeader('flowview.php?tab=filters&header=false&action=loadquery&query='+data);
						$('#text').show().text('Filter Settings Saved').fadeOut(2000);
					}
				});
				$('#fdialog').dialog('close');
			});
		}else{
			$('#action').attr('value', 'save');
			$.post('flowview.php', $('#flowview').serialize(), function(data) {
				$('#text').show().text('Filter Updated').fadeOut(2000);
			});
		}
	});

	$('#delete').click(function() {
		loadPageNoHeader('flowview.php?header=false&action=delete&query='+$('#query').val());
	});

	$('#defaults').click(function() {
		setDefaults();
	});

	function setDefaults() {
		// Flow Filter Settings
		$('#device').attr('value',0);
		$('#date1').attr('value', '');
		$('#start_time').attr('value','-8 HOURS');
		$('#date2').attr('value','');
		$('#end_time').attr('value','NOW');
		$('#source_address').attr('value','');
		$('#source_port').attr('value','');
		$('#source_if').attr('value','');
		$('#source_as').attr('value','');
		$('#dest_address').attr('value','');
		$('#dest_port').attr('value','');
		$('#dest_if').attr('value','');
		$('#dest_as').attr('value','');
		$('#protocols').attr('value',0);
		$('#tos_fields').attr('value','');
		$('#tcp_flags').attr('value','');
		// Report Settings
		$('#stat_report').attr('value',10);
		$('#print_report').attr('value',0);
		$('#flow_select').attr('value',1);
		$('#sort_field').attr('value',4);
		$('#cutoff_lines').attr('value','100');
		$('#cutoff_octets').attr('value', '');
		$('#resolve_addresses').attr('value',0);
		statSelect();
	}

	function setStatOption(choose) {
		stat = document.flowview.sort_field;
		stat.options.length = 0;
		defsort = 1;
		if (choose == 10) {
			stat.options[stat.options.length] = new Option('Source IP', '1');
			stat.options[stat.options.length] = new Option('Destination IP', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 5 || choose == 6 || choose == 7) {
			stat.options[stat.options.length] = new Option('Port', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 8 || choose == 9 || choose == 11) {
			stat.options[stat.options.length] = new Option('IP', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 12) {
			stat.options[stat.options.length] = new Option('Protocol', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 17 || choose == 18) {
			stat.options[stat.options.length] = new Option('Interface', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 23) {
			stat.options[stat.options.length] = new Option('Input Interface', '1');
			stat.options[stat.options.length] = new Option('Output Interface', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 19 || choose == 20) {
			stat.options[stat.options.length] = new Option('AS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 21) {
			stat.options[stat.options.length] = new Option('Source AS', '1');
			stat.options[stat.options.length] = new Option('Destination AS', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else if (choose == 22) {
			stat.options[stat.options.length] = new Option('TOS', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 24 || choose == 25) {
			stat.options[stat.options.length] = new Option('Prefix', '1');
			stat.options[stat.options.length] = new Option('Flows', '2');
			stat.options[stat.options.length] = new Option('Bytes', '3');
			stat.options[stat.options.length] = new Option('Packets', '4');
			defsort = 3;
		} else if (choose == 26) {
			stat.options[stat.options.length] = new Option('Source Prefix', '1');
			stat.options[stat.options.length] = new Option('Destination Prefix', '2');
			stat.options[stat.options.length] = new Option('Flows', '3');
			stat.options[stat.options.length] = new Option('Bytes', '4');
			stat.options[stat.options.length] = new Option('Packets', '5');
			defsort = 4;
		} else {

		}

		if (statreport == choose) {
			stat.value = sortfield;
		} else {
			stat.value = defsort;
		}
	}

	var sortfield='<?php 
    echo $sort_field;
    ?>
';
	var statreport='<?php 
    echo $stat_report > 0 ? $stat_report : 0;
    ?>
';

	</script>

	<?php 
}
コード例 #16
0
ファイル: thold_graph.php プロジェクト: teddywen/cacti
function hosts()
{
    global $config, $colors, $device_actions, $item_rows, $host_colors, $notmon_color;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("host_template_id"));
    input_validate_input_number(get_request_var_request("page"));
    input_validate_input_number(get_request_var_request("host_status"));
    input_validate_input_number(get_request_var_request("rows"));
    /* ==================================================== */
    /* clean up search string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up sort_column */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up search string */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear"])) {
        kill_session_var("sess_thold_host_current_page");
        kill_session_var("sess_thold_host_filter");
        kill_session_var("sess_thold_host_host_template_id");
        kill_session_var("sess_thold_host_status");
        kill_session_var("sess_thold_host_rows");
        kill_session_var("sess_thold_host_sort_column");
        kill_session_var("sess_thold_host_sort_direction");
        unset($_REQUEST["page"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["host_template_id"]);
        unset($_REQUEST["host_status"]);
        unset($_REQUEST["rows"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
    } else {
        /* if any of the settings changed, reset the page number */
        $changed = 0;
        $changed += thold_request_check_changed('filter', 'sess_thold_host_filter');
        $changed += thold_request_check_changed('host_template_id', 'sess_thold_host_template_id');
        $changed += thold_request_check_changed('host_status', 'sess_thold_host_status');
        $changed += thold_request_check_changed('rows', 'sess_thold_host_rows');
        $changed += thold_request_check_changed('sort_column', 'sess_thold_log_sort_column');
        $changed += thold_request_check_changed('sort_direction', 'sess_thold_log_sort_direction');
        if ($changed) {
            $_REQUEST['page'] = '1';
        }
    }
    if (!empty($_SESSION["sess_thold_host_status"]) && !empty($_REQUEST["host_status"])) {
        if ($_SESSION["sess_thold_host_status"] != $_REQUEST["host_status"]) {
            $_REQUEST["page"] = 1;
        }
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_thold_host_current_page", "1");
    load_current_session_value("filter", "sess_thold_host_filter", "");
    load_current_session_value("host_template_id", "sess_thold_host_host_template_id", "-1");
    load_current_session_value("host_status", "sess_thold_host_status", "-4");
    load_current_session_value("rows", "sess_thold_host_rows", read_config_option("num_rows_device"));
    load_current_session_value("sort_column", "sess_thold_host_sort_column", "description");
    load_current_session_value("sort_direction", "sess_thold_host_sort_direction", "ASC");
    /* if the number of rows is -1, set it to the default */
    if ($_REQUEST["rows"] == -1) {
        $_REQUEST["rows"] = read_config_option("num_rows_device");
    }
    ?>
	<script type="text/javascript">
	<!--

	function applyViewDeviceFilterChange(objForm) {
		strURL = '?tab=hoststat&host_status=' + objForm.host_status.value;
		strURL = strURL + '&host_template_id=' + objForm.host_template_id.value;
		strURL = strURL + '&rows=' + objForm.rows.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		document.location = strURL;
	}

	-->
	</script>
	<?php 
    html_start_box("<strong>Device Status</strong>", "100%", $colors["header"], "3", "center", "");
    form_host_filter();
    html_end_box();
    /* form the 'where' clause for our main sql query */
    $sql_where = "where (host.hostname LIKE '%%" . $_REQUEST["filter"] . "%%' OR host.description LIKE '%%" . $_REQUEST["filter"] . "%%')";
    if ($_REQUEST["host_status"] == "-1") {
        /* Show all items */
    } elseif ($_REQUEST["host_status"] == "-2") {
        $sql_where .= strlen($sql_where) ? " and host.disabled='on'" : "where host.disabled='on'";
    } elseif ($_REQUEST["host_status"] == "-3") {
        $sql_where .= strlen($sql_where) ? " and host.disabled=''" : "where host.disabled=''";
    } elseif ($_REQUEST["host_status"] == "-4") {
        $sql_where .= strlen($sql_where) ? " and (host.status!='3' or host.disabled='on')" : "where (host.status!='3' or host.disabled='on')";
    } elseif ($_REQUEST["host_status"] == "-5") {
        $sql_where .= strlen($sql_where) ? " and (host.availability_method=0)" : "where (host.availability_method=0)";
    } elseif ($_REQUEST["host_status"] == "3") {
        $sql_where .= strlen($sql_where) ? " and (host.availability_method!=0 and host.status=3 and host.disabled='')" : "where (host.availability_method=0 and host.status=3 and host.disabled='')";
    } else {
        $sql_where .= strlen($sql_where) ? " and (host.status=" . $_REQUEST["host_status"] . " AND host.disabled = '')" : "where (host.status=" . $_REQUEST["host_status"] . " AND host.disabled = '')";
    }
    if ($_REQUEST["host_template_id"] == "-1") {
        /* Show all items */
    } elseif ($_REQUEST["host_template_id"] == "0") {
        $sql_where .= strlen($sql_where) ? " and host.host_template_id=0" : "where host.host_template_id=0";
    } elseif (!empty($_REQUEST["host_template_id"])) {
        $sql_where .= strlen($sql_where) ? " and host.host_template_id=" . $_REQUEST["host_template_id"] : "where host.host_template_id=" . $_REQUEST["host_template_id"];
    }
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $sortby = $_REQUEST["sort_column"];
    if ($sortby == "hostname") {
        $sortby = "INET_ATON(hostname)";
    }
    $host_graphs = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id"), "host_id", "graphs");
    $host_data_sources = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id"), "host_id", "data_sources");
    $current_user = db_fetch_row('SELECT * FROM user_auth WHERE id=' . $_SESSION['sess_user_id']);
    $sql_where .= ' AND ' . get_graph_permissions_sql($current_user['policy_graphs'], $current_user['policy_hosts'], $current_user['policy_graph_templates']);
    $total_rows = db_fetch_cell("SELECT\r\n\t\tCOUNT(host.id)\r\n\t\tFROM host\r\n\t\tLEFT JOIN user_auth_perms\r\n\t\tON (host.id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=3\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\t{$sql_where}");
    $sql_query = "SELECT *\r\n\t\tFROM host\r\n\t\tLEFT JOIN user_auth_perms\r\n\t\tON (host.id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=3\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\t{$sql_where}\r\n\t\tORDER BY " . $sortby . " " . $_REQUEST["sort_direction"] . "\r\n\t\tLIMIT " . $_REQUEST["rows"] * ($_REQUEST["page"] - 1) . "," . $_REQUEST["rows"];
    //print $sql_query;
    $hosts = db_fetch_assoc($sql_query);
    /* generate page list */
    $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $_REQUEST["rows"], $total_rows, "thold_graph.php?tab=hoststat");
    if ($total_rows) {
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='11'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong>&lt;&lt; ";
        if ($_REQUEST["page"] > 1) {
            $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_graph.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"] . "&page=" . ($_REQUEST["page"] - 1)) . "'>";
        }
        $nav .= "Previous";
        if ($_REQUEST["page"] > 1) {
            $nav .= "</a>";
        }
        $nav .= "</strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tShowing Rows " . ($_REQUEST["rows"] * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < $_REQUEST["rows"] * $_REQUEST["page"] ? $total_rows : $_REQUEST["rows"] * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong>";
        if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) {
            $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_graph.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&host_status=" . $_REQUEST["host_status"] . "&page=" . ($_REQUEST["page"] + 1)) . "'>";
        }
        $nav .= "Next";
        if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) {
            $nav .= "</a>";
        }
        $nav .= " &gt;&gt;</strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n";
    } else {
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='11'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tNo Rows Found\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n";
    }
    print $nav;
    $display_text = array("nosort" => array("<br>Actions", ""), "description" => array("<br>Description", "ASC"), "id" => array("<br>ID", "ASC"), "nosort1" => array("<br>Graphs", "ASC"), "nosort2" => array("Data<br>Sources", "ASC"), "status" => array("<br>Status", "ASC"), "status_event_count" => array("Event<br>Count", "ASC"), "hostname" => array("<br>Hostname", "ASC"), "cur_time" => array("<br>Current (ms)", "DESC"), "avg_time" => array("<br>Average (ms)", "DESC"), "availability" => array("<br>Availability", "ASC"));
    html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
    $i = 0;
    if (sizeof($hosts)) {
        foreach ($hosts as $host) {
            if (isset($host_graphs[$host["id"]])) {
                $graphs = $host_graphs[$host["id"]];
            } else {
                $graphs = 0;
            }
            if (isset($host_data_sources[$host["id"]])) {
                $ds = $host_data_sources[$host["id"]];
            } else {
                $ds = 0;
            }
            if ($host["availability_method"] != 0) {
                form_host_status_row_color($host["status"], $host["disabled"]);
                $i++;
                print "<td width='1%' style='white-space:nowrap'>";
                if (api_user_realm_auth('host.php')) {
                    print '<a href="' . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $host["id"]) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="Edit Host"></a>';
                }
                print "<a href='" . htmlspecialchars($config['url_path'] . "graph_view.php?action=preview&graph_template_id=0&filter=&host_id=" . $host["id"]) . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='View Graphs'></a>";
                print "</td>";
                ?>
				<td>
					<?php 
                print strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["description"]) : $host["description"];
                ?>
				</td>
				<td width='80'><?php 
                print round($host["id"], 2);
                ?>
</td>
				<td width='80'><i><?php 
                print $graphs;
                ?>
</i></td>
				<td width='80'><i><?php 
                print $ds;
                ?>
</i></td>
				<td width='140'><?php 
                print get_uncolored_device_status($host["disabled"] == "on" ? true : false, $host["status"]);
                ?>
</td>
				<td width='100'><?php 
                print round($host["status_event_count"], 2);
                ?>
</td>
				<td><?php 
                print strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["hostname"]) : $host["hostname"];
                ?>
</td>
				<td width='100'><?php 
                print round($host["cur_time"], 2);
                ?>
</td>
				<td width='100'><?php 
                print round($host["avg_time"], 2);
                ?>
</td>
				<td width='100'><?php 
                print round($host["availability"], 2);
                ?>
</td>
				<?php 
            } else {
                form_alternate_row_color($notmon_color, $notmon_color, $i);
                $i++;
                print "<td width='1%' style='white-space:nowrap'>";
                if (api_user_realm_auth('host.php')) {
                    print '<a href="' . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $host["id"]) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="Edit Host"></a>';
                }
                print "<a href='" . htmlspecialchars($config['url_path'] . "graph_view.php?action=preview&graph_template_id=0&filter=&host_id=" . $host["id"]) . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='View Graphs'></a>";
                print "</td>";
                ?>
				<td>
					<?php 
                print strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["description"]) : $host["description"];
                ?>
				</td>
				<td width='80'><?php 
                print $host["id"];
                ?>
</td>
				<td width='80'><i><?php 
                print $graphs;
                ?>
</i></td>
				<td width='80'><i><?php 
                print $ds;
                ?>
</i></td>
				<td width='140'><?php 
                print "Not Monitored";
                ?>
</td>
				<td width='100'><?php 
                print "N/A";
                ?>
</td>
				<td><?php 
                print strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["hostname"]) : $host["hostname"];
                ?>
</td>
				<td width='100'><?php 
                print "N/A";
                ?>
</td>
				<td width='100'><?php 
                print "N/A";
                ?>
</td>
				<td width='100'><?php 
                print "N/A";
                ?>
</td>
				<?php 
            }
            form_end_row();
        }
    } else {
        print "<tr><td><em>No Hosts</em></td></tr>";
    }
    /* put the nav bar on the bottom as well */
    print $nav;
    html_end_box(false);
    host_legend();
    //thold_display_rusage();
}
コード例 #17
0
ファイル: setup.php プロジェクト: avillaverdec/cacti
function nmidSmokeping_tree_after ( $param )
{
	global $config, $database_default;
	preg_match( "/^(.+),(\d+)$/", $param, $hit );
	include_once( $config[ "library_path" ] . "/adodb/adodb.inc.php" );
	include_once( $config[ "library_path" ] . "/database.php" );
	if ( api_user_realm_auth( 'getSmokePingImage.php' ) ) {
        if ( nmidSmokeping_readPluginStatus( 'nmidWeb2' ) ) {
            print "<div class='sidebarBox portlet' id='item-sp01'>\n";
            print "<div class='portlet-header'>Graph Template:</strong> Availability Chart</div>\n";
            print "<div class='guideListing portlet-content'><center>\n";
        }
        else {
            ?>
            <tr bgcolor='#6d88ad'>
            <tr bgcolor='#a9b7cb'>
                <td colspan='3' class='textHeaderDark'>
                    <strong>Graph Template:</strong> SmokePing (external)
                </td>
            </tr>
            <tr align='center' style='background-color: #f9f9f9;'>
            <td align='center'>
            <?php
        }

        $tree_id = $_REQUEST[ 'tree_id' ];
        $host_leaf_id = $_REQUEST[ 'leaf_id' ];

        $host_list = db_fetch_assoc('select * from graph_tree_items where order_key like ( select Concat(replace(order_key,"000",""),"%") from graph_tree_items where id='.$host_leaf_id.' ) and host_id > 0');
        $column_count = 0;
        foreach ($host_list as $host_item ) {
            $host_id = $host_item['host_id'];
            $host_ip = db_fetch_cell( "select hostname from host where id=" . $host_id );
            $current_nwmgmt_settings = db_fetch_cell( "select nwmgmt_settings from host where id=" . $host_id );
            $nwmgmt_smokeping_path = db_fetch_cell( "select nwmgmt_smokeping_path from host where id=" . $host_id );
            $nwmgmt_smokeping_server = db_fetch_cell( "select nwmgmt_smokeping_server from host where id=" . $host_id );
            $nmid_server = '';
            if ( $nwmgmt_smokeping_server == read_config_option( "nmid_spserver1" ) ) {
                $nmid_server = "nmid_spserver1";
            }
            elseif ( $nwmgmt_smokeping_server == read_config_option( "nmid_spserver2" ) ) {
                $nmid_server = "nmid_spserver2";
            }
            elseif ( $nwmgmt_smokeping_server == read_config_option( "nmid_spserver3" ) ) {
                $nmid_server = "nmid_spserver3";
            }
            elseif ( $nwmgmt_smokeping_server == read_config_option( "nmid_spserver4" ) ) {
                $nmid_server = "nmid_spserver4";
            }
            /* Retrieve Smokeping Config Settings */
            $nmid_sp_url = $nwmgmt_smokeping_server . read_config_option( "nmid_spurl" );
            $nmid_sp_userid = read_config_option( "nmid_spuser" );
            $nmid_sp_password = read_config_option( "nmid_sppwd" );

            if ($_SESSION["sess_graph_view_thumbnails"] == "on") {

                /* Display Smokeping Graph if configured for this device */
                if ( preg_match( "/^s1/", $current_nwmgmt_settings ) > 0 ) {
                    if ( $column_count < 1 ) {
                        ?>
                        <tr align='center' style='background-color: #f9f9f9;'>
                        <?php
                    }
                    $column_count++;

                    ?>
                    <td align='center'>
                    <table width='1' cellpadding='0'>
                        <tr>
                            <td align='center' width='<?php print ceil(100 / read_graph_config_option("num_columns"));?>%'>
                            <table align='center' cellpadding='0'>
                                <tr>
                                    <td align='center'>
                                        <div style="min-height: <?php echo (1.6 * read_graph_config_option("default_height")) . "px"?>;">
                                        <?php
                                            print "<a target='_blank' href='" . $nmid_sp_url . "?target=" . $nwmgmt_smokeping_path . "'><img src='" . $config[ 'url_path' ] . "plugins/nmidSmokeping/getSmokePingImage.php?start=" . get_current_graph_start() . "&end=" . get_current_graph_end() . "&target=" . $nwmgmt_smokeping_path . "&server=" . $nmid_server . "&graphtype=detail&height=".read_graph_config_option("default_height")."&width=".read_graph_config_option("default_width") ."&hide=1' border='0'></a>\n";
                                        ?>
                                        </div>
                                    </td>
                                    <td valign='top' style='align: left; padding: 3px;'>
                                        <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=zoom&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
                                        <a href='<?php print htmlspecialchars($config['url_path'] . "graph_xport.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
                                        <a href='<?php print htmlspecialchars($config['url_path'] . "graph.php?action=properties&local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&" . $extra_url_args);?>'><img src='<?php print $config['url_path'];?>images/graph_properties.gif' border='0' alt='Graph Source/Properties' title='Graph Source/Properties' style='padding: 3px;'></a><br>
                                        <?php api_plugin_hook('graph_buttons_thumbnails', array('hook' => 'graphs_thumbnails', 'local_graph_id' => $graph['local_graph_id'], 'rra' =>  0, 'view_type' => '')); ?>
                                        <a href='#page_top'><img src='<?php print $config['url_path'] . "images/graph_page_top.gif";?>' border='0' alt='Page Top' title='Page Top' style='padding: 3px;'></a><br>
                                    </td>
                                </tr>
                            </table>
                            </td>
                        </tr>
                    </table>
                    </td>
                    <?php
                    if ( $column_count > (read_graph_config_option('num_columns')-1) ) {
                        $column_count = 0;
                        ?>
                        </tr>
                        <?php
                    }
                }
            }
            else {
                /* Display Smokeping Graph if configured for this device */
                if ( preg_match( "/^s1/", $current_nwmgmt_settings ) > 0 )
                {


                    print "	<table width='1' cellpadding='0'>\n";
                    print "		<tr>\n";
                    print "			<td valign='top' style='padding: 3px;' class='noprint'>\n";
                    if ( read_config_option( "nmid_spgraphtype" ) == "detail" ) {
                        print "				<a target='_blank' href='" . $nmid_sp_url . "?target=" . $nwmgmt_smokeping_path . "'><img src='" . $config[ 'url_path' ] . "plugins/nmidSmokeping/getSmokePingImage.php?start=" . get_current_graph_start() . "&end=" . get_current_graph_end() . "&target=" . $nwmgmt_smokeping_path . "&server=" . $nmid_server . "&graphtype=detail' border='0'></a>\n";
                    }
                    else {
                        print "				<a target='_blank' href='" . $nmid_sp_url . "?target=" . $nwmgmt_smokeping_path . "'><img src='" . $config[ 'url_path' ] . "plugins/nmidSmokeping/getSmokePingImage.php?start=" . get_current_graph_start() . "&end=" . get_current_graph_end() . "&target=" . $nwmgmt_smokeping_path . "&server=" . $nmid_server . "&graphtype=overview' border='0'></a>\n";
                    }

                    print "			</td>\n";
                    print "			<td valign='top' style='padding: 3px;' class='noprint'>";
                    if ( read_config_option( "nmid_spshowlink" ) ) {
                        print "             <a target='_blank' href='" . $nmid_sp_url . "?target=" . $nwmgmt_smokeping_path . "'><img src='" . $config[ 'url_path' ] . "images/graph_zoom.gif' border='0' alt='Go to Smokeping' title='Go to Smokeping' style='padding: 3px;'></a>";
                    }
                    else {
                        print "             <img src='" . $config[ 'url_path' ] . "images/graph_zoom.gif' border='0' alt='placeholder' title='placeholder' style='padding: 3px;'>";
                    }

                    if ( nmidSmokeping_readPluginStatus( 'nmidCreatePDF' ) ) {
                        print " 	     <input onClick=\"setData('sp_" . $host_id . "');\" type=checkbox id='sp_" . $host_id . "' name='sp_" . $host_id . "' value='" . $host_id . "'><br>";
                    }

                    print "         </td>";
                    print "		</tr>\n";
                    print "</table>\n";


                }
            }
        }
        if ( $column_count > 0 && $column_count < read_graph_config_option('num_columns') ) {
            print "</tr>";
        }
        if ($_SESSION["sess_graph_view_thumbnails"] <> "on") {
            if ( nmidSmokeping_readPluginStatus( 'nmidWeb2' ) ) {
                print "</center></div></div>";
            }
            else {
                print "</td></tr></tr>";
            }
        }
    }
	return $param;
}
コード例 #18
0
ファイル: functions.php プロジェクト: avillaverdec/cacti
function display_tabs()
{
    /* purge old flows if they exist */
    purgeFlows();
    /* draw the categories tabs on the top of the page */
    if (isset($_REQUEST['tab'])) {
        $_SESSION['flowview_current_tab'] = $_REQUEST['tab'];
    } elseif (isset($_SESSION['flowview_current_tab'])) {
        /* do nothing */
    } else {
        $_SESSION['flowview_current_tab'] = 'filters';
    }
    $ct = $_SESSION['flowview_current_tab'];
    print "<table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'><tr>\n";
    print "<td bgcolor='" . ($ct == 'filters' ? "silver" : "#DFDFDF") . "' nowrap='nowrap' width='" . strlen('Filters') * 9 . "' align='center' class='tab'>\n\t\t\t<span class='textHeader'><a title='Setup Flows' href='flowview.php?tab=filters'>Filters</a></span>\n\t\t\t</td>\n\n\t\t\t<td width='1'></td>\n";
    if (api_user_realm_auth('flowview_devices.php')) {
        print "<td bgcolor='" . ($ct == 'listeners' ? "silver" : "#DFDFDF") . "' nowrap='nowrap' width='" . strlen('Listeners') * 9 . "' align='center' class='tab'>\n\t\t\t\t<span class='textHeader'><a title='Manage Listeners' href='flowview_devices.php?tab=listeners'>Listeners</a></span>\n\t\t\t\t</td>\n\n\t\t\t\t<td width='1'></td>\n";
    }
    if (api_user_realm_auth('flowview_schedules.php')) {
        print "<td bgcolor='" . ($ct == 'sched' ? "silver" : "#DFDFDF") . "' nowrap='nowrap' width='" . strlen('Schedules') * 9 . "' align='center' class='tab'>\n\t\t\t\t<span class='textHeader'><a title='Manage e-Mail Reports' href='flowview_schedules.php?tab=sched'>Schedules</a></span>\n\t\t\t\t</td>\n\n\t\t\t\t<td width='1'></td>\n";
    }
    if (isset($_SESSION['flowview_flows']) && is_array($_SESSION['flowview_flows']) && sizeof($_SESSION['flowview_flows'])) {
        foreach ($_SESSION['flowview_flows'] as $sessionid => $data) {
            if (!isset($data['title'])) {
                $_SESSION['flowview_flows'][$sessionid]['title'] = $data['title'] = "Unknown";
            }
            print "<td bgcolor='" . ($ct == $sessionid ? "silver" : "#DFDFDF") . "' nowrap='nowrap' width='" . strlen($data['title']) * 9 . "' align='center' class='tab'>\n\t\t\t\t<span class='textHeader'><a style='white-space:nowrap;' href='flowview.php?tab={$sessionid}' title='View Flow'>" . $data['title'] . "</a>&nbsp<a href='flowview.php?action=killsession&session={$sessionid}' title='Remove Flow Cache'>x</a></span>\n\t\t\t\t</td>\n\n\t\t\t\t<td width='1'></td>\n";
        }
    }
    print "<td></td>\n</tr></table>\n";
}
コード例 #19
0
ファイル: setup.php プロジェクト: avillaverdec/cacti
function realtime_graph_buttons($args) {
	global $config;

	$local_graph_id = $args[1]['local_graph_id'];

	if (api_user_realm_auth("graph_popup_rt.php")) {
		echo "<a href='#' onclick=\"window.open('".$config['url_path']."plugins/realtime/graph_popup_rt.php?local_graph_id=".$local_graph_id."', 'popup_".$local_graph_id."', 'toolbar=no,menubar=no,location=no,scrollbars=no,status=no,titlebar=no,width=650,height=300,resizable=yes')\"><img src='".$config['url_path']."plugins/realtime/monitor_rt.gif' border='0' alt='Realtime' title='Realtime' style='padding: 3px;'></a><br/>";
	}

	realtime_setup_table();
}
コード例 #20
0
ファイル: setup.php プロジェクト: Cacti/plugin_syslog
function syslog_show_tab()
{
    global $config;
    if (api_user_realm_auth('syslog.php')) {
        if (substr_count($_SERVER['REQUEST_URI'], 'syslog.php')) {
            print '<a href="' . $config['url_path'] . 'plugins/syslog/syslog.php"><img src="' . $config['url_path'] . 'plugins/syslog/images/tab_syslog_down.gif" alt="syslog" align="absmiddle" border="0"></a>';
        } else {
            print '<a href="' . $config['url_path'] . 'plugins/syslog/syslog.php"><img src="' . $config['url_path'] . 'plugins/syslog/images/tab_syslog.gif" alt="syslog" align="absmiddle" border="0"></a>';
        }
    }
}
コード例 #21
0
function mactrack_format_device_row($device, $actions = false)
{
    global $config, $mactrack_device_types;
    /* viewer level */
    if ($actions) {
        $row = "<a href='" . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_interfaces.php?device_id=' . $device['device_id'] . '&issues=0&page=1') . "'><img src='" . $config['url_path'] . "plugins/mactrack/images/view_interfaces.gif' alt='' title='" . __('View Interfaces') . "' align='middle' border='0'></a>";
        /* admin level */
        if (api_user_realm_auth('mactrack_sites.php')) {
            if ($device['disabled'] == '') {
                $row .= "<img id='r_" . $device['device_id'] . "' src='" . $config['url_path'] . "plugins/mactrack/images/rescan_device.gif' alt='' onClick='scan_device(" . $device['device_id'] . ")' title='" . __('Rescan Device') . "' align='middle' border='0'>";
            } else {
                $row .= "<img src='" . $config['url_path'] . "plugins/mactrack/images/view_none.gif' alt='' align='middle' border='0'>";
            }
        }
        print "<td style='width:40px;'>" . $row . "</td>";
    }
    form_selectable_cell(filter_value($device['device_name'], get_request_var('filter'), "mactrack_devices.php?action=edit&device_id=" . $device['device_id']), $device['device_id']);
    form_selectable_cell($device['site_name'], $device['device_id']);
    form_selectable_cell(get_colored_device_status($device['disabled'] == 'on' ? true : false, $device['snmp_status']), $device['device_id']);
    form_selectable_cell(filter_value($device['hostname'], get_request_var('filter')), $device['device_id']);
    form_selectable_cell($device['device_type'] == '' ? __('Not Detected') : $device['device_type'], $device['device_id']);
    form_selectable_cell($device['scan_type'] == '1' ? __('N/A') : $device['ips_total'], $device['device_id']);
    form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_total'], $device['device_id']);
    form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_active'], $device['device_id']);
    form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_trunk'], $device['device_id']);
    form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['macs_active'], $device['device_id']);
    form_selectable_cell(number_format($device['last_runduration'], 1), $device['device_id']);
    form_checkbox_cell($device['device_name'], $device['device_id']);
    form_end_row();
}
コード例 #22
0
ファイル: setup.php プロジェクト: caiorasec/thold
function thold_graph_button($data)
{
    global $config;
    $local_graph_id = $data[1]['local_graph_id'];
    $rra_id = $data[1]['rra'];
    if (isset($_REQUEST['view_type']) && !empty($_REQUEST['view_type'])) {
        $view_type = $_REQUEST['view_type'];
    } else {
        $_REQUEST['view_type'] = '';
        $view_type = read_config_option('dataquery_type');
    }
    if (isset($_REQUEST['graph_start']) && !empty($_REQUEST['graph_start'])) {
        $start = $_REQUEST['graph_start'];
    } else {
        $_REQUEST['graph_start'] = '';
        $start = time() - 3600;
    }
    if (isset($_REQUEST['graph_end']) && !empty($_REQUEST['graph_end'])) {
        $end = $_REQUEST['graph_end'];
    } else {
        $_REQUEST['graph_end'] = '';
        $end = time();
    }
    if (!isset($_SESSION['sess_config_array']['thold_draw_vrules'])) {
        $_SESSION['sess_config_array']['thold_draw_vrules'] = 'off';
    }
    $url = $_SERVER['REQUEST_URI'];
    $url = str_replace('&thold_vrule=on', '', $url);
    $url = str_replace('&thold_vrule=off', '', $url);
    if (!substr_count($url, "?")) {
        $separator = "?";
    } else {
        $separator = "&";
    }
    if (api_user_realm_auth('thold_graph.php')) {
        print '<a href="' . $url . $separator . 'thold_vrule=' . ($_SESSION['sess_config_array']['thold_draw_vrules'] == 'on' ? 'off' : 'on') . '"><img src="' . $config['url_path'] . 'plugins/thold/images/reddot.png" border="0" alt="Thresholds" title="Toggle Threshold VRULES ' . ($_SESSION['sess_config_array']['thold_draw_vrules'] == 'on' ? 'Off' : 'On') . '" style="padding: 3px;"></a><br>';
    }
    // Add Threshold Creation button
    if (api_user_realm_auth('thold_add.php')) {
        if (isset($_REQUEST["tree_id"])) {
            input_validate_input_number($_REQUEST["tree_id"]);
        }
        if (isset($_REQUEST["leaf_id"])) {
            input_validate_input_number($_REQUEST["leaf_id"]);
        }
        print '<a href="' . $config['url_path'] . 'plugins/thold/thold_add.php?action2=' . $_REQUEST['action'] . (isset($_REQUEST['tree_id']) ? '&tree_id=' . $_REQUEST['tree_id'] : '') . (isset($_REQUEST['leaf_id']) ? '&leaf_id=' . $_REQUEST['leaf_id'] : '') . '&usetemplate=1&graphid=' . $local_graph_id . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="Thresholds" title="Create Threshold" style="padding: 3px;"></a><br>';
    }
}
コード例 #23
0
ファイル: setup.php プロジェクト: khoimt/cacti-sample
function hmib_show_tab()
{
    global $config;
    if (api_user_realm_auth('hmib.php')) {
        if (substr_count($_SERVER["REQUEST_URI"], "hmib.php")) {
            print '<a href="' . $config['url_path'] . 'plugins/hmib/hmib.php"><img src="' . $config['url_path'] . 'plugins/hmib/images/tab_hmib_down.gif" alt="hmib" align="absmiddle" border="0"></a>';
        } else {
            print '<a href="' . $config['url_path'] . 'plugins/hmib/hmib.php"><img src="' . $config['url_path'] . 'plugins/hmib/images/tab_hmib.gif" alt="hmib" align="absmiddle" border="0"></a>';
        }
    }
}