Example #1
0
while (false !== ($entry = $dir->read())) {
    if ($entry != '.' && $entry != '..') {
        if (is_dir($config['base_path'] . '/include/themes/' . $entry)) {
            $themes[$entry] = ucwords($entry);
        }
    }
}
asort($themes);
$dir->close();
/* tab information */
$tabs = array('general' => 'General', 'path' => 'Paths', 'poller' => 'Poller', 'export' => 'Graph Export', 'visual' => 'Visual', 'authentication' => 'Authentication', 'dsstats' => 'Data Source Statistics', 'boost' => 'Performance', 'mail' => 'Mail/Reporting/DNS');
$tabs_graphs = array('general' => 'General Settings', 'timespan' => 'Time Spanning/Shifting', 'thumbnail' => 'Graph Thumbnail Settings', 'tree' => 'Tree Settings', 'fonts' => 'Graph Fonts');
/* setting information */
$settings = array('path' => array('dependent_header' => array('friendly_name' => 'Required Tool Paths', 'collapsible' => 'true', 'method' => 'spacer'), 'path_snmpwalk' => array('friendly_name' => 'snmpwalk Binary Path', 'description' => 'The path to your snmpwalk binary.', 'method' => 'filepath', 'max_length' => '255'), 'path_snmpget' => array('friendly_name' => 'snmpget Binary Path', 'description' => 'The path to your snmpget binary.', 'method' => 'filepath', 'max_length' => '255'), 'path_snmpbulkwalk' => array('friendly_name' => 'snmpbulkwalk Binary Path', 'description' => 'The path to your snmpbulkwalk binary.', 'method' => 'filepath', 'max_length' => '255'), 'path_snmpgetnext' => array('friendly_name' => 'snmpgetnext Binary Path', 'description' => 'The path to your snmpgetnext binary.', 'method' => 'filepath', 'max_length' => '255'), 'path_snmptrap' => array('friendly_name' => 'snmptrap Binary Path', 'description' => 'The path to your snmptrap binary.', 'method' => 'filepath', 'max_length' => '255'), 'path_rrdtool' => array('friendly_name' => 'RRDTool Binary Path', 'description' => 'The path to the rrdtool binary.', 'method' => 'filepath', 'max_length' => '255'), 'path_php_binary' => array('friendly_name' => 'PHP Binary Path', 'description' => 'The path to your PHP binary file (may require a php recompile to get this file).', 'method' => 'filepath', 'max_length' => '255'), 'logging_header' => array('friendly_name' => 'Logging', 'collapsible' => 'true', 'method' => 'spacer'), 'path_cactilog' => array('friendly_name' => 'Cacti Log File Path', 'description' => 'The path to your Cacti log file (if blank, defaults to <path_cacti>/log/cacti.log)', 'method' => 'filepath', 'default' => $config['base_path'] . '/log/cacti.log', 'max_length' => '255'), 'logrotate_enabled' => array('friendly_name' => 'Rotate the Cacti Log Nightly', 'description' => 'This will rotate the Cacti Log every night at midnight.', 'method' => 'checkbox', 'default' => ''), 'logrotate_retain' => array('friendly_name' => 'Log Retention', 'description' => 'The number of days to retain old logs.  Use 0 to never remove any logs. (0-365)', 'method' => 'textbox', 'default' => '7', 'max_length' => 3), 'pollerpaths_header' => array('friendly_name' => 'Alternate Poller Path', 'collapsible' => 'true', 'method' => 'spacer'), 'path_spine' => array('friendly_name' => 'Spine Poller File Path', 'description' => 'The path to Spine binary.', 'method' => 'filepath', 'max_length' => '255'), 'extendedpaths_header' => array('friendly_name' => 'Structured RRD Path', 'collapsible' => 'true', 'method' => 'spacer'), 'extended_paths' => array('friendly_name' => 'Structured RRA Path (/host_id/local_data_id.rrd)', 'description' => 'Use a seperate subfolder for each hosts RRD files.', 'method' => 'checkbox'), 'rrdclean_header' => array('friendly_name' => 'RRD Cleaner', 'method' => 'spacer', 'collapsible' => 'true'), 'rrd_autoclean' => array('friendly_name' => 'RRDfile Auto Clean', 'description' => 'Automatically Delete, Archive, or Delete RRDfiles when removed from Cacti', 'method' => 'checkbox', 'default' => ''), 'rrd_autoclean_method' => array('friendly_name' => 'RRDfile Auto Clean Method', 'description' => 'The method used to Clean RRDfiles from Cacti after their deletion.', 'method' => 'drop_array', 'array' => array('1' => 'Delete', '3' => 'Archive'), 'default' => '1'), 'rrd_archive' => array('friendly_name' => 'Archive directory', 'description' => 'This is the directory where rrd files are <strong>moved</strong> for <strong>Archive</strong>', 'method' => 'dirpath', 'default' => $config['base_path'] . '/rra/archive/', 'max_length' => 255)), 'general' => array('event_logging_header' => array('friendly_name' => 'Event Logging', 'collapsible' => 'true', 'method' => 'spacer'), 'log_destination' => array('friendly_name' => 'Log File Destination', 'description' => 'How will Cacti handle event logging.', 'method' => 'drop_array', 'default' => 1, 'array' => $logfile_options), 'web_log' => array('friendly_name' => 'Web Events', 'description' => 'What Cacti website messages should be placed in the log.', 'method' => 'checkbox_group', 'tab' => 'general', 'items' => array('log_snmp' => array('friendly_name' => 'Web SNMP Messages', 'default' => ''), 'log_graph' => array('friendly_name' => 'Web RRD Graph Syntax', 'default' => ''), 'log_export' => array('friendly_name' => 'Graph Export Messages', 'default' => ''))), 'poller_specific_header' => array('friendly_name' => 'Poller Specific Logging', 'collapsible' => 'true', 'method' => 'spacer'), 'log_verbosity' => array('friendly_name' => 'Poller Logging Level', 'description' => 'What level of detail do you want sent to the log file.  WARNING: Leaving in any other status than NONE or LOW can exaust your disk space rapidly.', 'method' => 'drop_array', 'default' => POLLER_VERBOSITY_LOW, 'array' => $logfile_verbosity), 'poller_log' => array('friendly_name' => 'Poller Syslog/Eventlog Selection', 'description' => 'If you are using the Syslog/Eventlog, What Cacti poller messages should be placed in the Syslog/Eventlog.', 'method' => 'checkbox_group', 'tab' => 'poller', 'items' => array('log_pstats' => array('friendly_name' => 'Poller Statistics', 'default' => ''), 'log_pwarn' => array('friendly_name' => 'Poller Warnings', 'default' => ''), 'log_perror' => array('friendly_name' => 'Poller Errors', 'default' => 'on'))), 'versions_header' => array('friendly_name' => 'Required Tool Versions', 'collapsible' => 'true', 'method' => 'spacer'), 'snmp_version' => array('friendly_name' => 'SNMP Utility Version', 'description' => 'The type of SNMP you have installed.  Required if you are using SNMP v2c or dont have embedded SNMP support in PHP.', 'method' => 'drop_array', 'default' => 'net-snmp', 'array' => $snmp_implimentations), 'rrdtool_version' => array('friendly_name' => 'RRDTool Utility Version', 'description' => 'The version of RRDTool that you have installed.', 'method' => 'drop_array', 'default' => 'rrd-1.2.x', 'array' => $rrdtool_versions), 'snmp_header' => array('friendly_name' => 'SNMP Defaults', 'method' => 'spacer', 'collapsible' => 'true'), 'snmp_ver' => array('friendly_name' => 'SNMP Version', 'description' => 'Default SNMP version for all new hosts.', 'method' => 'drop_array', 'default' => '1', 'array' => $snmp_versions), 'snmp_community' => array('friendly_name' => 'SNMP Community', 'description' => 'Default SNMP read community for all new hosts.', 'method' => 'textbox', 'default' => 'public', 'max_length' => '100'), 'snmp_username' => array('friendly_name' => 'SNMP Username (v3)', 'description' => 'The SNMP v3 Username for polling hosts.', 'method' => 'textbox', 'default' => '', 'max_length' => '100'), 'snmp_password' => array('friendly_name' => 'SNMP Password (v3)', 'description' => 'The SNMP v3 Password for polling hosts.', 'method' => 'textbox_password', 'default' => '', 'max_length' => '100'), 'snmp_auth_protocol' => array('method' => 'drop_array', 'friendly_name' => 'SNMP Auth Protocol (v3)', 'description' => 'Choose the SNMPv3 Authorization Protocol.', 'default' => 'MD5', 'array' => $snmp_auth_protocols), 'snmp_priv_passphrase' => array('method' => 'textbox', 'friendly_name' => 'SNMP Privacy Passphrase (v3)', 'description' => 'Choose the SNMPv3 Privacy Passphrase.', 'default' => '', 'max_length' => '200'), 'snmp_priv_protocol' => array('method' => 'drop_array', 'friendly_name' => 'SNMP Privacy Protocol (v3)', 'description' => 'Choose the SNMPv3 Privacy Protocol.', 'default' => 'DES', 'array' => $snmp_priv_protocols), 'snmp_timeout' => array('friendly_name' => 'SNMP Timeout', 'description' => 'Default SNMP timeout in milli-seconds.', 'method' => 'textbox', 'default' => '500', 'max_length' => '10', 'size' => '5'), 'snmp_port' => array('friendly_name' => 'SNMP Port Number', 'description' => 'Default UDP port to be used for SNMP Calls.  Typically 161.', 'method' => 'textbox', 'default' => '161', 'max_length' => '10', 'size' => '5'), 'snmp_retries' => array('friendly_name' => 'SNMP Retries', 'description' => 'The number times the SNMP poller will attempt to reach the host before failing.', 'method' => 'textbox', 'default' => '3', 'max_length' => '10', 'size' => '5'), 'other_header' => array('friendly_name' => 'Other Defaults', 'collapsible' => 'true', 'method' => 'spacer'), 'graph_auth_method' => array('friendly_name' => 'Graph Permission Method', 'description' => 'There are two methods for determining a Users Graph Permissions.  The first is "Permissive".  Under the "Permissive" setting, a User only needs access to either the Graph, Device or Graph Template to gain access to the Graphs that apply to them.  Under "Restrictive", the User must have access to the Graph, the Device, and the Graph Template to gain access to the Graph.', 'method' => 'drop_array', 'default' => '1', 'array' => array('1' => 'Permissive', '2' => 'Restrictive')), 'reindex_method' => array('friendly_name' => 'Reindex Method for Data Queries', 'description' => 'The default reindex method to use for all Data Queries.', 'method' => 'drop_array', 'default' => '1', 'array' => $reindex_types), 'grds_creation_method' => array('method' => 'drop_array', 'friendly_name' => 'Graph/Data Source Creation Method', 'description' => 'If set to Simple, Graphs and Data Sources can only be created from New Graphs.  If Advanced, legacy Graph and Data Source creation is supported.', 'default' => '0', 'array' => array('0' => 'Simple', '1' => 'Advanced')), 'deletion_verification' => array('friendly_name' => 'Deletion Verification', 'description' => 'Prompt user before item deletion.', 'default' => 'on', 'method' => 'checkbox'), 'force_https' => array('friendly_name' => 'Force Connections over HTTPS', 'description' => 'When checked, any attempts to access Cacti will be redirected to HTTPS to insure high security.', 'default' => '', 'method' => 'checkbox')), 'export' => array('export_hdr_general' => array('friendly_name' => 'General', 'collapsible' => 'true', 'method' => 'spacer'), 'export_type' => array('friendly_name' => 'Export Method', 'description' => 'Choose which export method to use.', 'method' => 'drop_array', 'default' => 'disabled', 'array' => array('disabled' => 'Disabled (no exporting)', 'local' => 'Classic (local path)', 'ftp_php' => 'FTP (remote) - use php functions', 'ftp_ncftpput' => 'FTP (remote) - use ncftpput', 'sftp_php' => 'SFTP (remote) - use ssh php functions')), 'export_presentation' => array('friendly_name' => 'Presentation Method', 'description' => 'Choose which presentation would you want for the html generated pages. If you choose classical presentation, the graphs will be in a only-one-html page. If you choose tree presentation, the graph tree architecture will be kept in the static html pages', 'method' => 'drop_array', 'default' => 'disabled', 'array' => array('classical' => 'Classical Presentation', 'tree' => 'Tree Presentation')), 'export_tree_options' => array('friendly_name' => 'Tree Settings', 'method' => 'spacer', 'collapsible' => 'true'), 'export_tree_isolation' => array('friendly_name' => 'Tree Isolation', 'description' => 'This setting determines if the entire tree is treated as a single hierarchy or as separate hierarchies.  If they are treated separately, graphs will be isolated from one another.', 'method' => 'drop_array', 'default' => 'off', 'array' => array('off' => 'Single Tree Representation', 'on' => 'Multiple Tree Representation')), 'export_user_id' => array('friendly_name' => 'Effective User Name', 'description' => 'The user name to utilize for establishing export permissions.  This user name will be used to determine which graphs/trees are exported.  This setting works in conjunction with the current on/off behavior available within the current templates.', 'method' => 'drop_sql', 'sql' => 'SELECT id, username AS name FROM user_auth ORDER BY name', 'default' => '1'), 'export_tree_expand_hosts' => array('friendly_name' => 'Expand Tree Devices', 'description' => 'This settings determines if the tree hosts will be expanded or not.  If set to expanded, each host will have a sub-folder containing either data templates or data query items.', 'method' => 'drop_array', 'default' => 'off', 'array' => array('off' => 'Off', 'on' => 'On')), 'export_thumb_options' => array('friendly_name' => 'Thumbnail Settings', 'collapsible' => 'true', 'method' => 'spacer'), 'export_default_height' => array('friendly_name' => 'Thumbnail Height', 'description' => 'The height of thumbnail graphs in pixels.', 'method' => 'textbox', 'default' => '100', 'max_length' => '10', 'size' => '5'), 'export_default_width' => array('friendly_name' => 'Thumbnail Width', 'description' => 'The width of thumbnail graphs in pixels.', 'method' => 'textbox', 'default' => '300', 'max_length' => '10', 'size' => '5'), 'export_num_columns' => array('friendly_name' => 'Thumbnail Columns', 'description' => 'The number of columns to use when displaying thumbnail graphs.', 'method' => 'textbox', 'default' => '2', 'max_length' => '5', 'size' => '5'), 'export_hdr_paths' => array('friendly_name' => 'Paths', 'collapsible' => 'true', 'method' => 'spacer'), 'path_html_export' => array('friendly_name' => 'Export Directory (both local and ftp)', 'description' => 'This is the directory, either on the local system or on the remote system, that will contain the exported data.', 'method' => 'dirpath', 'max_length' => '255'), 'export_temporary_directory' => array('friendly_name' => 'Local Scratch Directory (ftp only)', 'description' => 'This is the a directory that cacti will temporarily store output prior to sending to the remote site via ftp.  The contents of this directory will be deleted after the ftp is completed.', 'method' => 'dirpath', 'max_length' => '255'), 'export_hdr_timing' => array('friendly_name' => 'Timing', 'method' => 'spacer'), 'export_timing' => array('friendly_name' => 'Export timing', 'description' => 'Choose when to export graphs.', 'method' => 'drop_array', 'default' => 'disabled', 'array' => array('disabled' => 'Disabled', 'classic' => 'Classic (export every x times)', 'export_hourly' => 'Hourly at specified minutes', 'export_daily' => 'Daily at specified time')), 'path_html_export_skip' => array('friendly_name' => 'Export Every x Times', 'description' => 'If you dont want Cacti to export static images every 5 minutes, put another number here. For instance, 3 would equal every 15 minutes.', 'method' => 'textbox', 'max_length' => '10', 'size' => '5'), 'export_hourly' => array('friendly_name' => 'Hourly at specified minutes', 'description' => 'If you want Cacti to export static images on an hourly basis, put the minutes of the hour when to do that. Cacti assumes that you run the data gathering script every 5 minutes, so it will round your value to the one closest to its runtime. For instance, 43 would equal 40 minutes past the hour.', 'method' => 'textbox', 'max_length' => '10', 'size' => '5'), 'export_daily' => array('friendly_name' => 'Daily at specified time', 'description' => 'If you want Cacti to export static images on an daily basis, put here the time when to do that. Cacti assumes that you run the data gathering script every 5 minutes, so it will round your value to the one closest to its runtime. For instance, 21:23 would equal 20 minutes after 9 PM.', 'method' => 'textbox', 'max_length' => '10', 'size' => '5'), 'export_hdr_ftp' => array('friendly_name' => 'FTP Options', 'method' => 'spacer', 'collapsible' => 'true'), 'export_ftp_sanitize' => array('friendly_name' => 'Sanitize remote directory', 'description' => 'Check this if you want to delete any existing files in the FTP remote directory. This option is in use only when using the PHP built-in ftp functions.', 'method' => 'checkbox', 'max_length' => '255'), 'export_ftp_host' => array('friendly_name' => 'FTP Host', 'description' => 'Denotes the host to upload your graphs by ftp.', 'placeholder' => 'hostname', 'method' => 'textbox', 'max_length' => '255'), 'export_ftp_port' => array('friendly_name' => 'FTP Port', 'description' => 'Communication port with the ftp server (leave empty for defaults). Default: 21.', 'placeholder' => '23', 'method' => 'textbox', 'max_length' => '10', 'size' => '5'), 'export_ftp_passive' => array('friendly_name' => 'Use passive mode', 'description' => 'Check this if you want to connect in passive mode to the FTP server.', 'method' => 'checkbox', 'max_length' => '255'), 'export_ftp_user' => array('friendly_name' => 'FTP User', 'description' => 'Account to logon on the remote server (leave empty for defaults). Default: Anonymous.', 'method' => 'textbox', 'placeholder' => 'anonymous', 'max_length' => '255'), 'export_ftp_password' => array('friendly_name' => 'FTP Password', 'description' => 'Password for the remote ftp account (leave empty for blank).', 'method' => 'textbox_password', 'max_length' => '255')), 'visual' => array('themes_header' => array('friendly_name' => 'Theme Settings', 'method' => 'spacer', 'collapsible' => 'true'), 'selected_theme' => array('friendly_name' => 'Theme', 'description' => 'Please select one of the available Themes to skin your Cacti with.', 'method' => 'drop_array', 'default' => 'classic', 'array' => $themes), 'table_header' => array('friendly_name' => 'Table Settings', 'collapsible' => 'true', 'method' => 'spacer'), 'num_rows_table' => array('friendly_name' => 'Rows Per Page', 'description' => 'The default number of rows to display on for a table.', 'method' => 'drop_array', 'default' => '30', 'array' => $item_rows), 'object_creation_header' => array('friendly_name' => 'Graph/Data Source/Data Query Settings', 'collapsible' => 'true', 'method' => 'spacer'), 'max_title_length' => array('friendly_name' => 'Maximum Title Length', 'description' => 'The maximum allowable Graph or Data Source titles.', 'method' => 'textbox', 'default' => '80', 'max_length' => '10', 'size' => '5'), 'max_data_query_field_length' => array('friendly_name' => 'Data Source Field Length', 'description' => 'The maximum Data Query field length.', 'method' => 'textbox', 'default' => '15', 'max_length' => '10', 'size' => '5'), 'graphs_new_header' => array('friendly_name' => 'Graph Creation', 'collapsible' => 'true', 'method' => 'spacer'), 'default_graphs_new_dropdown' => array('friendly_name' => 'Default Graph Type', 'description' => 'When creating graphs, what Graph Type would you like pre-selected?', 'method' => 'drop_array', 'default' => '-2', 'array' => array('-2' => 'All Types', '-1' => 'By Template/Data Query')), 'logmgmt_header' => array('friendly_name' => 'Log Management', 'collapsible' => 'true', 'method' => 'spacer'), 'num_rows_log' => array('friendly_name' => 'Default Log File Tail Lines', 'description' => 'Default number of lines of the Cacti log file to tail.', 'method' => 'drop_array', 'default' => 500, 'array' => $log_tail_lines), 'log_refresh_interval' => array('friendly_name' => 'Log File Tail Refresh', 'description' => 'How often do you want the Cacti log display to update.', 'method' => 'drop_array', 'default' => 60, 'array' => $page_refresh_interval), 'wathermark_header' => array('friendly_name' => 'RRDtool Graph Watermark', 'collapsible' => 'true', 'method' => 'spacer'), 'graph_wathermark' => array('friendly_name' => 'Watermark Text', 'description' => 'Test to place at the bottom center of every Graph.', 'method' => 'textbox', 'default' => COPYRIGHT_YEARS, 'max_length' => '80', 'size' => '60'), 'clog_header' => array('friendly_name' => 'Log Viewer Settings', 'collapsible' => 'true', 'method' => 'spacer'), 'clog_exclude' => array('friendly_name' => 'Exclusion Regex', 'description' => 'Any strings that match this regex will be excluded from the user display.
				<strong>For example, if you want to exclude all log lines that include the words "Admin" or "Login"
				you would type "(Admin || Login)"</strong>', 'method' => 'textarea', 'textarea_rows' => '5', 'textarea_cols' => '45', 'max_length' => 512), 'realtime_header' => array('friendly_name' => 'Realtime Graphs', 'method' => 'spacer', 'collapsible' => 'true'), 'realtime_enabled' => array('friendly_name' => 'Enable Realtime Graphing', 'description' => 'When an option is checked, users will be able to put Cacti into Realtime mode.', 'method' => 'checkbox', 'default' => 'on'), 'realtime_gwindow' => array('friendly_name' => 'Graph Timespan', 'description' => 'This timespan you wish to see on the default graph.', 'method' => 'drop_array', 'default' => 60, 'array' => $realtime_window), 'realtime_interval' => array('friendly_name' => 'Refresh Interval', 'description' => 'This is the time between graph updates.', 'method' => 'drop_array', 'default' => 15, 'array' => $realtime_refresh), 'realtime_cache_path' => array('friendly_name' => 'Cache Directory', 'description' => 'This is the location, on the web server where the RRDfiles and PNG files will be cached.
			This cache will be managed by the poller.', 'method' => 'dirpath', 'max_length' => 255, 'size' => 40), 'fonts_header' => array('friendly_name' => 'RRDtool Graph Font Control', 'method' => 'spacer', 'collapsible' => 'true'), 'font_method' => array('friendly_name' => 'Font Selection Method', 'description' => 'How do you wish fonts to be handled by default?', 'method' => 'drop_array', 'default' => 1, 'array' => array(0 => 'System', 1 => 'Theme')), 'path_rrdtool_default_font' => array('friendly_name' => 'Default Font', 'description' => (read_config_option('rrdtool_version') == 'rrd-1.2.x' ? 'When not using Theme based fonts, the path to the default True Type Font File.' : 'When not using Theme based font control, the Pangon font-config font name to use for all Graphs.') . '  Optionally, you may leave blank and control font settings on a per object basis.', 'method' => 'font', 'placeholder' => read_config_option('rrdtool_version') == 'rrd-1.2.x' ? 'Enter valid True Type Font File Path' : 'Enter Valid Font Config Value', 'max_length' => '255'), 'title_size' => array('friendly_name' => 'Title Font Size', 'description' => 'The size of the font used for Graph Titles', 'method' => 'textbox', 'default' => '10', 'max_length' => '10', 'size' => '5'), 'title_font' => array('friendly_name' => 'Title Font Setting', 'description' => 'The font to use for Graph Titles.  Enter either a valid True Type Font file or valid Pango font-config value.', 'method' => 'font', 'placeholder' => read_config_option('rrdtool_version') == 'rrd-1.2.x' ? 'Enter True Type Font Path' : 'Enter Valid Font Config Value', 'max_length' => '100'), 'legend_size' => array('friendly_name' => 'Legend Font Size', 'description' => 'The size of the font used for Graph Legend items', 'method' => 'textbox', 'default' => '8', 'max_length' => '10', 'size' => '5'), 'legend_font' => array('friendly_name' => 'Legend Font Setting', 'description' => 'The font to use for Graph Legends.  Enter either a valid True Type Font file or valid Pango font-config value.', 'method' => 'font', 'placeholder' => read_config_option('rrdtool_version') == 'rrd-1.2.x' ? 'Enter True Type Font Path' : 'Enter Valid Font Config Value', 'max_length' => '100'), 'axis_size' => array('friendly_name' => 'Axis Font Size', 'description' => 'The size of the font used for Graph Axis', 'method' => 'textbox', 'default' => '7', 'max_length' => '10', 'size' => '5'), 'axis_font' => array('friendly_name' => 'Axis Font Setting', 'description' => 'The font to use for Graph Axis items.  Enter either a valid True Type Font file or valid Pango font-config value.', 'method' => 'font', 'placeholder' => read_config_option('rrdtool_version') == 'rrd-1.2.x' ? 'Enter True Type Font Path' : 'Enter Valid Font Config Value', 'max_length' => '100'), 'unit_size' => array('friendly_name' => 'Unit Font Size', 'description' => 'The size of the font used for Graph Units', 'method' => 'textbox', 'default' => '7', 'max_length' => '10', 'size' => '5'), 'unit_font' => array('friendly_name' => 'Unit Font Setting', 'description' => 'The font to use for Graph Unit items.  Enter either a valid True Type Font file or valid Pango font-config value.', 'method' => 'font', 'placeholder' => read_config_option('rrdtool_version') == 'rrd-1.2.x' ? 'Enter True Type Font Path' : 'Enter Valid Font Config Value', 'max_length' => '100')), 'poller' => array('poller_header' => array('friendly_name' => 'General', 'collapsible' => 'true', 'method' => 'spacer'), 'poller_enabled' => array('friendly_name' => 'Data Collection Enabled', 'description' => 'If you wish to stop the polling process completely, uncheck this box.', 'method' => 'checkbox', 'default' => 'on', 'tab' => 'poller'), 'poller_type' => array('friendly_name' => 'Poller Type', 'description' => 'The poller type to use.  This setting will take effect at next polling interval.', 'method' => 'drop_array', 'default' => 1, 'array' => $poller_options), 'poller_interval' => array('friendly_name' => 'Poller Interval', 'description' => 'The polling interval in use.  This setting will effect how often rrd files are checked and updated.
			<strong><u>NOTE: If you change this value, you must re-populate the poller cache.  Failure to do so, may result in lost data.</u></strong>', 'method' => 'drop_array', 'default' => 300, 'array' => $poller_intervals), 'cron_interval' => array('friendly_name' => 'Cron Interval', 'description' => 'The cron interval in use.  You need to set this setting to the interval that your cron or scheduled task is currently running.', 'method' => 'drop_array', 'default' => 300, 'array' => $cron_intervals), 'concurrent_processes' => array('friendly_name' => 'Maximum Concurrent Poller Processes', 'description' => 'The number of concurrent processes to execute.  Using a higher number when using cmd.php will improve performance.  Performance improvements in spine are best resolved with the threads parameter', 'method' => 'textbox', 'default' => '1', 'max_length' => '10', 'size' => '5'), 'process_leveling' => array('friendly_name' => 'Balance Process Load', 'description' => 'If you choose this option, Cacti will attempt to balance the load of each poller process by equally distributing poller items per process.', 'method' => 'checkbox', 'default' => 'on'), 'oid_increasing_check_disable' => array('friendly_name' => 'Disable increasing OID Check', 'description' => 'Controls disabling check for increasing OID while walking OID tree.', 'method' => 'checkbox', 'default' => ''), 'spine_header' => array('friendly_name' => 'Spine Specific Execution Parameters', 'collapsible' => 'true', 'method' => 'spacer'), 'max_threads' => array('friendly_name' => 'Maximum Threads per Process', 'description' => 'The maximum threads allowed per process.  Using a higher number when using Spine will improve performance.', 'method' => 'textbox', 'default' => '1', 'max_length' => '10', 'size' => '5'), 'php_servers' => array('friendly_name' => 'Number of PHP Script Servers', 'description' => 'The number of concurrent script server processes to run per Spine process.  Settings between 1 and 10 are accepted.  This parameter will help if you are running several threads and script server scripts.', 'method' => 'textbox', 'default' => '1', 'max_length' => '10', 'size' => '5'), 'script_timeout' => array('friendly_name' => 'Script and Script Server Timeout Value', 'description' => 'The maximum time that Cacti will wait on a script to complete.  This timeout value is in seconds', 'method' => 'textbox', 'default' => '25', 'max_length' => '10', 'size' => '5'), 'max_get_size' => array('friendly_name' => 'The Maximum SNMP OIDs Per SNMP Get Request', 'description' => 'The maximum number of snmp get OIDs to issue per snmpbulkwalk request.  Increasing this value speeds poller performance over slow links.  The maximum value is 100 OIDs.  Decreasing this value to 0 or 1 will disable snmpbulkwalk', 'method' => 'textbox', 'default' => '10', 'max_length' => '10', 'size' => '5'), 'availability_header' => array('friendly_name' => 'Device Availability Settings', 'method' => 'spacer', 'collapsible' => 'true'), 'availability_method' => array('friendly_name' => 'Downed Device Detection', 'description' => 'The method Cacti will use to determine if a host is available for polling.  <br><i>NOTE: It is recommended that, at a minimum, SNMP always be selected.</i>', 'method' => 'drop_array', 'default' => AVAIL_SNMP, 'array' => $availability_options), 'ping_method' => array('friendly_name' => 'Ping Type', 'description' => 'The type of ping packet to sent.  <br><i>NOTE: ICMP requires that the Cacti Service ID have root privilages in Unix.</i>', 'method' => 'drop_array', 'default' => PING_UDP, 'array' => $ping_methods), 'ping_port' => array('friendly_name' => 'Ping Port', 'description' => 'When choosing either TCP or UDP Ping, which port should be checked for availability of the host prior to polling.', 'method' => 'textbox', 'default' => '23', 'max_length' => '10', 'size' => '5'), 'ping_timeout' => array('friendly_name' => 'Ping Timeout Value', 'description' => 'The timeout value to use for host ICMP and UDP pinging.  This host SNMP timeout value applies for SNMP pings.', 'method' => 'textbox', 'default' => '400', 'max_length' => '10', 'size' => '5'), 'ping_retries' => array('friendly_name' => 'Ping Retry Count', 'description' => 'The number of times Cacti will attempt to ping a host before failing.', 'method' => 'textbox', 'default' => '1', 'max_length' => '10', 'size' => '5'), 'updown_header' => array('friendly_name' => 'Device Up/Down Settings', 'collapsible' => 'true', 'method' => 'spacer'), 'ping_failure_count' => array('friendly_name' => 'Failure Count', 'description' => 'The number of polling intervals a host must be down before logging an error and reporting host as down.', 'method' => 'textbox', 'default' => '2', 'max_length' => '10', 'size' => '5'), 'ping_recovery_count' => array('friendly_name' => 'Recovery Count', 'description' => 'The number of polling intervals a host must remain up before returning host to an up status and issuing a notice.', 'method' => 'textbox', 'default' => '3', 'max_length' => '10', 'size' => '5')), 'authentication' => array('auth_header' => array('friendly_name' => 'General', 'method' => 'spacer'), 'auth_method' => array('friendly_name' => 'Authentication Method', 'description' => '<blockquote><i>None</i> - No authentication will be used, all users will have full access.<br><br><i>Builtin Authentication</i> - Cacti handles user authentication, which allows you to create users and give them rights to different areas within Cacti.<br><br><i>Web Basic Authentication</i> - Authentication is handled by the web server. Users can be added or created automatically on first login if the Template User is defined, otherwise the defined guest permissions will be used.<br><br><i>LDAP Authentication</i> - Allows for authentication against a LDAP server. Users will be created automatically on first login if the Template User is defined, otherwise the defined guest permissions will be used.  If PHPs LDAP module is not enabled, LDAP Authentication will not appear as a selectable option.<br><br><i>Multiple LDAP/AD Domain Authentication</i> - Allows administrators to support multiple desparate groups from different LDAP/AD directories to access Cacti resources.  Just as LDAP Authentication, the PHP LDAP module is required to utilize this method.</blockquote>', 'method' => 'drop_array', 'default' => 1, 'array' => $auth_methods), 'auth_cache_enabled' => array('friendly_name' => 'Support Authentication Cookies', 'description' => "If a user authenticates and selects 'Keep me signed in', an authentication cookie will be created on the users computer allowing that user to stay logged in.  The authentication cookie expires after 90 days of non-use.", 'default' => '', 'method' => 'checkbox'), 'special_users_header' => array('friendly_name' => 'Special Users', 'method' => 'spacer', 'collapsible' => 'true'), 'guest_user' => array('friendly_name' => 'Guest User', 'description' => 'The name of the guest user for viewing graphs; is "No User" by default.', 'method' => 'drop_sql', 'none_value' => 'No User', 'sql' => 'SELECT username AS id, username AS name FROM user_auth WHERE realm = 0 ORDER BY username', 'default' => '0'), 'user_template' => array('friendly_name' => 'User Template', 'description' => 'The name of the user that cacti will use as a template for new Web Basic and LDAP users; is "guest" by default.', 'method' => 'drop_sql', 'none_value' => 'No User', 'sql' => 'SELECT username AS id, username AS name FROM user_auth WHERE realm = 0 ORDER BY username', 'default' => '0'), 'secpass_header' => array('friendly_name' => 'Local Account Complexity Requirements', 'method' => 'spacer', 'collapsible' => 'true'), 'secpass_minlen' => array('friendly_name' => 'Minimum Length', 'description' => 'This is minimal length of allowed passwords.', 'method' => 'textbox', 'default' => '8', 'max_length' => 2, 'size' => 4), 'secpass_reqmixcase' => array('friendly_name' => 'Require Mix Case', 'description' => 'This will require new passwords to contains both lower and upper case characters.', 'method' => 'checkbox', 'default' => 'on'), 'secpass_reqnum' => array('friendly_name' => 'Require Number', 'description' => 'This will require new passwords to contain at least 1 numberical character.', 'method' => 'checkbox', 'default' => 'on'), 'secpass_reqspec' => array('friendly_name' => 'Require Special Character', 'description' => 'This will require new passwords to contain at least 1 special character.', 'method' => 'checkbox', 'default' => 'on'), 'secpass_forceold' => array('friendly_name' => 'Force Complexity Upon Old Passwords', 'description' => 'This will require all old passwords to also meet the new complexity requirements upon login.  If not met, it will force a password change.', 'method' => 'checkbox', 'default' => ''), 'secpass_expireaccount' => array('friendly_name' => 'Expire Inactive Accounts', 'description' => 'This is maximum number of days before inactive accounts are disabled.  The Admin account is excluded from this policy.  Set to 0 to disable.', 'method' => 'textbox', 'default' => '0', 'max_length' => 4, 'size' => 4), 'secpass_expirepass' => array('friendly_name' => 'Expire Password', 'description' => 'This is maximum number of days before a password is set to expire.  Set to 0 to disable.', 'method' => 'textbox', 'default' => '0', 'max_length' => 4, 'size' => 4), 'secpass_history' => array('friendly_name' => 'Password History', 'description' => 'Remember this number of old passwords and disallow re-using them.  Set to 0 to disable.', 'method' => 'textbox', 'default' => '0', 'max_length' => 2, 'size' => 4), 'secpass_lock_header' => array('friendly_name' => 'Account Locking', 'method' => 'spacer', 'collapsible' => 'true'), 'secpass_lockfailed' => array('friendly_name' => 'Lock Accounts', 'description' => 'Lock an account after this many failed attempts in 1 hour.  Set to 0 to disable.', 'method' => 'textbox', 'default' => '0', 'max_length' => 2, 'size' => 4), 'secpass_unlocktime' => array('friendly_name' => 'Auto Unlock', 'description' => 'An account will automatically be unlocked after this many minutes.  Even if the correct password is entered, the account will not unlock until this time limit has been met.  Set to 0 to disable.  Max of 1440 minutes (1 Day)', 'method' => 'textbox', 'default' => '60', 'max_length' => 4, 'size' => 4), 'ldap_general_header' => array('friendly_name' => 'LDAP General Settings', 'method' => 'spacer'), 'ldap_server' => array('friendly_name' => 'Server', 'description' => 'The dns hostname or ip address of the server.', 'method' => 'textbox', 'max_length' => '255'), 'ldap_port' => array('friendly_name' => 'Port Standard', 'description' => 'TCP/UDP port for Non SSL communications.', 'method' => 'textbox', 'max_length' => '5', 'default' => '389', 'size' => '5'), 'ldap_port_ssl' => array('friendly_name' => 'Port SSL', 'description' => 'TCP/UDP port for SSL communications.', 'method' => 'textbox', 'max_length' => '5', 'default' => '636', 'size' => '5'), 'ldap_version' => array('friendly_name' => 'Protocol Version', 'description' => 'Protocol Version that the server supports.', 'method' => 'drop_array', 'default' => '3', 'array' => $ldap_versions), 'ldap_encryption' => array('friendly_name' => 'Encryption', 'description' => 'Encryption that the server supports. TLS is only supported by Protocol Version 3.', 'method' => 'drop_array', 'default' => '0', 'array' => $ldap_encryption), 'ldap_referrals' => array('friendly_name' => 'Referrals', 'description' => 'Enable or Disable LDAP referrals.  If disabled, it may increase the speed of searches.', 'method' => 'drop_array', 'default' => '0', 'array' => array('0' => 'Disabled', '1' => 'Enable')), 'ldap_mode' => array('friendly_name' => 'Mode', 'description' => 'Mode which cacti will attempt to authenicate against the LDAP server.<blockquote><i>No Searching</i> - No Distinguished Name (DN) searching occurs, just attempt to bind with the provided Distinguished Name (DN) format.<br><br><i>Anonymous Searching</i> - Attempts to search for username against LDAP directory via anonymous binding to locate the users Distinguished Name (DN).<br><br><i>Specific Searching</i> - Attempts search for username against LDAP directory via Specific Distinguished Name (DN) and Specific Password for binding to locate the users Distinguished Name (DN).', 'method' => 'drop_array', 'default' => '0', 'array' => $ldap_modes), 'ldap_dn' => array('friendly_name' => 'Distinguished Name (DN)', 'description' => 'Distinguished Name syntax, such as for windows: <i>"&lt;username&gt;@win2kdomain.local"</i> or for OpenLDAP: <i>"uid=&lt;username&gt;,ou=people,dc=domain,dc=local"</i>.   "&lt;username&gt" is replaced with the username that was supplied at the login prompt.  This is only used when in "No Searching" mode.', 'method' => 'textbox', 'max_length' => '255'), 'ldap_group_require' => array('friendly_name' => 'Require Group Membership', 'description' => 'Require user to be member of group to authenicate. Group settings must be set for this to work, enabling without proper group settings will cause authenication failure.', 'default' => '', 'method' => 'checkbox'), 'ldap_group_header' => array('friendly_name' => 'LDAP Group Settings', 'method' => 'spacer'), 'ldap_group_dn' => array('friendly_name' => 'Group Distingished Name (DN)', 'description' => 'Distingished Name of the group that user must have membership.', 'method' => 'textbox', 'max_length' => '255'), 'ldap_group_attrib' => array('friendly_name' => 'Group Member Attribute', 'description' => 'Name of the attribute that contains the usernames of the members.', 'method' => 'textbox', 'max_length' => '255'), 'ldap_group_member_type' => array('friendly_name' => 'Group Member Type', 'description' => 'Defines if users use full Distingished Name or just Username in the defined Group Member Attribute.', 'method' => 'drop_array', 'default' => 1, 'array' => array(1 => 'Distingished Name', 2 => 'Username')), 'ldap_search_base_header' => array('friendly_name' => 'LDAP Specific Search Settings', 'method' => 'spacer'), 'ldap_search_base' => array('friendly_name' => 'Search Base', 'description' => 'Search base for searching the LDAP directory, such as <i>\'dc=win2kdomain,dc=local\'</i> or <i>\'ou=people,dc=domain,dc=local\'</i>.', 'method' => 'textbox', 'max_length' => '255'), 'ldap_search_filter' => array('friendly_name' => 'Search Filter', 'description' => 'Search filter to use to locate the user in the LDAP directory, such as for windows: <i>\'(&amp;(objectclass=user)(objectcategory=user)(userPrincipalName=&lt;username&gt;*))\'</i> or for OpenLDAP: <i>\'(&(objectClass=account)(uid=&lt;username&gt))\'</i>.  \'&lt;username&gt\' is replaced with the username that was supplied at the login prompt. ', 'method' => 'textbox', 'max_length' => '255'), 'ldap_specific_dn' => array('friendly_name' => 'Search Distingished Name (DN)', 'description' => 'Distinguished Name for Specific Searching binding to the LDAP directory.', 'method' => 'textbox', 'max_length' => '255'), 'ldap_specific_password' => array('friendly_name' => 'Search Password', 'description' => 'Password for Specific Searching binding to the LDAP directory.', 'method' => 'textbox_password', 'max_length' => '255')), 'mail' => array('settings_email_header' => array('friendly_name' => '<table width="99%" cellspacing="0" cellpadding="0" align="left"><tr><td class="textSubHeaderDark">Emailing Options</td><td align="right" class="textSubHeaderDark"><span id="emailtest" class="emailtest">Send a Test Email</font></span></td></tr></table>', 'method' => 'spacer'), 'settings_test_email' => array('friendly_name' => 'Test Email', 'description' => 'This is a email account used for sending a test message to ensure everything is working properly.', 'method' => 'textbox', 'max_length' => 255), 'settings_how' => array('friendly_name' => 'Mail Services', 'description' => 'Which mail service to use in order to send mail', 'method' => 'drop_array', 'default' => 'PHP Mail() Function', 'array' => array('PHP Mail() Function', 'Sendmail', 'SMTP')), 'settings_from_email' => array('friendly_name' => 'From Email Address', 'description' => 'This is the email address that the email will appear from.', 'method' => 'textbox', 'max_length' => 255), 'settings_from_name' => array('friendly_name' => 'From Name', 'description' => 'This is the actual name that the email will appear from.', 'method' => 'textbox', 'max_length' => 255), 'settings_wordwrap' => array('friendly_name' => 'Word Wrap', 'description' => 'This is how many characters will be allowed before a line in the email is automatically word wrapped. (0 = Disabled)', 'method' => 'textbox', 'default' => 120, 'max_length' => 4, 'size' => 5), 'settings_sendmail_header' => array('friendly_name' => 'Sendmail Options', 'collapsible' => 'true', 'method' => 'spacer'), 'settings_sendmail_path' => array('friendly_name' => 'Sendmail Path', 'description' => 'This is the path to sendmail on your server. (Only used if Sendmail is selected as the Mail Service)', 'method' => 'filepath', 'max_length' => 255, 'default' => '/usr/sbin/sendmail'), 'settings_smtp_header' => array('friendly_name' => 'SMTP Options', 'collapsible' => 'true', 'method' => 'spacer'), 'settings_smtp_host' => array('friendly_name' => 'SMTP Hostname', 'description' => 'This is the hostname/IP of the SMTP Server you will send the email to. For failover, separate your hosts using a semi-colon.', 'method' => 'textbox', 'default' => 'localhost', 'max_length' => 255), 'settings_smtp_port' => array('friendly_name' => 'SMTP Port', 'description' => 'The port on the SMTP Server to use.', 'method' => 'textbox', 'max_length' => 255, 'default' => 25, 'size' => 5), 'settings_smtp_username' => array('friendly_name' => 'SMTP Username', 'description' => 'The username to authenticate with when sending via SMTP. (Leave blank if you do not require authentication.)', 'method' => 'textbox', 'max_length' => 255), 'settings_smtp_password' => array('friendly_name' => 'SMTP Password', 'description' => 'The password to authenticate with when sending via SMTP. (Leave blank if you do not require authentication.)', 'method' => 'textbox_password', 'max_length' => 255), 'settings_smtp_secure' => array('friendly_name' => 'SMTP Security', 'description' => 'The encryption method to use for the email.', 'method' => 'drop_array', 'array' => array('none' => 'None', 'ssl' => 'SSL', 'tls' => 'TLS'), 'default' => 'none'), 'settings_smtp_timeout' => array('friendly_name' => 'SMTP Timeout', 'description' => 'Please enter the SMTP timeout in seconds.', 'method' => 'textbox', 'default' => '5', 'max_length' => '10', 'size' => '5'), 'reports_header' => array('friendly_name' => 'Reporting Presets', 'method' => 'spacer', 'collapsible' => 'true'), 'reports_default_image_format' => array('friendly_name' => 'Default Graph Image Format', 'description' => 'When creating a new report, what image type should be used for the inline graphs.', 'method' => 'drop_array', 'default' => REPORTS_TYPE_INLINE_PNG, 'array' => $attach_types), 'reports_max_attach' => array('friendly_name' => 'Maximum E-Mail Size', 'description' => 'The maximum size of the E-Mail message including all attachements.', 'method' => 'drop_array', 'default' => REPORTS_DEFAULT_MAX_SIZE, 'array' => $attachment_sizes), 'reports_log_verbosity' => array('friendly_name' => 'Poller Logging Level for Cacti Reporting', 'description' => 'What level of detail do you want sent to the log file. WARNING: Leaving in any other status than NONE or LOW can exaust your disk space rapidly.', 'method' => 'drop_array', 'default' => POLLER_VERBOSITY_LOW, 'array' => $logfile_verbosity), 'reports_allow_ln' => array('friendly_name' => 'Enable Lotus Notus (R) tweak', 'description' => 'Enable code tweak for specific handling of Lotus Notes Mail Clients.', 'method' => 'checkbox', 'default' => ''), 'settings_dns_header' => array('friendly_name' => 'DNS Options', 'collapsible' => 'true', 'method' => 'spacer'), 'settings_dns_primary' => array('friendly_name' => 'Primary DNS IP Address', 'description' => 'Enter the primary DNS IP Address to utilize for reverse lookups.', 'method' => 'textbox', 'default' => '', 'max_length' => '30'), 'settings_dns_secondary' => array('friendly_name' => 'Secondary DNS IP Address', 'description' => 'Enter the secondary DNS IP Address to utilize for reverse lookups.', 'method' => 'textbox', 'default' => '', 'max_length' => '30'), 'settings_dns_timeout' => array('friendly_name' => 'DNS Timeout', 'description' => 'Please enter the DNS timeout in milliseconds.  Cacti uses a PHP based DNS resolver.', 'method' => 'textbox', 'default' => '500', 'max_length' => '10', 'size' => '5')), 'dsstats' => array('dsstats_hq_header' => array('friendly_name' => 'Data Sources Statistics', 'collapsible' => 'true', 'method' => 'spacer'), 'dsstats_enable' => array('friendly_name' => 'Enable Data Source Statistics Collection', 'description' => 'Should Data Source Statistics be collected for this Cacti system?', 'method' => 'checkbox', 'default' => ''), 'dsstats_daily_interval' => array('friendly_name' => 'Daily Update Frequency', 'description' => 'How frequent should Daily Stats be updated?', 'default' => '60', 'method' => 'drop_array', 'array' => $dsstats_refresh_interval), 'dsstats_hourly_duration' => array('friendly_name' => 'Hourly Average Window', 'description' => 'The number of consecutive hours that represent the hourly
			average.  Keep in mind that a setting too high can result in very large memory tables', 'default' => '60', 'method' => 'drop_array', 'array' => $dsstats_hourly_avg), 'dsstats_major_update_time' => array('friendly_name' => 'Maintenance Time', 'description' => 'What time of day should Weekly, Monthly, and Yearly Data be updated?  Format is HH:MM [am/pm]', 'method' => 'textbox', 'default' => '12:00am', 'max_length' => '20', 'size' => '10'), 'dsstats_poller_mem_limit' => array('friendly_name' => 'Memory Limit for dsstats and Poller', 'description' => 'The maximum amount of memory for the Cacti Poller and dsstats Poller', 'method' => 'drop_array', 'default' => '1024', 'array' => $dsstats_max_memory), 'dsstats_debug_header' => array('friendly_name' => 'Debugging', 'method' => 'spacer', 'collapsible' => 'true'), 'dsstats_rrdtool_pipe' => array('friendly_name' => 'Enable Single RRDtool Pipe', 'description' => 'Using a single pipe will speed the RRDtool process by 10x.  However, RRDtool crashes
			problems can occur.  Disable this setting if you need to find a bad RRDfile.', 'method' => 'checkbox', 'default' => 'on'), 'dsstats_partial_retrieve' => array('friendly_name' => 'Enable Partial Reference Data Retrieve', 'description' => 'If using a large system, it may be beneficial for you to only gather data as needed
			during Cacti poller passes.  If you check this box, you DSStats will gather data this way.', 'method' => 'checkbox', 'default' => '')), 'boost' => array('boost_hq_header' => array('friendly_name' => 'On Demand RRD Update Settings', 'method' => 'spacer', 'collapsible' => 'true'), 'boost_rrd_update_enable' => array('friendly_name' => 'Enable On Demand RRD Updating', 'description' => 'Should Boost enable on demand RRD updating in Cacti?  If you disable, this change will not take affect until after the next polling cycle.', 'method' => 'checkbox', 'default' => ''), 'boost_rrd_update_system_enable' => array('friendly_name' => 'System Level RRD Updater', 'description' => 'Before RRD On Demand Update Can be Cleared, a poller run must alway pass', 'method' => 'hidden', 'default' => ''), 'boost_rrd_update_interval' => array('friendly_name' => 'How Often Should Boost Update All RRDs', 'description' => 'When you enable boost, your RRD files are only updated when they are requested by a user, or when this time period elapses.', 'default' => '60', 'method' => 'drop_array', 'default' => '60', 'array' => $boost_refresh_interval), 'boost_rrd_update_max_records' => array('friendly_name' => 'Maximum Records', 'description' => 'If the boost output table exceeds this size, in records, an update will take place.', 'method' => 'textbox', 'default' => '1000000', 'max_length' => '20', 'size' => '10'), 'boost_rrd_update_max_records_per_select' => array('friendly_name' => 'Maximum Data Source Items Per Pass', 'description' => 'To optimize performance, the boost RRD updater needs to know how many Data Source Items
			should be retrieved in one pass.  Please be careful not to set too high as graphing performance during
			major updates can be compromised.  If you encounter graphing or polling slowness during updates, lower this
			number.  The default value is 50000.', 'method' => 'drop_array', 'default' => '50000', 'array' => $boost_max_rows_per_select), 'boost_rrd_update_string_length' => array('friendly_name' => 'Maximum Argument Length', 'description' => 'When boost sends update commands to RRDtool, it must not exceed the operating systems
			Maximum Argument Length.  This varies by operating system and kernel level.  For example:
			Windows 2000 <= 2048, FreeBSD <= 65535, Linux 2.6.22-- <= 131072, Linux 2.6.23++ unlimited', 'method' => 'textbox', 'default' => '2000', 'max_length' => '20', 'size' => '10'), 'boost_poller_mem_limit' => array('friendly_name' => 'Memory Limit for Boost and Poller', 'description' => 'The maximum amount of memory for the Cacti Poller and Boosts Poller', 'method' => 'drop_array', 'default' => '1024', 'array' => $boost_max_memory), 'boost_rrd_update_max_runtime' => array('friendly_name' => 'Maximum RRD Update Script Run Time', 'description' => 'The maximum boot poller run time allowed prior to boost issuing warning
			messages relative to possible hardware/software issues preventing proper updates.', 'method' => 'drop_array', 'default' => '1200', 'array' => $boost_max_runtime), 'boost_redirect' => array('friendly_name' => 'Enable direct population of poller_output_boost table by spine', 'description' => 'Enables direct insert of records into poller output boost with results in a 25% time reduction in each poll cycle.', 'method' => 'checkbox', 'default' => ''), 'boost_srv_header' => array('friendly_name' => 'Boost Server Settings', 'method' => 'spacer', 'collapsible' => 'true'), 'boost_server_enable' => array('friendly_name' => 'Enable Boost Server', 'description' => 'Should Boost server be used to RRDupdates?  If you do not select, then your web server needs R/W to rra directories.', 'method' => 'checkbox', 'default' => ''), 'boost_server_effective_user' => array('friendly_name' => 'Effective User ID', 'description' => 'This UNIX/LINUX only option allows you to use this users UID to create and otherwise operate on RRDs.  In order to use this, you must also be using the POSIX module in PHP.  A Boost Server restart is required to enact any changes in this setting.', 'method' => 'textbox', 'default' => 'root', 'max_length' => '20'), 'boost_server_multiprocess' => array('friendly_name' => 'Multiprocess Server', 'description' => 'Do you want the boost server to fork a seprate update process for each boost request?  A Boost Server restart is required to enact any changes in this setting.', 'method' => 'drop_array', 'default' => '1', 'array' => array('0' => 'No', '1' => 'Yes')), 'boost_path_rrdupdate' => array('friendly_name' => 'RRDUpdate Path', 'description' => 'If you are using the Multiprocess Boost server, it is best to utilize the rrdupdate binary to update your RRDs.  Specify its path here.  Otherwise, boost will use the rrdtool binary.', 'method' => 'textbox', 'default' => '', 'max_length' => '255'), 'boost_server_hostname' => array('friendly_name' => 'Hostname or IP for Boost Server', 'description' => 'The Hostname/IP for the boost server.', 'method' => 'textbox', 'default' => 'localhost', 'max_length' => '100'), 'boost_server_listen_port' => array('friendly_name' => 'TCP Port to Communicate On', 'description' => 'The boost server will listen on this port and the client will talk to this port.  A Boost Server restart is required to enact any changes in this setting.', 'method' => 'textbox', 'default' => '9050', 'max_length' => '10'), 'boost_server_timeout' => array('friendly_name' => 'Boost Server Timeout', 'description' => 'The timeout, in seconds, that the client should wait on the boost server before giving up.', 'method' => 'textbox', 'default' => '2', 'max_length' => '10'), 'boost_server_clients' => array('friendly_name' => 'Allowed Web Hosts', 'description' => 'A comma separated list of host IP Addresses allowed to connect to the boost server.', 'method' => 'textbox', 'default' => '127.0.0.1', 'max_length' => '512'), 'boost_png_header' => array('friendly_name' => 'Image Caching', 'method' => 'spacer', 'collapsible' => 'true'), 'boost_png_cache_enable' => array('friendly_name' => 'Enable Image Caching', 'description' => 'Should image caching be enabled?', 'method' => 'checkbox', 'default' => ''), 'boost_png_cache_directory' => array('friendly_name' => 'Location for Image Files', 'description' => 'Specify the location where Boost should place your image files.  These files will be automatically purged by the poller when they expire.', 'method' => 'dirpath', 'max_length' => '255', 'default' => ''), 'boost_process_header' => array('friendly_name' => 'Process Interlocking', 'collapsible' => 'true', 'method' => 'spacer'), 'path_boost_log' => array('friendly_name' => 'Boost Debug Log', 'description' => 'If this field is non-blank, Boost will log RRDupdate output from the boost
			poller process.', 'method' => 'filepath', 'default' => '', 'max_length' => '255')));
$settings_graphs = array('general' => array('default_view_mode' => array('friendly_name' => 'Default View Mode', 'description' => 'Which mode you want displayed when you visit "graph_view.php"', 'method' => 'drop_array', 'array' => $graph_views, 'default' => '1'), 'show_graph_title' => array('friendly_name' => 'Show Graph Title', 'description' => 'Display the graph title on the page so that it may be searched using the browser.', 'method' => 'checkbox', 'default' => ''), 'default_date_format' => array('friendly_name' => 'Graph Date Display Format', 'description' => 'The date format to use for graphs', 'method' => 'drop_array', 'array' => $graph_dateformats, 'default' => GD_Y_MO_D), 'default_datechar' => array('friendly_name' => 'Graph Date Separator', 'description' => 'The date separator to be used for graphs', 'method' => 'drop_array', 'array' => $graph_datechar, 'default' => GDC_SLASH), 'page_refresh' => array('friendly_name' => 'Page Refresh', 'description' => 'The number of seconds between automatic page refreshes.', 'method' => 'drop_array', 'default' => '300', 'array' => array('15' => '15 Seconds', '20' => '20 Seconds', '30' => '30 Seconds', '60' => '1 Minute', '300' => '5 Minutes')), 'preview_graphs_per_page' => array('friendly_name' => 'Preview Graphs Per Page', 'description' => 'The number of graphs to display on one page in preview mode.', 'method' => 'drop_array', 'default' => '10', 'array' => $graphs_per_page)), 'timespan' => array('timespan_sel' => array('friendly_name' => 'Display Graph View Timespan Selector', 'description' => 'Choose if you want the time span selection box to be displayed.', 'method' => 'checkbox', 'default' => 'on'), 'default_rra_id' => array('friendly_name' => 'Default Time Range', 'description' => 'The default RRA to use when for Graphs the Timespan selector is disabled.', 'method' => 'drop_sql', 'sql' => 'SELECT id,name FROM rra ORDER BY timespan', 'default' => '1'), 'default_timespan' => array('friendly_name' => 'Default Graph View Timespan', 'description' => 'The default timespan you wish to be displayed when you display graphs', 'method' => 'drop_array', 'array' => $graph_timespans, 'default' => GT_LAST_DAY), 'default_timeshift' => array('friendly_name' => 'Default Graph View Timeshift', 'description' => 'The default timeshift you wish to be displayed when you display graphs', 'method' => 'drop_array', 'array' => $graph_timeshifts, 'default' => GTS_1_DAY), 'allow_graph_dates_in_future' => array('friendly_name' => 'Allow Graph to extend to Future', 'description' => 'When displaying Graphs, allow Graph Dates to extend "to future"', 'method' => 'checkbox', 'default' => 'on'), 'first_weekdayid' => array('friendly_name' => 'First Day of the Week', 'description' => 'The first Day of the Week for weekly Graph Displays', 'method' => 'drop_array', 'array' => $graph_weekdays, 'default' => WD_MONDAY), 'day_shift_start' => array('friendly_name' => 'Start of Daily Shift', 'description' => 'Start Time of the Daily Shift.', 'method' => 'textbox', 'default' => '07:00', 'max_length' => '5', 'size' => '7'), 'day_shift_end' => array('friendly_name' => 'End of Daily Shift', 'description' => 'End Time of the Daily Shift.', 'method' => 'textbox', 'default' => '18:00', 'max_length' => '5', 'size' => '7')), 'thumbnail' => array('thumbnail_sections' => array('friendly_name' => 'Thumbnail Sections', 'description' => 'Which portions of Cacti display Thumbnails by default.', 'method' => 'checkbox_group', 'items' => array('thumbnail_section_preview' => array('friendly_name' => 'Preview Mode', 'default' => 'on'), 'thumbnail_section_tree_2' => array('friendly_name' => 'Tree View', 'default' => ''))), 'num_columns' => array('friendly_name' => 'Thumbnail Columns', 'description' => 'The number of columns to use when displaying Thumbnail graphs.', 'method' => 'drop_array', 'default' => '2', 'array' => array('1' => '1 Column', '2' => '2 Columns', '3' => '3 Columns', '4' => '4 Columns', '5' => '5 Columns')), 'default_height' => array('friendly_name' => 'Thumbnail Height', 'description' => 'The height of Thumbnail graphs in pixels.', 'method' => 'textbox', 'default' => '100', 'max_length' => '10', 'size' => '7'), 'default_width' => array('friendly_name' => 'Thumbnail Width', 'description' => 'The width of Thumbnail graphs in pixels.', 'method' => 'textbox', 'default' => '300', 'max_length' => '10', 'size' => '7')), 'tree' => array('default_tree_id' => array('friendly_name' => 'Default Graph Tree', 'description' => 'The default graph tree to use when displaying graphs in tree mode.', 'method' => 'drop_sql', 'sql' => 'SELECT id,name FROM graph_tree ORDER BY name', 'default' => '0'), 'treeview_graphs_per_page' => array('friendly_name' => 'Graphs Per Page', 'description' => 'The number of graphs to display on one page in preview mode.', 'method' => 'drop_array', 'default' => '10', 'array' => $graphs_per_page), 'expand_hosts' => array('friendly_name' => 'Expand Devices', 'description' => 'Choose whether to expand the Graph Templates and Data Queries used by a Device on Tree.', 'method' => 'checkbox', 'default' => '')), 'fonts' => array('custom_fonts' => array('friendly_name' => 'Use Custom Fonts', 'description' => 'Choose whether to use your own custom fonts and font sizes or utilize the system defaults.', 'method' => 'checkbox', 'on_change' => 'graphSettings()', 'default' => ''), 'title_size' => array('friendly_name' => 'Title Font Size', 'description' => 'The size of the font used for Graph Titles', 'method' => 'textbox', 'default' => '12', 'max_length' => '10'), 'title_font' => array('friendly_name' => 'Title Font File', 'description' => 'The font file to use for Graph Titles', 'method' => 'font', 'max_length' => '100'), 'legend_size' => array('friendly_name' => 'Legend Font Size', 'description' => 'The size of the font used for Graph Legend items', 'method' => 'textbox', 'default' => '10', 'max_length' => '10'), 'legend_font' => array('friendly_name' => 'Legend Font File', 'description' => 'The font file to be used for Graph Legend items', 'method' => 'font', 'max_length' => '100'), 'axis_size' => array('friendly_name' => 'Axis Font Size', 'description' => 'The size of the font used for Graph Axis', 'method' => 'textbox', 'default' => '8', 'max_length' => '10'), 'axis_font' => array('friendly_name' => 'Axis Font File', 'description' => 'The font file to be used for Graph Axis items', 'method' => 'font', 'max_length' => '100'), 'unit_size' => array('friendly_name' => 'Unit Font Size', 'description' => 'The size of the font used for Graph Units', 'method' => 'textbox', 'default' => '8', 'max_length' => '10'), 'unit_font' => array('friendly_name' => 'Unit Font File', 'description' => 'The font file to be used for Graph Unit items', 'method' => 'font', 'max_length' => '100')));
api_plugin_hook('config_settings');
Example #2
0
File: host.php Project: MrWnn/cacti
function host_edit()
{
    global $fields_host_edit, $reindex_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    api_plugin_hook('host_edit_top');
    if (!empty($_REQUEST['id'])) {
        $host = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array($_REQUEST['id']));
        $header_label = '[edit: ' . htmlspecialchars($host['description']) . ']';
    } else {
        $header_label = '[new]';
    }
    if (!empty($host['id'])) {
        ?>
		<table width='100%' align='center'>
			<tr>
				<td class='textInfo' colspan='2'>
					<?php 
        print htmlspecialchars($host['description']);
        ?>
 (<?php 
        print htmlspecialchars($host['hostname']);
        ?>
)
				</td>
				<td rowspan='2' class='textInfo' valign='top' align='right'>
					<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
        print htmlspecialchars('graphs_new.php?host_id=' . $host['id']);
        ?>
'>Create Graphs for this Device</a><br>
					<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
        print htmlspecialchars('data_sources.php?host_id=' . $host['id'] . '&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1');
        ?>
'>Data Source List</a><br>
					<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
        print htmlspecialchars('graphs.php?host_id=' . $host['id'] . '&graph_rows=30&filter=&template_id=-1&page=1');
        ?>
'>Graph List</a>
					<?php 
        api_plugin_hook('device_edit_top_links');
        ?>
				</td>
			</tr>
			<tr>
				<td valign='top' class='textHeader'>
					<div id='ping_results'>Pinging Device&nbsp;<i style='font-size:12px;' class='fa fa-spin fa-spinner'></i><br><br></div>
				</td>
			</tr>
		</table>
		<?php 
    }
    html_start_box("<strong>Device</strong> {$header_label}", '100%', '', '3', 'center', '');
    /* preserve the host template id if passed in via a GET variable */
    if (!empty($_REQUEST['host_template_id'])) {
        $fields_host_edit['host_template_id']['value'] = $_REQUEST['host_template_id'];
    }
    draw_edit_form(array('config' => array('form_name' => 'chk'), 'fields' => inject_form_variables($fields_host_edit, isset($host) ? $host : array())));
    /* we have to hide this button to make a form change in the main form trigger the correct
     * submit action */
    echo "<div style='display:none;'><input type='submit' value='Default Submit Button'></div>";
    html_end_box();
    ?>
	<script type="text/javascript">
	<!--

	// default snmp information
	var snmp_community       = $('#snmp_community').val();
	var snmp_username        = $('#snmp_username').val();
	var snmp_password        = $('#snmp_password').val();
	var snmp_auth_protocol   = $('#snmp_auth_protocol').val();
	var snmp_priv_passphrase = $('#snmp_priv_passphrase').val();
	var snmp_priv_protocol   = $('#snmp_priv_protocol').val();
	var snmp_context         = $('#snmp_context').val();
	var snmp_port            = $('#snmp_port').val();
	var snmp_timeout         = $('#snmp_timeout').val();
	var max_oids             = $('#max_oids').val();

	// default ping methods
	var ping_method    = $('#ping_method').val();
	var ping_port      = $('#ping_port').val();
	var ping_timeout   = $('#ping_timeout').val();
	var ping_retries   = $('#ping_retries').val();

	function setPing() {
		availability_method = $('#availability_method').val();
		ping_method         = $('#ping_method').val();

		switch(availability_method) {
		case '0': // none
			$('#row_ping_method').css('display', 'none');
			$('#row_ping_port').css('display', 'none');
			$('#row_ping_timeout').css('display', 'none');
			$('#row_ping_retries').css('display', 'none');

			break;
		case '2': // snmp
		case '5': // snmp sysDesc
		case '6': // snmp getNext
			$('#row_ping_method').css('display', 'none');
			$('#row_ping_port').css('display', 'none');
			$('#row_ping_timeout').css('display', '');
			$('#row_ping_retries').css('display', '');

			break;
		default: // ping ok
			switch(ping_method) {
			case '1': // ping icmp
				$('#row_ping_method').css('display', '');
				$('#row_ping_port').css('display', 'none');
				$('#row_ping_timeout').css('display', '');
				$('#row_ping_retries').css('display', '');

				break;
			case '2': // ping udp
			case '3': // ping tcp
				$('#row_ping_method').css('display', '');
				$('#row_ping_port').css('display', '');
				$('#row_ping_timeout').css('display', '');
				$('#row_ping_retries').css('display', '');

				break;
			}

			break;
		}
	}

	function setAvailability() {
		if ($('#snmp_version').val() == '0') {
			methods = [ 
				{ value: '0', text: 'None' }, 
				{ value: '3', text: 'Ping' }
			];

			if ($('#availability_method').val() != '3' && $('#availability_method').val() != '0') {
				$('#availability_method').val('3');
			}

			$('#availability_method').replaceOptions(methods, $('#availability_method').val());
		}else{
			methods = [
				{ value: '0', text: 'None' }, 
				{ value: '1', text: 'Ping and SNMP Uptime' }, 
				{ value: '2', text: 'SNMP Uptime' }, 
				{ value: '3', text: 'Ping' }, 
				{ value: '4', text: 'Ping or SNMP Uptime' }, 
				{ value: '5', text: 'SNMP Desc' }, 
				{ value: '6', text: 'SNMP GetNext' }
			];

			$('#availability_method').replaceOptions(methods, $('#availability_method').val());
		}

		switch($('#availibility_method').val()) {
			case '0': // availability none
				$('#row_ping_method').hide();
				$('#ping_method').val(0);
				$('#row_ping_timeout').hide();
				$('#row_ping_port').hide();
				$('#row_ping_timeout').hide();
				$('#row_ping_retrie').hide();

				break;
			case '1': // ping and snmp sysUptime
			case '3': // ping
			case '4': // ping or snmp sysUptime
				if (($('#row_ping_method').css('display', 'none')) ||
					($('#row_ping_method').css('display') == undefined)) {
					$('#ping_method').val(ping_method);
					$('#row_ping_method').css('display', '');
				}

				break;
			case '2': // snmp sysUptime
			case '5': // snmp sysDesc
			case '6': // snmp getNext
				$('#row_ping_method').css('display', 'none');
				$('#ping_method').val(0);

				break;
		}

		if ($('#availability_method-button').length) {
			$('#availability_method').selectmenu('refresh');
		}
	}

	function changeHostForm() {
		setSNMP();
		setAvailability();
		setPing();
	}

	function setSNMP() {
		snmp_version = $('#snmp_version').val();
		switch(snmp_version) {
		case '0': // No SNMP
			$('#row_snmp_username').hide();
			$('#row_snmp_password').hide();
			$('#row_snmp_community').hide();
			$('#row_snmp_auth_protocol').hide();
			$('#row_snmp_priv_passphrase').hide();
			$('#row_snmp_priv_protocol').hide();
			$('#row_snmp_context').hide();
			$('#row_snmp_port').hide();
			$('#row_snmp_timeout').hide();
			$('#row_max_oids').hide();
			break;
		case '1': // SNMP v1
		case '2': // SNMP v2c
			$('#row_snmp_username').hide();
			$('#row_snmp_password').hide();
			$('#row_snmp_community').show();
			$('#row_snmp_auth_protocol').hide();
			$('#row_snmp_priv_passphrase').hide();
			$('#row_snmp_priv_protocol').hide();
			$('#row_snmp_context').hide();
			$('#row_snmp_port').show();
			$('#row_snmp_timeout').show();
			$('#row_max_oids').show();
			break;
		case '3': // SNMP v3
			$('#row_snmp_username').show();
			$('#row_snmp_password').show();
			$('#row_snmp_community').hide();
			$('#row_snmp_auth_protocol').show();
			$('#row_snmp_priv_passphrase').show();
			$('#row_snmp_priv_protocol').show();
			$('#row_snmp_context').show();
			$('#row_snmp_port').show();
			$('#row_snmp_timeout').show();
			$('#row_max_oids').show();
			break;
		}
	}

	$(function() {
		changeHostForm();
		$('#dbghide').click(function(data) {
			$('#dqdebug').fadeOut('fast');
		});

		$.get('host.php?action=ping_host&id='+$('#id').val(), function(data) {
			$('#ping_results').html(data);
		});
	});

	-->
	</script>
	<?php 
    if (isset($_REQUEST['display_dq_details']) && isset($_SESSION['debug_log']['data_query'])) {
        print "<table id='dqdebug' width='100%' class='cactiDebugTable' cellpadding='0' cellspacing='0' border='0' align='center'><tr><td>\n";
        print "<table width='100%' class='cactiTableTitle' cellspacing='0' cellpadding='3' border='0'>\n";
        print "<tr><td class='textHeaderDark'><a name='dqdbg'></a><strong>Data Query Debug Information</strong></td><td class='textHeaderDark' align='right'><a style='cursor:pointer;' id='dbghide' class='linkOverDark'>Hide</a></td></tr>\n";
        print "</table>\n";
        print "<table width='100%' class='cactiTable' cellspacing='0' cellpadding='3' border='0'>\n";
        print "<tr><td class='odd'><span style='font-family: monospace;'>" . debug_log_return('data_query') . "</span></td></tr>";
        print "</table>\n";
        print "</table>\n";
    }
    if (!empty($host['id'])) {
        html_start_box('<strong>Associated Graph Templates</strong>', '100%', '', '3', 'center', '');
        html_header(array('Graph Template Name', 'Status'), 2);
        $selected_graph_templates = db_fetch_assoc_prepared('SELECT
			graph_templates.id,
			graph_templates.name
			FROM (graph_templates, host_graph)
			WHERE graph_templates.id = host_graph.graph_template_id
			AND host_graph.host_id = ?
			ORDER BY graph_templates.name', array($_REQUEST['id']));
        $available_graph_templates = db_fetch_assoc('SELECT
			graph_templates.id, graph_templates.name
			FROM snmp_query_graph RIGHT JOIN graph_templates
			ON (snmp_query_graph.graph_template_id = graph_templates.id)
			WHERE (((snmp_query_graph.name) Is Null)) ORDER BY graph_templates.name');
        $i = 0;
        if (sizeof($selected_graph_templates) > 0) {
            foreach ($selected_graph_templates as $item) {
                form_alternate_row('', true);
                /* get status information for this graph template */
                $is_being_graphed = sizeof(db_fetch_assoc_prepared('SELECT id FROM graph_local WHERE graph_template_id = ? AND host_id = ?', array($item['id'], $_REQUEST['id']))) > 0 ? true : false;
                ?>
					<td style="padding: 4px;">
						<strong><?php 
                print $i;
                ?>
)</strong> <?php 
                print htmlspecialchars($item['name']);
                ?>
					</td>
					<td>
						<?php 
                print $is_being_graphed == true ? "<span style='color: green;'>Is Being Graphed</span> (<a href='" . htmlspecialchars('graphs.php?action=graph_edit&id=' . db_fetch_cell_prepared('SELECT id FROM graph_local WHERE graph_template_id = ? AND host_id = ? LIMIT 0,1', array($item['id'], $_REQUEST['id']))) . "'>Edit</a>)" : "<span style='color: #484848;'>Not Being Graphed</span>";
                ?>
					</td>
					<td align='right' nowrap>
						<a href='<?php 
                print htmlspecialchars('host.php?action=gt_remove&id=' . $item['id'] . '&host_id=' . $_REQUEST['id']);
                ?>
'><img src='images/delete_icon_large.gif' title='Delete Graph Template Association' alt='Delete Graph Template Association' border='0' align='middle'></a>
					</td>
				<?php 
                form_end_row();
                $i++;
            }
        } else {
            print "<tr class='tableRow'><td colspan='2'><em>No associated graph templates.</em></td></tr>";
        }
        ?>
		<tr class='odd'>
			<td class='saveRow' colspan="4">
				<table cellspacing="0" cellpadding="1" width="100%">
					<td nowrap>Add Graph Template:&nbsp;
						<?php 
        form_dropdown('graph_template_id', $available_graph_templates, 'name', 'id', '', '', '');
        ?>
					</td>
					<td align="right">
						&nbsp;<input type="submit" value="Add" name="add_gt_x" title="Add Graph Template to Device">
					</td>
				</table>
			</td>
		</tr>

		<?php 
        html_end_box();
        html_start_box('<strong>Associated Data Queries</strong>', '100%', '', '3', 'center', '');
        html_header(array('Data Query Name', 'Debugging', 'Re-Index Method', 'Status'), 2);
        $selected_data_queries = db_fetch_assoc_prepared('SELECT
			snmp_query.id,
			snmp_query.name,
			host_snmp_query.reindex_method
			FROM (snmp_query, host_snmp_query)
			WHERE snmp_query.id = host_snmp_query.snmp_query_id
			AND host_snmp_query.host_id = ?
			ORDER BY snmp_query.name', array($_REQUEST['id']));
        $available_data_queries = db_fetch_assoc('SELECT
			snmp_query.id,
			snmp_query.name
			FROM snmp_query
			ORDER BY snmp_query.name');
        $keeper = array();
        foreach ($available_data_queries as $item) {
            if (sizeof(db_fetch_assoc_prepared('SELECT snmp_query_id FROM host_snmp_query WHERE host_id = ? AND snmp_query_id = ?', array($_REQUEST['id'], $item['id']))) > 0) {
                /* do nothing */
            } else {
                array_push($keeper, $item);
            }
        }
        $available_data_queries = $keeper;
        $i = 0;
        if (sizeof($selected_data_queries) > 0) {
            foreach ($selected_data_queries as $item) {
                form_alternate_row('', true);
                /* get status information for this data query */
                $num_dq_items = sizeof(db_fetch_assoc_prepared('SELECT snmp_index FROM host_snmp_cache WHERE host_id = ? AND snmp_query_id = ?', array($_REQUEST['id'], $item['id'])));
                $num_dq_rows = sizeof(db_fetch_assoc_prepared('SELECT snmp_index FROM host_snmp_cache WHERE host_id = ? AND snmp_query_id = ? GROUP BY snmp_index', array($_REQUEST['id'], $item['id'])));
                $status = 'success';
                ?>
					<td style="padding: 4px;">
						<strong><?php 
                print $i;
                ?>
)</strong> <?php 
                print htmlspecialchars($item['name']);
                ?>
					</td>
					<td>
						(<a href="<?php 
                print htmlspecialchars('host.php?action=query_verbose&id=' . $item['id'] . '&host_id=' . $_REQUEST['id']);
                ?>
">Verbose Query</a>)
					</td>
					<td>
					<?php 
                print $reindex_types[$item['reindex_method']];
                ?>
					</td>
					<td>
						<?php 
                print $status == 'success' ? "<span style='color: green;'>Success</span>" : "<span style='color: green;'>Fail</span>";
                ?>
 [<?php 
                print $num_dq_items;
                ?>
 Item<?php 
                print $num_dq_items == 1 ? '' : 's';
                ?>
, <?php 
                print $num_dq_rows;
                ?>
 Row<?php 
                print $num_dq_rows == 1 ? '' : 's';
                ?>
]
					</td>
					<td align='right' nowrap>
						<a href='<?php 
                print htmlspecialchars('host.php?action=query_reload&id=' . $item['id'] . '&host_id=' . $_REQUEST['id']);
                ?>
'><img src='images/reload_icon_small.gif' title='Reload Data Query' alt='Reload Data Query' border='0' align='middle'></a>&nbsp;
						<a href='<?php 
                print htmlspecialchars('host.php?action=query_remove&id=' . $item['id'] . '&host_id=' . $_REQUEST['id']);
                ?>
'><img src='images/delete_icon_large.gif' title='Delete Data Query Association' alt='Delete Data Query Association' border='0' align='middle'></a>
					</td>
				<?php 
                form_end_row();
                $i++;
            }
        } else {
            print "<tr class='tableRow'><td colspan='4'><em>No associated data queries.</em></td></tr>";
        }
        ?>
		<tr class='odd'>
			<td class='saveRow' colspan="5">
				<table cellspacing="0" cellpadding="1" width="100%">
					<td nowrap>Add Data Query:&nbsp;
						<?php 
        form_dropdown('snmp_query_id', $available_data_queries, 'name', 'id', '', '', '');
        ?>
					</td>
					<td nowrap>Re-Index Method:&nbsp;
						<?php 
        form_dropdown('reindex_method', $reindex_types, '', '', read_config_option('reindex_method'), '', '');
        ?>
					</td>
					<td align="right">
						&nbsp;<input type="submit" value="Add" name="add_dq_x" title="Add Data Query to Device">
					</td>
				</table>
				<a name='dqtop'></a>
			</td>
		</tr>

		<?php 
        html_end_box();
    }
    form_save_button('host.php', 'return');
    api_plugin_hook('host_edit_bottom');
}
Example #3
0
function utilities()
{
    html_start_box("<strong>Cacti System Utilities</strong>", "100%", "", "3", "center", "");
    ?>
	<colgroup span="3">
		<col valign="top" width="20%"></col>
		<col valign="top" width="80%"></col>
	</colgroup>

	<?php 
    html_header(array("Technical Support"), 2);
    form_alternate_row();
    ?>
		<td class="textArea">
			<a href='<?php 
    print htmlspecialchars("utilities.php?action=view_tech");
    ?>
'>Technical Support</a>
		</td>
		<td class="textArea">
			Cacti technical support page.  Used by developers and technical support persons to assist with issues in Cacti.  Includes checks for common configuration issues.
		</td>
	</tr>

	<?php 
    html_header(array("Log Administration"), 2);
    form_alternate_row();
    ?>
		<td class="textArea">
			<a href='<?php 
    print htmlspecialchars("utilities.php?action=view_logfile");
    ?>
'>View Cacti Log File</a>
		</td>
		<td class="textArea">
			The Cacti Log File stores statistic, error and other message depending on system settings.  This information can be used to identify problems with the poller and application.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class="textArea">
			<a href='<?php 
    print htmlspecialchars("utilities.php?action=view_user_log");
    ?>
'>View User Log</a>
		</td>
		<td class="textArea">
			Allows Administrators to browse the user log.  Administrators can filter and export the log as well.
		</td>
	</tr>

	<?php 
    html_header(array("Poller Cache Administration"), 2);
    form_alternate_row();
    ?>
		<td class="textArea">
			<a href='<?php 
    print htmlspecialchars("utilities.php?action=view_poller_cache");
    ?>
'>View Poller Cache</a>
		</td>
		<td class="textArea">
			This is the data that is being passed to the poller each time it runs. This data is then in turn executed/interpreted and the results are fed into the rrd files for graphing or the database for display.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class="textArea">
			<a href='<?php 
    print htmlspecialchars("utilities.php?action=view_snmp_cache");
    ?>
'>View SNMP Cache</a>
		</td>
		<td class="textArea">
			The SNMP cache stores information gathered from SNMP queries. It is used by cacti to determine the OID to use when gathering information from an SNMP-enabled host.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class="textArea">
			<a href='<?php 
    print htmlspecialchars("utilities.php?action=clear_poller_cache");
    ?>
'>Rebuild Poller Cache</a>
		</td>
		<td class="textArea">
			The poller cache will be cleared and re-generated if you select this option. Sometimes host/data source data can get out of sync with the cache in which case it makes sense to clear the cache and start over.
		</td>
	</tr>

	<?php 
    api_plugin_hook('utilities_list');
    html_end_box();
}
Example #4
0
function syslog_filter($sql_where, $tab)
{
    global $colors, $config, $graph_timespans, $graph_timeshifts, $reset_multi, $page_refresh_interval;
    include dirname(__FILE__) . "/config.php";
    if (isset($_SESSION["sess_current_date1"])) {
        $filter_text = "</strong> [ Start: '" . $_SESSION["sess_current_date1"] . "' to End: '" . $_SESSION["sess_current_date2"] . "' ]";
    } else {
        $filter_text = "</strong>";
    }
    ?>
	<script type="text/javascript">
	<!--
	// Initialize the calendar
	calendar=null;

	// This function displays the calendar associated to the input field 'id'
	function showCalendar(id) {
		var el = document.getElementById(id);
		if (calendar != null) {
			// we already have some calendar created
			calendar.hide();  // so we hide it first.
		} else {
			// first-time call, create the calendar.
			var cal = new Calendar(true, null, selected, closeHandler);
			cal.weekNumbers = false;  // Do not display the week number
			cal.showsTime = true;     // Display the time
			cal.time24 = true;        // Hours have a 24 hours format
			cal.showsOtherMonths = false;    // Just the current month is displayed
			calendar = cal;                  // remember it in the global var
			cal.setRange(1900, 2070);        // min/max year allowed.
			cal.create();
		}

		calendar.setDateFormat('%Y-%m-%d %H:%M');    // set the specified date format
		calendar.parseDate(el.value);                // try to parse the text in field
		calendar.sel = el;                           // inform it what input field we use

		// Display the calendar below the input field
		calendar.showAtElement(el, "Br");        // show the calendar

		return false;
	}

	// This function update the date in the input field when selected
	function selected(cal, date) {
		cal.sel.value = date;      // just update the date in the input field.
	}

	// This function gets called when the end-user clicks on the 'Close' button.
	// It just hides the calendar without destroying it.
	function closeHandler(cal) {
		cal.hide();                        // hide the calendar
		calendar = null;
	}

	function applyTimespanFilterChange(objForm) {
		strURL = '?predefined_timespan=' + objForm.predefined_timespan.value;
		strURL = strURL + '&predefined_timeshift=' + objForm.predefined_timeshift.value;
		document.location = strURL;
	}
	-->
	</script>
	<form style='margin:0px;padding:0px;' id="syslog_form" name="syslog_form" method="post" action="syslog.php">
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td colspan="2" style="background-color:#EFEFEF;">
				<table width='100%' cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td width='100%'>
							<?php 
    html_start_box("<strong>Syslog Message Filter{$filter_text}", "100%", $colors["header"], "1", "center", "");
    ?>
							<tr bgcolor="<?php 
    print $colors["panel"];
    ?>
" class="noprint">
								<td class="noprint">
									<table cellpadding="0" cellspacing="0" border="0">
										<tr>
											<td nowrap style='white-space: nowrap;' width='60'>
												&nbsp;<strong>Presets:</strong>&nbsp;
											</td>
											<td nowrap style='white-space: nowrap;' width='130'>
												<select name='predefined_timespan' onChange="applyTimespanFilterChange(document.syslog_form)">
													<?php 
    if ($_SESSION["custom"]) {
        $graph_timespans[GT_CUSTOM] = "Custom";
        $_REQUEST["predefined_timespan"] = GT_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 ($_REQUEST["predefined_timespan"] == $value) {
                print " selected";
            }
            print ">" . title_trim($graph_timespans[$value], 40) . "</option>\n";
        }
    }
    ?>
												</select>
											</td>
											<td nowrap style='white-space: nowrap;' width='30'>
												&nbsp;<strong>From:</strong>&nbsp;
											</td>
											<td width='150' nowrap style='white-space: nowrap;'>
												<input type='text' name='date1' id='date1' title='Graph Begin Timestamp' size='14' value='<?php 
    print isset($_SESSION["sess_current_date1"]) ? $_SESSION["sess_current_date1"] : "";
    ?>
'>
												&nbsp;<input style='padding-bottom: 4px;' type='image' src='<?php 
    print $config["url_path"];
    ?>
images/calendar.gif' alt='Start date selector' title='Start date selector' border='0' align='absmiddle' onclick="return showCalendar('date1');">&nbsp;
											</td>
											<td nowrap style='white-space: nowrap;' width='20'>
												&nbsp;<strong>To:</strong>&nbsp;
											</td>
											<td width='150' nowrap style='white-space: nowrap;'>
												<input type='text' name='date2' id='date2' title='Graph End Timestamp' size='14' value='<?php 
    print isset($_SESSION["sess_current_date2"]) ? $_SESSION["sess_current_date2"] : "";
    ?>
'>
												&nbsp;<input style='padding-bottom: 4px;' type='image' src='<?php 
    print $config["url_path"];
    ?>
images/calendar.gif' alt='End date selector' title='End date selector' border='0' align='absmiddle' onclick="return showCalendar('date2');">
											</td>
											<td width='125' nowrap style='white-space: nowrap;'>
												&nbsp;&nbsp;<input style='padding-bottom: 4px;' type='image' name='move_left' src='<?php 
    print $config["url_path"];
    ?>
images/move_left.gif' alt='Left' border='0' align='absmiddle' title='Shift Left'>
												<select name='predefined_timeshift' title='Define Shifting Interval' onChange="applyTimespanFilterChange(document.syslog_form)">
													<?php 
    $start_val = 1;
    $end_val = sizeof($graph_timeshifts) + 1;
    if (sizeof($graph_timeshifts) > 0) {
        for ($shift_value = $start_val; $shift_value < $end_val; $shift_value++) {
            print "<option value='{$shift_value}'";
            if ($_REQUEST["predefined_timeshift"] == $shift_value) {
                print " selected";
            }
            print ">" . title_trim($graph_timeshifts[$shift_value], 40) . "</option>\n";
        }
    }
    ?>
												</select>
												<input style='padding-bottom: 4px;' type='image' name='move_right' src='<?php 
    print $config["url_path"];
    ?>
images/move_right.gif' alt='Right' border='0' align='absmiddle' title='Shift Right'>
											</td>
											<td>
												&nbsp;<input type="submit" value='Go' name='go' title="Go">
											</td>
											<td>
												&nbsp;<input type='submit' value='Clear' name='button_clear_x' title='Return to the default time span'>
											</td>
											<td>
												&nbsp;<input type='submit' value='Export' name='export' title='Export Records to CSV'>
											</td>
											<td>
												<input type='hidden' name='action' value='actions'>
												<input type='hidden' name='syslog_pdt_change' value='false'>
											</td>
										</tr>
									</table>
								</td><?php 
    if (api_plugin_user_realm_auth('syslog_alerts.php')) {
        ?>
								<td align='right' style='white-space:nowrap;'>
									<input type='button' value='Alerts' title='View Syslog Alert Rules' onClick='javascript:document.location="<?php 
        print $config['url_path'] . "plugins/syslog/syslog_alerts.php";
        ?>
"'>
									<input type='button' value='Removals' title='View Syslog Removal Rules' onClick='javascript:document.location="<?php 
        print $config['url_path'] . "plugins/syslog/syslog_removal.php";
        ?>
"'>
									<input type='button' value='Reports' title='View Syslog Reports' onClick='javascript:document.location="<?php 
        print $config['url_path'] . "plugins/syslog/syslog_reports.php";
        ?>
"'>&nbsp;
								</td><?php 
    }
    ?>
							</tr>
						</table>
						<table width="100%" cellpadding="0" cellspacing="0" border="0">
							<tr bgcolor="<?php 
    print $colors["panel"];
    ?>
" class="noprint">
								<td>
									<table cellpadding="0" cellspacing="0">
										<tr>
											<td nowrap style='white-space: nowrap;' width='60'>
												&nbsp;<strong>Search:</strong>
											</td>
											<td style='padding-right:2px;'>
												<input type="text" name="filter" size="30" value="<?php 
    print $_REQUEST["filter"];
    ?>
">
											</td>
											<?php 
    api_plugin_hook('syslog_extend_filter');
    ?>
											<td style='padding-right:2px;'>
												<select name="efacility" onChange="javascript:document.getElementById('syslog_form').submit();" title="Facilities">
													<option value="0"<?php 
    if ($_REQUEST["efacility"] == "0") {
        ?>
 selected<?php 
    }
    ?>
>All Facilities</option>
													<?php 
    if (!isset($hostfilter)) {
        $hostfilter = "";
    }
    $efacilities = syslog_db_fetch_assoc("SELECT DISTINCT f.facility_id, f.facility\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog_host_facilities` AS fh\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN `" . $syslogdb_default . "`.`syslog_facilities` AS f\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON f.facility_id=fh.facility_id " . (strlen($hostfilter) ? "WHERE " : "") . $hostfilter . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY facility");
    if (sizeof($efacilities)) {
        foreach ($efacilities as $efacility) {
            print "<option value=" . $efacility["facility_id"];
            if ($_REQUEST["efacility"] == $efacility["facility_id"]) {
                print " selected";
            }
            print ">" . ucfirst($efacility["facility"]) . "</option>\n";
        }
    }
    ?>
												</select>
											</td>
											<td style='padding-right:2px;'>
												<select name="elevel" onChange="javascript:document.getElementById('syslog_form').submit();" title="Priority Levels">
													<option value="0"<?php 
    if ($_REQUEST["elevel"] == "0") {
        ?>
 selected<?php 
    }
    ?>
>All Priorities</option>
													<option value="1"<?php 
    if ($_REQUEST["elevel"] == "1") {
        ?>
 selected<?php 
    }
    ?>
>Emergency</option>
													<option value="2"<?php 
    if ($_REQUEST["elevel"] == "2") {
        ?>
 selected<?php 
    }
    ?>
>Critical++</option>
													<option value="2o"<?php 
    if ($_REQUEST["elevel"] == "2o") {
        ?>
 selected<?php 
    }
    ?>
>Critical</option>
													<option value="3"<?php 
    if ($_REQUEST["elevel"] == "3") {
        ?>
 selected<?php 
    }
    ?>
>Alert++</option>
													<option value="3o"<?php 
    if ($_REQUEST["elevel"] == "3o") {
        ?>
 selected<?php 
    }
    ?>
>Alert</option>
													<option value="4"<?php 
    if ($_REQUEST["elevel"] == "4") {
        ?>
 selected<?php 
    }
    ?>
>Error++</option>
													<option value="4o"<?php 
    if ($_REQUEST["elevel"] == "4o") {
        ?>
 selected<?php 
    }
    ?>
>Error</option>
													<option value="5"<?php 
    if ($_REQUEST["elevel"] == "5") {
        ?>
 selected<?php 
    }
    ?>
>Warning++</option>
													<option value="5o"<?php 
    if ($_REQUEST["elevel"] == "5o") {
        ?>
 selected<?php 
    }
    ?>
>Warning</option>
													<option value="6"<?php 
    if ($_REQUEST["elevel"] == "6") {
        ?>
 selected<?php 
    }
    ?>
>Notice++</option>
													<option value="6o"<?php 
    if ($_REQUEST["elevel"] == "6o") {
        ?>
 selected<?php 
    }
    ?>
>Notice</option>
													<option value="7"<?php 
    if ($_REQUEST["elevel"] == "7") {
        ?>
 selected<?php 
    }
    ?>
>Info++</option>
													<option value="7o"<?php 
    if ($_REQUEST["elevel"] == "7o") {
        ?>
 selected<?php 
    }
    ?>
>Info</option>
													<option value="8"<?php 
    if ($_REQUEST["elevel"] == "8") {
        ?>
 selected<?php 
    }
    ?>
>Debug</option>
												</select>
											</td>
											<?php 
    if ($_REQUEST["tab"] == "syslog") {
        ?>
											<td style='padding-right:2px;'>
												<select name="removal" onChange="javascript:document.getElementById('syslog_form').submit();" title="Removal Handling">
													<option value="1"<?php 
        if ($_REQUEST["removal"] == "1") {
            ?>
 selected<?php 
        }
        ?>
>All Records</option>
													<option value="-1"<?php 
        if ($_REQUEST["removal"] == "-1") {
            ?>
 selected<?php 
        }
        ?>
>Main Records</option>
													<option value="2"<?php 
        if ($_REQUEST["removal"] == "2") {
            ?>
 selected<?php 
        }
        ?>
>Removed Records</option>
												</select>
											</td>
											<?php 
    }
    ?>
											<td style='padding-right:2px;'>
												<select name="rows" onChange="javascript:document.getElementById('syslog_form').submit();" title="Display Rows">
													<option value="10"<?php 
    if ($_REQUEST["rows"] == "10") {
        ?>
 selected<?php 
    }
    ?>
>10</option>
													<option value="15"<?php 
    if ($_REQUEST["rows"] == "15") {
        ?>
 selected<?php 
    }
    ?>
>15</option>
													<option value="20"<?php 
    if ($_REQUEST["rows"] == "20") {
        ?>
 selected<?php 
    }
    ?>
>20</option>
													<option value="25"<?php 
    if ($_REQUEST["rows"] == "25") {
        ?>
 selected<?php 
    }
    ?>
>25</option>
													<option value="30"<?php 
    if ($_REQUEST["rows"] == "30") {
        ?>
 selected<?php 
    }
    ?>
>30</option>
													<option value="35"<?php 
    if ($_REQUEST["rows"] == "35") {
        ?>
 selected<?php 
    }
    ?>
>35</option>
													<option value="40"<?php 
    if ($_REQUEST["rows"] == "40") {
        ?>
 selected<?php 
    }
    ?>
>40</option>
													<option value="45"<?php 
    if ($_REQUEST["rows"] == "45") {
        ?>
 selected<?php 
    }
    ?>
>45</option>
													<option value="50"<?php 
    if ($_REQUEST["rows"] == "50") {
        ?>
 selected<?php 
    }
    ?>
>50</option>
													<option value="100"<?php 
    if ($_REQUEST["rows"] == "100") {
        ?>
 selected<?php 
    }
    ?>
>100</option>
													<option value="200"<?php 
    if ($_REQUEST["rows"] == "200") {
        ?>
 selected<?php 
    }
    ?>
>200</option>
													<option value="500"<?php 
    if ($_REQUEST["rows"] == "500") {
        ?>
 selected<?php 
    }
    ?>
>500</option>
												</select>
											</td>
											<td style='padding-right:2px;'>
												<select name="trimval" onChange="javascript:document.getElementById('syslog_form').submit();" title="Message Trim">
													<option value="1024"<?php 
    if ($_REQUEST["trimval"] == "1024") {
        ?>
 selected<?php 
    }
    ?>
>All Text</option>
													<option value="30"<?php 
    if ($_REQUEST["trimval"] == "30") {
        ?>
 selected<?php 
    }
    ?>
>30 Chars</option>
													<option value="50"<?php 
    if ($_REQUEST["trimval"] == "50") {
        ?>
 selected<?php 
    }
    ?>
>50 Chars</option>
													<option value="75"<?php 
    if ($_REQUEST["trimval"] == "75") {
        ?>
 selected<?php 
    }
    ?>
>75 Chars</option>
													<option value="100"<?php 
    if ($_REQUEST["trimval"] == "100") {
        ?>
 selected<?php 
    }
    ?>
>100 Chars</option>
													<option value="150"<?php 
    if ($_REQUEST["trimval"] == "150") {
        ?>
 selected<?php 
    }
    ?>
>150 Chars</option>
													<option value="300"<?php 
    if ($_REQUEST["trimval"] == "300") {
        ?>
 selected<?php 
    }
    ?>
>300 Chars</option>
												</select>
											</td>
											<td width="1">
												<select name="refresh" onChange="javascript:document.getElementById('syslog_form').submit();">
													<?php 
    foreach ($page_refresh_interval as $seconds => $display_text) {
        print "<option value='" . $seconds . "'";
        if ($_REQUEST["refresh"] == $seconds) {
            print " selected";
        }
        print ">" . $display_text . "</option>\n";
    }
    ?>
												</select>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<?php 
    html_end_box(false);
    ?>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td valign="top" style="border-right: #aaaaaa 1px solid;" bgcolor='#efefef'>
				<table align="center" cellpadding="1" cellspacing="0" border="0">
					<tr>
						<td>
							<?php 
    html_start_box("", "", $colors["header"], "3", "center", "");
    ?>
							<tr>
								<td class="textHeader" nowrap>
									Select Host(s):&nbsp;
								</td>
							</tr>
							<tr>
								<td>
									<select title="Host Filters" id="host_select" name="host[]" multiple size="20" style="width: 150px; overflow: scroll; height: auto;" onChange="javascript:document.getElementById('syslog_form').submit();">
										<?php 
    if ($tab == "syslog") {
        ?>
<option id="host_all" value="0"<?php 
        if (is_array($_REQUEST["host"]) && $_REQUEST["host"][0] == "0" || $reset_multi) {
            ?>
 selected<?php 
        }
        ?>
>Show All Hosts</option><?php 
    } else {
        ?>
										<option id="host_all" value="0"<?php 
        if (is_array($_REQUEST["host"]) && $_REQUEST["host"][0] == "0" || $reset_multi) {
            ?>
 selected<?php 
        }
        ?>
>Show All Logs</option>
										<option id="host_none" value="-1"<?php 
        if (is_array($_REQUEST["host"]) && $_REQUEST["host"][0] == "-1") {
            ?>
 selected<?php 
        }
        ?>
>Threshold Logs</option><?php 
    }
    ?>
										<?php 
    $hosts_where = "";
    $hosts_where = api_plugin_hook_function('syslog_hosts_where', $hosts_where);
    $hosts = syslog_db_fetch_assoc("SELECT * FROM `" . $syslogdb_default . "`.`syslog_hosts` {$hosts_where} ORDER BY host");
    if (sizeof($hosts)) {
        foreach ($hosts as $host) {
            print "<option value=" . $host["host_id"];
            if (sizeof($_REQUEST["host"])) {
                foreach ($_REQUEST["host"] as $rh) {
                    if ($rh == $host["host_id"] && !$reset_multi) {
                        print " selected";
                        break;
                    }
                }
            } else {
                if ($host["host_id"] == $_REQUEST["host"] && !$reset_multi) {
                    print " selected";
                }
            }
            print ">";
            print $host["host"] . "</option>\n";
        }
    }
    ?>
									</select>
								</td>
							</tr>
							<?php 
    html_end_box(false);
    ?>
						</td>
					</tr>
				</table>
			</td>
			<td width="100%" valign="top" style="padding: 0px;">
				<table width="100%" cellspacing="0" cellpadding="1">
					<tr>
						<td width="100%" valign="top"><?php 
    display_output_messages();
    ?>
							<?php 
    if ($tab == "syslog") {
        if ($_REQUEST["removal"] == 1) {
            $total_rows = syslog_db_fetch_cell("SELECT SUM(totals)\n\t\t\t\t\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\t\t\t\tSELECT count(*) AS totals\n\t\t\t\t\t\t\t\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog` " . $sql_where . "\n\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\tSELECT count(*) AS totals\n\t\t\t\t\t\t\t\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog_removed` " . $sql_where . ") AS rowcount");
        } elseif ($_REQUEST["removal"] == -1) {
            $total_rows = syslog_db_fetch_cell("SELECT count(*) FROM `" . $syslogdb_default . "`.`syslog` " . $sql_where);
        } else {
            $total_rows = syslog_db_fetch_cell("SELECT count(*) FROM `" . $syslogdb_default . "`.`syslog_removed` " . $sql_where);
        }
    } else {
        $total_rows = syslog_db_fetch_cell("SELECT count(*)\n\t\t\t\t\t\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog_logs` AS sl\n\t\t\t\t\t\t\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_facilities` AS sf\n\t\t\t\t\t\t\t\t\tON sl.facility=sf.facility\n\t\t\t\t\t\t\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_priorities` AS sp\n\t\t\t\t\t\t\t\t\tON sl.priority=sp.priority\n\t\t\t\t\t\t\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_hosts` AS sh\n\t\t\t\t\t\t\t\t\tON sl.host=sh.host\n\t\t\t\t\t\t\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_alert` AS sa\n\t\t\t\t\t\t\t\t\tON sl.alert_id=sa.id " . $sql_where);
    }
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $hostarray = "";
    if (is_array($_REQUEST["host"])) {
        foreach ($_REQUEST["host"] as $h) {
            $hostarray .= "host[]={$h}&";
        }
    } else {
        $hostarray .= "host[]=" . $_REQUEST["host"] . "&";
    }
    return $total_rows;
}
Example #5
0
function utilities()
{
    html_start_box('<strong>Cacti System Utilities</strong>', '100%', '', '3', 'center', '');
    ?>
	<colgroup span='3'>
		<col valign='top' width='20%'></col>
		<col valign='top' width='80%'></col>
	</colgroup>

	<?php 
    html_header(array('Technical Support'), 2);
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_tech');
    ?>
'>Technical Support</a>
		</td>
		<td class='textArea'>
			Cacti technical support page.  Used by developers and technical support persons to assist with issues in Cacti.  Includes checks for common configuration issues.
		</td>
	</tr>

	<?php 
    html_header(array('Log Administration'), 2);
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_logfile');
    ?>
'>View Cacti Log File</a>
		</td>
		<td class='textArea'>
			The Cacti Log File stores statistic, error and other message depending on system settings.  This information can be used to identify problems with the poller and application.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_user_log');
    ?>
'>View User Log</a>
		</td>
		<td class='textArea'>
			Allows Administrators to browse the user log.  Administrators can filter and export the log as well.
		</td>
	</tr>

	<?php 
    html_header(array('Poller Cache Administration'), 2);
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_poller_cache');
    ?>
'>View Poller Cache</a>
		</td>
		<td class='textArea'>
			This is the data that is being passed to the poller each time it runs. This data is then in turn executed/interpreted and the results are fed into the rrd files for graphing or the database for display.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_snmp_cache');
    ?>
'>View SNMP Cache</a>
		</td>
		<td class='textArea'>
			The SNMP cache stores information gathered from SNMP queries. It is used by cacti to determine the OID to use when gathering information from an SNMP-enabled host.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=clear_poller_cache');
    ?>
'>Rebuild Poller Cache</a>
		</td>
		<td class='textArea'>
			The poller cache will be cleared and re-generated if you select this option. Sometimes host/data source data can get out of sync with the cache in which case it makes sense to clear the cache and start over.
		</td>
	</tr>
	<?php 
    html_header(array('Boost Utilities'), 2);
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_boost_status');
    ?>
'>View Boost Status</a>
		</td>
		<td class='textArea'>
			This menu pick allows you to view various boost settings and statistics associated with the current running Boost configuration.
		</td>
	</tr>
	<?php 
    html_header(array('RRD Utilities'), 2);
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('rrdcleaner.php');
    ?>
'>RRDfile Cleaner</a>
		</td>
		<td class='textArea'>
			When you delete Data Sources from Cacti, the corresponding RRDfiles are not removed automatically.  Use this utility to facilitate the removal of these old files.
		</td>
	</tr>
	<?php 
    html_header(array('SNMPAgent Utilities'), 2);
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_snmpagent_cache');
    ?>
'>View SNMPAgent Cache</a>
		</td>
		<td class='textArea'>
			This shows all objects being handled by the SNMPAgent.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=rebuild_snmpagent_cache');
    ?>
'>Rebuild SNMPAgent Cache</a>
		</td>
		<td class='textArea'>
			The snmp cache will be cleared and re-generated if you select this option. Note that it takes another poller run to restore the SNMP cache completely.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('utilities.php?action=view_snmpagent_events');
    ?>
'>View SNMPAgent Notification Log</a>
		</td>
		<td class='textArea'>
			This menu pick allows you to view the latest events SNMPAgent has handled in relation to the registered notification receivers.
		</td>
	</tr>
	<?php 
    form_alternate_row();
    ?>
		<td class='textArea'>
			<a href='<?php 
    print htmlspecialchars('managers.php');
    ?>
'>SNMP Notification Receivers</a>
		</td>
		<td class='textArea'>
			Allows Administrators to maintain SNMP notification receivers.
		</td>
	</tr>
	<?php 
    api_plugin_hook('utilities_list');
    html_end_box();
}
Example #6
0
        }
    }
    unset($input);
}
/* include base modules */
include_once $config["library_path"] . "/adodb/adodb.inc.php";
include_once $config["library_path"] . "/database.php";
/* connect to the database server */
db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port, $database_ssl);
/* include additional modules */
include_once $config["library_path"] . "/adodb/adodb.inc.php";
include_once $config["library_path"] . "/database.php";
include_once $config["library_path"] . "/functions.php";
include_once $config["include_path"] . "/global_constants.php";
include_once $config["library_path"] . "/plugins.php";
include_once $config["include_path"] . "/plugins.php";
include_once $config["include_path"] . "/global_arrays.php";
include_once $config["include_path"] . "/global_settings.php";
/* connect to the database server */
db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port, $database_ssl);
/* include additional modules */
include_once $config["include_path"] . "/global_form.php";
include_once $config["library_path"] . "/html.php";
include_once $config["library_path"] . "/html_form.php";
include_once $config["library_path"] . "/html_utility.php";
include_once $config["library_path"] . "/html_validate.php";
include_once $config["library_path"] . "/variables.php";
include_once $config["library_path"] . "/auth.php";
api_plugin_hook("config_insert");
/* current cacti version */
$config["cacti_version"] = "0.8.7i";
Example #7
0
function graphs()
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("host_id"));
    input_validate_input_number(get_request_var_request("graph_type"));
    /* ==================================================== */
    /* clean up search string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear_x"])) {
        kill_session_var("sess_graphs_new_filter");
        unset($_REQUEST["filter"]);
        $changed = true;
    } else {
        /* if any of the settings changed, reset the page number */
        $changed = false;
        $changed += check_changed("host_id", "sess_graphs_new_host_id");
        $changed += check_changed("graph_type", "sess_graphs_new_graph_type");
        $changed += check_changed("filter", "sess_graphs_new_filter");
    }
    load_current_session_value("host_id", "sess_graphs_new_host_id", db_fetch_cell("select id from host order by description,hostname limit 1"));
    load_current_session_value("graph_type", "sess_graphs_new_graph_type", read_config_option("default_graphs_new_dropdown"));
    load_current_session_value("filter", "sess_graphs_new_filter", "");
    $host = db_fetch_row("select id,description,hostname,host_template_id from host where id=" . $_REQUEST["host_id"]);
    $row_limit = read_config_option("num_rows_data_query");
    $debug_log = debug_log_return("new_graphs");
    $header = " [ " . htmlspecialchars($host["description"]) . " (" . htmlspecialchars($host["hostname"]) . ") " . (!empty($host["host_template_id"]) ? htmlspecialchars(db_fetch_cell("select name from host_template where id=" . $host["host_template_id"])) : '') . " ]";
    html_start_box("<strong>New Graphs for</strong> {$header}", "100%", "", "3", "center", "");
    form_alternate_row();
    print "<td>";
    if (!empty($debug_log)) {
        debug_log_clear("new_graphs");
        if (read_config_option("cacti_popup_messages") == "on") {
            ?>
		<div id='message'>
			<?php 
            print "<table align='center' class='cactiTable' width='100%'><tr><td style='align:center;padding:3px;font-weight:bold;font-size:10pt;text-align:center;'>Graphs Created</td><td style='width:1px;align:right;'><input type='button' value='Clear' onClick='javascript:document.getElementById(\"message\").style.display=\"none\"' style='align=right;'></td></tr></table>";
            ?>
			<?php 
            print "<table align='left' style='width:100%;'><tr><td><ul style='text-align:left;white-space:nowrap;color:#000000;padding:2px 10px;margin:10px;'>" . $debug_log . "</ul></td></tr></table>";
            ?>
		</div>
		<?php 
        } else {
            ?>
		<table width='100%' class='textArea' align='center'>
			<tr class='even'>
				<td style="padding: 3px; font-family: monospace;">
					<ul style='margin:0px 5px;padding-left:10px'><?php 
            print $debug_log;
            ?>
</ul>
				</td>
			</tr>
		</table>
		<br><?php 
        }
    }
    ?>
	<script type="text/javascript">
	<!--
	<?php 
    if (read_config_option("cacti_popup_messages") == "on") {
        ?>
	var obj = document.getElementById('message');

	if (obj) {
		if (window.innerHeight) {
			height = window.innerHeight;
			width  = window.innerWidth;
		}else{
			height = document.body.clientHeight;
			width  = document.body.clientWidth;
		}
		obj.style.class = "popupBox";
		cw = obj.offsetWidth;
		// Adjust for IE6
		if (!cw) cw = 150;
		ch = obj.offsetHeight;
		obj.style.top = '65px';
		obj.style.left = ((width/2) - (cw/2) - 88)+'px';
	}
	<?php 
    }
    ?>

	function applyGraphsNewFilterChange(objForm) {
		strURL = '?graph_type=' + objForm.graph_type.value;
		strURL = strURL + '&host_id=' + objForm.host_id.value;
		strURL = strURL + '&filter=' + objForm.filter.value;;
		document.location = strURL;
	}

	-->
	</script>
	<form name="form_graphs_new" action="graphs_new.php">
	<table width="100%" class="textHeader" cellpadding="2" align="left">
		<tr>
			<td width="55" valign='top'>
				Host:
			</td>
			<td width="1" valign='top'>
				<select name="host_id" onChange="applyGraphsNewFilterChange(document.form_graphs_new)">
				<?php 
    $hosts = db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname");
    if (sizeof($hosts) > 0) {
        foreach ($hosts as $item) {
            print "<option value='" . $item["id"] . "'";
            if ($_REQUEST["host_id"] == $item["id"]) {
                print " selected";
            }
            print ">" . htmlspecialchars($item["name"]) . "</option>\n";
        }
    }
    ?>
				</select>
			</td>
			<td style='white-space:nowrap;' valign='top' width="100">
				Graph Types:
			</td>
			<td width="1" valign='top'>
				<select name="graph_type" onChange="applyGraphsNewFilterChange(document.form_graphs_new)">
				<option value="-2"<?php 
    if ($_REQUEST["graph_type"] == "-2") {
        ?>
 selected<?php 
    }
    ?>
