コード例 #1
0
ファイル: simple_action_data.cpp プロジェクト: KDE/khotkeys
void SimpleActionData::doDisable()
{
    if (trigger())
    {
        trigger()->disable();
        update_triggers();
    }
}
コード例 #2
0
ファイル: timer.c プロジェクト: Shmuma/z
/******************************************************************************
 *                                                                            *
 * Function: main_timer_loop                                                  *
 *                                                                            *
 * Purpose: periodically updates time-related triggers                        *
 *                                                                            *
 * Parameters:                                                                *
 *                                                                            *
 * Return value:                                                              *
 *                                                                            *
 * Author: Alexei Vladishev                                                   *
 *                                                                            *
 * Comments: does update once per 30 seconds (hardcoded)                      *
 *                                                                            *
 ******************************************************************************/
void main_timer_loop()
{
	int	now, cur;

/*	int	itemid,functionid;
	char	*function;
	char	*parameter;*/

	DB_ITEM	item;

	DB_RESULT	result;
	DB_ROW	row;

	for(;;)
	{
		zbx_setproctitle("Timer: updating nodata() functions");

		DBconnect(ZBX_DB_CONNECT_NORMAL);

		now=time(NULL);
/*
#ifdef HAVE_POSTGRESQL
		zbx_snprintf(sql,sizeof(sql),"select distinct f.itemid,f.functionid,f.parameter from functions f, items i,hosts h where h.hostid=i.hostid and h.status=%d and i.itemid=f.itemid and f.function in ('nodata','date','dayofweek','time','now') and i.lastclock+f.parameter::text::integer<=%d and i.status=%d", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE);
#else
		zbx_snprintf(sql,sizeof(sql),"select distinct f.itemid,f.functionid,f.parameter,f.function from functions f, items i,hosts h where h.hostid=i.hostid and h.status=%d and i.itemid=f.itemid and f.function in ('nodata','date','dayofweek','time','now') and i.lastclock+f.parameter<=%d and i.status=%d", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE);
#endif
	*/

		result = DBselect("select %s, functions f where h.hostid=i.hostid and h.status=%d and i.status=%d and f.function in ('nodata','date','dayofweek','time','now','count') and i.itemid=f.itemid and " ZBX_COND_SITE,
			ZBX_SQL_ITEM_SELECT,
			HOST_STATUS_MONITORED,
			ITEM_STATUS_ACTIVE,
			getSiteCondition ());
		cur = 1;

		while((row=DBfetch(result)))
		{
#ifdef HAVE_MYSQL			
			zbx_setproctitle("Timer: processing %d item of %d", cur++, result->row_count);
#endif
			DBget_item_from_db(&item,row);

			DBbegin();
			update_functions(&item);
			update_triggers(item.itemid);
			DBcommit();

			DBfree_item(&item);
		}

		DBfree_result(result);
		DBclose();

		zbx_setproctitle("Timer: sleeping for 10 sec");

		sleep(10);
	}
}
コード例 #3
0
ファイル: scripts.c プロジェクト: balagopalraj/clearlinux
void run_scripts(void)
{
	LOG_INFO(NULL, "calling update helpers", class_scripts, "");

	if (need_update_boot)
		update_kernel();
	if (need_update_bootloader)
		update_bootloader();

	/* Crudely call post-update hooks after every update, must fix with proper conditions and log output */
	update_triggers();
}
コード例 #4
0
ファイル: functions.c プロジェクト: rennhak/zabbix
/******************************************************************************
 *                                                                            *
 * Function: process_new_value                                                *
 *                                                                            *
 * Purpose: process new item value                                            *
 *                                                                            *
 * Parameters: item - item data                                               *
 *             value - new value of the item                                  *
 *                                                                            *
 * Author: Alexei Vladishev                                                   *
 *                                                                            *
 * Comments: for trapper poller process                                       *
 *                                                                            *
 ******************************************************************************/
