Beispiel #1
0
/******************************************************************************
 *                                                                            *
 * Function: main_nodewatcher_loop                                            *
 *                                                                            *
 * Purpose: periodically calculates checksum of config data                   *
 *                                                                            *
 * Parameters:                                                                *
 *                                                                            *
 * Return value:                                                              *
 *                                                                            *
 * Author: Alexei Vladishev                                                   *
 *                                                                            *
 * Comments: never returns                                                    *
 *                                                                            *
 ******************************************************************************/
void	main_nodewatcher_loop()
{
	int	start, end;
	int	lastrun = 0;

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

	zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type));

	DBconnect(ZBX_DB_CONNECT_NORMAL);

	for (;;)
	{
		zbx_setproctitle("%s [exchanging data]", get_process_type_string(process_type));

		start = time(NULL);

		zabbix_log(LOG_LEVEL_DEBUG, "Starting sync with nodes");

		if (lastrun + 120 < start)
		{
			process_nodes();
			lastrun = start;
		}

		/* send new history data to master node */
		main_historysender();

		end = time(NULL);

		zbx_sleep_loop(10 - (end - start));
	}
}
Beispiel #2
0
/******************************************************************************
 *                                                                            *
 * Function: main_nodewatcher_loop                                            *
 *                                                                            *
 * Purpose: periodically calculates checks sum of config data                 *
 *                                                                            *
 * Parameters:                                                                *
 *                                                                            *
 * Return value:                                                              *
 *                                                                            *
 * Author: Alexei Vladishev                                                   *
 *                                                                            *
 * Comments: never returns                                                    *
 *                                                                            *
 ******************************************************************************/
int main_nodewatcher_loop()
{
    int start, end;
    int	lastrun = 0;

    zabbix_log( LOG_LEVEL_DEBUG, "In main_nodeupdater_loop()");
    for(;;)
    {
        start = time(NULL);

        zbx_setproctitle("connecting to the database");
        zabbix_log( LOG_LEVEL_DEBUG, "Starting sync with nodes");

        DBconnect(ZBX_DB_CONNECT_NORMAL);

#if 0
        if(lastrun + 120 < start)
        {

            DBbegin();
            calculate_checksums();
            compare_checksums();
            update_checksums();

            /* Send configuration changes to required nodes */
            main_nodesender();
            DBcommit();

            lastrun = start;
        }
#endif
        /* Send new events to master node */
        main_eventsender();

        /* Send new history data to master node */
        main_historysender();

        DBclose();

        end = time(NULL);

        if(end-start<10)
        {
            zbx_setproctitle("sender [sleeping for %d seconds]",
                             10-(end-start));
            zabbix_log( LOG_LEVEL_DEBUG, "Sleeping %d seconds",
                        10-(end-start));
            sleep(10-(end-start));
        }
    }
}