>All</option>
				<option value="-1"<?php 
    if ($_REQUEST["graph_type"] == "-1") {
        ?>
 selected<?php 
    }
    ?>
>Graph Template Based</option>
				<?php 
    $snmp_queries = db_fetch_assoc("SELECT\n\t\t\t\t\tsnmp_query.id,\n\t\t\t\t\tsnmp_query.name,\n\t\t\t\t\tsnmp_query.xml_path\n\t\t\t\t\tFROM (snmp_query,host_snmp_query)\n\t\t\t\t\tWHERE host_snmp_query.snmp_query_id=snmp_query.id\n\t\t\t\t\tAND host_snmp_query.host_id=" . $host["id"] . "\n\t\t\t\t\tORDER BY snmp_query.name");
    if (sizeof($snmp_queries) > 0) {
        foreach ($snmp_queries as $query) {
            print "<option value='" . $query["id"] . "'";
            if ($_REQUEST["graph_type"] == $query["id"]) {
                print " selected";
            }
            print ">" . $query["name"] . "</option>\n";
        }
    }
    ?>
				</select>
			</td>
			<td rowspan="2" class="textInfo" align="right" valign="top">
				<span class="linkMarker">*</span><a href="<?php 
    print htmlspecialchars("host.php?action=edit&id=" . $_REQUEST["host_id"]);
    ?>