void	process_new_value(DB_ITEM *item, AGENT_RESULT *value, time_t now)
{
	zabbix_log( LOG_LEVEL_DEBUG, "In process_new_value(%s)",
		item->key);

	if (0 == CONFIG_DBSYNCER_FORKS)
	{
		if (SUCCEED == add_history(item, value, now))
		{
			update_item(item, value, now);
			update_functions(item, now);
			update_triggers(item->itemid);
		}
		else
			update_item(item, value, now);
	}
	else
		dc_add_history(item, value, now);
}
コード例 #5
0
ファイル: zlog.c プロジェクト: Shmuma/z
/******************************************************************************
 *                                                                            *
 * Function: zabbix_syslog                                                    *
 *                                                                            *
 * Purpose: save internal warning or error message in item zabbix[log]        *
 *                                                                            *
 * Parameters: va_list arguments                                              *
 *                                                                            *
 * Return value:                                                              *
 *                                                                            *
 * Author: Alexei Vladishev                                                   *
 *                                                                            *
 * Comments: do nothing if no zabbix[log] items                               *
 *                                                                            *
 ******************************************************************************/
void __zbx_zabbix_syslog(const char *fmt, ...)
{ 
	va_list		ap;
	char		value_str[MAX_STRING_LEN];

	DB_ITEM		item;
	DB_RESULT	result;
	DB_ROW	row;

	AGENT_RESULT	agent;

	zabbix_log(LOG_LEVEL_DEBUG, "In zabbix_log()");

	/* This is made to disable writing to database for watchdog */
	if(CONFIG_ENABLE_LOG == 0)	return;

	result = DBselect("select %s where h.hostid=i.hostid and i.key_='%s' and i.value_type=%d and " ZBX_COND_SITE,
		ZBX_SQL_ITEM_SELECT,
		SERVER_ZABBIXLOG_KEY,
		ITEM_VALUE_TYPE_STR,
		getSiteCondition ());

	while((row=DBfetch(result)))
	{
		DBget_item_from_db(&item,row);

		va_start(ap,fmt);
		vsnprintf(value_str,sizeof(value_str),fmt,ap);
		value_str[MAX_STRING_LEN-1]=0;
		va_end(ap);

		init_result(&agent);
		SET_STR_RESULT(&agent, strdup(value_str));
		process_new_value(0, &item,&agent, 0, NULL);
		free_result(&agent);

		update_triggers(item.itemid);
		DBfree_item(&item);
	}

	DBfree_result(result);
}
コード例 #6
0
ファイル: resmon_config.c プロジェクト: karig/robinhood
int Reload_ResourceMon_Config( void *module_config )
{
    resource_monitor_config_t *conf = ( resource_monitor_config_t * ) module_config;

    /* parameters that can't be modified dynamically */

    if ( resmon_config.nb_threads_purge != conf->nb_threads_purge )
        DisplayLog( LVL_MAJOR, RESMONCFG_TAG, PURGE_PARAM_BLOCK
                    "::nb_threads_purge changed in config file, but cannot be modified dynamically");

    if ( resmon_config.purge_queue_size != conf->purge_queue_size )
        DisplayLog( LVL_MAJOR, RESMONCFG_TAG, PURGE_PARAM_BLOCK
                    "::purge_queue_size changed in config file, but cannot be modified dynamically");

#ifdef _TMP_FS_MGR
    if (strcmp(conf->purge_command, resmon_config.purge_command))
        DisplayLog(LVL_MAJOR, RESMONCFG_TAG, PURGE_PARAM_BLOCK
                   "::purge_command changed in config file, but cannot be modified dynamically");
#endif

    /* dynamic parameters */

    if ( resmon_config.post_purge_df_latency != conf->post_purge_df_latency )
    {
        DisplayLog( LVL_EVENT, RESMONCFG_TAG, PURGE_PARAM_BLOCK
                    "::post_purge_df_latency updated: %lu->%lu",
                    resmon_config.post_purge_df_latency, conf->post_purge_df_latency );
        resmon_config.post_purge_df_latency = conf->post_purge_df_latency;
    }

    if ( resmon_config.db_request_limit != conf->db_request_limit )
    {
        DisplayLog( LVL_EVENT, RESMONCFG_TAG, PURGE_PARAM_BLOCK
                    "::db_result_size_max updated: %u->%u",
                    resmon_config.db_request_limit, conf->db_request_limit );
        resmon_config.db_request_limit = conf->db_request_limit;
    }

#ifdef ATTR_INDEX_status
    if ( resmon_config.check_purge_status_on_startup != conf->check_purge_status_on_startup )
    {
        DisplayLog( LVL_EVENT, RESMONCFG_TAG, PURGE_PARAM_BLOCK
                    "::check_purge_status_on_startup updated: %u->%u",
                    resmon_config.check_purge_status_on_startup,
                    conf->check_purge_status_on_startup );
        resmon_config.check_purge_status_on_startup = conf->check_purge_status_on_startup;
    }
#endif
    if ( resmon_config.recheck_ignored_classes != conf->recheck_ignored_classes )
    {
        DisplayLog( LVL_EVENT, RESMONCFG_TAG, PURGE_PARAM_BLOCK
                    "::recheck_ignored_classes updated: %u->%u",
                    resmon_config.recheck_ignored_classes, conf->recheck_ignored_classes );
        resmon_config.recheck_ignored_classes = conf->recheck_ignored_classes;
    }


    update_triggers( conf->trigger_list, conf->trigger_count );

    free_triggers( conf->trigger_list, conf->trigger_count );

    return 0;
}
コード例 #7
0
ファイル: action_data.cpp プロジェクト: KDE/khotkeys
void ActionData::doEnable()
    {
    triggers()->enable();
    update_triggers();
    }
