Example #1
0
function plugin_maint_install()
{
    api_plugin_register_hook('maint', 'config_arrays', 'maint_config_arrays', 'setup.php');
    api_plugin_register_hook('maint', 'draw_navigation_text', 'maint_draw_navigation_text', 'setup.php');
    api_plugin_register_realm('maint', 'maint.php', 'Maintenance Schedules', 1);
    maint_setup_database();
}
Example #2
0
function plugin_syslog_install()
{
    global $config, $syslog_upgrade;
    static $bg_inprocess = false;
    include dirname(__FILE__) . '/config.php';
    syslog_connect();
    $syslog_exists = sizeof(syslog_db_fetch_row('SHOW TABLES FROM `' . $syslogdb_default . "` LIKE 'syslog'"));
    $db_version = syslog_get_mysql_version('syslog');
    /* ================= input validation ================= */
    get_filter_request_var('days');
    /* ==================================================== */
    api_plugin_register_hook('syslog', 'config_arrays', 'syslog_config_arrays', 'setup.php');
    api_plugin_register_hook('syslog', 'draw_navigation_text', 'syslog_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('syslog', 'config_settings', 'syslog_config_settings', 'setup.php');
    api_plugin_register_hook('syslog', 'top_header_tabs', 'syslog_show_tab', 'setup.php');
    api_plugin_register_hook('syslog', 'top_graph_header_tabs', 'syslog_show_tab', 'setup.php');
    api_plugin_register_hook('syslog', 'top_graph_refresh', 'syslog_top_graph_refresh', 'setup.php');
    api_plugin_register_hook('syslog', 'poller_bottom', 'syslog_poller_bottom', 'setup.php');
    api_plugin_register_hook('syslog', 'graph_buttons', 'syslog_graph_buttons', 'setup.php');
    api_plugin_register_hook('syslog', 'config_insert', 'syslog_config_insert', 'setup.php');
    api_plugin_register_hook('syslog', 'utilities_list', 'syslog_utilities_list', 'setup.php');
    api_plugin_register_hook('syslog', 'utilities_action', 'syslog_utilities_action', 'setup.php');
    api_plugin_register_realm('syslog', 'syslog.php', 'Plugin -> Syslog User', 1);
    api_plugin_register_realm('syslog', 'syslog_alerts.php,syslog_removal.php,syslog_reports.php', 'Plugin -> Syslog Administration', 1);
    if (isset_request_var('install') || isset_request_var('return') || isset_request_var('cancel')) {
        if (!$bg_inprocess) {
            syslog_execute_update($syslog_exists, $_REQUEST);
            $bg_inprocess = true;
        }
    } else {
        syslog_install_advisor($syslog_exists, $db_version);
        exit;
    }
}
Example #3
0
function plugin_iper_install()
{
    api_plugin_register_hook('iper', 'top_header_tabs', 'plugin_iper_show_tab', 'includes/tab.php');
    api_plugin_register_hook('iper', 'top_graph_header_tabs', 'plugin_iper_show_tab', 'includes/tab.php');
    api_plugin_register_hook('iper', 'config_arrays', 'iper_config_arrays', 'setup.php');
    api_plugin_register_hook('iper', 'config_settings', 'iper_config_settings', 'setup.php');
    api_plugin_register_hook('iper', 'draw_navigation_text', 'iper_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('iper', 'poller_bottom', 'iper_poller_bottom', 'setup.php');
    api_plugin_register_hook('iper', 'page_title', 'iper_page_title', 'setup.php');
    api_plugin_register_realm('iper', 'iper_index.php,iper_db.php', 'Plugin -> iper: View', 1);
    api_plugin_register_realm('iper', 'iper_db_admin.php', 'Plugin -> iper: Manage', 1);
    iper_setup_table();
}
Example #4
0
function realtime_check_upgrade () {
	global $config;

	$files = array('index.php', 'plugins.php', 'realtime.php');
	if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
		return;
	}

	$current = plugin_realtime_version();
	$current = $current['version'];
	$old     = db_fetch_row("SELECT * FROM plugin_config WHERE directory='realtime'");

	if (sizeof($old) && $current != $old["version"]) {
		if ($old < "4.1" || $old = '') {
			api_plugin_register_realm('realtime', 'graph_image_rt.php, graph_popup_rt.php, graph_ajax_rt.php', 'Plugin -> Realtime', 1);

			/* get the realm id's and change from old to new */
			$user  = db_fetch_cell("SELECT id FROM plugin_realms WHERE file='graph_image_rt.php'")+100;
			$users = db_fetch_assoc("SELECT user_id FROM user_auth_realm WHERE realm_id=36");
			if (sizeof($users)) {
				foreach($users as $u) {
					db_execute("INSERT INTO user_auth_realm
						(realm_id, user_id) VALUES ($user, " . $u["user_id"] . ")
						ON DUPLICATE KEY UPDATE realm_id=VALUES(realm_id)");
					db_execute("DELETE FROM user_auth_realm
						WHERE user_id=" . $u["user_id"] . "
						AND realm_id=$user");
				}
			}
		}

		/* if the plugin is installed and/or active */
		if ($old["status"] == 1 || $old["status"] == 4) {
			/* re-register the hooks */
			plugin_realtime_install();

			/* perform a database upgrade */
			realtime_database_upgrade();
		}

		/* update the plugin information */
		$info = plugin_realtime_version();
		$id   = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='realtime'");
		db_execute("UPDATE plugin_config
			SET name='" . $info["longname"] . "',
			author='"   . $info["author"]   . "',
			webpage='"  . $info["homepage"] . "',
			version='"  . $info["version"]  . "'
			WHERE id='$id'");
	}
}
Example #5
0
function plugin_flowview_install()
{
    api_plugin_register_hook('flowview', 'config_arrays', 'flowview_config_arrays', 'setup.php');
    api_plugin_register_hook('flowview', 'draw_navigation_text', 'flowview_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('flowview', 'config_settings', 'flowview_config_settings', 'setup.php');
    api_plugin_register_hook('flowview', 'poller_bottom', 'flowview_poller_bottom', 'setup.php');
    api_plugin_register_hook('flowview', 'top_header_tabs', 'flowview_show_tab', 'setup.php');
    api_plugin_register_hook('flowview', 'top_graph_header_tabs', 'flowview_show_tab', 'setup.php');
    api_plugin_register_hook('flowview', 'page_head', 'flowview_page_head', 'setup.php');
    api_plugin_register_hook('flowview', 'page_bottom', 'flowview_page_bottom', 'setup.php');
    api_plugin_register_realm('flowview', 'flowview.php', 'Plugin -> Flow Viewer', 1);
    api_plugin_register_realm('flowview', 'flowview_devices.php,flowview_schedules.php', 'Plugin -> Flow Admin', 1);
    flowview_setup_table();
}
Example #6
0
function plugin_mikrotik_install()
{
    # graph setup all arrays needed for automation
    api_plugin_register_hook('mikrotik', 'config_arrays', 'mikrotik_config_arrays', 'setup.php');
    api_plugin_register_hook('mikrotik', 'config_form', 'mikrotik_config_form', 'setup.php');
    api_plugin_register_hook('mikrotik', 'config_settings', 'mikrotik_config_settings', 'setup.php');
    api_plugin_register_hook('mikrotik', 'draw_navigation_text', 'mikrotik_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('mikrotik', 'poller_bottom', 'mikrotik_poller_bottom', 'setup.php');
    api_plugin_register_hook('mikrotik', 'top_header_tabs', 'mikrotik_show_tab', 'setup.php');
    api_plugin_register_hook('mikrotik', 'top_graph_header_tabs', 'mikrotik_show_tab', 'setup.php');
    api_plugin_register_realm('mikrotik', 'mikrotik.php', 'Plugin -> MikroTik Viewer', 1);
    api_plugin_register_realm('mikrotik', 'mikrotik_users.php', 'Plugin -> MikroTik Admin', 1);
    mikrotik_setup_table();
}
Example #7
0
function plugin_monitor_install()
{
    api_plugin_register_hook('monitor', 'top_header_tabs', 'monitor_show_tab', 'setup.php');
    api_plugin_register_hook('monitor', 'top_graph_header_tabs', 'monitor_show_tab', 'setup.php');
    api_plugin_register_hook('monitor', 'draw_navigation_text', 'monitor_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('monitor', 'config_form', 'monitor_config_form', 'setup.php');
    api_plugin_register_hook('monitor', 'api_device_save', 'monitor_api_device_save', 'setup.php');
    api_plugin_register_hook('monitor', 'top_graph_refresh', 'monitor_top_graph_refresh', 'setup.php');
    api_plugin_register_hook('monitor', 'config_settings', 'monitor_config_settings', 'setup.php');
    api_plugin_register_hook('monitor', 'device_action_array', 'monitor_device_action_array', 'setup.php');
    api_plugin_register_hook('monitor', 'device_action_execute', 'monitor_device_action_execute', 'setup.php');
    api_plugin_register_hook('monitor', 'device_action_prepare', 'monitor_device_action_prepare', 'setup.php');
    api_plugin_register_realm('monitor', 'monitor.php', 'View Monitoring', 1);
}
Example #8
0
function plugin_nmidSmokeping_install()
{
	api_plugin_register_hook( 'nmidSmokeping', 'config_settings', 'nmidSmokeping_config_settings', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'console_after', 'nmidSmokeping_console_after', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'tree_after', 'nmidSmokeping_tree_after', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'nmid_plugin_value', 'nmidSmokeping_value', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'nmid_plugin_header', 'nmidSmokeping_header', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'nmid_plugin_save', 'nmidSmokeping_save', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'nmid_plugin_configCreate', 'nmidSmokeping_configCreate', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'device_action_array', 'plugin_nmidSmokeping_device_action_array', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'device_action_prepare', 'plugin_nmidSmokeping_device_action_prepare', 'setup.php' );
	api_plugin_register_hook( 'nmidSmokeping', 'device_action_execute', 'plugin_nmidSmokeping_device_action_execute', 'setup.php' );
	api_plugin_register_realm( 'nmidSmokeping', 'getSmokePingImage.php', 'NMID - View Smokeping Charts', 1200 );
	nmidSmokeping_setup_table_new();
}
Example #9
0
function plugin_thold_install()
{
    global $config;
    if (version_compare($config['cacti_version'], '1.0.0') < 0) {
        return false;
    }
    api_plugin_register_hook('thold', 'page_head', 'thold_page_head', 'setup.php');
    api_plugin_register_hook('thold', 'top_header_tabs', 'thold_show_tab', 'includes/tab.php');
    api_plugin_register_hook('thold', 'top_graph_header_tabs', 'thold_show_tab', 'includes/tab.php');
    api_plugin_register_hook('thold', 'config_insert', 'thold_config_insert', 'includes/settings.php');
    api_plugin_register_hook('thold', 'config_arrays', 'thold_config_arrays', 'includes/settings.php');
    api_plugin_register_hook('thold', 'config_form', 'thold_config_form', 'includes/settings.php');
    api_plugin_register_hook('thold', 'config_settings', 'thold_config_settings', 'includes/settings.php');
    api_plugin_register_hook('thold', 'draw_navigation_text', 'thold_draw_navigation_text', 'includes/settings.php');
    api_plugin_register_hook('thold', 'data_sources_table', 'thold_data_sources_table', 'setup.php');
    api_plugin_register_hook('thold', 'graphs_new_top_links', 'thold_graphs_new', 'setup.php');
    api_plugin_register_hook('thold', 'api_device_save', 'thold_api_device_save', 'setup.php');
    api_plugin_register_hook('thold', 'update_host_status', 'thold_update_host_status', 'includes/polling.php');
    api_plugin_register_hook('thold', 'poller_output', 'thold_poller_output', 'includes/polling.php');
    api_plugin_register_hook('thold', 'device_action_array', 'thold_device_action_array', 'setup.php');
    api_plugin_register_hook('thold', 'device_action_execute', 'thold_device_action_execute', 'setup.php');
    api_plugin_register_hook('thold', 'device_action_prepare', 'thold_device_action_prepare', 'setup.php');
    api_plugin_register_hook('thold', 'host_edit_bottom', 'thold_host_edit_bottom', 'setup.php');
    api_plugin_register_hook('thold', 'user_admin_setup_sql_save', 'thold_user_admin_setup_sql_save', 'setup.php');
    api_plugin_register_hook('thold', 'poller_bottom', 'thold_poller_bottom', 'includes/polling.php');
    api_plugin_register_hook('thold', 'user_admin_edit', 'thold_user_admin_edit', 'setup.php');
    api_plugin_register_hook('thold', 'rrd_graph_graph_options', 'thold_rrd_graph_graph_options', 'setup.php');
    api_plugin_register_hook('thold', 'graph_buttons', 'thold_graph_button', 'setup.php');
    api_plugin_register_hook('thold', 'snmpagent_cache_install', 'thold_snmpagent_cache_install', 'setup.php');
    /* hooks to add dropdown to allow the assignment of a cluster resource */
    api_plugin_register_hook('thold', 'data_source_action_array', 'thold_data_source_action_array', 'setup.php');
    api_plugin_register_hook('thold', 'data_source_action_prepare', 'thold_data_source_action_prepare', 'setup.php');
    api_plugin_register_hook('thold', 'data_source_action_execute', 'thold_data_source_action_execute', 'setup.php');
    api_plugin_register_hook('thold', 'graphs_action_array', 'thold_graphs_action_array', 'setup.php');
    api_plugin_register_hook('thold', 'graphs_action_prepare', 'thold_graphs_action_prepare', 'setup.php');
    api_plugin_register_hook('thold', 'graphs_action_execute', 'thold_graphs_action_execute', 'setup.php');
    api_plugin_register_hook('thold', 'device_template_edit', 'thold_device_template_edit', 'setup.php');
    api_plugin_register_hook('thold', 'device_template_top', 'thold_device_template_top', 'setup.php');
    api_plugin_register_hook('thold', 'device_edit_pre_bottom', 'thold_device_edit_pre_bottom', 'setup.php');
    api_plugin_register_hook('thold', 'api_device_new', 'thold_api_device_new', 'setup.php');
    api_plugin_register_realm('thold', 'thold.php', __('Plugin -> Configure Thresholds'), 1);
    api_plugin_register_realm('thold', 'thold_templates.php', __('Plugin -> Configure Threshold Templates'), 1);
    api_plugin_register_realm('thold', 'notify_lists.php', __('Plugin -> Manage Notification Lists'), 1);
    api_plugin_register_realm('thold', 'thold_graph.php,graph_thold.php,thold_view_failures.php,thold_view_normal.php,thold_view_recover.php,thold_view_recent.php,thold_view_host.php', __('Plugin -> View Thresholds'), 1);
    include_once $config['base_path'] . '/plugins/thold/includes/database.php';
    thold_setup_database();
    thold_snmpagent_cache_install();
}
Example #10
0
function plugin_hmib_install()
{
    # graph setup all arrays needed for automation
    api_plugin_register_hook('hmib', 'config_arrays', 'hmib_config_arrays', 'setup.php');
    api_plugin_register_hook('hmib', 'config_form', 'hmib_config_form', 'setup.php');
    api_plugin_register_hook('hmib', 'config_settings', 'hmib_config_settings', 'setup.php');
    api_plugin_register_hook('hmib', 'draw_navigation_text', 'hmib_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('hmib', 'poller_bottom', 'hmib_poller_bottom', 'setup.php');
    api_plugin_register_hook('hmib', 'top_header_tabs', 'hmib_show_tab', 'setup.php');
    api_plugin_register_hook('hmib', 'top_graph_header_tabs', 'hmib_show_tab', 'setup.php');
    api_plugin_register_hook('hmib', 'hmib_get_cpu', 'hmib_get_cpu', 'setup.php');
    api_plugin_register_hook('hmib', 'hmib_get_disk', 'hmib_get_disk', 'setup.php');
    api_plugin_register_realm('hmib', 'hmib.php', 'Plugin -> Host MIB Viewer', 1);
    api_plugin_register_realm('hmib', 'hmib_types.php', 'Plugin -> Host MIB Admin', 1);
    hmib_setup_table();
}
Example #11
0
function plugin_gpsmap_install()
{
    global $config;
    api_plugin_register_hook('gpsmap', 'top_header_tabs', 'gpsmap_show_tab', 'includes/setup/tabs.php');
    api_plugin_register_hook('gpsmap', 'top_graph_header_tabs', 'gpsmap_show_tab', 'includes/setup/tabs.php');
    api_plugin_register_hook('gpsmap', 'config_arrays', 'gpsmap_config_arrays', 'includes/setup/settings.php');
    api_plugin_register_hook('gpsmap', 'config_settings', 'gpsmap_config_settings', 'includes/setup/settings.php');
    api_plugin_register_hook('gpsmap', 'draw_navigation_text', 'gpsmap_draw_navigation_text', 'includes/setup/settings.php');
    api_plugin_register_hook('gpsmap', 'api_device_save', 'gpsmap_api_device_save', 'includes/setup/settings.php');
    api_plugin_register_hook('gpsmap', 'config_form', 'gpsmap_config_form', 'setup.php');
    api_plugin_register_hook('gpsmap', 'poller_bottom', 'gpsmap_poller_bottom', 'includes/polling.php');
    api_plugin_register_realm('gpsmap', 'gpstemplates.php,gpstemplates_add.php', 'Configure GPSMap', 1);
    api_plugin_register_realm('gpsmap', 'gpsmap.php', 'View GPSMap', 1);
    include_once $config['base_path'] . '/plugins/gpsmap/includes/setup/database.php';
    gpsmap_setup_database();
}
Example #12
0
function plugin_predict_install()
{
    global $database_type;
    $rrd_ver = read_config_option("rrdtool_version");
    if ($rrd_ver < "rrd-1.4") {
        die("<br/>rrdtool must be at least 1.4 to use predict. Your version is {$rrd_ver}<br />Please go back to cacti within your browser<br/>");
    } else {
        api_plugin_register_hook('predict', 'top_header_tabs', 'predict_show_tab', 'setup.php');
        api_plugin_register_hook('predict', 'top_graph_header_tabs', 'predict_show_tab', 'setup.php');
        api_plugin_register_hook('predict', 'draw_navigation_text', 'predict_draw_navigation_text', 'setup.php');
        api_plugin_register_hook('predict', 'config_settings', 'predict_config_settings', 'setup.php');
        api_plugin_register_realm('predict', 'predict.php', 'Plugin -> Predict', 1);
        $sql = "INSERT INTO settings VALUES ( 'predict_def_tspan', 2 ), ( 'predict_def_units', 3 ), ( 'predict_def_window', 300 ), ( 'predict_def_typeds', 0 ), ( 'predict_def_typepred', 2 ), ( 'predict_def_colds', 7 ), ( 'predict_def_colpred', 9 ), ( 'predict_def_width', 700 ), ( 'predict_def_height', 300 )";
        if ($database_type === "mysql") {
            $result = mysql_query($sql) or die(mysql_error());
        } else {
            $result = pg_query($sql) or die(pg_last_error());
        }
    }
}
Example #13
0
function cycle_check_upgrade()
{
    global $config;
    $files = array('index.php', 'plugins.php', 'cycle.php');
    if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
        return;
    }
    $current = plugin_cycle_version();
    $current = $current['version'];
    $old = db_fetch_row("SELECT * FROM plugin_config WHERE directory='cycle'");
    if (sizeof($old) && $current != $old['version']) {
        /* if the plugin is installed and/or active */
        if ($old['status'] == 1 || $old['status'] == 4) {
            /* re-register the hooks */
            plugin_cycle_install();
            /* perform a database upgrade */
            cycle_database_upgrade();
        }
        if ($old < '1.0') {
            api_plugin_register_realm('cycle', 'cycle.php,cycle_ajax.php', 'Plugin -> Cycle Graphs', 1);
            /* get the realm id's and change from old to new */
            $user = db_fetch_cell("SELECT id FROM plugin_realms WHERE file='cycle.php'") + 100;
            $users = db_fetch_assoc('SELECT user_id FROM user_auth_realm WHERE realm_id=42');
            if (sizeof($users)) {
                foreach ($users as $u) {
                    db_execute('INSERT INTO user_auth_realm
						(realm_id, user_id) VALUES (' . $user . ', ' . $u['user_id'] . ')
						ON DUPLICATE KEY UPDATE realm_id=VALUES(realm_id)');
                    db_execute('DELETE FROM user_auth_realm
						WHERE user_id=' . $u['user_id'] . '
						AND realm_id=' . $user);
                }
            }
        }
        /* update the plugin information */
        $info = plugin_cycle_version();
        $id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='cycle'");
        db_execute("UPDATE plugin_config\n\t\t\tSET name='" . $info['longname'] . "',\n\t\t\tauthor='" . $info['author'] . "',\n\t\t\twebpage='" . $info['homepage'] . "',\n\t\t\tversion='" . $info['version'] . "'\n\t\t\tWHERE id='{$id}'");
    }
}
Example #14
0
function plugin_nfsen_install() {
   api_plugin_register_hook('nfsen', 'top_header_tabs',       'nfsen_show_tab',             "setup.php");
   api_plugin_register_hook('nfsen', 'top_graph_header_tabs', 'nfsen_show_tab',             "setup.php");
   //api_plugin_register_hook('nfsen', 'config_arrays',         'nfsen_config_arrays',        "setup.php");
   //api_plugin_register_hook('nfsen', 'draw_navigation_text',  'nfsen_draw_navigation_text', "setup.php");
   api_plugin_register_hook('nfsen', 'config_form',           'nfsen_config_form',          "setup.php");
   api_plugin_register_hook('nfsen', 'config_settings',       'nfsen_config_settings',      "setup.php");
   //api_plugin_register_hook('nfsen', 'api_graph_save',        'nfsen_api_graph_save',       "setup.php");
   //api_plugin_register_hook('nfsen', 'body_style', 'nfsen_api_plugin_hook_function_body_style', "setup.php");
   /* uncomment if you need more hooks */
   //api_plugin_register_hook('nfsen', 'top_graph_refresh',     'nfsen_top_graph_refresh',    "setup.php");
//   api_plugin_register_hook('nfsen', 'device_action_array',   'nfsen_device_action_array',  "setup.php");
//   api_plugin_register_hook('nfsen', 'device_action_execute', 'nfsen_device_action_execute',"setup.php");
//   api_plugin_register_hook('nfsen', 'device_action_prepare', 'nfsen_device_action_prepare',"setup.php");
//   api_plugin_register_hook('nfsen', 'poller_output', 'nfsen_poller_output', 'poller_nfsen.php');
//   api_plugin_register_hook('nfsen', 'poller_bottom', 'nfsen_poller_bottom', 'poller_nfsen.php');

   // register the realm for each php file
   api_plugin_register_realm('nfsen', 'nfsen.php', 'View nfsen', 1);
   //other example api_plugin_register_realm('nfsen', 'nfsen.php,nfsen2.php', 'View nfsen', 1);

   nfsen_setup_table_new ();
}
Example #15
0
function plugin_mactrack_install()
{
    api_plugin_register_hook('mactrack', 'top_header_tabs', 'mactrack_show_tab', 'setup.php');
    api_plugin_register_hook('mactrack', 'top_graph_header_tabs', 'mactrack_show_tab', 'setup.php');
    api_plugin_register_hook('mactrack', 'config_arrays', 'mactrack_config_arrays', 'setup.php');
    api_plugin_register_hook('mactrack', 'draw_navigation_text', 'mactrack_draw_navigation_text', 'setup.php');
    api_plugin_register_hook('mactrack', 'config_form', 'mactrack_config_form', 'setup.php');
    api_plugin_register_hook('mactrack', 'config_settings', 'mactrack_config_settings', 'setup.php');
    api_plugin_register_hook('mactrack', 'poller_bottom', 'mactrack_poller_bottom', 'setup.php');
    api_plugin_register_hook('mactrack', 'page_head', 'mactrack_page_head', 'setup.php');
    # device hook: intercept on device save
    api_plugin_register_hook('mactrack', 'api_device_save', 'sync_cacti_to_mactrack', 'mactrack_actions.php');
    # device hook: Add a new dropdown Action for Device Management
    api_plugin_register_hook('mactrack', 'device_action_array', 'mactrack_device_action_array', 'mactrack_actions.php');
    # device hook: Device Management Action dropdown selected: prepare the list of devices for a confirmation request
    api_plugin_register_hook('mactrack', 'device_action_prepare', 'mactrack_device_action_prepare', 'mactrack_actions.php');
    # device hook: Device Management Action dropdown selected: execute list of device
    api_plugin_register_hook('mactrack', 'device_action_execute', 'mactrack_device_action_execute', 'mactrack_actions.php');
    # Register our realms
    api_plugin_register_realm('mactrack', 'mactrack_view_ips.php,mactrack_view_arp.php,mactrack_view_macs.php,mactrack_view_sites.php,mactrack_view_devices.php,mactrack_view_interfaces.php,mactrack_view_graphs.php,mactrack_ajax.php', 'MacTrack Viewer', 1);
    api_plugin_register_realm('mactrack', 'mactrack_ajax_admin.php,mactrack_devices.php,mactrack_snmp.php,mactrack_sites.php,mactrack_device_types.php,mactrack_utilities.php,mactrack_macwatch.php,mactrack_macauth.php,mactrack_vendormacs.php', 'Plugin -> MacTrack Administrator', 1);
    mactrack_setup_table_new();
}
Example #16
0
function rrdclean_config_arrays()
{
    global $user_auth_realms, $user_auth_realm_filenames, $menu;
    if (function_exists('api_plugin_register_realm')) {
        # register all php modules required for this plugin
        api_plugin_register_realm('rrdclean', 'rrdcleaner.php,rrdmove.php', 'RRD Cleaner', 1);
    } else {
        # realms
        $user_auth_realms[36] = 'RRD Cleaner';
        # these are the files protected by our realm id
        $user_auth_realm_filenames['rrdcleaner.php'] = 36;
        $user_auth_realm_filenames['rrdcleaner.php?action=restart'] = 36;
    }
    $temp = $menu["Utilities"]['logout.php'];
    unset($menu["Utilities"]['logout.php']);
    $menu["Utilities"]['plugins/rrdclean/rrdcleaner.php'] = "RRD Cleaner";
    $menu["Utilities"]['logout.php'] = $temp;
}
Example #17
0
function thold_upgrade_database()
{
    global $config, $database_default;
    include_once $config['library_path'] . '/database.php';
    thold_setup_database();
    include_once $config['base_path'] . '/plugins/thold/setup.php';
    include_once $config['base_path'] . '/plugins/thold/thold_functions.php';
    $v = plugin_thold_version();
    $oldv = read_config_option('plugin_thold_version');
    if ($oldv < 0.1) {
        db_execute('INSERT INTO settings (name, value) VALUES ("plugin_thold_version", "' . $v['version'] . '")');
        $oldv = $v['version'];
    }
    // Check for needed Cacti Indexes
    $indexes = array_rekey(db_fetch_assoc("SHOW INDEX FROM graph_templates_item"), "Key_name", "Key_name");
    if (!array_key_exists("task_item_id", $indexes)) {
        db_execute("ALTER TABLE graph_templates_item ADD INDEX task_item_id(task_item_id)");
    }
    $indexes = array_rekey(db_fetch_assoc("SHOW INDEX FROM data_local"), "Key_name", "Key_name");
    if (!array_key_exists("data_template_id", $indexes)) {
        db_execute("ALTER TABLE data_local ADD INDEX data_template_id(data_template_id)");
    }
    if (!array_key_exists("snmp_query_id", $indexes)) {
        db_execute("ALTER TABLE data_local ADD INDEX snmp_query_id(snmp_query_id)");
    }
    $indexes = array_rekey(db_fetch_assoc("SHOW INDEX FROM host_snmp_cache"), "Key_name", "Key_name");
    if (!array_key_exists("snmp_query_id", $indexes)) {
        db_execute("ALTER TABLE host_snmp_cache ADD INDEX snmp_query_id(snmp_query_id)");
    }
    $indexes = array_rekey(db_fetch_assoc("SHOW INDEX FROM data_template_rrd"), "Key_name", "Key_name");
    if (!array_key_exists("data_source_name", $indexes)) {
        db_execute("ALTER TABLE data_template_rrd ADD INDEX data_source_name(data_source_name)");
    }
    // Added in thold v0.4
    if ($oldv < 0.4) {
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'name', 'type' => 'varchar(100)', 'NULL' => false, 'default' => '', 'after' => 'id'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_hi', 'type' => 'varchar(100)', 'NULL' => true, 'after' => 'thold_fail_trigger'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_low', 'type' => 'varchar(100)', 'NULL' => true, 'after' => 'time_hi'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_fail_trigger', 'type' => 'int (12)', 'NULL' => false, 'default' => 1, 'after' => 'time_low'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_fail_length', 'type' => 'int (12)', 'NULL' => false, 'default' => 1, 'after' => 'time_fail_trigger'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'thold_type', 'type' => 'int (3)', 'NULL' => false, 'default' => 0, 'after' => 'thold_enabled'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'data_type', 'type' => 'int (3)', 'NULL' => false, 'default' => 0, 'after' => 'notify_extra'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'percent_ds', 'type' => 'varchar(64)', 'NULL' => false, 'default' => 0, 'after' => 'cdef'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'tcheck', 'type' => 'int(1)', 'NULL' => false, 'default' => 0));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'exempt', 'type' => 'char(3)', 'NULL' => false, 'default' => ''));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'local_graph_id', 'type' => 'int(11)', 'NULL' => false, 'default' => 0, 'after' => 'data_id'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'graph_template_id', 'type' => 'int(11)', 'NULL' => false, 'default' => 0, 'after' => 'graph_id'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'data_template_id', 'type' => 'int(11)', 'NULL' => false, 'default' => 0, 'after' => 'graph_template'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'restored_alert', 'type' => 'char(3)', 'NULL' => false, 'default' => ''));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'name', 'type' => 'varchar(100)', 'NULL' => false, 'default' => '', 'after' => 'id'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_hi', 'type' => 'varchar(100)', 'NULL' => true, 'after' => 'thold_fail_trigger'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_low', 'type' => 'varchar(100)', 'NULL' => true, 'after' => 'time_hi'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_fail_trigger', 'type' => 'int (12)', 'NULL' => false, 'default' => 1, 'after' => 'time_low'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_fail_length', 'type' => 'int (12)', 'NULL' => false, 'default' => 1, 'after' => 'time_fail_trigger'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'thold_type', 'type' => 'int (3)', 'NULL' => false, 'default' => 0, 'after' => 'thold_enabled'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'data_type', 'type' => 'int (3)', 'NULL' => false, 'default' => 0, 'after' => 'syslog_priority'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'percent_ds', 'type' => 'varchar(64)', 'NULL' => false, 'default' => 0, 'after' => 'cdef'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'exempt', 'type' => 'char(3)', 'NULL' => false, 'default' => ''));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'restored_alert', 'type' => 'char(3)', 'NULL' => false, 'default' => ''));
        // Update our hooks
        db_execute('UPDATE plugin_hooks SET file = "includes/settings.php" WHERE name = "thold" AND hook = "config_arrays"');
        db_execute('UPDATE plugin_hooks SET file = "includes/settings.php" WHERE name = "thold" AND hook = "config_settings"');
        db_execute('UPDATE plugin_hooks SET file = "includes/settings.php" WHERE name = "thold" AND hook = "draw_navigation_text"');
        db_execute('UPDATE plugin_hooks SET function = "thold_poller_bottom", file = "includes/polling.php" WHERE name = "thold" AND hook = "poller_bottom"');
        // Register the new hooks
        api_plugin_register_hook('thold', 'rrd_graph_graph_options', 'thold_rrd_graph_graph_options', 'setup.php');
        api_plugin_register_hook('thold', 'graph_buttons', 'thold_graph_button', 'setup.php');
        api_plugin_register_hook('thold', 'data_source_action_array', 'thold_data_source_action_array', 'setup.php');
        api_plugin_register_hook('thold', 'data_source_action_prepare', 'thold_data_source_action_prepare', 'setup.php');
        api_plugin_register_hook('thold', 'data_source_action_execute', 'thold_data_source_action_execute', 'setup.php');
        api_plugin_register_hook('thold', 'graphs_action_array', 'thold_graphs_action_array', 'setup.php');
        api_plugin_register_hook('thold', 'graphs_action_prepare', 'thold_graphs_action_prepare', 'setup.php');
        api_plugin_register_hook('thold', 'graphs_action_execute', 'thold_graphs_action_execute', 'setup.php');
        api_plugin_enable_hooks('thold');
        // Fix our realms
        db_execute('UPDATE plugin_realms SET file = "thold.php" WHERE display = "Configure Thresholds"');
        api_plugin_register_realm('thold', 'thold_templates.php', 'Configure Threshold Templates', 1);
        db_execute('ALTER TABLE thold_data ADD INDEX ( tcheck )', FALSE);
        db_execute('ALTER TABLE thold_data ADD INDEX ( local_graph_id )', FALSE);
        db_execute('ALTER TABLE thold_data ADD INDEX ( graph_template_id )', FALSE);
        db_execute('ALTER TABLE thold_data ADD INDEX ( data_template_id )', FALSE);
        // Rename some columns
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN rra_id local_data_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN data_id data_template_rrd_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN template thold_template_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN data_template data_template_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN graph_id local_graph_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN graph_template graph_template_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE plugin_thold_log CHANGE COLUMN graph_id local_graph_id int(11) UNSIGNED NOT NULL default "0"');
        /* Set the default names on threshold and templates */
        db_execute("UPDATE thold_data, data_template_data, data_template_rrd SET\n\t\t\t thold_data.name = CONCAT_WS('',data_template_data.name_cache, ' [', data_template_rrd.data_source_name, ']', '')\n\t\t\t WHERE data_template_data.local_data_id = thold_data.local_data_id AND data_template_rrd.id = thold_data.data_template_rrd_id AND thold_data.name = ''");
        db_execute("UPDATE thold_template SET name = CONCAT_WS('', data_template_name, ' [', data_source_name, ']', '') WHERE name = ''");
        /* Set the graph_ids for all thresholds */
        db_execute('UPDATE thold_data, graph_templates_item, data_template_rrd
			 SET thold_data.local_graph_id = graph_templates_item.local_graph_id, 
				thold_data.graph_template_id = graph_templates_item.graph_template_id, 
				thold_data.data_template_id = data_template_rrd.data_template_id
			 WHERE data_template_rrd.local_data_id=thold_data.local_data_id AND data_template_rrd.id=graph_templates_item.task_item_id');
    }
    // End 0.4 Upgrade
    if (version_compare($oldv, '0.4.3', '<')) {
        // Fix a few hooks
        db_execute('DELETE FROM plugin_hooks WHERE name = "thold" AND hook = "config_insert"');
        db_execute('DELETE FROM plugin_hooks WHERE name = "thold" AND hook = "config_arrays"');
        api_plugin_register_hook('thold', 'config_insert', 'thold_config_insert', 'includes/settings.php');
        api_plugin_register_hook('thold', 'config_arrays', 'thold_config_arrays', 'includes/settings.php');
        api_plugin_enable_hooks('thold');
        $e = strtolower(db_fetch_cell("SELECT `value` FROM settings WHERE `name` = 'thold_from_email'"));
        if ($e == '*****@*****.**') {
            db_execute("UPDATE settings SET `value`='cacti@localhost' WHERE `name`='thold_from_email'");
        }
    }
    if (version_compare($oldv, '0.4.4', '<')) {
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'lasttime', 'type' => 'TIMESTAMP', 'NULL' => false, 'after' => 'lastread'));
        db_execute('ALTER TABLE thold_data ADD COLUMN bl_thold_valid INT UNSIGNED NOT NULL DEFAULT 0', FALSE);
        db_execute('ALTER TABLE thold_data MODIFY name varchar(150) default NULL');
        db_execute('ALTER TABLE thold_template MODIFY COLUMN bl_pct_down varchar(100)');
        db_execute('ALTER TABLE thold_template MODIFY COLUMN bl_pct_up varchar(100)');
        db_execute('ALTER TABLE thold_data MODIFY COLUMN bl_pct_down varchar(100)');
        db_execute('ALTER TABLE thold_data MODIFY COLUMN bl_pct_up varchar(100)');
    }
    if (version_compare($oldv, '0.4.5', '<')) {
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'thold_warning_hi', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'thold_warning_low', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'thold_warning_fail_trigger', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'thold_warning_fail_count', 'type' => 'int(11)', 'NULL' => false, 'default' => '0'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_warning_hi', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_warning_low', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_warning_fail_trigger', 'type' => 'int (12)', 'NULL' => false, 'default' => 1));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'time_warning_fail_length', 'type' => 'int (12)', 'NULL' => false, 'default' => 1));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'notify_warning_extra', 'type' => 'text', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_warning_fail_length', 'type' => 'int (12)', 'NULL' => false, 'default' => 1));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'thold_warning_hi', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'thold_warning_low', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'thold_warning_fail_trigger', 'type' => 'int(10)', 'NULL' => true, 'unsigned' => true));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'thold_warning_fail_count', 'type' => 'int(11)', 'NULL' => false, 'default' => '0'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_warning_hi', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_warning_low', 'type' => 'varchar(100)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_warning_fail_trigger', 'type' => 'int (12)', 'NULL' => false, 'default' => 1));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'time_warning_fail_length', 'type' => 'int (12)', 'NULL' => false, 'default' => 1));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'notify_warning_extra', 'type' => 'text', 'NULL' => true));
        db_execute('ALTER TABLE thold_data MODIFY COLUMN notify_extra text');
        db_execute('ALTER TABLE thold_template MODIFY COLUMN notify_extra text');
        $data = array();
        $data['columns'][] = array('name' => 'id', 'type' => 'int(12)', 'NULL' => false, 'auto_increment' => true);
        $data['columns'][] = array('name' => 'name', 'type' => 'varchar(128)', 'NULL' => false);
        $data['columns'][] = array('name' => 'description', 'type' => 'varchar(512)', 'NULL' => false);
        $data['columns'][] = array('name' => 'emails', 'type' => 'varchar(512)', 'NULL' => false);
        $data['primary'] = 'id';
        $data['type'] = 'InnoDB';
        $data['comment'] = 'Table of Notification Lists';
        api_plugin_db_table_create('thold', 'plugin_notification_lists', $data);
        api_plugin_db_add_column('thold', 'host', array('name' => 'thold_send_email', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false, 'default' => '1', 'after' => 'disabled'));
        api_plugin_db_add_column('thold', 'host', array('name' => 'thold_host_email', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => true, 'after' => 'thold_send_email'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'notify_warning', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false, 'default' => '1', 'after' => 'notify_warning_extra'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'notify_alert', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false, 'default' => '1', 'after' => 'notify_warning_extra'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'notify_warning', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false, 'default' => '1', 'after' => 'notify_warning_extra'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'notify_alert', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false, 'default' => '1', 'after' => 'notify_warning_extra'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'hash', 'type' => 'varchar(32)', 'NULL' => true, 'after' => 'id'));
        db_execute("ALTER TABLE thold_data REMOVE COLUMN bl_enabled", FALSE);
        db_execute("ALTER TABLE thold_template REMOVE COLUMN bl_enabled", FALSE);
        api_plugin_register_hook('thold', 'config_form', 'thold_config_form', 'includes/settings.php');
        api_plugin_register_realm('thold', 'notify_lists.php', 'Plugin -> Manage Notification Lists', 1);
        /* set unique hash values for all thold templates */
        $templates = db_fetch_assoc("SELECT id FROM thold_template");
        if (sizeof($templates)) {
            foreach ($templates as $t) {
                $hash = get_hash_thold_template($t['id']);
                db_execute("UPDATE thold_template SET hash='{$hash}' WHERE id=" . $t['id']);
            }
        }
    }
    if (version_compare($oldv, '0.4.7', '<')) {
        $data = array();
        $data['columns'][] = array('name' => 'id', 'type' => 'int(12)', 'NULL' => false, 'unsigned' => true, 'auto_increment' => true);
        $data['columns'][] = array('name' => 'host_id', 'type' => 'int(12)', 'unsigned' => true, 'NULL' => false);
        $data['primary'] = 'id';
        $data['type'] = 'InnoDB';
        $data['comment'] = 'Table of Devices in a Down State';
        api_plugin_db_table_create('thold', 'plugin_thold_host_failed', $data);
        db_execute("DELETE FROM settings WHERE name='thold_failed_hosts'");
        /* increase the size of the settings table */
        db_execute("ALTER TABLE settings MODIFY column `value` varchar(1024) not null default ''");
    }
    if (version_compare($oldv, '0.6', '<')) {
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'snmp_event_category', 'type' => 'varchar(255)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'snmp_event_severity', 'type' => 'tinyint(1)', 'NULL' => false, 'default' => '3'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'snmp_event_warning_severity', 'type' => 'tinyint(1)', 'NULL' => false, 'default' => '2'));
        api_plugin_db_add_column('thold', 'thold_data', array('name' => 'thold_daemon_pid', 'type' => 'varchar(25)', 'NULL' => false, 'default' => ''));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'snmp_event_category', 'type' => 'varchar(255)', 'NULL' => true));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'snmp_event_severity', 'type' => 'tinyint(1)', 'NULL' => false, 'default' => '3'));
        api_plugin_db_add_column('thold', 'thold_template', array('name' => 'snmp_event_warning_severity', 'type' => 'tinyint(1)', 'NULL' => false, 'default' => '2'));
        $data = array();
        $data['columns'][] = array('name' => 'id', 'type' => 'int(11)', 'NULL' => false);
        $data['columns'][] = array('name' => 'pid', 'type' => 'varchar(25)', 'NULL' => false);
        $data['columns'][] = array('name' => 'rrd_reindexed', 'type' => 'varchar(600)', 'NULL' => false);
        $data['columns'][] = array('name' => 'rrd_time_reindexed', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false);
        $data['keys'][] = array('name' => 'id', 'columns' => 'id`, `pid');
        $data['type'] = 'InnoDB';
        $data['comment'] = 'Table of Poller Outdata needed for queued daemon processes';
        api_plugin_db_table_create('thold', 'plugin_thold_daemon_data', $data);
        $data = array();
        $data['columns'][] = array('name' => 'pid', 'type' => 'varchar(25)', 'NULL' => false);
        $data['columns'][] = array('name' => 'start', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false, 'default' => '0');
        $data['columns'][] = array('name' => 'end', 'type' => 'int(10)', 'unsigned' => true, 'NULL' => false, 'default' => '0');
        $data['columns'][] = array('name' => 'processed_items', 'type' => 'mediumint(8)', 'NULL' => false, 'default' => '0');
        $data['primary'] = 'pid';
        $data['type'] = 'InnoDB';
        $data['comment'] = 'Table of Thold Daemon Processes being queued';
        api_plugin_db_table_create('thold', 'plugin_thold_daemon_processes', $data);
        // Rename some columns
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN rra_id local_data_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN data_id data_template_rrd_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN template thold_template_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN data_template data_template_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN graph_id local_graph_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE thold_data CHANGE COLUMN graph_template graph_template_id int(11) UNSIGNED NOT NULL default "0"');
        db_execute('ALTER IGNORE TABLE plugin_thold_log CHANGE COLUMN graph_id local_graph_id int(11) UNSIGNED NOT NULL default "0"');
    }
    if (version_compare($oldv, '1.0', '<')) {
        $data = array();
        $data['columns'][] = array('name' => 'id', 'type' => 'int(11)', 'unsigned' => true, 'NULL' => false, 'auto_increment' => true);
        $data['columns'][] = array('name' => 'device_template_id', 'type' => 'int(11)', 'unsigned' => true, 'NULL' => false, 'default' => '0');
        $data['columns'][] = array('name' => 'thold_template_id', 'type' => 'int(11)', 'unsigned' => true, 'NULL' => false, 'default' => '0');
        $data['primary'] = 'id';
        $data['type'] = 'InnoDB';
        $data['comment'] = 'Table of Device Template Threshold Templates';
        api_plugin_db_table_create('thold', 'plugin_thold_device_template', $data);
        api_plugin_register_hook('thold', 'device_template_edit', 'thold_device_template_edit', 'setup.php');
        api_plugin_register_hook('thold', 'device_template_top', 'thold_device_template_top', 'setup.php');
        api_plugin_register_hook('thold', 'device_edit_pre_bottom', 'thold_device_edit_pre_bottom', 'setup.php');
        api_plugin_register_hook('thold', 'api_device_new', 'thold_api_device_new', 'setup.php');
        if (api_plugin_is_enabled('thold')) {
            api_plugin_enable_hooks('thold');
        }
    }
    db_execute('UPDATE settings SET value = "' . $v['version'] . '" WHERE name = "plugin_thold_version"');
    db_execute('UPDATE plugin_config SET version = "' . $v['version'] . '" WHERE directory = "thold"');
}
function weathermap_config_arrays()
{
    global $menu;
    if (function_exists('api_plugin_register_realm')) {
        api_plugin_register_realm('weathermap', 'weathermap-cacti-plugin.php', 'Plugin -> Weathermap: View', 1);
        api_plugin_register_realm('weathermap', 'weathermap-cacti-plugin-mgmt.php', 'Plugin -> Weathermap: Configure/Manage', 1);
        api_plugin_register_realm('weathermap', 'weathermap-cacti-plugin-editor.php', 'Plugin -> Weathermap: Edit Maps', 1);
    }
    $menu["Management"]['plugins/weathermap/weathermap-cacti-plugin-mgmt.php'] = array('plugins/weathermap/weathermap-cacti-plugin-mgmt.php' => "Weathermaps");
}
Example #19
0
function weathermap_config_arrays()
{
    global $user_auth_realms, $user_auth_realm_filenames, $menu;
    global $tree_item_types, $tree_item_handlers;
    if (function_exists('api_plugin_register_realm')) {
        api_plugin_register_realm('weathermap', 'weathermap-cacti-plugin.php', 'Plugin -> Weathermap: View', 1);
        api_plugin_register_realm('weathermap', 'weathermap-cacti-plugin-mgmt.php', 'Plugin -> Weathermap: Configure/Manage', 1);
    } else {
        $user_auth_realms[42] = 'Plugin -> Weathermap: Configure/Manage';
        $user_auth_realms[43] = 'Plugin -> Weathermap: View';
        $user_auth_realm_filenames['weathermap-cacti-plugin.php'] = 43;
        $user_auth_realm_filenames['weathermap-cacti-plugin-mgmt.php'] = 42;
        #		$user_auth_realm_filenames['weathermap-cacti-plugin-mgmt-groups.php'] = 42;
    }
    // if there is support for custom graph tree types, then register ourselves
    if (isset($tree_item_handlers)) {
        $tree_item_types[10] = "Weathermap";
        $tree_item_handlers[10] = array("render" => "weathermap_tree_item_render", "name" => "weathermap_tree_item_name", "edit" => "weathermap_tree_item_edit");
    }
    $wm_menu = array('plugins/weathermap/weathermap-cacti-plugin-mgmt.php' => "Weathermaps", 'plugins/weathermap/weathermap-cacti-plugin-mgmt-groups.php' => "Groups");
    $menu["Management"]['plugins/weathermap/weathermap-cacti-plugin-mgmt.php'] = $wm_menu;
}
Example #20
0
function syslog_upgrade_pre_oneoh_tables($options = false, $isbackground = false)
{
    global $config, $cnn_id, $syslog_levels, $database_default, $syslog_upgrade;
    include dirname(__FILE__) . "/config.php";
    $syslog_levels = array(1 => 'emerg', 2 => 'crit', 3 => 'alert', 4 => 'err', 5 => 'warn', 6 => 'notice', 7 => 'info', 8 => 'debug', 9 => 'other');
    if ($isbackground) {
        $table = 'syslog_pre_upgrade';
    } else {
        $table = 'syslog';
    }
    /* validate some simple information */
    $mysqlVersion = syslog_get_mysql_version("syslog");
    $truncate = isset($options["upgrade_type"]) && $options["upgrade_type"] == "truncate" ? true : false;
    $upgrade_type = isset($options["upgrade_type"]) ? $options["upgrade_type"] : "inline";
    $engine = isset($options["engine"]) && $options["engine"] == "innodb" ? "InnoDB" : "MyISAM";
    $partitioned = isset($options["db_type"]) && $options["db_type"] == "part" ? true : false;
    $syslogexists = sizeof(syslog_db_fetch_row("SHOW TABLES FROM `" . $syslogdb_default . "` LIKE '{$table}'"));
    /* disable collection for a bit */
    set_config_option('syslog_enabled', '');
    if ($upgrade_type == "truncate") {
        return;
    }
    if ($upgrade_type == "inline" || $isbackground) {
        syslog_setup_table_new($options);
        api_plugin_register_realm('syslog', 'syslog.php', 'Plugin -> Syslog User', 1);
        api_plugin_register_realm('syslog', 'syslog_alerts.php,syslog_removal.php,syslog_reports.php', 'Plugin -> Syslog Administration', 1);
        /* get the realm id's and change from old to new */
        $user = db_fetch_cell("SELECT id FROM plugin_realms WHERE file='syslog.php'") + 100;
        $admin = db_fetch_cell("SELECT id FROM plugin_realms WHERE file='syslog_alerts.php'") + 100;
        if ($user > 100) {
            $users = db_fetch_assoc("SELECT user_id FROM user_auth_realm WHERE realm_id=37");
            if (sizeof($users)) {
                foreach ($users as $u) {
                    db_execute("INSERT INTO user_auth_realm\n\t\t\t\t\t(realm_id, user_id) VALUES ({$user}, " . $u["user_id"] . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE realm_id=VALUES(realm_id)");
                    db_execute("DELETE FROM user_auth_realm\n\t\t\t\t\tWHERE user_id=" . $u["user_id"] . "\n\t\t\t\t\tAND realm_id=37");
                }
            }
        }
        if ($admin > 100) {
            $admins = db_fetch_assoc("SELECT user_id FROM user_auth_realm WHERE realm_id=38");
            if (sizeof($admins)) {
                foreach ($admins as $user) {
                    db_execute("INSERT INTO user_auth_realm\n\t\t\t\t\t(realm_id, user_id) VALUES ({$admin}, " . $user["user_id"] . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE realm_id=VALUES(realm_id)");
                    db_execute("DELETE FROM user_auth_realm\n\t\t\t\t\tWHERE user_id=" . $user["user_id"] . "\n\t\t\t\t\tAND realm_id=38");
                }
            }
        }
        /* get the database table names */
        $rows = syslog_db_fetch_assoc("SHOW TABLES FROM `" . $syslogdb_default . "`");
        if (sizeof($rows)) {
            foreach ($rows as $row) {
                $tables[] = $row["Tables_in_" . $syslogdb_default];
            }
        }
        /* create the reports table */
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_logs` (\n\t\t\talert_id integer unsigned not null default '0',\n\t\t\tlogseq bigint unsigned NOT NULL,\n\t\t\tlogtime TIMESTAMP NOT NULL default '0000-00-00 00:00:00',\n\t\t\tlogmsg " . ($mysqlVersion > 5 ? "varchar(1024)" : "text") . " default NULL,\n\t\t\thost varchar(32) default NULL,\n\t\t\tfacility varchar(10) default NULL,\n\t\t\tpriority varchar(10) default NULL,\n\t\t\tcount integer unsigned NOT NULL default '0',\n\t\t\thtml blob default NULL,\n\t\t\tseq bigint unsigned NOT NULL auto_increment,\n\t\t\tPRIMARY KEY (seq),\n\t\t\tKEY logseq (logseq),\n\t\t\tKEY alert_id (alert_id),\n\t\t\tKEY host (host),\n\t\t\tKEY seq (seq),\n\t\t\tKEY logtime (logtime),\n\t\t\tKEY priority (priority),\n\t\t\tKEY facility (facility)) ENGINE={$engine};");
        /* create the soft removal table */
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_host_facilities` (\n\t\t\t`host_id` int(10) unsigned NOT NULL,\n\t\t\t`facility_id` int(10) unsigned NOT NULL,\n\t\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY  (`host_id`,`facility_id`)) ENGINE={$engine};");
        /* create the host reference table */
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_hosts` (\n\t\t\t`host_id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t`host` VARCHAR(128) NOT NULL,\n\t\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY (`host`),\n\t\t\tKEY host_id (`host_id`),\n\t\t\tKEY last_updated (`last_updated`)) ENGINE={$engine}\n\t\t\tCOMMENT='Contains all hosts currently in the syslog table'");
        /* check upgrade of syslog_alert */
        $sql = "DESCRIBE `" . $syslogdb_default . "`.`syslog_alert`";
        $columns = array();
        $array = syslog_db_fetch_assoc($sql);
        if (sizeof($array)) {
            foreach ($array as $row) {
                $columns[] = $row["Field"];
            }
        }
        if (!in_array("enabled", $columns)) {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`syslog_alert` MODIFY COLUMN message varchar(128) DEFAULT NULL, ADD COLUMN enabled CHAR(2) DEFAULT 'on' AFTER type;");
        }
        if (!in_array("method", $columns)) {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`syslog_alert` ADD COLUMN method int(10) unsigned NOT NULL default '0' AFTER name");
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`syslog_alert` ADD COLUMN num int(10) unsigned NOT NULL default '1' AFTER method");
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`syslog_alert` ADD COLUMN severity INTEGER UNSIGNED NOT NULL default '0' AFTER name");
        }
        if (!in_array("command", $columns)) {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`syslog_alert` ADD COLUMN command varchar(255) DEFAULT NULL AFTER email;");
        }
        /* check upgrade of syslog_alert */
        $sql = "DESCRIBE `" . $syslogdb_default . "`.`syslog_remove`";
        $columns = array();
        $array = syslog_db_fetch_assoc($sql);
        if (sizeof($array)) {
            foreach ($array as $row) {
                $columns[] = $row["Field"];
            }
        }
        if (!in_array("enabled", $columns)) {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`syslog_remove` MODIFY COLUMN message varchar(128) DEFAULT NULL, ADD COLUMN enabled CHAR(2) DEFAULT 'on' AFTER type;");
        }
        if (!in_array("method", $columns)) {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`syslog_remove` ADD COLUMN method CHAR(5) DEFAULT 'del' AFTER enabled;");
        }
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_hosts`");
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_hosts` (\n\t\t\t`host_id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t`host` VARCHAR(128) NOT NULL,\n\t\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY (`host`),\n\t\t\tKEY host_id (`host_id`),\n\t\t\tKEY last_updated (`last_updated`)) TYPE={$engine}\n\t\t\tCOMMENT='Contains all hosts currently in the syslog table'");
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_facilities`");
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_facilities` (\n\t\t\t`facility_id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t`facility` varchar(10) NOT NULL,\n\t\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY (`facility`),\n\t\t\tKEY facility_id (`facility_id`)) ENGINE={$engine};");
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_priorities`");
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_priorities` (\n\t\t\t`priority_id` int(10) unsigned NOT NULL auto_increment,\n\t\t\t`priority` varchar(10) NOT NULL,\n\t\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY  (`priority`),\n\t\t\tKEY priority_id (`priority_id`)) ENGINE={$engine};");
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_host_facilities`");
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_host_facilities` (\n\t\t\t`host_id` int(10) unsigned NOT NULL,\n\t\t\t`facility_id` int(10) unsigned NOT NULL,\n\t\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\t\tPRIMARY KEY  (`host_id`,`facility_id`)) ENGINE={$engine};");
        /* populate the tables */
        syslog_db_execute("INSERT INTO `" . $syslogdb_default . "`.`syslog_hosts` (host) SELECT DISTINCT host FROM `" . $syslogdb_default . "`.`{$table}`");
        syslog_db_execute("INSERT INTO `" . $syslogdb_default . "`.`syslog_facilities` (facility) SELECT DISTINCT facility FROM `" . $syslogdb_default . "`.`{$table}`");
        foreach ($syslog_levels as $id => $priority) {
            syslog_db_execute("REPLACE INTO `" . $syslogdb_default . "`.`syslog_priorities` (priority_id, priority) VALUES ({$id}, '{$priority}')");
        }
        /* a bit more horsepower please */
        syslog_db_execute("INSERT INTO `" . $syslogdb_default . "`.`syslog_host_facilities`\n\t\t\t(host_id, facility_id)\n\t\t\tSELECT host_id, facility_id\n\t\t\tFROM ((SELECT DISTINCT host, facility\n\t\t\t\tFROM `" . $syslogdb_default . "`.`{$table}`) AS s\n\t\t\t\tINNER JOIN `" . $syslogdb_default . "`.`syslog_hosts` AS sh\n\t\t\t\tON s.host=sh.host\n\t\t\t\tINNER JOIN `" . $syslogdb_default . "`.`syslog_facilities` AS sf\n\t\t\t\tON sf.facility=s.facility)");
        /* change the structure of the syslog table for performance sake */
        $mysqlVersion = syslog_get_mysql_version("syslog");
        if ($mysqlVersion >= 5) {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`{$table}`\n\t\t\t\tMODIFY COLUMN message varchar(1024) DEFAULT NULL,\n\t\t\t\tADD COLUMN facility_id int(10) UNSIGNED NULL AFTER facility,\n\t\t\t\tADD COLUMN priority_id int(10) UNSIGNED NULL AFTER facility_id,\n\t\t\t\tADD COLUMN host_id int(10) UNSIGNED NULL AFTER priority_id,\n\t\t\t\tADD COLUMN logtime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER priority,\n\t\t\t\tADD INDEX facility_id (facility_id),\n\t\t\t\tADD INDEX priority_id (priority_id),\n\t\t\t\tADD INDEX host_id (host_id),\n\t\t\t\tADD INDEX logtime(logtime);");
        } else {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`{$table}`\n\t\t\t\tADD COLUMN facility_id int(10) UNSIGNED NULL AFTER host,\n\t\t\t\tADD COLUMN priority_id int(10) UNSIGNED NULL AFTER facility_id,\n\t\t\t\tADD COLUMN host_id int(10) UNSIGNED NULL AFTER priority_id,\n\t\t\t\tADD COLUMN logtime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER priority,\n\t\t\t\tADD INDEX facility_id (facility_id),\n\t\t\t\tADD INDEX priority_id (priority_id),\n\t\t\t\tADD INDEX host_id (host_id),\n\t\t\t\tADD INDEX logtime(logtime);");
        }
        /* convert dates and times to timestamp */
        syslog_db_execute("UPDATE `" . $syslogdb_default . "`.`{$table}` SET logtime=TIMESTAMP(`date`, `time`)");
        /* update the host_ids */
        $hosts = syslog_db_fetch_assoc("SELECT * FROM `" . $syslogdb_default . "`.`syslog_hosts`");
        if (sizeof($hosts)) {
            foreach ($hosts as $host) {
                syslog_db_execute("UPDATE `" . $syslogdb_default . "`.`{$table}`\n\t\t\t\tSET host_id=" . $host["host_id"] . "\n\t\t\t\tWHERE host='" . $host["host"] . "'");
            }
        }
        /* update the priority_ids */
        $priorities = $syslog_levels;
        if (sizeof($priorities)) {
            foreach ($priorities as $id => $priority) {
                syslog_db_execute("UPDATE `" . $syslogdb_default . "`.`{$table}`\n\t\t\t\tSET priority_id=" . $id . "\n\t\t\t\tWHERE priority='" . $priority . "'");
            }
        }
        /* update the facility_ids */
        $fac = syslog_db_fetch_assoc("SELECT * FROM `" . $syslogdb_default . "`.`syslog_facilities`");
        if (sizeof($fac)) {
            foreach ($fac as $f) {
                syslog_db_execute("UPDATE `" . $syslogdb_default . "`.`{$table}`\n\t\t\t\tSET facility_id=" . $f["facility_id"] . "\n\t\t\t\tWHERE facility='" . $f["facility"] . "'");
            }
        }
        if (!$isbackground) {
            syslog_db_execute("ALTER TABLE `" . $syslogdb_default . "`.`{$table}`\n\t\t\t\tDROP COLUMN `date`,\n\t\t\t\tDROP COLUMN `time`,\n\t\t\t\tDROP COLUMN `host`,\n\t\t\t\tDROP COLUMN `facility`,\n\t\t\t\tDROP COLUMN `priority`");
        } else {
            while (true) {
                $fetch_size = '10000';
                $sequence = syslog_db_fetch_cell("SELECT max(seq) FROM (SELECT seq FROM `" . $syslogdb_default . "`.`{$table}` ORDER BY seq LIMIT {$fetch_size}) AS preupgrade");
                if ($sequence > 0 && $sequence != '') {
                    syslog_db_execute("INSERT INTO `" . $syslogdb_default . "`.`syslog` (facility_id, priority_id, host_id, logtime, message)\n\t\t\t\t\t\tSELECT facility_id, priority_id, host_id, logtime, message\n\t\t\t\t\t\tFROM `" . $syslogdb_default . "`.`{$table}`\n\t\t\t\t\t\tWHERE seq<{$sequence}");
                    syslog_db_execute("DELETE FROM `" . $syslogdb_default . "`.`{$table}` WHERE seq<={$sequence}");
                } else {
                    syslog_db_execute("DROP TABLE `" . $syslogdb_default . "`.`{$table}`");
                    break;
                }
            }
        }
        /* create the soft removal table */
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_removed`");
        syslog_db_execute("CREATE TABLE `" . $syslogdb_default . "`.`syslog_removed` LIKE `" . $syslogdb_default . "`.`syslog`");
    } else {
        include_once $config['base_path'] . "/lib/poller.php";
        $p = dirname(__FILE__);
        $command_string = read_config_option("path_php_binary");
        $extra_args = ' -q ' . $config['base_path'] . '/plugins/syslog/syslog_upgrade.php --type=' . $options["db_type"] . ' --engine=' . $engine . ' --days=' . $options["days"];
        cacti_log("SYSLOG NOTE: Launching Background Syslog Database Upgrade Process", false, "SYSTEM");
        exec_background($command_string, $extra_args);
    }
    /* reenable syslog xferral */
    set_config_option('syslog_enabled', 'on');
}
Example #21
0
function plugin_settings_install()
{
    api_plugin_register_hook('settings', 'config_settings', 'settings_config_settings', 'setup.php');
    api_plugin_register_realm('settings', 'email-test.php', 'Send Test Email', 1);
}