">Edit this Host</a><br>
				<span class="linkMarker">*</span><a href="<?php 
    print htmlspecialchars("host.php?action=edit");
    ?>
">Create New Host</a><br>
				<?php 
    api_plugin_hook('graphs_new_top_links');
    ?>
			</td>
		</tr>
	<?php 
    if ($_REQUEST["graph_type"] > 0) {
        ?>
		<tr>
			<td width="55" valign='top'>
				Search:
			</td>
			<td valign='top'>
				<input type="text" name="filter" size="30" value="<?php 
        print htmlspecialchars(get_request_var_request("filter"));
        ?>
">
			</td>
			<td colspan='2' valign='top'>
				<input type="submit" value="Go" title="Set/Refresh Filters">
				<input type="submit" name="clear_x" value="Clear" title="Clear Filters">
			</td>
		</tr>
	<?php 
    } else {
        form_hidden_box("filter", $_REQUEST["filter"], "");
    }
    ?>
	</table>
	</form>
	</td>
	</tr>

	<?php 
    html_end_box();
    ?>

	<form name="chk" method="post" action="graphs_new.php">
	<?php 
    $total_rows = sizeof(db_fetch_assoc("select graph_template_id from host_graph where host_id=" . $_REQUEST["host_id"]));
    $i = 0;
    if ($changed) {
        foreach ($snmp_queries as $query) {
            kill_session_var("sess_graphs_new_page" . $query["id"]);
            unset($_REQUEST["page" . $query["id"]]);
            load_current_session_value("page" . $query["id"], "sess_graphs_new_page" . $query["id"], "1");
        }
    }
    if ($_REQUEST["graph_type"] > 0) {
        load_current_session_value("page" . $_REQUEST["graph_type"], "sess_graphs_new_page" . $_REQUEST["graph_type"], "1");
    } else {
        if ($_REQUEST["graph_type"] == -2) {
            foreach ($snmp_queries as $query) {
                load_current_session_value("page" . $query["id"], "sess_graphs_new_page" . $query["id"], "1");
            }
        }
    }
    $script = "<script type='text/javascript'>\nvar gt_created_graphs = new Array();\nvar created_graphs = new Array()\n";
    if ($_REQUEST["graph_type"] < 0) {
        html_start_box("<strong>Graph Templates</strong>", "100%", "", "3", "center", "");
        print "<tr class='tableHeader'>\n\t\t\t\t<td class='tableSubHeaderColumn'>Graph Template Name</td>\n\t\t\t\t<td width='1%' align='center' class='tableSubHeaderCheckbox' style='" . get_checkbox_style() . "'><input type='checkbox' style='margin: 0px;' name='all_cg' title='Select All' onClick='SelectAll(\"cg\",this.checked);gt_update_selection_indicators();'></td>\n\n\t\t\t</tr>\n";
        $graph_templates = db_fetch_assoc("SELECT\n\t\t\tgraph_templates.id AS graph_template_id,\n\t\t\tgraph_templates.name AS graph_template_name\n\t\t\tFROM (host_graph,graph_templates)\n\t\t\tWHERE host_graph.graph_template_id=graph_templates.id\n\t\t\tAND host_graph.host_id=" . $_REQUEST["host_id"] . "\n\t\t\tORDER BY graph_templates.name");
        $template_graphs = db_fetch_assoc("SELECT\n\t\t\tgraph_local.graph_template_id\n\t\t\tFROM (graph_local,host_graph)\n\t\t\tWHERE graph_local.graph_template_id=host_graph.graph_template_id\n\t\t\tAND graph_local.host_id=host_graph.host_id\n\t\t\tAND graph_local.host_id=" . $host["id"] . "\n\t\t\tGROUP BY graph_local.graph_template_id");
        if (sizeof($template_graphs) > 0) {
            $script .= "var gt_created_graphs = new Array(";
            $cg_ctr = 0;
            foreach ($template_graphs as $template_graph) {
                $script .= ($cg_ctr > 0 ? "," : "") . "'" . $template_graph["graph_template_id"] . "'";
                $cg_ctr++;
            }
            $script .= ")\n";
        }
        /* create a row for each graph template associated with the host template */
        if (sizeof($graph_templates) > 0) {
            foreach ($graph_templates as $graph_template) {
                $query_row = $graph_template["graph_template_id"];
                print "<tr id='gt_line{$query_row}' class='" . ($i % 2 == 0 ? "odd" : "even") . "'>";
                $i++;
                print "\t\t<td onClick='gt_select_line(" . $graph_template["graph_template_id"] . ");'>\n\t\t\t\t\t\t<span id='gt_text{$query_row}" . "_0'><strong>Create:</strong> " . htmlspecialchars($graph_template["graph_template_name"]) . "</span>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td align='right'>\n\t\t\t\t\t\t<input type='checkbox' name='cg_{$query_row}' id='cg_{$query_row}' onClick='gt_update_selection_indicators();'>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>";
            }
        }
        $script .= "gt_update_deps(1);\n";
        $available_graph_templates = db_fetch_assoc("SELECT\n\t\t\tgraph_templates.id, graph_templates.name\n\t\t\tFROM snmp_query_graph RIGHT JOIN graph_templates\n\t\t\tON (snmp_query_graph.graph_template_id = graph_templates.id)\n\t\t\tWHERE (((snmp_query_graph.name) Is Null)) ORDER BY graph_templates.name");
        /* create a row at the bottom that lets the user create any graph they choose */
        print "\t<tr class='" . ($i % 2 == 0 ? "odd" : "even") . "'>\n\t\t\t\t<td colspan='2' width='60' nowrap>\n\t\t\t\t\t<strong>Create:</strong>&nbsp;";
        form_dropdown("cg_g", $available_graph_templates, "name", "id", "", "(Select a graph type to create)", "", "textArea");
        print "\t\t</td>\n\t\t\t</tr>";
        html_end_box();
    }
    if ($_REQUEST["graph_type"] != -1) {
        $snmp_queries = db_fetch_assoc("SELECT\n\t\t\tsnmp_query.id,\n\t\t\tsnmp_query.name,\n\t\t\tsnmp_query.xml_path\n\t\t\tFROM (snmp_query,host_snmp_query)\n\t\t\tWHERE host_snmp_query.snmp_query_id=snmp_query.id\n\t\t\tAND host_snmp_query.host_id=" . $host["id"] . ($_REQUEST["graph_type"] != -2 ? " AND snmp_query.id=" . $_REQUEST["graph_type"] : '') . "\n\t\t\tORDER BY snmp_query.name");
        if (sizeof($snmp_queries) > 0) {
            foreach ($snmp_queries as $snmp_query) {
                unset($total_rows);
                if (!$changed) {
                    $page = $_REQUEST["page" . $snmp_query["id"]];
                } else {
                    $page = 1;
                }
                $xml_array = get_data_query_array($snmp_query["id"]);
                $num_input_fields = 0;
                $num_visible_fields = 0;
                if ($xml_array != false) {
                    /* loop through once so we can find out how many input fields there are */
                    reset($xml_array["fields"]);
                    while (list($field_name, $field_array) = each($xml_array["fields"])) {
                        if ($field_array["direction"] == "input") {
                            $num_input_fields++;
                            if (!isset($total_rows)) {
                                $total_rows = db_fetch_cell("SELECT count(*) FROM host_snmp_cache WHERE host_id=" . $host["id"] . " and snmp_query_id=" . $snmp_query["id"] . " AND field_name='{$field_name}'");
                            }
                        }
                    }
                }
                if (!isset($total_rows)) {
                    $total_rows = 0;
                }
                $snmp_query_graphs = db_fetch_assoc("SELECT snmp_query_graph.id,snmp_query_graph.name FROM snmp_query_graph WHERE snmp_query_graph.snmp_query_id=" . $snmp_query["id"] . " ORDER BY snmp_query_graph.name");
                if (sizeof($snmp_query_graphs) > 0) {
                    foreach ($snmp_query_graphs as $snmp_query_graph) {
                        $created_graphs = db_fetch_assoc("SELECT DISTINCT\n\t\t\t\t\t\tdata_local.snmp_index\n\t\t\t\t\t\tFROM (data_local,data_template_data)\n\t\t\t\t\t\tLEFT JOIN data_input_data ON (data_template_data.id=data_input_data.data_template_data_id)\n\t\t\t\t\t\tLEFT JOIN data_input_fields ON (data_input_data.data_input_field_id=data_input_fields.id)\n\t\t\t\t\t\tWHERE data_local.id=data_template_data.local_data_id\n\t\t\t\t\t\tAND data_input_fields.type_code='output_type'\n\t\t\t\t\t\tAND data_input_data.value='" . $snmp_query_graph["id"] . "'\n\t\t\t\t\t\tAND data_local.host_id=" . $host["id"]);
                        $script .= "created_graphs[" . $snmp_query_graph["id"] . "] = new Array(";
                        $cg_ctr = 0;
                        if (sizeof($created_graphs) > 0) {
                            foreach ($created_graphs as $created_graph) {
                                $script .= ($cg_ctr > 0 ? "," : "") . "'" . encode_data_query_index($created_graph["snmp_index"]) . "'";
                                $cg_ctr++;
                            }
                        }
                        $script .= ")\n";
                    }
                }
                print "\t<table width='100%' class='cactiTable' align='center' cellpadding='3' cellspacing='0'>\n\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='" . ($num_input_fields + 1) . "'>\n\t\t\t\t\t\t\t<table  cellspacing='0' cellpadding='0' width='100%' >\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t\t<strong>Data Query</strong> [" . $snmp_query["name"] . "]\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td align='right' nowrap>\n\t\t\t\t\t\t\t\t\t\t<a href='" . htmlspecialchars("graphs_new.php?action=query_reload&id=" . $snmp_query["id"] . "&host_id=" . $host["id"]) . "'><img src='images/reload_icon_small.gif' title='Reload Associated Query' alt='' border='0' align='middle'></a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
                if ($xml_array != false) {
                    $html_dq_header = "";
                    $snmp_query_indexes = array();
                    reset($xml_array["fields"]);
                    /* if there is a where clause, get the matching snmp_indexes */
                    $sql_where = "";
                    if (strlen($_REQUEST["filter"])) {
                        $sql_where = "";
                        $indexes = db_fetch_assoc("SELECT DISTINCT snmp_index\n\t\t\t\t\t\tFROM host_snmp_cache\n\t\t\t\t\t\tWHERE field_value LIKE '%%" . $_REQUEST["filter"] . "%%'\n\t\t\t\t\t\tAND snmp_query_id=" . $snmp_query["id"] . "\n\t\t\t\t\t\tAND host_id=" . $host["id"]);
                        if (sizeof($indexes)) {
                            foreach ($indexes as $index) {
                                if (strlen($sql_where)) {
                                    $sql_where .= ", '" . $index["snmp_index"] . "'";
                                } else {
                                    $sql_where .= " AND snmp_index IN('" . $index["snmp_index"] . "'";
                                }
                            }
                            $sql_where .= ")";
                        }
                    }
                    if (strlen($_REQUEST["filter"]) == 0 || strlen($_REQUEST["filter"]) && sizeof($indexes)) {
                        /* determine the sort order */
                        if (isset($xml_array["index_order_type"])) {
                            if ($xml_array["index_order_type"] == "numeric") {
                                $sql_order = "ORDER BY CAST(snmp_index AS unsigned)";
                            } else {
                                if ($xml_array["index_order_type"] == "alphabetic") {
                                    $sql_order = "ORDER BY snmp_index";
                                } else {
                                    if ($xml_array["index_order_type"] == "natural") {
                                        $sql_order = "ORDER BY INET_ATON(snmp_index)";
                                    } else {
                                        $sql_order = "";
                                    }
                                }
                            }
                        } else {
                            $sql_order = "";
                        }
                        /* get the unique field values from the database */
                        $field_names = db_fetch_assoc("SELECT DISTINCT field_name\n\t\t\t\t\t\tFROM host_snmp_cache\n\t\t\t\t\t\tWHERE host_id=" . $host["id"] . "\n\t\t\t\t\t\tAND snmp_query_id=" . $snmp_query["id"]);
                        /* build magic query */
                        $sql_query = "SELECT host_id, snmp_query_id, snmp_index";
                        $num_visible_fields = sizeof($field_names);
                        $i = 0;
                        if (sizeof($field_names) > 0) {
                            foreach ($field_names as $column) {
                                $field_name = $column["field_name"];
                                $sql_query .= ", MAX(CASE WHEN field_name='{$field_name}' THEN field_value ELSE NULL END) AS '{$field_name}'";
                                $i++;
                            }
                        }
                        $sql_query .= " FROM host_snmp_cache\n\t\t\t\t\t\tWHERE host_id=" . $host["id"] . "\n\t\t\t\t\t\tAND snmp_query_id=" . $snmp_query["id"] . "\n\t\t\t\t\t\t{$sql_where}\n\t\t\t\t\t\tGROUP BY host_id, snmp_query_id, snmp_index\n\t\t\t\t\t\t{$sql_order}\n\t\t\t\t\t\tLIMIT " . $row_limit * ($page - 1) . "," . $row_limit;
                        $rows_query = "SELECT host_id, snmp_query_id, snmp_index\n\t\t\t\t\t\tFROM host_snmp_cache\n\t\t\t\t\t\tWHERE host_id=" . $host["id"] . "\n\t\t\t\t\t\tAND snmp_query_id=" . $snmp_query["id"] . "\n\t\t\t\t\t\t{$sql_where}\n\t\t\t\t\t\tGROUP BY host_id, snmp_query_id, snmp_index";
                        $snmp_query_indexes = db_fetch_assoc($sql_query);
                        $total_rows = sizeof(db_fetch_assoc($rows_query));
                        if (($page - 1) * $row_limit > $total_rows) {
                            $page = 1;
                            $_REQUEST["page" . $query["id"]] = $page;
                            load_current_session_value("page" . $query["id"], "sess_graphs_new_page" . $query["id"], "1");
                        }
                        $nav = html_nav_bar("graphs_new.php", MAX_DISPLAY_PAGES, $page, $row_limit, $total_rows, 15, "Items", "page" . $snmp_query["id"]);
                        print $nav;
                        while (list($field_name, $field_array) = each($xml_array["fields"])) {
                            if ($field_array["direction"] == "input") {
                                foreach ($field_names as $row) {
                                    if ($row["field_name"] == $field_name) {
                                        $html_dq_header .= "<td class='tableSubHeaderColumn'>" . $field_array["name"] . "</td>\n";
                                        break;
                                    }
                                }
                            }
                        }
                        if (!sizeof($snmp_query_indexes)) {
                            print "<tr class='odd'><td>This data query returned 0 rows, perhaps there was a problem executing this\n\t\t\t\t\t\t\tdata query. You can <a href='" . htmlspecialchars("host.php?action=query_verbose&id=" . $snmp_query["id"] . "&host_id=" . $host["id"]) . "'>run this data\n\t\t\t\t\t\t\tquery in debug mode</a> to get more information.</td></tr>\n";
                        } else {
                            print "<tr class='tableHeader'>\n\t\t\t\t\t\t\t\t{$html_dq_header}\n\t\t\t\t\t\t\t\t<td width='1%' align='center' class='tableSubHeaderCheckbox' style='" . get_checkbox_style() . "'><input type='checkbox' style='margin: 0px;' name='all_" . $snmp_query["id"] . "' title='Select All' onClick='SelectAll(\"sg_" . $snmp_query["id"] . "\",this.checked);dq_update_selection_indicators();'></td>\n\n\t\t\t\t\t\t\t</tr>\n";
                        }
                        $row_counter = 0;
                        $column_counter = 0;
                        $fields = array_rekey($field_names, "field_name", "field_name");
                        if (sizeof($snmp_query_indexes) > 0) {
                            foreach ($snmp_query_indexes as $row) {
                                $query_row = $snmp_query["id"] . "_" . encode_data_query_index($row["snmp_index"]);
                                print "<tr id='line{$query_row}' class='" . ($row_counter % 2 == 0 ? "odd" : "even") . "'>";
                                $i++;
                                $column_counter = 0;
                                reset($xml_array["fields"]);
                                while (list($field_name, $field_array) = each($xml_array["fields"])) {
                                    if ($field_array["direction"] == "input") {
                                        if (in_array($field_name, $fields)) {
                                            if (isset($row[$field_name])) {
                                                print "<td onClick='dq_select_line(" . $snmp_query["id"] . ",\"" . encode_data_query_index($row["snmp_index"]) . "\");'><span id='text{$query_row}" . "_" . $column_counter . "'>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $row[$field_name]) : $row[$field_name]) . "</span></td>";
                                            } else {
                                                print "<td onClick='dq_select_line(" . $snmp_query["id"] . ",\"" . encode_data_query_index($row["snmp_index"]) . "\");'><span id='text{$query_row}" . "_" . $column_counter . "'></span></td>";
                                            }
                                            $column_counter++;
                                        }
                                    }
                                }
                                print "<td align='right'>";
                                print "<input type='checkbox' name='sg_{$query_row}' id='sg_{$query_row}' onClick='dq_update_selection_indicators();'>";
                                print "</td>";
                                print "</tr>\n";
                                $row_counter++;
                            }
                        }
                        if ($total_rows > $row_limit) {
                            print $nav;
                        }
                    } else {
                        print "<tr class='odd'><td colspan='2' style='color: red; font-size: 12px; font-weight: bold;'>Search Returned no Rows.</td></tr>\n";
                    }
                } else {
                    print "<tr class='odd'><td colspan='2' style='color: red; font-size: 12px; font-weight: bold;'>Error in data query.</td></tr>\n";
                }
                print "</table>";
                /* draw the graph template drop down here */
                $data_query_graphs = db_fetch_assoc("select snmp_query_graph.id,snmp_query_graph.name from snmp_query_graph where snmp_query_graph.snmp_query_id=" . $snmp_query["id"] . " order by snmp_query_graph.name");
                if (sizeof($data_query_graphs) == 1) {
                    echo "<input type='hidden' id='sgg_" . $snmp_query["id"] . "' name='sgg_" . $snmp_query["id"] . "' value='" . $data_query_graphs[0]["id"] . "'>\n";
                } elseif (sizeof($data_query_graphs) > 1) {
                    print "\t<table align='center' width='100%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width='1' valign='top'>\n\t\t\t\t\t\t\t\t<img src='images/arrow.gif' alt=''>&nbsp;\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td align='right'>\n\t\t\t\t\t\t\t\t<span style='font-size: 12px; font-style: italic;'>Select a graph type:</span>&nbsp;\n\t\t\t\t\t\t\t\t<select name='sgg_" . $snmp_query["id"] . "' id='sgg_" . $snmp_query["id"] . "' onChange='dq_update_deps(" . $snmp_query["id"] . "," . (isset($column_counter) ? $column_counter : "") . ");'>\n\t\t\t\t\t\t\t\t\t";
                    html_create_list($data_query_graphs, "name", "id", "0");
                    print "\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>";
                }
                print "<br>";
                $script .= "dq_update_deps(" . $snmp_query["id"] . "," . $num_visible_fields . ");\n";
            }
        }
    }
    if (strlen($script)) {
        $script .= "</script>\n";
        print $script;
    }
    form_hidden_box("save_component_graph", "1", "");
    form_hidden_box("host_id", $host["id"], "0");
    form_hidden_box("host_template_id", $host["host_template_id"], "0");
    if (isset($_SERVER["HTTP_REFERER"]) && !substr_count($_SERVER["HTTP_REFERER"], "graphs_new")) {
        $_REQUEST["returnto"] = basename($_SERVER["HTTP_REFERER"]);
    }
    load_current_session_value("returnto", "sess_graphs_new_returnto", "");
    form_save_button($_REQUEST["returnto"]);
    print "<script type='text/javascript'>dq_update_selection_indicators();</script>\n";
    print "<script type='text/javascript'>gt_update_selection_indicators();</script>\n";
}
Example #8
0
 | Cacti: The Complete RRDTool-based Graphing Solution                     |
 +-------------------------------------------------------------------------+
 | This code is designed, written, and maintained by the Cacti Group. See  |
 | about.php and/or the AUTHORS file for specific developer information.   |
 +-------------------------------------------------------------------------+
 | http://www.cacti.net/                                                   |
 +-------------------------------------------------------------------------+