コード例 #8
0
ファイル: action_data.cpp プロジェクト: KDE/khotkeys
void ActionData::doDisable()
    {
    triggers()->disable();
    update_triggers();
    }
コード例 #9
0
ファイル: policy_run_cfg.c プロジェクト: cea-hpc/robinhood
/** reload parameters for a single policy */
static int polrun_reload(const char *blkname, policy_run_config_t *cfg_tgt,
                         policy_run_config_t *cfg_new,
                         bool *recompute_interval)
{
    /* parameters that can't be modified dynamically */
    if (cfg_tgt->nb_threads != cfg_new->nb_threads)
        no_param_updt_msg(blkname, "nb_threads");

    if (cfg_tgt->queue_size != cfg_new->queue_size)
        no_param_updt_msg(blkname, "queue_size");

// FIXME can change action functions, but not cmd string
//    if (strcmp(cfg_new->default_action, cfg_tgt->default_action))
//        no_param_updt_msg(blkname, "default_action");
//  TODO parse action and action_params
//       and set params_attr_mask accordingly.

    if (cfg_tgt->lru_sort_attr != cfg_new->lru_sort_attr)
        no_param_updt_msg(blkname, "lru_sort_attr");

    /* dynamic parameters */
    if (cfg_tgt->max_action_nbr != cfg_new->max_action_nbr) {
        PARAM_UPDT_MSG(blkname, "max_action_count", "%u",
                       cfg_tgt->max_action_nbr, cfg_new->max_action_nbr);
        cfg_tgt->max_action_nbr = cfg_new->max_action_nbr;
    }

    if (cfg_tgt->max_action_vol != cfg_new->max_action_vol) {
        PARAM_UPDT_MSG(blkname, "max_action_volume", "%llu",
                       cfg_tgt->max_action_vol, cfg_new->max_action_vol);
        cfg_tgt->max_action_vol = cfg_new->max_action_vol;
    }

    if (cfg_tgt->suspend_error_pct != cfg_new->suspend_error_pct) {
        PARAM_UPDT_MSG(blkname, "suspend_error_pct", "%.2f%%",
                       cfg_tgt->suspend_error_pct, cfg_new->suspend_error_pct);
        cfg_tgt->suspend_error_pct = cfg_new->suspend_error_pct;
    }

    if (cfg_tgt->suspend_error_min != cfg_new->suspend_error_min) {
        PARAM_UPDT_MSG(blkname, "suspend_error_min", "%u",
                       cfg_tgt->suspend_error_min, cfg_new->suspend_error_min);
        cfg_tgt->suspend_error_min = cfg_new->suspend_error_min;
    }

    if (cfg_tgt->report_interval != cfg_new->report_interval) {
        PARAM_UPDT_MSG(blkname, "report_interval", "%lu",
                       cfg_tgt->report_interval, cfg_new->report_interval);
        cfg_tgt->report_interval = cfg_new->report_interval;
    }

    if (cfg_tgt->action_timeout != cfg_new->action_timeout) {
        PARAM_UPDT_MSG(blkname, "action_timeout", "%lu",
                       cfg_tgt->action_timeout, cfg_new->action_timeout);
        cfg_tgt->action_timeout = cfg_new->action_timeout;
    }

    if (cfg_tgt->check_action_status_delay !=
            cfg_new->check_action_status_delay) {
        PARAM_UPDT_MSG(blkname, "check_actions_interval", "%lu",
                       cfg_tgt->check_action_status_delay,
                       cfg_new->check_action_status_delay);
        cfg_tgt->check_action_status_delay = cfg_new->check_action_status_delay;
    }

    if (cfg_tgt->db_request_limit != cfg_new->db_request_limit) {
        PARAM_UPDT_MSG(blkname, "db_result_size_max", "%u",
                       cfg_tgt->db_request_limit, cfg_new->db_request_limit);
        cfg_tgt->db_request_limit = cfg_new->db_request_limit;
    }

    if (cfg_tgt->pre_maintenance_window != cfg_new->pre_maintenance_window) {
        PARAM_UPDT_MSG(blkname, "pre_maintenance_window", "%lu",
                       cfg_tgt->pre_maintenance_window,
                       cfg_new->pre_maintenance_window);
        cfg_tgt->pre_maintenance_window = cfg_new->pre_maintenance_window;
    }

    if (cfg_tgt->maint_min_apply_delay != cfg_new->maint_min_apply_delay) {
        PARAM_UPDT_MSG(blkname, "maint_min_apply_delay", "%lu",
                       cfg_tgt->maint_min_apply_delay,
                       cfg_new->maint_min_apply_delay);
        cfg_tgt->maint_min_apply_delay = cfg_new->maint_min_apply_delay;
    }

    if (cfg_tgt->check_action_status_on_startup !=
            cfg_new->check_action_status_on_startup) {
        PARAM_UPDT_MSG(blkname, "check_actions_on_startup", "%s",
                       bool2str(cfg_tgt->check_action_status_on_startup),
                       bool2str(cfg_new->check_action_status_on_startup));
        cfg_tgt->check_action_status_on_startup =
            cfg_new->check_action_status_on_startup;
    }

    if (cfg_tgt->recheck_ignored_entries != cfg_new->recheck_ignored_entries) {
        PARAM_UPDT_MSG(blkname, "recheck_ignored_entries", "%s",
                       bool2str(cfg_tgt->recheck_ignored_entries),
                       bool2str(cfg_new->recheck_ignored_entries));
        cfg_tgt->recheck_ignored_entries = cfg_new->recheck_ignored_entries;
    }

    if (cfg_tgt->report_actions != cfg_new->report_actions) {
        PARAM_UPDT_MSG(blkname, "report_actions", "%s",
                       bool2str(cfg_tgt->report_actions),
                       bool2str(cfg_new->report_actions));
        cfg_tgt->report_actions = cfg_new->report_actions;
    }

    update_triggers(cfg_tgt->trigger_list, cfg_tgt->trigger_count,
                    cfg_new->trigger_list, cfg_new->trigger_count,
                    recompute_interval);
    return 0;
}