*/
include './include/auth.php';
global $config;
api_plugin_hook('logout_pre_session_destroy');
/* Clear session */
setcookie(session_name(), '', time() - 3600, '/');
session_destroy();
$version = db_fetch_cell('SELECT cacti FROM version');
api_plugin_hook('logout_post_session_destroy');
/* Check to see if we are using Web Basic Auth */
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'timeout') {
    print "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n";
    print "<html>\n";
    print "<head>\n";
    print "\t<title>Logout of Cacti</title>\n";
    print "\t<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>\n";
    print "\t<link href='" . $config['url_path'] . "include/themes/" . read_config_option('selected_theme') . "/main.css' type='text/css' rel='stylesheet'>\n";
    print "\t<link href='" . $config['url_path'] . "include/themes/" . read_config_option('selected_theme') . "/jquery-ui.css' type='text/css' rel='stylesheet'>\n";
    print "\t<link href='" . $config['url_path'] . "images/favicon.ico' rel='shortcut icon'>\n";
    print "\t<script type='text/javascript' src='" . $config['url_path'] . "include/js/jquery.js' language='javascript'></script>\n";
    print "\t<script type='text/javascript' src='" . $config['url_path'] . "include/js/jquery-ui.js' language='javascript'></script>\n";
    print "\t<script type='text/javascript' src='" . $config['url_path'] . "include/js/jquery.cookie.js' language='javascript'></script>\n";
    print "\t<script type='text/javascript' src='" . $config['url_path'] . "include/js/jquery.hotkeys.js'></script>\n";
    print "\t<script type='text/javascript' src='" . $config['url_path'] . "include/layout.js'></script>\n";
Example #9
0
function draw_login_status($using_guest_account = false)
{
    global $config;
    $guest_account = db_fetch_cell_prepared('SELECT id FROM user_auth WHERE username = ?', array(read_config_option('guest_user')));
    $auth_method = read_config_option('auth_method');
    if (isset($_SESSION['sess_user_id']) && $_SESSION['sess_user_id'] == $guest_account) {
        api_plugin_hook('nav_login_before');
        print "Logged in as <span id='user' class='user usermenuup'>guest</span></div><div><ul class='menuoptions' style='display:none;'><li><a href='" . $config['url_path'] . "index.php'>Login as Regular User</a></li></ul>\n";
        api_plugin_hook('nav_login_after');
        print "</div>\n";
    } elseif (isset($_SESSION['sess_user_id']) && $using_guest_account == false) {
        api_plugin_hook('nav_login_before');
        print "Logged in as <span id='user' class='user usermenuup'>" . db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id'])) . "</span></div><div><ul class='menuoptions' style='display:none;'>" . (is_realm_allowed(20) ? "<li><a href='" . $config['url_path'] . "auth_profile.php?action=edit'>Edit Profile</a></li>" : "") . ($auth_method == 1 ? "<li><a href='" . $config['url_path'] . "auth_changepassword.php'>Change Password</a></li>" : '') . ($auth_method > 0 ? "<li><a href='" . $config['url_path'] . "logout.php'>Logout</a></li>" : "") . "</ul>\n";
        api_plugin_hook('nav_login_after');
        print "</div>\n";
    }
}
Example #10
0
if (read_config_option("auth_method") == "3" || api_plugin_hook_function('login_realms_exist')) {
    $realms = api_plugin_hook_function('login_realms', array("local" => array("name" => "Local", "selected" => false), "ldap" => array("name" => "LDAP", "selected" => true)));
    ?>
		<tr id="realm_row">
			<td>Realm:</td>
			<td>
				<select name="realm" style="width: 295px;"><?php 
    if (sizeof($realms)) {
        foreach ($realms as $name => $realm) {
            print "\t\t\t\t\t<option value='" . $name . "'" . ($realm["selected"] ? " selected" : "") . ">" . htmlspecialchars($realm["name"], ENT_QUOTES) . "</option>\n";
        }
    }
    ?>
				</select>
			</td>
		</tr>
		<?php 
}
?>
		<tr style="height:10px;"><td></td></tr>
		<tr>
			<td><input type="submit" value="Login"></td>
		</tr>
	</table>
<?php 
api_plugin_hook('login_after');
?>
	</form>
</body>
</html>
Example #11
0
function mikrotik_graph_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "", $columns = 2, $thumbnails = "true")
{
    global $config;
    if ($thumbnails == "true" || $thumbnails == "on") {
        $th_option = "&graph_nolegend=true&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width");
    } else {
        $th_option = "";
    }
    $i = 0;
    $k = 0;
    if (sizeof($graph_array) > 0) {
        if ($header != "") {
            print $header;
        }
        print "<tr>";
        foreach ($graph_array as $graph) {
            ?>
			<td align='center' width='<?php 
            print 98 / $columns;
            ?>
%'>
				<table width='1' cellpadding='0'>
					<tr>
						<td>
							<a href='<?php 
            print htmlspecialchars($config['url_path'] . "graph.php?action=view&rra_id=all&local_graph_id=" . $graph["local_graph_id"]);
            ?>
'><img class='graphimage' id='graph_<?php 
            print $graph["local_graph_id"];
            ?>
' src='<?php 
            print $config['url_path'];
            ?>
graph_image.php?local_graph_id=<?php 
            print $graph["local_graph_id"] . "&rra_id=0" . $th_option . ($extra_url_args == "" ? "" : "&{$extra_url_args}");
            ?>
' border='0' alt='<?php 
            print $graph["title_cache"];
            ?>
'></a>
						</td>
						<td valign='top' style='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='#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>
							<?php 
            api_plugin_hook('graph_buttons', array('hook' => 'thumbnails', 'local_graph_id' => $graph["local_graph_id"], 'rra' => 0, 'view_type' => ''));
            ?>
						</td>
					</tr>
				</table>
			</td>
			<?php 
            $i++;
            $k++;
            if ($i == $columns && $k < count($graph_array)) {
                $i = 0;
                print "</tr><tr>";
            }
        }
        print "</tr>";
    } else {
        if ($no_graphs_message != "") {
            print "<td><em>{$no_graphs_message}</em></td>";
        }
    }
}
Example #12
0
function host_edit()
{
    global $colors, $fields_host_edit, $reindex_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    /* ==================================================== */
    /* modify for multi user start */
    if (!check_host($_GET["id"])) {
        $_GET["id"] = "";
    }
    /* modify for multi user end */
    api_plugin_hook('host_edit_top');
    if (!empty($_GET["id"])) {
        $host = db_fetch_row("select * from host where id=" . $_GET["id"]);
        $header_label = "[edit: " . htmlspecialchars($host["description"]) . "]";
    } else {
        $header_label = "[new]";
    }
    if (!empty($host["id"])) {
        ?>
		<table width="100%" align="center">
			<tr>
				<td class="textInfo" colspan="2">
					<?php 
        print htmlspecialchars($host["description"]);
        ?>
 (<?php 
        print htmlspecialchars($host["hostname"]);
        ?>
)
				</td>
			</tr>
			<tr>
				<td class="textHeader">
				<?php 
        if ($host["availability_method"] == AVAIL_SNMP || $host["availability_method"] == AVAIL_SNMP_GET_NEXT || $host["availability_method"] == AVAIL_SNMP_GET_SYSDESC || $host["availability_method"] == AVAIL_SNMP_AND_PING || $host["availability_method"] == AVAIL_SNMP_OR_PING) {
            ?>
					SNMP Information<br>

					<span style="font-size: 10px; font-weight: normal; font-family: monospace;">
					<?php 
            if ($host["snmp_community"] == "" && $host["snmp_username"] == "" || $host["snmp_version"] == 0) {
                print "<span style='color: #ab3f1e; font-weight: bold;'>SNMP not in use</span>\n";
            } else {
                $snmp_system = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.1.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                /* modify for some system descriptions */
                /* 0000937: System output in host.php poor for Alcatel */
                if (substr_count($snmp_system, "00:")) {
                    $snmp_system = str_replace("00:", "", $snmp_system);
                    $snmp_system = str_replace(":", " ", $snmp_system);
                }
                if ($snmp_system == "") {
                    print "<span style='color: #ff0000; font-weight: bold;'>SNMP error</span>\n";
                } else {
                    $snmp_uptime = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.3.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    $snmp_hostname = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.5.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    $snmp_location = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.6.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    $snmp_contact = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.4.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_auth_protocol"], $host["snmp_priv_passphrase"], $host["snmp_priv_protocol"], $host["snmp_context"], $host["snmp_port"], $host["snmp_timeout"], read_config_option("snmp_retries"), SNMP_WEBUI);
                    print "<strong>System:</strong>" . html_split_string($snmp_system) . "<br>\n";
                    $days = intval($snmp_uptime / (60 * 60 * 24 * 100));
                    $remainder = $snmp_uptime % (60 * 60 * 24 * 100);
                    $hours = intval($remainder / (60 * 60 * 100));
                    $remainder = $remainder % (60 * 60 * 100);
                    $minutes = intval($remainder / (60 * 100));
                    print "<strong>Uptime:</strong> {$snmp_uptime}";
                    print "&nbsp;({$days} days, {$hours} hours, {$minutes} minutes)<br>\n";
                    print "<strong>Hostname:</strong> {$snmp_hostname}<br>\n";
                    print "<strong>Location:</strong> {$snmp_location}<br>\n";
                    print "<strong>Contact:</strong> {$snmp_contact}<br>\n";
                }
            }
            ?>
					</span>
				<?php 
        }
        if ($host["availability_method"] == AVAIL_PING || $host["availability_method"] == AVAIL_SNMP_AND_PING || $host["availability_method"] == AVAIL_SNMP_OR_PING) {
            /* create new ping socket for host pinging */
            $ping = new Net_Ping();
            $ping->host = $host;
            $ping->port = $host["ping_port"];
            /* perform the appropriate ping check of the host */
            if ($ping->ping($host["availability_method"], $host["ping_method"], $host["ping_timeout"], $host["ping_retries"])) {
                $host_down = false;
                $color = "#000000";
            } else {
                $host_down = true;
                $color = "#ff0000";
            }
            ?>
					<br>Ping Results<br>
					<span style="font-size: 10px; font-weight: normal; color: <?php 
            print $color;
            ?>
; font-family: monospace;">
					<?php 
            print $ping->ping_response;
            ?>
					</span>
				<?php 
        } else {
            if ($host["availability_method"] == AVAIL_NONE) {
                ?>
					No Availability Check In Use<br>
				<?php 
            }
        }
        ?>
				</td>
				<td class="textInfo" valign="top">
					<span style="color: #c16921;">*</span><a href="<?php 
        print htmlspecialchars("graphs_new.php?host_id=" . $host["id"]);
        ?>
">Create Graphs for this Host</a><br>
					<span style="color: #c16921;">*</span><a href="<?php 
        print htmlspecialchars("data_sources.php?host_id=" . $host["id"] . "&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1");
        ?>
">Data Source List</a><br>
					<span style="color: #c16921;">*</span><a href="<?php 
        print htmlspecialchars("graphs.php?host_id=" . $host["id"] . "&graph_rows=30&filter=&template_id=-1&page=1");
        ?>
">Graph List</a>
					<?php 
        api_plugin_hook('device_edit_top_links');
        ?>
				</td>
			</tr>
		</table>
		<?php 
    }
    html_start_box("<strong>Devices</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    /* preserve the host template id if passed in via a GET variable */
    if (!empty($_GET["host_template_id"])) {
        $fields_host_edit["host_template_id"]["value"] = $_GET["host_template_id"];
    }
    /* modify for multi user start */
    if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) {
        $fields_host_edit["device_threads"]["method"] = "hidden";
        $fields_host_edit["ping_timeout"]["method"] = "hidden";
        $fields_host_edit["ping_retries"]["method"] = "hidden";
        $fields_host_edit["snmp_timeout"]["method"] = "hidden";
        $fields_host_edit["max_oids"]["method"] = "hidden";
        $fields_host_edit["host_template_id"]["sql"] = "SELECT id,name FROM host_template WHERE name NOT LIKE '%@system' ORDER BY name";
    }
    if ($_SESSION["permission"] < ACCESS_PREMIUM_USER) {
        if ($fields_host_edit["thold_send_email"]) {
            $fields_host_edit["thold_send_email"]["method"] = "hidden";
        }
    }
    if ($host["disabled"] === "ps") {
        $fields_host_edit["disabled"]["method"] = "";
    }
    /* modify for multi user end */
    draw_edit_form(array("config" => array("form_name" => "chk"), "fields" => inject_form_variables($fields_host_edit, isset($host) ? $host : array())));
    /* we have to hide this button to make a form change in the main form trigger the correct
     * submit action */
    echo "<div style='display:none;'><input type='submit' value='Default Submit Button'></div>";
    html_end_box();
    ?>
	<script type="text/javascript">
	<!--

	// default snmp information
	var snmp_community       = document.getElementById('snmp_community').value;
	var snmp_username        = document.getElementById('snmp_username').value;
	var snmp_password        = document.getElementById('snmp_password').value;
	var snmp_auth_protocol   = document.getElementById('snmp_auth_protocol').value;
	var snmp_priv_passphrase = document.getElementById('snmp_priv_passphrase').value;
	var snmp_priv_protocol   = document.getElementById('snmp_priv_protocol').value;
	var snmp_context         = document.getElementById('snmp_context').value;
	var snmp_port            = document.getElementById('snmp_port').value;
	var snmp_timeout         = document.getElementById('snmp_timeout').value;
	var max_oids             = document.getElementById('max_oids').value;

	// default ping methods
	var ping_method    = document.getElementById('ping_method').value;
	var ping_port      = document.getElementById('ping_port').value;
	var ping_timeout   = document.getElementById('ping_timeout').value;
	var ping_retries   = document.getElementById('ping_retries').value;

	var availability_methods = document.getElementById('availability_method').options;
	var num_methods          = document.getElementById('availability_method').length;
	var selectedIndex        = document.getElementById('availability_method').selectedIndex;

	var agent = navigator.userAgent;
	agent = agent.match("MSIE");

	function setPingVisibility() {
		availability_method = document.getElementById('availability_method').value;
		ping_method         = document.getElementById('ping_method').value;

		/* debugging, uncomment as required */
		//alert("The availability method is '" + availability_method + "'");
		//alert("The ping method is '" + ping_method + "'");

		switch(availability_method) {
		case "0": // none
			document.getElementById('row_ping_method').style.display  = "none";
			document.getElementById('row_ping_port').style.display    = "none";
            if (document.getElementById('row_ping_timeout')) {
			document.getElementById('row_ping_timeout').style.display = "none";
			document.getElementById('row_ping_retries').style.display = "none";
            }

			break;
		case "2": // snmp
		case "5": // snmp sysDesc
		case "6": // snmp getNext
			document.getElementById('row_ping_method').style.display  = "none";
			document.getElementById('row_ping_port').style.display    = "none";
            if (document.getElementById('row_ping_timeout')) {
			document.getElementById('row_ping_timeout').style.display = "";
			document.getElementById('row_ping_retries').style.display = "";
            }

			break;
		default: // ping ok
			switch(ping_method) {
			case "1": // ping icmp
				document.getElementById('row_ping_method').style.display  = "";
				document.getElementById('row_ping_port').style.display    = "none";
                if (document.getElementById('row_ping_timeout')) {
				document.getElementById('row_ping_timeout').style.display = "";
				document.getElementById('row_ping_retries').style.display = "";
                }

				break;
			case "2": // ping udp
			case "3": // ping tcp
				document.getElementById('row_ping_method').style.display  = "";
				document.getElementById('row_ping_port').style.display    = "";
                if (document.getElementById('row_ping_timeout')) {
				document.getElementById('row_ping_timeout').style.display = "";
				document.getElementById('row_ping_retries').style.display = "";
                }

				break;
			}

			break;
		}
	}

	function addSelectItem(item, formObj) {
		if (agent != "MSIE") {
			formObj.add(item,null); // standards compliant
		}else{
			formObj.add(item);      // IE only
		}
	}

	function setAvailability(type) {
		/* get the availability structure */
		var am=document.getElementById('availability_method');

		/* get current selectedIndex */
		selectedIndex = document.getElementById('availability_method').selectedIndex;

		/* debugging uncomment as required */
		//alert("The selectedIndex is '" + selectedIndex + "'");
		//alert("The array length is '" + am.length + "'");

		switch(type) {
		case "NoSNMP":
			/* remove snmp options */
			if (am.length == 7) {
				am.remove(1);
				am.remove(1);
				am.remove(1);
				am.remove(1);
				am.remove(1);
			}

			/* set the index to something valid, like "ping" */
			if (selectedIndex > 1) {
				am.selectedIndex=1;
			}

			break;
		case "All":
			/* restore all options */
			if (am.length == 2) {
				am.remove(0);
				am.remove(0);

				var a=document.createElement('option');
				var b=document.createElement('option');
				var c=document.createElement('option');
				var d=document.createElement('option');
				var e=document.createElement('option');
				var f=document.createElement('option');
				var g=document.createElement('option');

				a.value="0";
				a.text="None";
				addSelectItem(a,am);

				b.value="1";
				b.text="Ping and SNMP Uptime";
				addSelectItem(b,am);

				e.value="4";
				e.text="Ping or SNMP Uptime";
				addSelectItem(e,am);

				c.value="2";
				c.text="SNMP Uptime";
				addSelectItem(c,am);

				f.value="5";
				f.text="SNMP Desc";
				addSelectItem(f,am);

				g.value="6";
				g.text="SNMP getNext";
				addSelectItem(g,am);

				d.value="3";
				d.text="Ping";
				addSelectItem(d,am);

				/* restore the correct index number */
				if (selectedIndex == 0) {
					am.selectedIndex = 0;
				}else{
					am.selectedIndex = 3;
				}
			}

			break;
		}

		setAvailabilityVisibility(type, am.selectedIndex);
		setPingVisibility();
	}

	function setAvailabilityVisibility(type, selectedIndex) {
		switch(type) {
		case "NoSNMP":
			switch(selectedIndex) {
			case "0": // availability none
				document.getElementById('row_ping_method').style.display="none";
				document.getElementById('ping_method').value=0;

				break;
			case "1": // ping
				document.getElementById('row_ping_method').style.display="";
				document.getElementById('ping_method').value=ping_method;

				break;
			}
		case "All":
			switch(selectedIndex) {
			case "0": // availability none
				document.getElementById('row_ping_method').style.display="none";
				document.getElementById('ping_method').value=0;

				break;
			case "1": // ping and snmp sysUptime
			case "3": // ping
			case "4": // ping or snmp sysUptime
				if ((document.getElementById('row_ping_method').style.display == "none") ||
					(document.getElementById('row_ping_method').style.display == undefined)) {
					document.getElementById('ping_method').value=ping_method;
					document.getElementById('row_ping_method').style.display="";
				}

				break;
			case "2": // snmp sysUptime
			case "5": // snmp sysDesc
			case "6": // snmp getNext
				document.getElementById('row_ping_method').style.display="none";
				document.getElementById('ping_method').value="0";

				break;
			}
		}
	}

	function changeHostForm() {
		snmp_version        = document.getElementById('snmp_version').value;

		switch(snmp_version) {
		case "0":
			setAvailability("NoSNMP");
			setSNMP("None");

			break;
		case "1":
		case "2":
			setAvailability("All");
			setSNMP("v1v2");

			break;
		case "3":
			setAvailability("All");
			setSNMP("v3");

			break;
		}
	}

	function setSNMP(snmp_type) {
		switch(snmp_type) {
		case "None":
			document.getElementById('row_snmp_username').style.display        = "none";
			document.getElementById('row_snmp_password').style.display        = "none";
			document.getElementById('row_snmp_community').style.display       = "none";
			document.getElementById('row_snmp_auth_protocol').style.display   = "none";
			document.getElementById('row_snmp_priv_passphrase').style.display = "none";
			document.getElementById('row_snmp_priv_protocol').style.display   = "none";
			document.getElementById('row_snmp_context').style.display         = "none";
			document.getElementById('row_snmp_port').style.display            = "none";
            if (document.getElementById('row_snmp_timeout')) {
			document.getElementById('row_snmp_timeout').style.display         = "none";
			document.getElementById('row_max_oids').style.display             = "none";
            }

			break;
		case "v1v2":
			document.getElementById('row_snmp_username').style.display        = "none";
			document.getElementById('row_snmp_password').style.display        = "none";
			document.getElementById('row_snmp_community').style.display       = "";
			document.getElementById('row_snmp_auth_protocol').style.display   = "none";
			document.getElementById('row_snmp_priv_passphrase').style.display = "none";
			document.getElementById('row_snmp_priv_protocol').style.display   = "none";
			document.getElementById('row_snmp_context').style.display         = "none";
			document.getElementById('row_snmp_port').style.display            = "";
            if (document.getElementById('row_snmp_timeout')) {
			document.getElementById('row_snmp_timeout').style.display         = "";
			document.getElementById('row_max_oids').style.display             = "";
            }

			break;
		case "v3":
			document.getElementById('row_snmp_username').style.display        = "";
			document.getElementById('row_snmp_password').style.display        = "";
			document.getElementById('row_snmp_community').style.display       = "none";
			document.getElementById('row_snmp_auth_protocol').style.display   = "";
			document.getElementById('row_snmp_priv_passphrase').style.display = "";
			document.getElementById('row_snmp_priv_protocol').style.display   = "";
			document.getElementById('row_snmp_context').style.display         = "";
			document.getElementById('row_snmp_port').style.display            = "";
            if (document.getElementById('row_snmp_timeout')) {
			document.getElementById('row_snmp_timeout').style.display         = "";
			document.getElementById('row_max_oids').style.display             = "";
            }

			break;
		}
	}

	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}

	addLoadEvent(changeHostForm);

	-->
	</script>
	<?php 
    if (isset($_GET["display_dq_details"]) && isset($_SESSION["debug_log"]["data_query"])) {
        html_start_box("<strong>Data Query Debug Information</strong>", "100%", $colors["header"], "3", "center", "");
        print "<tr><td><span style='font-family: monospace;'>" . debug_log_return("data_query") . "</span></td></tr>";
        html_end_box();
    }
    if (!empty($host["id"])) {
        html_start_box("<strong>Associated Graph Templates</strong>", "100%", $colors["header"], "3", "center", "");
        html_header(array("Graph Template Name", "Status"), 2);
        $selected_graph_templates = db_fetch_assoc("select\r\n\t\t\tgraph_templates.id,\r\n\t\t\tgraph_templates.name\r\n\t\t\tfrom (graph_templates,host_graph)\r\n\t\t\twhere graph_templates.id=host_graph.graph_template_id\r\n\t\t\tand host_graph.host_id=" . $_GET["id"] . "\r\n\t\t\torder by graph_templates.name");
        /* modify for multi user start */
        $sql_where = "";
        if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) {
            $sql_where = "AND graph_templates.name NOT LIKE '%@system'";
        }
        $available_graph_templates = db_fetch_assoc("SELECT\r\n\t\t\tgraph_templates.id, graph_templates.name\r\n\t\t\tFROM snmp_query_graph RIGHT JOIN graph_templates\r\n\t\t\tON (snmp_query_graph.graph_template_id = graph_templates.id)\r\n\t\t\tWHERE (((snmp_query_graph.name) Is Null)) {$sql_where} ORDER BY graph_templates.name");
        /* modify for multi user end */
        $i = 0;
        if (sizeof($selected_graph_templates) > 0) {
            foreach ($selected_graph_templates as $item) {
                $i++;
                /* get status information for this graph template */
                $is_being_graphed = sizeof(db_fetch_assoc("select id from graph_local where graph_template_id=" . $item["id"] . " and host_id=" . $_GET["id"])) > 0 ? true : false;
                ?>
			<tr>
				<td style="padding: 4px;">
					<strong><?php 
                print $i;
                ?>
)</strong> <?php 
                print htmlspecialchars($item["name"]);
                ?>
				</td>
				<td>
					<?php 
                print $is_being_graphed == true ? "<span style='color: green;'>Is Being Graphed</span> (<a href='" . htmlspecialchars("graphs.php?action=graph_edit&id=" . db_fetch_cell("select id from graph_local where graph_template_id=" . $item["id"] . " and host_id=" . $_GET["id"] . " limit 0,1")) . "'>Edit</a>)" : "<span style='color: #484848;'>Not Being Graphed</span>";
                ?>
				</td>
				<td align='right' nowrap>
					<a href='<?php 
                print htmlspecialchars("host.php?action=gt_remove&id=" . $item["id"] . "&host_id=" . $_GET["id"]);
                ?>
'><img src='images/delete_icon_large.gif' title='Delete Graph Template Association' alt='Delete Graph Template Association' border='0' align='middle'></a>
				</td>
			</tr>
			<?php 
            }
        } else {
            print "<tr><td><em>No associated graph templates.</em></td></tr>";
        }
        ?>
		<tr bgcolor="#<?php 
        print $colors["form_alternate1"];
        ?>
">
			<td colspan="4">
				<table cellspacing="0" cellpadding="1" width="100%">
					<td nowrap>Add Graph Template:&nbsp;
						<?php 
        form_dropdown("graph_template_id", $available_graph_templates, "name", "id", "", "", "");
        ?>
					</td>
					<td align="right">
						&nbsp;<input type="submit" value="Add" name="add_gt_x" title="Add Graph Template to Host"<?php 
        /* modify for multi user start */
        if (!check_resource_count(RESOURCE_GRAPH) || !check_resource_count(RESOURCE_DATA)) {
            print " disabled";
        }
        /* modify for multi user end */
        ?>
>
					</td>
				</table>
			</td>
		</tr>

		<?php 
        html_end_box();
        html_start_box("<strong>Associated Data Queries</strong>", "100%", $colors["header"], "3", "center", "");
        html_header(array("Data Query Name", "Debugging", "Re-Index Method", "Status"), 2);
        $selected_data_queries = db_fetch_assoc("select\r\n\t\t\tsnmp_query.id,\r\n\t\t\tsnmp_query.name,\r\n\t\t\thost_snmp_query.reindex_method\r\n\t\t\tfrom (snmp_query,host_snmp_query)\r\n\t\t\twhere snmp_query.id=host_snmp_query.snmp_query_id\r\n\t\t\tand host_snmp_query.host_id=" . $_GET["id"] . "\r\n\t\t\torder by snmp_query.name");
        /* modify for multi user start */
        $sql_where = "";
        if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) {
            $sql_where = "WHERE snmp_query.name NOT LIKE '%@system'";
        }
        $available_data_queries = db_fetch_assoc("select\r\n\t\t\tsnmp_query.id,\r\n\t\t\tsnmp_query.name\r\n\t\t\tfrom snmp_query\r\n            {$sql_where}\r\n\t\t\torder by snmp_query.name");
        /* modify for multi user end */
        $keeper = array();
        foreach ($available_data_queries as $item) {
            if (sizeof(db_fetch_assoc("SELECT snmp_query_id FROM host_snmp_query " . " WHERE ((host_id=" . $_GET["id"] . ")" . " and (snmp_query_id=" . $item["id"] . "))")) > 0) {
                /* do nothing */
            } else {
                array_push($keeper, $item);
            }
        }
        $available_data_queries = $keeper;
        $i = 0;
        if (sizeof($selected_data_queries) > 0) {
            foreach ($selected_data_queries as $item) {
                $i++;
                /* get status information for this data query */
                $num_dq_items = sizeof(db_fetch_assoc("select snmp_index from host_snmp_cache where host_id=" . $_GET["id"] . " and snmp_query_id=" . $item["id"]));
                $num_dq_rows = sizeof(db_fetch_assoc("select snmp_index from host_snmp_cache where host_id=" . $_GET["id"] . " and snmp_query_id=" . $item["id"] . " group by snmp_index"));
                $status = "success";
                ?>
			<tr>
				<td style="padding: 4px;">
					<strong><?php 
                print $i;
                ?>
)</strong> <?php 
                print htmlspecialchars($item["name"]);
                ?>
				</td>
				<td>
					(<a href="<?php 
                print htmlspecialchars("host.php?action=query_verbose&id=" . $item["id"] . "&host_id=" . $_GET["id"]);
                ?>
">Verbose Query</a>)
				</td>
				<td>
					<?php 
                print $reindex_types[$item["reindex_method"]];
                ?>
				</td>
				<td>
					<?php 
                print $status == "success" ? "<span style='color: green;'>Success</span>" : "<span style='color: green;'>Fail</span>";
                ?>
 [<?php 
                print $num_dq_items;
                ?>
 Item<?php 
                print $num_dq_items == 1 ? "" : "s";
                ?>
, <?php 
                print $num_dq_rows;
                ?>
 Row<?php 
                print $num_dq_rows == 1 ? "" : "s";
                ?>
]
				</td>
				<td align='right' nowrap>
					<a href='<?php 
                print htmlspecialchars("host.php?action=query_reload&id=" . $item["id"] . "&host_id=" . $_GET["id"]);
                ?>
'><img src='images/reload_icon_small.gif' title='Reload Data Query' alt='Reload Data Query' border='0' align='middle'></a>&nbsp;
					<a href='<?php 
                print htmlspecialchars("host.php?action=query_remove&id=" . $item["id"] . "&host_id=" . $_GET["id"]);
                ?>
'><img src='images/delete_icon_large.gif' title='Delete Data Query Association' alt='Delete Data Query Association' border='0' align='middle'></a>
				</td>
			</tr>
			<?php 
            }
        } else {
            print "<tr><td><em>No associated data queries.</em></td></tr>";
        }
        ?>
		<tr bgcolor="#<?php 
        print $colors["form_alternate1"];
        ?>
">
			<td colspan="5">
				<table cellspacing="0" cellpadding="1" width="100%">
					<td nowrap>Add Data Query:&nbsp;
						<?php 
        form_dropdown("snmp_query_id", $available_data_queries, "name", "id", "", "", "");
        ?>
					</td>
					<td nowrap>Re-Index Method:&nbsp;
						<?php 
        form_dropdown("reindex_method", $reindex_types, "", "", read_config_option("reindex_method"), "", "");
        ?>
					</td>
					<td align="right">
						&nbsp;<input type="submit" value="Add" name="add_dq_x" title="Add Data Query to Host"<?php 
        /* modify for multi user start */
        if (!check_resource_count(RESOURCE_GRAPH) || !check_resource_count(RESOURCE_DATA)) {
            print " disabled";
        }
        /* modify for multi user end */
        ?>
>
					</td>
				</table>
			</td>
		</tr>

		<?php 
        html_end_box();
    }
    form_save_button("host.php", "return");
    api_plugin_hook('host_edit_bottom');
}
Example #13
0
?>
include/jscalendar/calendar-setup.js'></script>
	<script type='text/javascript' src='<?php 
echo $config['url_path'];
?>
include/layout.js'></script>
	<script type='text/javascript' src='<?php 
echo $config['url_path'];
?>
include/themes/<?php 
print read_config_option('selected_theme');
?>
/main.js'></script>
	<?php 
include $config['base_path'] . '/include/global_session.php';
api_plugin_hook('page_head');
?>
</head>

<?php 
if ($oper_mode == OPER_MODE_NATIVE) {
    ?>
<body class='cactiConsoleBody' <?php 
    print api_plugin_hook_function('body_style', '');
    ?>
>
<?php 
} else {
    ?>
<body class='cactiConsoleBody' <?php 
    print api_plugin_hook_function('body_style', '');
Example #14
0
    /* determine if you must output boost table now */
    $max_records = read_config_option('boost_rrd_update_max_records');
    $current_records = boost_get_total_rows();
    if ($time_till_next_run <= 0 || $forcerun || $current_records >= $max_records || $next_run_time <= $current_time) {
        db_execute("REPLACE INTO settings (name, value) VALUES ('boost_last_run_time', '" . date('Y-m-d G:i:s', $current_time) . "')");
        /* output all the rrd data to the rrd files */
        $rrd_updates = output_rrd_data($current_time, $forcerun);
        if ($rrd_updates != '-1') {
            log_boost_statistics($rrd_updates);
            $next_run_time = $current_time + $seconds_offset;
        } else {
            /* rollback last run time */
            db_execute("REPLACE INTO settings (name, value) VALUES ('boost_last_run_time', '" . date('Y-m-d G:i:s', $last_run_time) . "')");
        }
        dsstats_boost_bottom();
        api_plugin_hook('boost_poller_bottom');
    }
    /* store the next run time so that people understand */
    db_execute("REPLACE INTO settings (name, value) VALUES ('boost_next_run_time', '" . date('Y-m-d G:i:s', $next_run_time) . "')");
} else {
    /* turn off the system level updates */
    if (read_config_option('boost_rrd_update_system_enable') == 'on') {
        db_execute("REPLACE INTO settings (name,value)\n\t\t\tVALUES ('boost_rrd_update_system_enable','')");
    }
    $rows = boost_get_total_rows();
    if ($rows > 0) {
        /* determine the time to clear the table */
        $current_time = time();
        /* output all the rrd data to the rrd files */
        $rrd_updates = output_rrd_data($current_time, $forcerun);
        if ($rrd_updates != '-1') {
Example #15
0
                if ($found) {
                    $resend = false;
                }
            }
            if ($resend) {
                syslog_sendemail(trim($alert['email']), '', 'Event Alert - ' . $alert['name'], $html ? $htmlm : $alertm, $smsalert);
                if ($alert['open_ticket'] == 'on' && strlen(read_config_option('syslog_ticket_command'))) {
                    if (is_executable(read_config_option('syslog_ticket_command'))) {
                        exec(read_config_option('syslog_ticket_command') . " --alert-name='" . clean_up_name($alert['name']) . "'" . " --severity='" . $alert['severity'] . "'" . " --hostlist='" . implode(',', $hostlist) . "'" . " --message='" . $alert['message'] . "'");
                    }
                }
            }
        }
    }
}
api_plugin_hook('plugin_syslog_after_processing');
/* move syslog records to the syslog table */
syslog_db_execute('INSERT INTO `' . $syslogdb_default . '`.`syslog` (logtime, priority_id, facility_id, program_id, host_id, message)
	SELECT TIMESTAMP(`' . $syslog_incoming_config['dateField'] . '`, `' . $syslog_incoming_config['timeField'] . '`),
	priority_id, facility_id, program_id, host_id, message
	FROM (SELECT date, time, priority_id, facility_id, program_id, host_id, message
		FROM syslog_incoming AS si
		INNER JOIN syslog_hosts AS sh
		ON sh.host=si.host
		INNER JOIN syslog_programs AS sp
		ON sp.program=si.program
		WHERE status=' . $uniqueID . ') AS merge');
$moved = db_affected_rows($syslog_cnn);
syslog_debug('Moved   ' . $moved . ",  Message(s) to the 'syslog' table");
/* remove flagged messages */
syslog_db_execute('DELETE FROM `' . $syslogdb_default . '`.`syslog_incoming` WHERE status=' . $uniqueID);
Example #16
0
<?php if (isset($refresh)) { print "\t<meta http-equiv=refresh content=\"" . $refresh["seconds"] . "; url='" . $refresh["page"] . "'\">\n"; }
initializeCookieVariable();
api_plugin_hook('page_head');
?>
</head>
<body id='body'>
<script type="text/javascript" src="<?php echo CACTI_URL_PATH; ?>include/js/wztooltip/wz_tooltip.js"></script>
<div id='header'>
	<div id='logobar' class='logobar'></div>
	<div id='navbar' class='navbar'>
		<div id='navbar_l'>
			<ul>
				<?php echo draw_header_tab("console", __("Console"), CACTI_URL_PATH . "index.php");?>
				<?php echo draw_header_tab("graphs", __("Graphs"), CACTI_URL_PATH . "graph_view.php");?>
				<?php api_plugin_hook('top_header_tabs'); ?>
			</ul>
		</div>
	</div>
	<div id='navbrcrumb'>
		<div style='float:left;'>
			<?php print draw_navigation_text() . "\n";?>
		</div>
		<div style='float:right;'>
			<a href="<?php echo cacti_wiki_url();?>" target="_blank">
			<img src="<?php echo CACTI_URL_PATH; ?>images/help.gif" title="<?php print __("Help");?>" alt="<?php print __("Help");?>" align="top">
			</a>
		</div>
		<div style='float:right'>
		<?php	if (read_config_option("auth_method") != 0) {
					if(read_config_option('i18n_timezone_support') != 0) {
Example #17
0
    ?>
					</td>
					<td align="right">
						<?php 
    if (read_config_option("auth_method") != 0) {
        api_plugin_hook('nav_login_before');
        ?>
							Logged in as <strong><?php 
        print db_fetch_cell("select username from user_auth where id=" . $_SESSION["sess_user_id"]);
        ?>
</strong> (<a href="<?php 
        echo $config['url_path'];
        ?>
logout.php">Logout</a>)&nbsp;
							<?php 
        api_plugin_hook('nav_login_after');
    }
    ?>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td bgcolor="#f5f5f5" colspan="1" style="height:8px;width:135px;background-image: url(<?php 
    echo $config['url_path'];
    ?>
images/shadow_gray.gif); background-repeat: repeat-x; border-right: #aaaaaa 1px solid;">
			<img src="<?php 
    echo $config['url_path'];
    ?>
Example #18
0
function form_save() {
	global $settings_graphs;
	require_once(CACTI_BASE_PATH . "/include/auth/auth_constants.php");

	/* graph permissions */
	if ((isset($_POST["save_component_graph_perms"])) && (!is_error_message())) {
		/* ================= input validation ================= */
		input_validate_input_number(get_request_var_post("id"));
		input_validate_input_number(get_request_var_post("perm_graphs"));
		input_validate_input_number(get_request_var_post("perm_trees"));
		input_validate_input_number(get_request_var_post("perm_devices"));
		input_validate_input_number(get_request_var_post("perm_graph_templates"));
		input_validate_input_number(get_request_var_post("policy_graphs"));
		input_validate_input_number(get_request_var_post("policy_trees"));
		input_validate_input_number(get_request_var_post("policy_devices"));
		input_validate_input_number(get_request_var_post("policy_graph_templates"));
		/* ==================================================== */

		$add_button_clicked = false;

		if (isset($_POST["add_graph_y"])) {
			db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_graphs") . "," . PERM_GRAPHS . ")");
			$add_button_clicked = true;
		}elseif (isset($_POST["add_tree_y"])) {
			db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_trees") . "," . PERM_TREES . ")");
			$add_button_clicked = true;
		}elseif (isset($_POST["add_device_y"])) {
			db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_devices") . "," . PERM_DEVICES . ")");
			$add_button_clicked = true;
		}elseif (isset($_POST["add_graph_template_y"])) {
			db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_graph_templates") . "," . PERM_GRAPH_TEMPLATES . ")");
			$add_button_clicked = true;
		}

		db_execute("UPDATE user_auth
			SET
				policy_graphs=" . get_request_var_post("policy_graphs") . ",
				policy_trees="  . get_request_var_post("policy_trees"). ",
				policy_devices="  . get_request_var_post("policy_devices"). ",
				policy_graph_templates=" . get_request_var_post("policy_graph_templates") . "
			WHERE id=" . get_request_var_post("id"));

		if ($add_button_clicked == true) {
			header("Location: user_admin.php?action=graph_perms_edit&id=" . get_request_var_post("id"));
			exit;
		}
	}

	/* user management save */
	if (isset($_POST["save_component_user"])) {
		/* ================= input validation ================= */
		input_validate_input_number(get_request_var_post("id"));
		input_validate_input_number(get_request_var_post("realm"));
		/* ==================================================== */

		if ((get_request_var_post("password") == "") && (get_request_var_post("password_confirm") == "")) {
			$password = db_fetch_cell("SELECT password FROM user_auth WHERE id = " . get_request_var_post("id"));
		}else{
			$password = md5(get_request_var_post("password"));
		}

		/* check duplicate username */
		if (sizeof(db_fetch_row("select * from user_auth where realm = " . get_request_var_post("realm") . " and username = '******' and id != " . get_request_var_post("id")))) {
			raise_message(12);
		}

		/* check for guest or template user */
		$username = db_fetch_cell("select username from user_auth where id = " . get_request_var_post("id"));
		if ($username != get_request_var_post("username")) {
			if ($username == read_config_option("user_template")) {
				raise_message(20);
			}
			if ($username == read_config_option("guest_user")) {
				raise_message(20);
			}
		}

		/* check to make sure the passwords match; if not error */
		if (get_request_var_post("password") != get_request_var_post("password_confirm")) {
			raise_message(4);
		}

		form_input_validate(get_request_var_post("password"), "password", "" . preg_quote(get_request_var_post("password_confirm")) . "", true, 4);
		form_input_validate(get_request_var_post("password_confirm"), "password_confirm", "" . preg_quote(get_request_var_post("password")) . "", true, 4);

		$save["id"] = get_request_var_post("id");
		$save["username"] = form_input_validate(get_request_var_post("username"), "username", "^[A-Za-z0-9\._\\\@\ -]+$", false, 3);
		$save["full_name"] = form_input_validate(get_request_var_post("full_name"), "full_name", "", true, 3);
		$save["password"] = $password;
		$save["must_change_password"] = form_input_validate(get_request_var_post("must_change_password", ""), "must_change_password", "", true, 3);
		$save["show_tree"] = form_input_validate(get_request_var_post("show_tree", ""), "show_tree", "", true, 3);
		$save["show_list"] = form_input_validate(get_request_var_post("show_list", ""), "show_list", "", true, 3);
		$save["show_preview"] = form_input_validate(get_request_var_post("show_preview", ""), "show_preview", "", true, 3);
		$save["graph_settings"] = form_input_validate(get_request_var_post("graph_settings", ""), "graph_settings", "", true, 3);
		$save["login_opts"] = form_input_validate(get_request_var_post("login_opts"), "login_opts", "", true, 3);
		$save["policy_graphs"] = form_input_validate(get_request_var_post("policy_graphs", get_request_var_post("_policy_graphs")), "policy_graphs", "", true, 3);
		$save["policy_trees"] = form_input_validate(get_request_var_post("policy_trees", get_request_var_post("_policy_trees")), "policy_trees", "", true, 3);
		$save["policy_devices"] = form_input_validate(get_request_var_post("policy_devices", get_request_var_post("_policy_devices")), "policy_devices", "", true, 3);
		$save["policy_graph_templates"] = form_input_validate(get_request_var_post("policy_graph_templates", get_request_var_post("_policy_graph_templates")), "policy_graph_templates", "", true, 3);
		$save["realm"] = get_request_var_post("realm", 0);
		$save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3);
		$save = api_plugin_hook_function('user_admin_setup_sql_save', $save);

		if (!is_error_message()) {
			$user_id = sql_save($save, "user_auth");

			if ($user_id) {
				raise_message(1);
			}else{
				raise_message(2);
			}
		}
	}else if (isset($_POST["save_component_realm_perms"])) {
		$user_id = get_request_var_post("id");
		db_execute("DELETE FROM user_auth_realm WHERE user_id = " . $user_id);

		while (list($var, $val) = each($_POST)) {
			if (substr($var, 0, 7) == "section") {
			    db_execute("REPLACE INTO user_auth_realm (user_id,realm_id) VALUES (" . $user_id . "," . substr($var, 7) . ")");
			}
		}
	}elseif (isset($_POST["save_component_graph_settings"])) {
		$user_id = get_request_var_post("id");
		while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
			while (list($field_name, $field_array) = each($tab_fields)) {
				if ((isset($field_array["items"])) && (is_array($field_array["items"]))) {
					while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
						db_execute("REPLACE INTO settings_graphs (user_id,name,value) VALUES (" . (!empty($user_id) ? $user_id : get_request_var_post("id")) . ",'$sub_field_name', '" . get_request_var_post($sub_field_name, "") . "')");
					}
				}else{
					db_execute("REPLACE INTO settings_graphs (user_id,name,value) VALUES (" . (!empty($user_id) ? $user_id : $_POST["id"]) . ",'$field_name', '" . get_request_var_post($field_name) . "')");
				}
			}
		}

		/* reset local settings cache so the user sees the new settings */
		kill_session_var("sess_graph_config_array");
	}elseif (isset($_POST["save_component_graph_perms"])) {
		db_execute("UPDATE user_auth SET
			policy_graphs = " . get_request_var_post("policy_graphs") . ",
			policy_trees = " . get_request_var_post("policy_trees") . ",
			policy_devices = " . get_request_var_post("policy_devices") . ",
			policy_graph_templates = " . get_request_var_post("policy_graph_templates") . "
			WHERE id = " . get_request_var_post("id"));
	} else {
		api_plugin_hook('user_admin_user_save');
	}

	/* redirect to the appropriate page */
	if (isset($_POST["save_component_realm_perms"])) {
		header("Location: user_admin.php?action=user_realms_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id));
	}elseif (isset($_POST["save_component_graph_perms"])) {
		header("Location: user_admin.php?action=graph_perms_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id));
	}elseif (isset($_POST["save_component_graph_settings"])) {
		header("Location: user_admin.php?action=graph_settings_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id));
	}elseif (isset($_POST["save_component_user"])) {
		header("Location: user_admin.php?action=user_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id));
	}else{
		header(api_plugin_hook_function('user_admin_save_location', "Location: user_admin.php?action=user_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id)));
	}
	exit;
}
Example #19
0
' border='0' alt='<?php 
        print htmlspecialchars($graph_title);
        ?>
'>
					</td>
					<td valign='top' style='padding: 3px;'>
						<a href='<?php 
        print htmlspecialchars("graph.php?action=zoom&local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"] . "&graph_start=" . get_request_var("graph_start") . "&graph_end=" . get_request_var("graph_end"));
        ?>
'><img src='images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'></a><br>
						<a href='<?php 
        print htmlspecialchars("graph_xport.php?local_graph_id=" . $_GET["local_graph_id"] . "&rra_id=" . $_GET["rra_id"] . "&view_type=" . $_REQUEST["view_type"]);
        ?>
'><img src='images/graph_query.png' border='0' alt='CSV Export' title='CSV Export' style='padding: 3px;'></a><br>
						<?php 
        api_plugin_hook('graph_buttons', array('hook' => 'properties', 'local_graph_id' => $_GET['local_graph_id'], 'rra' => $_GET['rra_id'], 'view_type' => $_REQUEST['view_type']));
        ?>
					</td>
				</tr>
				<tr>
					<td colspan='2' align='center'>
						<strong><?php 
        print htmlspecialchars(db_fetch_cell("select name from rra where id=" . $_GET["rra_id"]));
        ?>
</strong>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php 
Example #20
0
		/* log some nice debug information */
		if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG) {
			echo "Loop  Time is: " . ($loop_end - $loop_start) . "\n";
			echo "Sleep Time is: " . $sleep_time . "\n";
			echo "Total Time is: " . ($loop_end - $poller_start) . "\n";
 		}

		/* sleep the appripriate amount of time */
		if ($poller_id == 0) {
			if ($poller_runs_completed < $poller_runs) {
				api_plugin_hook('poller_bottom');
				db_close();
				usleep($sleep_time * 1000000);
				db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
				api_plugin_hook('poller_top');
			}
		}
	}else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM) {
		cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
	}
}

function log_cacti_stats($loop_start, $method, $concurrent_processes, $max_threads, $num_devices,
	$devices_per_process, $num_polling_items, $rrds_processed) {
	global $poller_id;

	/* take time and log performance data */
	list($micro,$seconds) = explode(" ", microtime());
	$loop_end = $seconds + $micro;
Example #21
0
function ds_edit()
{
    global $struct_data_source, $struct_data_source_item, $data_source_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("host_id"));
    /* ==================================================== */
    api_plugin_hook('data_source_edit_top');
    $use_data_template = true;
    $host_id = 0;
    if (!empty($_GET["id"])) {
        $data_local = db_fetch_row("select host_id,data_template_id from data_local where id='" . $_GET["id"] . "'");
        $data = db_fetch_row("select * from data_template_data where local_data_id='" . $_GET["id"] . "'");
        if (isset($data_local["data_template_id"]) && $data_local["data_template_id"] >= 0) {
            $data_template = db_fetch_row("select id,name from data_template where id='" . $data_local["data_template_id"] . "'");
            $data_template_data = db_fetch_row("select * from data_template_data where data_template_id='" . $data_local["data_template_id"] . "' and local_data_id=0");
        } else {
            $_SESSION["sess_messages"] = 'Data Source "' . $_GET["id"] . '" does not exist.';
            header("Location: data_sources.php");
            exit;
        }
        $header_label = "[edit: " . htmlspecialchars(get_data_source_title($_GET["id"])) . "]";
        if (empty($data_local["data_template_id"])) {
            $use_data_template = false;
        }
    } else {
        $header_label = "[new]";
        $use_data_template = false;
    }
    /* handle debug mode */
    if (isset($_GET["debug"])) {
        if ($_GET["debug"] == "0") {
            kill_session_var("ds_debug_mode");
        } elseif ($_GET["debug"] == "1") {
            $_SESSION["ds_debug_mode"] = true;
        }
    }
    include_once "./include/top_header.php";
    if (!empty($_GET["id"])) {
        ?>
		<table width="100%" align="center">
			<tr>
				<td class="textInfo" colspan="2" valign="top">
					<?php 
        print htmlspecialchars(get_data_source_title($_GET["id"]));
        ?>
				</td>
				<td class="textInfo" align="right" valign="top">
					<span style="color: #c16921;">*<a href='<?php 
        print htmlspecialchars("data_sources.php?action=ds_edit&id=" . (isset($_GET["id"]) ? $_GET["id"] : "0"));
        ?>
&debug=<?php 
        print isset($_SESSION["ds_debug_mode"]) ? "0" : "1";
        ?>
'>Turn <strong><?php 
        print isset($_SESSION["ds_debug_mode"]) ? "Off" : "On";
        ?>
</strong> Data Source Debug Mode.</a><br>
					<?php 
        if (!empty($data_template["id"])) {
            ?>
<span style="color: #c16921;">*<a href='<?php 
            print htmlspecialchars("data_templates.php?action=template_edit&id=" . (isset($data_template["id"]) ? $data_template["id"] : "0"));
            ?>
'>Edit Data Template.</a><br><?php 
        }
        if (!empty($_GET["host_id"]) || !empty($data_local["host_id"])) {
            ?>
<span style="color: #c16921;">*<a href='<?php 
            print htmlspecialchars("host.php?action=edit&id=" . (isset($_GET["host_id"]) ? $_GET["host_id"] : $data_local["host_id"]));
            ?>
'>Edit Host.</a><br><?php 
        }
        ?>
				</td>
			</tr>
		</table>
		<br>
		<?php 
    }
    html_start_box("<strong>Data Template Selection</strong> {$header_label}", "100%", "", "3", "center", "");
    $form_array = array("data_template_id" => array("method" => "drop_sql", "friendly_name" => "Selected Data Template", "description" => "The name given to this data template.", "value" => isset($data_template) ? $data_template["id"] : "0", "none_value" => "None", "sql" => "select id,name from data_template order by name"), "host_id" => array("method" => "drop_sql", "friendly_name" => "Host", "description" => "Choose the host that this graph belongs to.", "value" => isset($_GET["host_id"]) ? $_GET["host_id"] : $data_local["host_id"], "none_value" => "None", "sql" => "select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"), "_data_template_id" => array("method" => "hidden", "value" => isset($data_template) ? $data_template["id"] : "0"), "_host_id" => array("method" => "hidden", "value" => empty($data_local["host_id"]) ? isset($_GET["host_id"]) ? $_GET["host_id"] : "0" : $data_local["host_id"]), "_data_input_id" => array("method" => "hidden", "value" => isset($data["data_input_id"]) ? $data["data_input_id"] : "0"), "data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["id"] : "0"), "local_data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_template_data_id"] : "0"), "local_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_id"] : "0"));
    draw_edit_form(array("config" => array(), "fields" => $form_array));
    html_end_box();
    /* only display the "inputs" area if we are using a data template for this data source */
    if (!empty($data["data_template_id"])) {
        $template_data_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
        html_start_box("<strong>Supplemental Data Template Data</strong>", "100%", "", "3", "center", "");
        draw_nontemplated_fields_data_source($data["data_template_id"], $data["local_data_id"], $data, "|field|", "<strong>Data Source Fields</strong>", true, true, 0);
        draw_nontemplated_fields_data_source_item($data["data_template_id"], $template_data_rrds, "|field|_|id|", "<strong>Data Source Item Fields</strong>", true, true, true, 0);
        draw_nontemplated_fields_custom_data($data["id"], "value_|id|", "<strong>Custom Data</strong>", true, true, 0);
        form_hidden_box("save_component_data", "1", "");
        html_end_box();
    }
    if ((isset($_GET["id"]) || isset($_GET["new"])) && empty($data["data_template_id"])) {
        html_start_box("<strong>Data Source</strong>", "100%", "", "3", "center", "");
        $form_array = array();
        while (list($field_name, $field_array) = each($struct_data_source)) {
            $form_array += array($field_name => $struct_data_source[$field_name]);
            if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
                $form_array[$field_name]["description"] = "";
            }
            $form_array[$field_name]["value"] = isset($data[$field_name]) ? $data[$field_name] : "";
            $form_array[$field_name]["form_id"] = empty($data["id"]) ? "0" : $data["id"];
            if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
                $form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
            }
        }
        draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($form_array, isset($data) ? $data : array())));
        html_end_box();
        /* fetch ALL rrd's for this data source */
        if (!empty($_GET["id"])) {
            $template_data_rrds = db_fetch_assoc("select id,data_source_name from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
        }
        /* select the first "rrd" of this data source by default */
        if (empty($_GET["view_rrd"])) {
            $_GET["view_rrd"] = isset($template_data_rrds[0]["id"]) ? $template_data_rrds[0]["id"] : "0";
        }
        /* get more information about the rrd we chose */
        if (!empty($_GET["view_rrd"])) {
            $local_data_template_rrd_id = db_fetch_cell("select local_data_template_rrd_id from data_template_rrd where id=" . $_GET["view_rrd"]);
            $rrd = db_fetch_row("select * from data_template_rrd where id=" . $_GET["view_rrd"]);
            $rrd_template = db_fetch_row("select * from data_template_rrd where id={$local_data_template_rrd_id}");
            $header_label = "[edit: " . $rrd["data_source_name"] . "]";
        } else {
            $header_label = "";
        }
        $i = 0;
        if (isset($template_data_rrds)) {
            if (sizeof($template_data_rrds) > 1) {
                /* draw the data source tabs on the top of the page */
                print "\t<table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'>\n\t\t\t\t\t<tr>\n";
                foreach ($template_data_rrds as $template_data_rrd) {
                    $i++;
                    print "\t<td " . ($template_data_rrd["id"] == $_GET["view_rrd"] ? "class='even'" : "class='odd'") . " width='" . (strlen($template_data_rrd["data_source_name"]) * 9 + 50) . "' align='center' class='tab'>\n\t\t\t\t\t\t\t\t<span class='textHeader'><a href='" . htmlspecialchars("data_sources.php?action=ds_edit&id=" . $_GET["id"] . "&view_rrd=" . $template_data_rrd["id"]) . "'>{$i}: " . htmlspecialchars($template_data_rrd["data_source_name"]) . "</a>" . ($use_data_template == false ? " <a href='" . htmlspecialchars("data_sources.php?action=rrd_remove&id=" . $template_data_rrd["id"] . "&local_data_id=" . $_GET["id"]) . "'><img src='images/delete_icon.gif' border='0' alt='Delete'></a>" : "") . "</span>\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t<td width='1'></td>\n";
                }
                print "\n\t\t\t\t\t<td></td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n";
            } elseif (sizeof($template_data_rrds) == 1) {
                $_GET["view_rrd"] = $template_data_rrds[0]["id"];
            }
        }
        html_start_box("", "100%", "", "3", "center", "");
        print "\t<tr>\n\t\t\t\t<td class='textHeaderDark'>\n\t\t\t\t\t<strong>Data Source Item</strong> {$header_label}\n\t\t\t\t</td>\n\t\t\t\t<td class='textHeaderDark' align='right'>\n\t\t\t\t\t" . (!empty($_GET["id"]) && empty($data_template["id"]) ? "<strong><a class='linkOverDark' href='" . htmlspecialchars("data_sources.php?action=rrd_add&id=" . $_GET["id"]) . "'>New</a>&nbsp;</strong>" : "") . "\n\t\t\t\t</td>\n\t\t\t</tr>\n";
        /* data input fields list */
        if (empty($data["data_input_id"]) || db_fetch_cell("select type_id from data_input where id=" . $data["data_input_id"]) > "1") {
            unset($struct_data_source_item["data_input_field_id"]);
        } else {
            $struct_data_source_item["data_input_field_id"]["sql"] = "select id,CONCAT(data_name,' - ',name) as name from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='out' and update_rra='on' order by data_name,name";
        }
        $form_array = array();
        while (list($field_name, $field_array) = each($struct_data_source_item)) {
            $form_array += array($field_name => $struct_data_source_item[$field_name]);
            if (!($use_data_template == false || $rrd_template["t_" . $field_name] == "on")) {
                $form_array[$field_name]["description"] = "";
            }
            $form_array[$field_name]["value"] = isset($rrd) ? $rrd[$field_name] : "";
            if (!($use_data_template == false || $rrd_template["t_" . $field_name] == "on")) {
                $form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
            }
        }
        draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => array("data_template_rrd_id" => array("method" => "hidden", "value" => isset($rrd) ? $rrd["id"] : "0"), "local_data_template_rrd_id" => array("method" => "hidden", "value" => isset($rrd) ? $rrd["local_data_template_rrd_id"] : "0")) + $form_array));
        html_end_box();
        /* data source data goes here */
        data_edit();
        form_hidden_box("current_rrd", $_GET["view_rrd"], "0");
    }
    /* display the debug mode box if the user wants it */
    if (isset($_SESSION["ds_debug_mode"]) && isset($_GET["id"])) {
        ?>
		<table width="100%" align="center">
			<tr>
				<td>
					<span class="textInfo">Data Source Debug</span><br>
					<pre><?php 
        print @rrdtool_function_create($_GET["id"], true);
        ?>
</pre>
				</td>
			</tr>
		</table>
		<?php 
    }
    if (isset($_GET["id"]) || isset($_GET["new"])) {
        form_hidden_box("save_component_data_source", "1", "");
    } else {
        form_hidden_box("save_component_data_source_new", "1", "");
    }
    form_save_button("data_sources.php");
    api_plugin_hook('data_source_edit_bottom');
    include_once "./include/bottom_footer.php";
}
Example #22
0
<table width="100%" align="center">
	<tr>
		<td class="textHeader">
			<strong><?php print __('You are now logged into <a href="about.php">Cacti</a>. You can follow these basic steps to get
			started.');?></strong>

			<ul>
				<li><strong><?php print '<a href="devices.php">' . __('Create devices') . " </a>" . __('for your network');?></strong></li>
				<li><strong><?php print '<a href="graphs_new.php">' . __('Create graphs') . " </a>" . __('for your new devices');?></strong></li>
				<li><strong><?php print '<a href="graph_view.php">' . __('View') . " </a>" . __('your new graphs');?></strong></li>
			</ul>
			<strong>
			<?php print __('Find help for each page when clicking the');?>
			<a href="<?php echo cacti_wiki_url();?>" target="_blank">
			<img src='images/help.gif' title="<?php print __("Help");?>" alt="<?php print __("Help");?>" align="top">
			</a>
			<?php print __('icon on the upper right.');?>
			</strong>
		</td>
		<td class="textHeader" align="right" valign="top">
			<strong><?php print __('Version') . " " . CACTI_VERSION;?></strong>
		</td>
	</tr>
</table>

<?php

api_plugin_hook('console_after');

include(CACTI_BASE_PATH . "/include/bottom_footer.php");
Example #23
0
$struct_data_source = array("name" => array("friendly_name" => "Name", "method" => "textbox", "max_length" => "250", "default" => "", "description" => "Choose a name for this data source.", "flags" => ""), "data_source_path" => array("friendly_name" => "Data Source Path", "method" => "textbox", "max_length" => "255", "default" => "", "description" => "The full path to the RRD file.", "flags" => "NOTEMPLATE"), "data_input_id" => array("friendly_name" => "Data Input Method", "method" => "drop_sql", "sql" => "select id,name from data_input order by name", "default" => "", "none_value" => "None", "description" => "The script/source used to gather data for this data source.", "flags" => "ALWAYSTEMPLATE"), "rra_id" => array("method" => "drop_multi_rra", "friendly_name" => "Associated RRA's", "description" => "Which RRA's to use when entering data. (It is recommended that you select all of these values).", "form_id" => "|arg1:id|", "sql" => "select rra_id as id,data_template_data_id from data_template_data_rra where data_template_data_id=|arg1:id|", "sql_all" => "select rra.id from rra order by id", "sql_print" => "select rra.name from (data_template_data_rra,rra) where data_template_data_rra.rra_id=rra.id and data_template_data_rra.data_template_data_id=|arg1:id|", "flags" => "ALWAYSTEMPLATE"), "rrd_step" => array("friendly_name" => "Step", "method" => "textbox", "max_length" => "10", "size" => "20", "default" => "300", "description" => "The amount of time in seconds between expected updates.", "flags" => ""), "active" => array("friendly_name" => "Data Source Active", "method" => "checkbox", "default" => "on", "description" => "Whether Cacti should gather data for this data source or not.", "flags" => ""));
/* file: (data_sources.php|data_templates.php), action: (ds|template)_edit */
$struct_data_source_item = array("data_source_name" => array("friendly_name" => "Internal Data Source Name", "method" => "textbox", "max_length" => "19", "default" => "", "description" => "Choose unique name to represent this piece of data inside of the rrd file."), "rrd_minimum" => array("friendly_name" => "Minimum Value ('U' for No Minimum)", "method" => "textbox", "max_length" => "20", "size" => "30", "default" => "0", "description" => "The minimum value of data that is allowed to be collected."), "rrd_maximum" => array("friendly_name" => "Maximum Value ('U' for No Maximum)", "method" => "textbox", "max_length" => "20", "size" => "30", "default" => "0", "description" => "The maximum value of data that is allowed to be collected."), "data_source_type_id" => array("friendly_name" => "Data Source Type", "method" => "drop_array", "array" => $data_source_types, "default" => "", "description" => "How data is represented in the RRA."), "rrd_heartbeat" => array("friendly_name" => "Heartbeat", "method" => "textbox", "max_length" => "20", "size" => "30", "default" => "600", "description" => "The maximum amount of time that can pass before data is entered as \"unknown\".\n\t\t\t(Usually 2x300=600)"), "data_input_field_id" => array("friendly_name" => "Output Field", "method" => "drop_sql", "default" => "0", "description" => "When data is gathered, the data for this field will be put into this data source."));
/* file: grprint_presets.php, action: edit */
$fields_grprint_presets_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "Enter a name for this GPRINT preset, make sure it is something you recognize.", "value" => "|arg1:name|", "max_length" => "50"), "gprint_text" => array("method" => "textbox", "friendly_name" => "GPRINT Text", "description" => "Enter the custom GPRINT string here.", "value" => "|arg1:gprint_text|", "max_length" => "50"), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_gprint_presets" => array("method" => "hidden", "value" => "1"));
/* file: (graphs.php|graph_templates.php), action: (graph|template)_edit */
$struct_graph = array("title" => array("friendly_name" => "Title (--title)", "method" => "textbox", "max_length" => "255", "default" => "", "description" => "The name that is printed on the graph."), "image_format_id" => array("friendly_name" => "Image Format (--imgformat)", "method" => "drop_array", "array" => $image_types, "default" => "1", "description" => "The type of graph that is generated; PNG, GIF or SVG.  The selection of graph image type is very RRDtool dependent."), "height" => array("friendly_name" => "Height (--height)", "method" => "textbox", "max_length" => "50", "default" => "120", "description" => "The height (in pixels) that the graph is."), "width" => array("friendly_name" => "Width (--width)", "method" => "textbox", "max_length" => "50", "default" => "500", "description" => "The width (in pixels) that the graph is."), "slope_mode" => array("friendly_name" => "Slope Mode (--slope-mode)", "method" => "checkbox", "default" => "on", "description" => "Using Slope Mode, in RRDtool 1.2.x and above, evens out the shape of the graphs at the expense of\n\t\t\tsome on screen resolution."), "auto_scale" => array("friendly_name" => "Auto Scale", "method" => "checkbox", "default" => "on", "description" => "Auto scale the y-axis instead of defining an upper and lower limit. Note: if this is check both the\n\t\t\tUpper and Lower limit will be ignored."), "auto_scale_opts" => array("friendly_name" => "Auto Scale Options", "method" => "radio", "default" => "2", "description" => "Use <br>\n\t\t\t--alt-autoscale to scale to the absolute minimum and maximum <br>\n\t\t    --alt-autoscale-max to scale to the maximum value, using a given lower limit <br>\n\t\t    --alt-autoscale-min to scale to the minimum value, using a given upper limit <br>\n\t\t\t--alt-autoscale (with limits) to scale using both lower and upper limits (rrdtool default) <br>\n\t\t    ", "items" => array(0 => array("radio_value" => "1", "radio_caption" => "Use --alt-autoscale (ignoring given limits)"), 1 => array("radio_value" => "2", "radio_caption" => "Use --alt-autoscale-max (accepting a lower limit)"), 2 => array("radio_value" => "3", "radio_caption" => "Use --alt-autoscale-min (accepting an upper limit, requires rrdtool 1.2.x)"), 3 => array("radio_value" => "4", "radio_caption" => "Use --alt-autoscale (accepting both limits, rrdtool default)"))), "auto_scale_log" => array("friendly_name" => "Logarithmic Scaling (--logarithmic)", "method" => "checkbox", "default" => "", "on_change" => "changeScaleLog()", "description" => "Use Logarithmic y-axis scaling"), "scale_log_units" => array("friendly_name" => "SI Units for Logarithmic Scaling (--units=si)", "method" => "checkbox", "default" => "", "description" => "Use SI Units for Logarithmic Scaling instead of using exponential notation (not available for rrdtool-1.0.x).<br>\n\t\t\tNote: Linear graphs use SI notation by default."), "auto_scale_rigid" => array("friendly_name" => "Rigid Boundaries Mode (--rigid)", "method" => "checkbox", "default" => "", "description" => "Do not expand the lower and upper limit if the graph contains a value outside the valid range."), "auto_padding" => array("friendly_name" => "Auto Padding", "method" => "checkbox", "default" => "on", "description" => "Pad text so that legend and graph data always line up. Note: this could cause\n\t\t\tgraphs to take longer to render because of the larger overhead. Also Auto Padding may not\n\t\t\tbe accurate on all types of graphs, consistant labeling usually helps."), "export" => array("friendly_name" => "Allow Graph Export", "method" => "checkbox", "default" => "on", "description" => "Choose whether this graph will be included in the static html/png export if you use\n\t\t\tcacti's export feature."), "upper_limit" => array("friendly_name" => "Upper Limit (--upper-limit)", "method" => "textbox", "max_length" => "50", "default" => "100", "description" => "The maximum vertical value for the rrd graph."), "lower_limit" => array("friendly_name" => "Lower Limit (--lower-limit)", "method" => "textbox", "max_length" => "255", "default" => "0", "description" => "The minimum vertical value for the rrd graph."), "base_value" => array("friendly_name" => "Base Value (--base)", "method" => "textbox", "max_length" => "50", "default" => "1000", "description" => "Should be set to 1024 for memory and 1000 for traffic measurements."), "unit_value" => array("friendly_name" => "Unit Grid Value (--unit/--y-grid)", "method" => "textbox", "max_length" => "50", "default" => "", "description" => "Sets the xponent value on the Y-axis for numbers. Note: This option was\n\t\t\tadded in rrdtool 1.0.36 and depricated in 1.2.x.  In RRDtool 1.2.x, this value is replaced by the --y-grid option.\n\t\t\tIn this option, Y-axis grid lines appear at each grid step interval.  Labels are placed every label factor lines."), "unit_exponent_value" => array("friendly_name" => "Unit Exponent Value (--units-exponent)", "method" => "textbox", "max_length" => "50", "default" => "", "description" => "What unit cacti should use on the Y-axis. Use 3 to display everything in 'k' or -6\n\t\t\tto display everything in 'u' (micro)."), "vertical_label" => array("friendly_name" => "Vertical Label (--vertical-label)", "method" => "textbox", "max_length" => "255", "default" => "", "description" => "The label vertically printed to the left of the graph."));
/* file: (graphs.php|graph_templates.php), action: item_edit */
$struct_graph_item = array("task_item_id" => array("friendly_name" => "Data Source", "method" => "drop_sql", "sql" => "select\n\t\t\tCONCAT_WS('',case when host.description is null then 'No Host' when host.description is not null then host.description end,' - ',data_template_data.name,' (',data_template_rrd.data_source_name,')') as name,\n\t\t\tdata_template_rrd.id\n\t\t\tfrom (data_template_data,data_template_rrd,data_local)\n\t\t\tleft join host on (data_local.host_id=host.id)\n\t\t\twhere data_template_rrd.local_data_id=data_local.id\n\t\t\tand data_template_data.local_data_id=data_local.id\n\t\t\torder by name", "default" => "0", "none_value" => "None", "description" => "The data source to use for this graph item."), "color_id" => array("friendly_name" => "Color", "method" => "drop_color", "default" => "0", "on_change" => "changeColorId()", "description" => "The color to use for the legend."), "alpha" => array("friendly_name" => "Opacity/Alpha Channel", "method" => "drop_array", "default" => "FF", "array" => $graph_color_alpha, "description" => "The opacity/alpha channel of the color. Not available for rrdtool-1.0.x."), "graph_type_id" => array("friendly_name" => "Graph Item Type", "method" => "drop_array", "array" => $graph_item_types, "default" => "0", "description" => "How data for this item is represented visually on the graph."), "consolidation_function_id" => array("friendly_name" => "Consolidation Function", "method" => "drop_array", "array" => $consolidation_functions, "default" => "0", "description" => "How data for this item is represented statistically on the graph."), "cdef_id" => array("friendly_name" => "CDEF Function", "method" => "drop_sql", "sql" => "select id,name from cdef order by name", "default" => "0", "none_value" => "None", "description" => "A CDEF (math) function to apply to this item on the graph."), "value" => array("friendly_name" => "Value", "method" => "textbox", "max_length" => "50", "default" => "", "description" => "The value of an HRULE or VRULE graph item."), "gprint_id" => array("friendly_name" => "GPRINT Type", "method" => "drop_sql", "sql" => "select id,name from graph_templates_gprint order by name", "default" => "2", "description" => "If this graph item is a GPRINT, you can optionally choose another format\n\t\t\there. You can define additional types under \"GPRINT Presets\"."), "text_format" => array("friendly_name" => "Text Format", "method" => "textbox", "max_length" => "255", "default" => "", "description" => "Text that will be displayed on the legend for this graph item."), "hard_return" => array("friendly_name" => "Insert Hard Return", "method" => "checkbox", "default" => "", "description" => "Forces the legend to the next line after this item."), "sequence" => array("friendly_name" => "Sequence", "method" => "view"));
/* file: graph_templates.php, action: template_edit */
$fields_graph_template_template_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "The name given to this graph template.", "value" => "|arg1:name|", "max_length" => "150"), "graph_template_id" => array("method" => "hidden_zero", "value" => "|arg2:graph_template_id|"), "graph_template_graph_id" => array("method" => "hidden_zero", "value" => "|arg2:id|"), "save_component_template" => array("method" => "hidden", "value" => "1"));
/* file: graph_templates.php, action: input_edit */
$fields_graph_template_input_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "Enter a name for this graph item input, make sure it is something you recognize.", "value" => "|arg1:name|", "max_length" => "50"), "description" => array("method" => "textarea", "friendly_name" => "Description", "description" => "Enter a description for this graph item input to describe what this input is used for.", "value" => "|arg1:description|", "textarea_rows" => "5", "textarea_cols" => "40"), "column_name" => array("method" => "drop_array", "friendly_name" => "Field Type", "description" => "How data is to be represented on the graph.", "value" => "|arg1:column_name|", "array" => "|arg2:|"), "graph_template_id" => array("method" => "hidden_zero", "value" => "|arg3:graph_template_id|"), "graph_template_input_id" => array("method" => "hidden_zero", "value" => "|arg3:id|"), "save_component_input" => array("method" => "hidden", "value" => "1"));
/* file: host.php, action: edit */
$fields_host_edit = array("host_header" => array("method" => "spacer", "friendly_name" => "General Host Options"), "description" => array("method" => "textbox", "friendly_name" => "Description", "description" => "Give this host a meaningful description.", "value" => "|arg1:description|", "max_length" => "250"), "hostname" => array("method" => "textbox", "friendly_name" => "Hostname", "description" => "Fully qualified hostname or IP address for this device.", "value" => "|arg1:hostname|", "max_length" => "250"), "host_template_id" => array("method" => "drop_sql", "friendly_name" => "Host Template", "description" => "Choose the Host Template to use to define the default Graph Templates and Data Queries associated with this Host.", "value" => "|arg1:host_template_id|", "none_value" => "None", "sql" => "select id,name from host_template order by name"), "device_threads" => array("method" => "drop_array", "friendly_name" => "Number of Collection Threads", "description" => "The number of concurrent threads to use for polling this device.  This applies to the Spine poller only.", "value" => "|arg1:device_threads|", "default" => "1", "array" => $device_threads), "disabled" => array("method" => "checkbox", "friendly_name" => "Disable Host", "description" => "Check this box to disable all checks for this host.", "value" => "|arg1:disabled|", "default" => "", "form_id" => false), "availability_header" => array("method" => "spacer", "friendly_name" => "Availability/Reachability Options"), "availability_method" => array("friendly_name" => "Downed Device Detection", "description" => "The method Cacti will use to determine if a host is available for polling.  <br><i>NOTE: It is recommended that, at a minimum, SNMP always be selected.</i>", "on_change" => "changeHostForm()", "value" => "|arg1:availability_method|", "method" => "drop_array", "default" => read_config_option("availability_method"), "array" => $availability_options), "ping_method" => array("friendly_name" => "Ping Method", "description" => "The type of ping packet to sent.  <br><i>NOTE: ICMP on Linux/UNIX requires root privileges.</i>", "on_change" => "changeHostForm()", "value" => "|arg1:ping_method|", "method" => "drop_array", "default" => read_config_option("ping_method"), "array" => $ping_methods), "ping_port" => array("method" => "textbox", "friendly_name" => "Ping Port", "value" => "|arg1:ping_port|", "description" => "TCP or UDP port to attempt connection.", "default" => read_config_option("ping_port"), "max_length" => "50", "size" => "15"), "ping_timeout" => array("friendly_name" => "Ping Timeout Value", "description" => "The timeout value to use for host ICMP and UDP pinging.  This host SNMP timeout value applies for SNMP pings.", "method" => "textbox", "value" => "|arg1:ping_timeout|", "default" => read_config_option("ping_timeout"), "max_length" => "10", "size" => "15"), "ping_retries" => array("friendly_name" => "Ping Retry Count", "description" => "After an initial failure, the number of ping retries Cacti will attempt before failing.", "method" => "textbox", "value" => "|arg1:ping_retries|", "default" => read_config_option("ping_retries"), "max_length" => "10", "size" => "15"), "spacer1" => array("method" => "spacer", "friendly_name" => "SNMP Options"), "snmp_version" => array("method" => "drop_array", "friendly_name" => "SNMP Version", "description" => "Choose the SNMP version for this device.", "on_change" => "changeHostForm()", "value" => "|arg1:snmp_version|", "default" => read_config_option("snmp_ver"), "array" => $snmp_versions), "snmp_community" => array("method" => "textbox", "friendly_name" => "SNMP Community", "description" => "SNMP read community for this device.", "value" => "|arg1:snmp_community|", "form_id" => "|arg1:id|", "default" => read_config_option("snmp_community"), "max_length" => "100", "size" => "15"), "snmp_username" => array("method" => "textbox", "friendly_name" => "SNMP Username (v3)", "description" => "SNMP v3 username for this device.", "value" => "|arg1:snmp_username|", "default" => read_config_option("snmp_username"), "max_length" => "50", "size" => "15"), "snmp_password" => array("method" => "textbox_password", "friendly_name" => "SNMP Password (v3)", "description" => "SNMP v3 authentication pass phrase for this device.", "value" => "|arg1:snmp_password|", "default" => read_config_option("snmp_password"), "max_length" => "50", "size" => "15"), "snmp_auth_protocol" => array("method" => "drop_array", "friendly_name" => "SNMP Auth Protocol (v3)", "description" => "Choose the SNMPv3 authentication protocol.", "value" => "|arg1:snmp_auth_protocol|", "default" => read_config_option("snmp_auth_protocol"), "array" => $snmp_auth_protocols), "snmp_priv_passphrase" => array("method" => "textbox", "friendly_name" => "SNMP Privacy Passphrase (v3)", "description" => "Choose the SNMPv3 privacy passphrase.", "value" => "|arg1:snmp_priv_passphrase|", "default" => read_config_option("snmp_priv_passphrase"), "max_length" => "200", "size" => "40"), "snmp_priv_protocol" => array("method" => "drop_array", "friendly_name" => "SNMP privacy protocol (v3)", "description" => "Choose the SNMPv3 privacy protocol.", "value" => "|arg1:snmp_priv_protocol|", "default" => read_config_option("snmp_priv_protocol"), "array" => $snmp_priv_protocols), "snmp_context" => array("method" => "textbox", "friendly_name" => "SNMP Context", "description" => "Enter the SNMP context to use for this device.", "value" => "|arg1:snmp_context|", "default" => "", "max_length" => "64", "size" => "25"), "snmp_port" => array("method" => "textbox", "friendly_name" => "SNMP Port", "description" => "Enter the UDP port number to use for SNMP (default is 161).", "value" => "|arg1:snmp_port|", "max_length" => "5", "default" => read_config_option("snmp_port"), "size" => "15"), "snmp_timeout" => array("method" => "textbox", "friendly_name" => "SNMP Timeout", "description" => "The maximum number of milliseconds Cacti will wait for an SNMP response (does not work with php-snmp support).", "value" => "|arg1:snmp_timeout|", "max_length" => "8", "default" => read_config_option("snmp_timeout"), "size" => "15"), "max_oids" => array("method" => "textbox", "friendly_name" => "Maximum OID's Per Get Request", "description" => "Specified the number of OID's that can be obtained in a single SNMP Get request.", "value" => "|arg1:max_oids|", "max_length" => "8", "default" => read_config_option("max_get_size"), "size" => "15"), "header4" => array("method" => "spacer", "friendly_name" => "Additional Options"), "notes" => array("method" => "textarea", "friendly_name" => "Notes", "description" => "Enter notes to this host.", "class" => "textAreaNotes", "value" => "|arg1:notes|", "textarea_rows" => "5", "textarea_cols" => "50"), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "_host_template_id" => array("method" => "hidden_zero", "value" => "|arg1:host_template_id|"), "save_component_host" => array("method" => "hidden", "value" => "1"));
/* file: host_templates.php, action: edit */
$fields_host_template_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "A useful name for this host template.", "value" => "|arg1:name|", "max_length" => "255"), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_template" => array("method" => "hidden", "value" => "1"));
/* file: rra.php, action: edit */
$fields_rra_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "How data is to be entered in RRA's.", "value" => "|arg1:name|", "max_length" => "100"), "consolidation_function_id" => array("method" => "drop_multi", "friendly_name" => "Consolidation Functions", "description" => "How data is to be entered in RRA's.", "array" => $consolidation_functions, "sql" => "select consolidation_function_id as id,rra_id from rra_cf where rra_id=|arg1:id|"), "x_files_factor" => array("method" => "textbox", "friendly_name" => "X-Files Factor", "description" => "The amount of unknown data that can still be regarded as known.", "value" => "|arg1:x_files_factor|", "max_length" => "10"), "steps" => array("method" => "textbox", "friendly_name" => "Steps", "description" => "How many data points are needed to put data into the RRA.", "value" => "|arg1:steps|", "max_length" => "8"), "rows" => array("method" => "textbox", "friendly_name" => "Rows", "description" => "How many generations data is kept in the RRA.", "value" => "|arg1:rows|", "max_length" => "12"), "timespan" => array("method" => "textbox", "friendly_name" => "Timespan", "description" => "How many seconds to display in graph for this RRA.", "value" => "|arg1:timespan|", "max_length" => "12"), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_rra" => array("method" => "hidden", "value" => "1"));
/* file: data_queries.php, action: edit */
$fields_data_query_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "A name for this data query.", "value" => "|arg1:name|", "max_length" => "100"), "description" => array("method" => "textbox", "friendly_name" => "Description", "description" => "A description for this data query.", "value" => "|arg1:description|", "size" => "80", "max_length" => "255"), "xml_path" => array("method" => "textbox", "friendly_name" => "XML Path", "description" => "The full path to the XML file containing definitions for this data query.", "value" => "|arg1:xml_path|", "default" => "<path_cacti>/resource/", "size" => "80", "max_length" => "255"), "data_input_id" => array("method" => "drop_sql", "friendly_name" => "Data Input Method", "description" => "Choose the input method for this Data Query.  This input method defines how data is collected for each Host associated with the Data Query.", "value" => "|arg1:data_input_id|", "sql" => "select id,name from data_input where (type_id=3 or type_id=4 or type_id=5 or type_id=6) order by name"), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_snmp_query" => array("method" => "hidden", "value" => "1"));
/* file: data_queries.php, action: item_edit */
$fields_data_query_item_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "A name for this associated graph.", "value" => "|arg1:name|", "max_length" => "100"), "graph_template_id" => array("method" => "drop_sql", "friendly_name" => "Graph Template", "description" => "Choose the Graph Template to use for this Data Query Graph Template item.", "value" => "|arg1:graph_template_id|", "sql" => "select id,name from graph_templates order by name"), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "snmp_query_id" => array("method" => "hidden_zero", "value" => "|arg2:snmp_query_id|"), "_graph_template_id" => array("method" => "hidden_zero", "value" => "|arg1:graph_template_id|"), "save_component_snmp_query_item" => array("method" => "hidden", "value" => "1"));
/* file: tree.php, action: edit */
$fields_tree_edit = array("name" => array("method" => "textbox", "friendly_name" => "Name", "description" => "A useful name for this graph tree.", "value" => "|arg1:name|", "max_length" => "255"), "sort_type" => array("method" => "drop_array", "friendly_name" => "Sorting Type", "description" => "Choose how items in this tree will be sorted.", "value" => "|arg1:sort_type|", "array" => $tree_sort_types), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_tree" => array("method" => "hidden", "value" => "1"));
/* file: user_admin.php, action: user_edit (host) */
$fields_user_user_edit_host = array("username" => array("method" => "textbox", "friendly_name" => "User Name", "description" => "The login name for this user.", "value" => "|arg1:username|", "max_length" => "255"), "full_name" => array("method" => "textbox", "friendly_name" => "Full Name", "description" => "A more descriptive name for this user, that can include spaces or special characters.", "value" => "|arg1:full_name|", "max_length" => "255"), "password" => array("method" => "textbox_password", "friendly_name" => "Password", "description" => "Enter the password for this user twice. Remember that passwords are case sensitive!", "value" => "", "max_length" => "255"), "enabled" => array("method" => "checkbox", "friendly_name" => "Enabled", "description" => "Determines if user is able to login.", "value" => "|arg1:enabled|", "default" => ""), "grp1" => array("friendly_name" => "Account Options", "method" => "checkbox_group", "description" => "Set any user account-specific options here.", "items" => array("must_change_password" => array("value" => "|arg1:must_change_password|", "friendly_name" => "User Must Change Password at Next Login", "form_id" => "|arg1:id|", "default" => ""), "graph_settings" => array("value" => "|arg1:graph_settings|", "friendly_name" => "Allow this User to Keep Custom Graph Settings", "form_id" => "|arg1:id|", "default" => "on"))), "grp2" => array("friendly_name" => "Graph Options", "method" => "checkbox_group", "description" => "Set any graph-specific options here.", "items" => array("show_tree" => array("value" => "|arg1:show_tree|", "friendly_name" => "User Has Rights to Tree View", "form_id" => "|arg1:id|", "default" => "on"), "show_list" => array("value" => "|arg1:show_list|", "friendly_name" => "User Has Rights to List View", "form_id" => "|arg1:id|", "default" => "on"), "show_preview" => array("value" => "|arg1:show_preview|", "friendly_name" => "User Has Rights to Preview View", "form_id" => "|arg1:id|", "default" => "on"))), "login_opts" => array("friendly_name" => "Login Options", "method" => "radio", "default" => "1", "description" => "What to do when this user logs in.", "value" => "|arg1:login_opts|", "items" => array(0 => array("radio_value" => "1", "radio_caption" => "Show the page that user pointed their browser to."), 1 => array("radio_value" => "2", "radio_caption" => "Show the default console screen."), 2 => array("radio_value" => "3", "radio_caption" => "Show the default graph screen."))), "realm" => array("method" => "drop_array", "friendly_name" => "Authentication Realm", "description" => "Only used if you have LDAP or Web Basic Authentication enabled.  Changing this to an non-enabled realm will effectively disable the user.", "value" => "|arg1:realm|", "default" => 0, "array" => $auth_realms), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "_policy_graphs" => array("method" => "hidden", "default" => "2", "value" => "|arg1:policy_graphs|"), "_policy_trees" => array("method" => "hidden", "default" => "2", "value" => "|arg1:policy_trees|"), "_policy_hosts" => array("method" => "hidden", "default" => "2", "value" => "|arg1:policy_hosts|"), "_policy_graph_templates" => array("method" => "hidden", "default" => "2", "value" => "|arg1:policy_graph_templates|"), "save_component_user" => array("method" => "hidden", "value" => "1"));
$export_types = array("graph_template" => array("name" => "Graph Template", "title_sql" => "select name from graph_templates where id=|id|", "dropdown_sql" => "select id,name from graph_templates order by name"), "data_template" => array("name" => "Data Template", "title_sql" => "select name from data_template where id=|id|", "dropdown_sql" => "select id,name from data_template order by name"), "host_template" => array("name" => "Host Template", "title_sql" => "select name from host_template where id=|id|", "dropdown_sql" => "select id,name from host_template order by name"), "data_query" => array("name" => "Data Query", "title_sql" => "select name from snmp_query where id=|id|", "dropdown_sql" => "select id,name from snmp_query order by name"));
$fields_template_import = array("import_file" => array("friendly_name" => "Import Template from Local File", "description" => "If the XML file containing template data is located on your local machine, select it here.", "method" => "file"), "import_text" => array("method" => "textarea", "friendly_name" => "Import Template from Text", "description" => "If you have the XML file containing template data as text, you can paste it into this box to import it.", "value" => "", "default" => "", "textarea_rows" => "10", "textarea_cols" => "50", "class" => "textAreaNotes"), "import_rra" => array("friendly_name" => "Import RRA Settings", "description" => "Choose whether to allow Cacti to import custom RRA settings from imported templates or whether to use the defaults for this installation.", "method" => "radio", "value" => "", "default" => "1", "on_change" => "changeRRA()", "items" => array(0 => array("radio_value" => "1", "radio_caption" => "Select your RRA settings below (Recommended)"), 1 => array("radio_value" => "2", "radio_caption" => "Use custom RRA settings from the template"))), "rra_id" => array("method" => "drop_multi_rra", "friendly_name" => "Associated RRA's", "description" => "Which RRA's to use when entering data (It is recommended that you <strong>deselect unwanted values</strong>).", "form_id" => "", "sql_all" => "select rra.id from rra where id in (1,2,3,4) order by id"));
api_plugin_hook('config_form');
Example #24
0
function utilities() {
	global $colors;

	html_start_box("<strong>" . __("Cacti System Utilities") . "</strong>", "100", $colors["header"], 0, "center", "");


	print "<tr><td>";
	html_header(array(__("Technical Support")), 2,'','','left wp100'); ?>

	<tr class="rowAlternate1">
		<td class="textAreaNotes">
			<a href='<?php print htmlspecialchars("utilities.php?action=view_tech&tab=general");?>'><?php print __("Technical Support");?></a>
		</td>
		<td class="textAreaNotes">
			<?php print __("Cacti technical support page.  Used by developers and technical support persons to assist with issues in Cacti.  Includes checks for common configuration issues.");?>
		</td>
	</tr>

	<?php
	print "</table></td></tr>";		/* end of html_header */
	print "<tr><td>";
	html_header(array(__("Log Administration")), 2,'','','left wp100');?>

	<tr class="rowAlternate1">
		<td class="textAreaNotes">
			<a href='<?php print htmlspecialchars("utilities.php?action=view_logfile");?>'><?php print __("View Cacti Log File");?></a>
		</td>
		<td class="textAreaNotes">
			<?php print __("The Cacti Log File stores statistic, error and other message depending on system settings.  This information can be used to identify problems with the poller and application.");?>
		</td>
	</tr>
	<tr class="rowAlternate2">
		<td class="textAreaNotes">
			<a href='<?php print htmlspecialchars("utilities.php?action=view_user_log");?>'><?php print __("View User Log");?></a>
		</td>
		<td class="textAreaNotes">
			<?php print __("Allows Administrators to browse the user log.  Administrators can filter and export the log as well.");?>
		</td>
	</tr>

	<?php
	print "</table></td></tr>";		/* end of html_header */
	print "<tr><td>";
	html_header(array(__("Poller Cache Administration")), 2,'','','left wp100'); ?>

	<tr class="rowAlternate1">
		<td class="textAreaNotes">
			<a href='<?php print htmlspecialchars("utilities.php?action=view_poller_cache");?>'><?php print __("View Poller Cache");?></a>
		</td>
		<td class="textAreaNotes">
			<?php print __("This is the data that is being passed to the poller each time it runs. This data is then in turn executed/interpreted and the results are fed into the rrd files for graphing or the database for display.");?>
		</td>
	</tr>
	<tr class="rowAlternate2">
		<td class="textAreaNotes">
			<a href='<?php print htmlspecialchars("utilities.php?action=view_snmp_cache");?>'><?php print __("View SNMP Cache");?></a>
		</td>
		<td class="textAreaNotes">
			<?php print __("The SNMP cache stores information gathered from SNMP queries. It is used by cacti to determine the OID to use when gathering information from an SNMP-enabled device.");?>
		</td>
	</tr>
	<tr class="rowAlternate1">
		<td class="textAreaNotes">
			<a href='<?php print htmlspecialchars("utilities.php?action=clear_poller_cache");?>'><?php print __("Rebuild Poller Cache");?></a>
		</td>
		<td class="textAreaNotes">
			<?php print __("The poller cache will be cleared and re-generated if you select this option. Sometimes device/data source data can get out of sync with the cache in which case it makes sense to clear the cache and start over.");?>
		</td>
	</tr>

	<?php

	print "</table></td></tr>";		/* end of html_header */

	api_plugin_hook('utilities_list');

	html_end_box();
}
Example #25
0
        }
        ?>
<a href="<?php 
        echo $config['url_path'];
        ?>
graph_view.php"><img src="<?php 
        echo $config['url_path'];
        ?>
images/tab_graphs<?php 
        if (substr(basename($_SERVER["PHP_SELF"]), 0, 5) == "graph" || basename($_SERVER["PHP_SELF"]) == "graph_settings.php") {
            print "_down";
        }
        print ".gif";
        ?>
" alt="Graphs" align="absmiddle" border="0"></a><?php 
        api_plugin_hook('top_graph_header_tabs');
        ?>
&nbsp;
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr height="2" colspan="2" bgcolor="#183c8f" class="noprint">
		<td colspan="2">
			<img src="<?php 
        echo $config['url_path'];
        ?>
images/transparent_line.gif" width="170" height="2" border="0"><br>
		</td>
	</tr>
Example #26
0
function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "")
{
    global $config;
    $i = 0;
    $k = 0;
    $j = 0;
    $num_graphs = sizeof($graph_array);
    if ($num_graphs > 0) {
        if ($header != "") {
            print $header;
        }
        $start = true;
        foreach ($graph_array as $graph) {
            if (isset($graph["graph_template_name"])) {
                if (isset($prev_graph_template_name)) {
                    if ($prev_graph_template_name != $graph["graph_template_name"]) {
                        $print = true;
                        $prev_graph_template_name = $graph["graph_template_name"];
                    } else {
                        $print = false;
                    }
                } else {
                    $print = true;
                    $prev_graph_template_name = $graph["graph_template_name"];
                }
                if ($print) {
                    if (!$start) {
                        while ($i % read_graph_config_option("num_columns") != 0) {
                            print "<td align='center' width='" . ceil(100 / read_graph_config_option("num_columns")) . "%'></td>";
                            $i++;
                        }
                        print "</tr>";
                    }
                    print "<tr style='background-color:#a9b7cb;'>\r\n\t\t\t\t\t\t<td style='background-color:#a9b7cb;' colspan='" . read_graph_config_option("num_columns") . "' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t<strong>Graph Template:</strong> " . $graph["graph_template_name"] . "\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>";
                    $i = 0;
                }
            } elseif (isset($graph["data_query_name"])) {
                if (isset($prev_data_query_name)) {
                    if ($prev_data_query_name != $graph["data_query_name"]) {
                        $print = true;
                        $prev_data_query_name = $graph["data_query_name"];
                    } else {
                        $print = false;
                    }
                } else {
                    $print = true;
                    $prev_data_query_name = $graph["data_query_name"];
                }
                if ($print) {
                    if (!$start) {
                        while ($i % read_graph_config_option("num_columns") != 0) {
                            print "<td align='center' width='" . ceil(100 / read_graph_config_option("num_columns")) . "%'></td>";
                            $i++;
                        }
                        print "</tr>";
                    }
                    print "<tr style='background-color:#a9b7cb;'>\r\n\t\t\t\t\t\t\t<td style='background-color:#a9b7cb;' colspan='" . read_graph_config_option("num_columns") . "' class='textHeaderDark'><strong>Data Query:</strong> " . $graph["data_query_name"] . "</td>\r\n\t\t\t\t\t\t</tr>";
                    $i = 0;
                }
                if (!isset($prev_sort_field_value) || $prev_sort_field_value != $graph["sort_field_value"]) {
                    $prev_sort_field_value = $graph["sort_field_value"];
                    print "<tr style='background-color:#a9b7cb;'>\r\n\t\t\t\t\t\t<td style='background-color:#a9b7cb;' colspan='" . read_graph_config_option("num_columns") . "' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t" . $graph["sort_field_value"] . "\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>";
                    $i = 0;
                    $j = 0;
                }
            }
            if ($i == 0) {
                print "<tr style='background-color: #" . ($j % 2 == 0 ? "F2F2F2" : "FFFFFF") . ";'>";
                $start = false;
            }
            ?>
			<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";
            ?>
;"><a href='<?php 
            print htmlspecialchars($config['url_path'] . "graph.php?action=view&rra_id=all&local_graph_id=" . $graph["local_graph_id"]);
            ?>
'><img class='graphimage' id='graph_<?php 
            print $graph["local_graph_id"];
            ?>
' src='<?php 
            print htmlspecialchars($config["url_path"] . "graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=0&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true" . ($extra_url_args == "" ? "" : "&{$extra_url_args}"));
            ?>
' border='0' alt='<?php 
            print htmlspecialchars($graph["title_cache"]);
            ?>
'></a></div>
							<?php 
            print read_graph_config_option("show_graph_title") == "on" ? "<p style='font-size: 10;' align='center'><strong>" . htmlspecialchars($graph["title_cache"]) . "</strong></p>" : "";
            ?>
						</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>
			<?php 
            $i++;
            $k++;
            if ($i % read_graph_config_option("num_columns") == 0 && $k < $num_graphs) {
                $i = 0;
                $j++;
                print "</tr>";
                $start = true;
            }
        }
        if (!$start) {
            while ($i % read_graph_config_option("num_columns") != 0) {
                print "<td align='center' width='" . ceil(100 / read_graph_config_option("num_columns")) . "%'></td>";
                $i++;
            }
            print "</tr>";
        }
    } else {
        if ($no_graphs_message != "") {
            print "<td><em>{$no_graphs_message}</em></td>";
        }
    }
}
Example #27
0
function graphs()
{
    global $item_rows;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('host_id'));
    input_validate_input_number(get_request_var_request('graph_type'));
    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_request('filter'));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST['clear_x'])) {
        kill_session_var('sess_graphs_new_filter');
        kill_session_var('sess_default_rows');
        unset($_REQUEST['filter']);
        unset($_REQUEST['rows']);
        $changed = true;
    } else {
        /* if any of the settings changed, reset the page number */
        $changed = false;
        $changed += check_changed('host_id', 'sess_graphs_new_host_id');
        $changed += check_changed('graph_type', 'sess_graphs_new_graph_type');
        $changed += check_changed('filter', 'sess_graphs_new_filter');
        $changed += check_changed('rows', 'sess_default_rows');
    }
    load_current_session_value('host_id', 'sess_graphs_new_host_id', db_fetch_cell('SELECT id FROM host ORDER BY description, hostname LIMIT 1'));
    load_current_session_value('graph_type', 'sess_graphs_new_graph_type', read_config_option('default_graphs_new_dropdown'));
    load_current_session_value('filter', 'sess_graphs_new_filter', '');
    load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table'));
    if (!empty($_REQUEST['host_id'])) {
        $host = db_fetch_row_prepared('SELECT id, description, hostname, host_template_id FROM host WHERE id = ?', array($_REQUEST['host_id']));
        $header = ' [ ' . htmlspecialchars($host['description']) . ' (' . htmlspecialchars($host['hostname']) . ') ' . (!empty($host['host_template_id']) ? htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM host_template WHERE id = ?', array($host['host_template_id']))) : '') . ' ]';
    } else {
        $host = array();
        $header = 'None Host Type';
    }
    $row_limit = get_request_var_request('rows');
    html_start_box("<strong>New Graphs for</strong> {$header}", '100%', '', '3', 'center', '');
    form_alternate_row();
    print '<td class="even">';
    ?>
	<script type='text/javascript'>
	<!--

	function applyFilter() {
		strURL = '?graph_type=' + $('#graph_type').val();
		strURL = strURL + '&host_id=' + $('#host_id').val();
		strURL = strURL + '&filter=' + $('#filter').val();;
		strURL = strURL + '&rows=' + $('#rows').val();;
		document.location = strURL;
	}

	-->
	</script>
	<form name='form_graphs_new' action='graphs_new.php'>
	<table width='100%' cellpadding='2' cellspacing='0' border='0' align='left'>
		<tr>
			<?php 
    print html_host_filter($_REQUEST['host_id']);
    ?>
			<td style='white-space:nowrap;' width='1'>
				Graph Types
			</td>
			<td width='1'>
				<select id='graph_type' name='graph_type' onChange='applyFilter()'>
					<option value='-2'<?php 
    if ($_REQUEST['graph_type'] == '-2') {
        ?>
 selected<?php 
    }
    ?>
>All</option>
					<option value='-1'<?php 
    if ($_REQUEST['graph_type'] == '-1') {
        ?>
 selected<?php 
    }
    ?>
>Graph Template Based</option>
					<?php 
    $snmp_queries = db_fetch_assoc_prepared('SELECT
						snmp_query.id,
						snmp_query.name,
						snmp_query.xml_path
						FROM (snmp_query, host_snmp_query)
						WHERE host_snmp_query.snmp_query_id = snmp_query.id
						AND host_snmp_query.host_id = ?
						ORDER BY snmp_query.name', array($host['id']));
    if (sizeof($snmp_queries) > 0) {
        foreach ($snmp_queries as $query) {
            print "<option value='" . $query['id'] . "'";
            if ($_REQUEST['graph_type'] == $query['id']) {
                print ' selected';
            }
            print '>' . $query['name'] . "</option>\n";
        }
    }
    ?>
				</select>
			</td>
			<td width='50'>
				Rows
			</td>
			<td>
				<select id='rows' name='rows' onChange='applyFilter()'>
					<?php 
    if (sizeof($item_rows) > 0) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if (get_request_var_request('rows') == $key) {
                print ' selected';
            }
            print '>' . htmlspecialchars($value) . "</option>\n";
        }
    }
    ?>
				</select>
			</td>
			<td rowspan='3' class='textInfo' align='right' valign='top'>
				<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
    print htmlspecialchars('host.php?action=edit&id=' . $_REQUEST['host_id']);
    ?>
'>Edit this Device</a><br>
				<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
    print htmlspecialchars('host.php?action=edit');
    ?>
'>Create New Device</a><br>
				<?php 
    api_plugin_hook('graphs_new_top_links');
    ?>
			</td>
		</tr>
		<tr style='<?php 
    if ($_REQUEST['graph_type'] <= 0) {
        ?>
display:none;<?php 
    }
    ?>
'>
			<td width='50'>
				Search
			</td>
			<td style='white-space:nowrap;'>
				<input id='filter' type='text' name='filter' size='25' value='<?php 
    print htmlspecialchars(get_request_var_request('filter'));
    ?>
'>
			</td>
			<td colspan='3' style='white-space:nowrap;'>
				<input type='submit' value='Go' title='Set/Refresh Filters'>
				<input type='submit' name='clear_x' value='Clear' title='Clear Filters'>
			</td>
		</tr>
	</table>
	</form>
	</td>
	</tr>

	<?php 
    html_end_box();
    ?>

	<form name='chk' method='post' action='graphs_new.php'>
	<?php 
    $total_rows = sizeof(db_fetch_assoc_prepared('SELECT graph_template_id FROM host_graph WHERE host_id = ?', array($_REQUEST['host_id'])));
    $i = 0;
    if ($changed) {
        foreach ($snmp_queries as $query) {
            kill_session_var('sess_graphs_new_page' . $query['id']);
            unset($_REQUEST['page' . $query['id']]);
            load_current_session_value('page' . $query['id'], 'sess_graphs_new_page' . $query['id'], '1');
        }
    }
    if ($_REQUEST['graph_type'] > 0) {
        load_current_session_value('page' . $_REQUEST['graph_type'], 'sess_graphs_new_page' . $_REQUEST['graph_type'], '1');
    } else {
        if ($_REQUEST['graph_type'] == -2) {
            foreach ($snmp_queries as $query) {
                load_current_session_value('page' . $query['id'], 'sess_graphs_new_page' . $query['id'], '1');
            }
        }
    }
    $script = "<script type='text/javascript'>\nvar gt_created_graphs = new Array();\nvar created_graphs = new Array()\n";
    if ($_REQUEST['graph_type'] < 0) {
        html_start_box('<strong>Graph Templates</strong>', '100%', '', '3', 'center', '');
        print "<tr class='tableHeader'>\n\t\t\t\t<td class='tableSubHeaderColumn'>Graph Template Name</td>\n\t\t\t\t<td width='1%' align='center' class='tableSubHeaderCheckbox' style='" . get_checkbox_style() . "'><input type='checkbox' style='margin: 0px;' name='all_cg' title='Select All' onClick='SelectAll(\"sg\",this.checked);'></td>\n\n\t\t\t</tr>\n";
        $graph_templates = db_fetch_assoc_prepared('SELECT
			graph_templates.id AS graph_template_id,
			graph_templates.name AS graph_template_name
			FROM (host_graph, graph_templates)
			WHERE host_graph.graph_template_id = graph_templates.id
			AND host_graph.host_id = ?
			ORDER BY graph_templates.name', array($_REQUEST['host_id']));
        if (!empty($_REQUEST['host_id'])) {
            $template_graphs = db_fetch_assoc_prepared('SELECT
				graph_local.graph_template_id
				FROM (graph_local, host_graph)
				WHERE graph_local.graph_template_id = host_graph.graph_template_id
				AND graph_local.host_id = host_graph.host_id
				AND graph_local.host_id = ?
				GROUP BY graph_local.graph_template_id', array($host['id']));
            if (sizeof($template_graphs) > 0) {
                $script .= 'var gt_created_graphs = new Array(';
                $cg_ctr = 0;
                foreach ($template_graphs as $template_graph) {
                    $script .= ($cg_ctr > 0 ? ',' : '') . "'" . $template_graph['graph_template_id'] . "'";
                    $cg_ctr++;
                }
                $script .= ")\n";
            }
        }
        /* create a row for each graph template associated with the host template */
        if (sizeof($graph_templates) > 0) {
            foreach ($graph_templates as $graph_template) {
                $query_row = $graph_template['graph_template_id'];
                print "<tr id='gt_line{$query_row}' class='selectable " . ($i % 2 == 0 ? 'odd' : 'even') . "'>";
                $i++;
                print "<td>\n\t\t\t\t\t\t<span id='gt_text{$query_row}" . "_0'>" . htmlspecialchars($graph_template['graph_template_name']) . "</span>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td align='right' class='checkbox'>\n\t\t\t\t\t\t<input type='checkbox' name='cg_{$query_row}' id='cg_{$query_row}'>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>";
            }
        }
        html_end_box();
        html_start_box('', '100%', '', '3', 'center', '');
        $available_graph_templates = db_fetch_assoc('SELECT
			graph_templates.id, graph_templates.name
			FROM snmp_query_graph RIGHT JOIN graph_templates
			ON (snmp_query_graph.graph_template_id = graph_templates.id)
			WHERE (((snmp_query_graph.name) Is Null)) ORDER BY graph_templates.name');
        /* create a row at the bottom that lets the user create any graph they choose */
        print "\t<tr class='even'>\n\t\t\t\t<td width='1'><i>Create</i></td>\n\t\t\t\t<td align='left'>";
        form_dropdown('cg_g', $available_graph_templates, 'name', 'id', '', '(Select a graph type to create)', '', 'textArea');
        print '</td>
			</tr>';
        html_end_box();
    }
    if ($_REQUEST['graph_type'] != -1 && !empty($_REQUEST['host_id'])) {
        $snmp_queries = db_fetch_assoc('SELECT
			snmp_query.id,
			snmp_query.name,
			snmp_query.xml_path
			FROM (snmp_query,host_snmp_query)
			WHERE host_snmp_query.snmp_query_id=snmp_query.id
			AND host_snmp_query.host_id=' . $host['id'] . ($_REQUEST['graph_type'] != -2 ? ' AND snmp_query.id=' . $_REQUEST['graph_type'] : '') . '
			ORDER BY snmp_query.name');
        if (sizeof($snmp_queries) > 0) {
            foreach ($snmp_queries as $snmp_query) {
                unset($total_rows);
                if (!$changed) {
                    $page = $_REQUEST['page' . $snmp_query['id']];
                } else {
                    $page = 1;
                }
                $xml_array = get_data_query_array($snmp_query['id']);
                $num_input_fields = 0;
                $num_visible_fields = 0;
                if ($xml_array != false) {
                    /* loop through once so we can find out how many input fields there are */
                    reset($xml_array['fields']);
                    while (list($field_name, $field_array) = each($xml_array['fields'])) {
                        if ($field_array['direction'] == 'input') {
                            $num_input_fields++;
                            if (!isset($total_rows)) {
                                $total_rows = db_fetch_cell_prepared('SELECT count(*) FROM host_snmp_cache WHERE host_id = ? AND snmp_query_id = ? AND field_name = ?', array($host['id'], $snmp_query['id'], $field_name));
                            }
                        }
                    }
                }
                if (!isset($total_rows)) {
                    $total_rows = 0;
                }
                $snmp_query_graphs = db_fetch_assoc_prepared('SELECT snmp_query_graph.id,snmp_query_graph.name FROM snmp_query_graph WHERE snmp_query_graph.snmp_query_id = ? ORDER BY snmp_query_graph.name', array($snmp_query['id']));
                if (sizeof($snmp_query_graphs) > 0) {
                    foreach ($snmp_query_graphs as $snmp_query_graph) {
                        $created_graphs = db_fetch_assoc_prepared("SELECT DISTINCT\n\t\t\t\t\t\tdata_local. snmp_index\n\t\t\t\t\t\tFROM (data_local, data_template_data)\n\t\t\t\t\t\tLEFT JOIN data_input_data ON (data_template_data.id = data_input_data.data_template_data_id)\n\t\t\t\t\t\tLEFT JOIN data_input_fields ON (data_input_data.data_input_field_id = data_input_fields.id)\n\t\t\t\t\t\tWHERE data_local.id = data_template_data.local_data_id\n\t\t\t\t\t\tAND data_input_fields.type_code = 'output_type'\n\t\t\t\t\t\tAND data_input_data.value = ?\n\t\t\t\t\t\tAND data_local.host_id = ?", array($snmp_query_graph['id'], $host['id']));
                        $script .= 'created_graphs[' . $snmp_query_graph['id'] . '] = new Array(';
                        $cg_ctr = 0;
                        if (sizeof($created_graphs) > 0) {
                            foreach ($created_graphs as $created_graph) {
                                $script .= ($cg_ctr > 0 ? ',' : '') . "'" . encode_data_query_index($created_graph['snmp_index']) . "'";
                                $cg_ctr++;
                            }
                        }
                        $script .= ")\n";
                    }
                }
                print "\t<table width='100%' class='cactiTable' align='center' cellpadding='3' cellspacing='0'>\n\n\t\t\t\t\t<tr class='cactiTableTitle'>\n\t\t\t\t\t\t<td colspan='" . ($num_input_fields + 1) . "'>\n\t\t\t\t\t\t\t<table  cellspacing='0' cellpadding='0' width='100%' >\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t\t<strong>Data Query</strong> [" . $snmp_query['name'] . "]\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td align='right' nowrap>\n\t\t\t\t\t\t\t\t\t\t<a href='" . htmlspecialchars('graphs_new.php?action=query_reload&id=' . $snmp_query['id'] . '&host_id=' . $host['id']) . "'><img src='images/reload_icon_small.gif' title='Reload Associated Query' alt='' border='0' align='absmiddle'></a>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
                if ($xml_array != false) {
                    $html_dq_header = '';
                    $snmp_query_indexes = array();
                    reset($xml_array['fields']);
                    /* if there is a where clause, get the matching snmp_indexes */
                    $sql_where = '';
                    if (strlen($_REQUEST['filter'])) {
                        $sql_where = '';
                        $indexes = db_fetch_assoc("SELECT DISTINCT snmp_index\n\t\t\t\t\t\tFROM host_snmp_cache\n\t\t\t\t\t\tWHERE field_value LIKE '%%" . $_REQUEST['filter'] . "%%'\n\t\t\t\t\t\tAND snmp_query_id=" . $snmp_query['id'] . "\n\t\t\t\t\t\tAND host_id=" . $host['id']);
                        if (sizeof($indexes)) {
                            foreach ($indexes as $index) {
                                if (strlen($sql_where)) {
                                    $sql_where .= ", '" . $index['snmp_index'] . "'";
                                } else {
                                    $sql_where .= " AND snmp_index IN('" . $index['snmp_index'] . "'";
                                }
                            }
                            $sql_where .= ')';
                        }
                    }
                    if (strlen($_REQUEST['filter']) == 0 || strlen($_REQUEST['filter']) && sizeof($indexes)) {
                        /* determine the sort order */
                        if (isset($xml_array['index_order_type'])) {
                            if ($xml_array['index_order_type'] == 'numeric') {
                                $sql_order = 'ORDER BY CAST(snmp_index AS unsigned)';
                            } else {
                                if ($xml_array['index_order_type'] == 'alphabetic') {
                                    $sql_order = 'ORDER BY snmp_index';
                                } else {
                                    if ($xml_array['index_order_type'] == 'natural') {
                                        $sql_order = 'ORDER BY INET_ATON(snmp_index)';
                                    } else {
                                        $sql_order = '';
                                    }
                                }
                            }
                        } else {
                            $sql_order = '';
                        }
                        /* get the unique field values from the database */
                        $field_names = db_fetch_assoc_prepared('SELECT DISTINCT field_name
						FROM host_snmp_cache
						WHERE host_id = ?
						AND snmp_query_id = ?', array($host['id'], $snmp_query['id']));
                        /* build magic query */
                        $sql_query = 'SELECT host_id, snmp_query_id, snmp_index';
                        $num_visible_fields = sizeof($field_names);
                        $i = 0;
                        if (sizeof($field_names) > 0) {
                            foreach ($field_names as $column) {
                                $field_name = $column['field_name'];
                                $sql_query .= ", MAX(CASE WHEN field_name='{$field_name}' THEN field_value ELSE NULL END) AS '{$field_name}'";
                                $i++;
                            }
                        }
                        $sql_query .= ' FROM host_snmp_cache
						WHERE host_id=' . $host['id'] . '
						AND snmp_query_id=' . $snmp_query['id'] . "\n\t\t\t\t\t\t{$sql_where}\n\t\t\t\t\t\tGROUP BY host_id, snmp_query_id, snmp_index\n\t\t\t\t\t\t{$sql_order}\n\t\t\t\t\t\tLIMIT " . $row_limit * ($page - 1) . ',' . $row_limit;
                        $rows_query = 'SELECT host_id, snmp_query_id, snmp_index
						FROM host_snmp_cache
						WHERE host_id=' . $host['id'] . '
						AND snmp_query_id=' . $snmp_query['id'] . "\n\t\t\t\t\t\t{$sql_where}\n\t\t\t\t\t\tGROUP BY host_id, snmp_query_id, snmp_index";
                        $snmp_query_indexes = db_fetch_assoc($sql_query);
                        $total_rows = sizeof(db_fetch_assoc($rows_query));
                        if (($page - 1) * $row_limit > $total_rows) {
                            $page = 1;
                            $_REQUEST['page' . $query['id']] = $page;
                            load_current_session_value('page' . $query['id'], 'sess_graphs_new_page' . $query['id'], '1');
                        }
                        $nav = html_nav_bar('graphs_new.php', MAX_DISPLAY_PAGES, $page, $row_limit, $total_rows, 15, 'Items', 'page' . $snmp_query['id']);
                        print $nav;
                        while (list($field_name, $field_array) = each($xml_array['fields'])) {
                            if ($field_array['direction'] == 'input' && sizeof($field_names)) {
                                foreach ($field_names as $row) {
                                    if ($row['field_name'] == $field_name) {
                                        $html_dq_header .= "<td class='tableSubHeaderColumn'>" . $field_array['name'] . "</td>\n";
                                        break;
                                    }
                                }
                            }
                        }
                        if (!sizeof($snmp_query_indexes)) {
                            print "<tr class='odd'><td>This Data Query returned 0 rows, perhaps there was a problem executing this\n\t\t\t\t\t\t\tData Query. You can <a href='" . htmlspecialchars('host.php?action=query_verbose&id=' . $snmp_query['id'] . '&host_id=' . $host['id']) . "'>run this Data Query in debug mode</a> to get more information.</td></tr>\n";
                        } else {
                            print "<tr class='tableHeader'>\n\t\t\t\t\t\t\t\t{$html_dq_header}\n\t\t\t\t\t\t\t\t<td width='1%' align='center' class='tableSubHeaderCheckbox' style='" . get_checkbox_style() . "'><input type='checkbox' style='margin: 0px;' name='all_" . $snmp_query['id'] . "' title='Select All' onClick='SelectAll(\"sg_" . $snmp_query['id'] . "\",this.checked)'></td>\n\n\t\t\t\t\t\t\t</tr>\n";
                        }
                        $row_counter = 0;
                        $column_counter = 0;
                        $fields = array_rekey($field_names, 'field_name', 'field_name');
                        if (sizeof($snmp_query_indexes) > 0) {
                            foreach ($snmp_query_indexes as $row) {
                                $query_row = $snmp_query['id'] . '_' . encode_data_query_index($row['snmp_index']);
                                print "<tr id='line{$query_row}' class='selectable " . ($row_counter % 2 == 0 ? 'odd' : 'even') . "'>";
                                $i++;
                                $column_counter = 0;
                                reset($xml_array['fields']);
                                while (list($field_name, $field_array) = each($xml_array['fields'])) {
                                    if ($field_array['direction'] == 'input') {
                                        if (in_array($field_name, $fields)) {
                                            if (isset($row[$field_name])) {
                                                print "<td><span id='text{$query_row}" . '_' . $column_counter . "'>" . (strlen($_REQUEST['filter']) ? preg_replace('/(' . preg_quote($_REQUEST['filter']) . ')/i', "<span class='filteredValue'>\\1</span>", $row[$field_name]) : $row[$field_name]) . '</span></td>';
                                            } else {
                                                print "<td><span id='text{$query_row}" . '_' . $column_counter . "'></span></td>";
                                            }
                                            $column_counter++;
                                        }
                                    }
                                }
                                print "<td class='checkbox' align='right'>";
                                print "<input type='checkbox' name='sg_{$query_row}' id='sg_{$query_row}'>";
                                print '</td>';
                                print "</tr>\n";
                                $row_counter++;
                            }
                        }
                        if ($total_rows > $row_limit) {
                            print $nav;
                        }
                    } else {
                        print "<tr class='odd'><td class='textError'>Search Returned no Rows.</td></tr>\n";
                    }
                } else {
                    print "<tr class='odd'><td class='textError'>Error in data query.</td></tr>\n";
                }
                print '</table>';
                /* draw the graph template drop down here */
                $data_query_graphs = db_fetch_assoc_prepared('SELECT snmp_query_graph.id, snmp_query_graph.name FROM snmp_query_graph WHERE snmp_query_graph.snmp_query_id = ? ORDER BY snmp_query_graph.name', array($snmp_query['id']));
                if (sizeof($data_query_graphs) == 1) {
                    echo "<input type='hidden' id='sgg_" . $snmp_query['id'] . "' name='sgg_" . $snmp_query['id'] . "' value='" . $data_query_graphs[0]['id'] . "'>\n";
                } elseif (sizeof($data_query_graphs) > 1) {
                    print "\t<table align='center' width='100%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width='100%' valign='middle'>\n\t\t\t\t\t\t\t\t<img src='images/arrow.gif' align='absmiddle' alt=''>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td style='white-space:nowrap;font-style: italic;'' align='right'>\n\t\t\t\t\t\t\t\tSelect a Graph Type to Create\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td align='right'>\n\t\t\t\t\t\t\t\t<select name='sgg_" . $snmp_query['id'] . "' id='sgg_" . $snmp_query['id'] . "' onChange='dqUpdateDeps(" . $snmp_query['id'] . ',' . (isset($column_counter) ? $column_counter : '') . ");'>\n\t\t\t\t\t\t\t\t\t";
                    html_create_list($data_query_graphs, 'name', 'id', '0');
                    print "\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n";
                }
                print '<br>';
                $script .= 'dqUpdateDeps(' . $snmp_query['id'] . ',' . $num_visible_fields . ");\n";
            }
        }
    }
    if (strlen($script)) {
        $script .= "</script>\n";
        print $script;
    }
    form_hidden_box('save_component_graph', '1', '');
    if (!empty($_REQUEST['host_id'])) {
        form_hidden_box('host_id', $host['id'], '0');
        form_hidden_box('host_template_id', $host['host_template_id'], '0');
    }
    if (isset($_SERVER['HTTP_REFERER']) && !substr_count($_SERVER['HTTP_REFERER'], 'graphs_new')) {
        $_REQUEST['returnto'] = basename($_SERVER['HTTP_REFERER']);
    }
    load_current_session_value('returnto', 'sess_graphs_new_returnto', '');
    form_save_button($_REQUEST['returnto']);
}
Example #28
0
            }
            api_plugin_hook('poller_top');
        }
    } else {
        if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
            cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end - $loop_start - $poller_interval . " seconds", TRUE, "POLLER");
        }
    }
}
function log_cacti_stats($loop_start, $method, $concurrent_processes, $max_threads, $num_hosts, $hosts_per_process, $num_polling_items, $rrds_processed)
{
    /* take time and log performance data */
    list($micro, $seconds) = explode(" ", microtime());
    $loop_end = $seconds + $micro;
    $cacti_stats = sprintf("Time:%01.4f " . "Method:%s " . "Processes:%s " . "Threads:%s " . "Hosts:%s " . "HostsPerProcess:%s " . "DataSources:%s " . "RRDsProcessed:%s", round($loop_end - $loop_start, 4), $method, $concurrent_processes, $max_threads, $num_hosts, $hosts_per_process, $num_polling_items, $rrds_processed);
    cacti_log("STATS: " . $cacti_stats, true, "SYSTEM");
    /* insert poller stats into the settings table */
    db_execute("REPLACE INTO settings (name,value) VALUES ('stats_poller','{$cacti_stats}')");
    api_plugin_hook_function('cacti_stats_update', array(round($loop_end - $loop_start, 4), $method, $concurrent_processes, $max_threads, $num_hosts, $hosts_per_process, $num_polling_items, $rrds_processed));
}
function display_help()
{
    echo "Cacti Poller Version " . db_fetch_cell("SELECT cacti FROM version") . ", Copyright 2004-2013 - The Cacti Group\n\n";
    echo "A simple command line utility to run the Cacti Poller.\n\n";
    echo "usage: poller.php [--force] [--debug|-d]\n\n";
    echo "Options:\n";
    echo "    --force        Override poller overrun detection and force a poller run\n";
    echo "    --debug|-d     Output debug information.  Similar to cacti's DEBUG logging level.\n\n";
}
api_plugin_hook('poller_bottom');
Example #29
0
function do_hook($name)
{
    $data = func_get_args();
    $data = api_plugin_hook($name, $data);
    return $data;
}
Example #30
0
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;
}