/****************************************************************************** * * * Function: * * * * Purpose: * * * * Parameters: * * * * Return value: * * * * Comments: * * * ******************************************************************************/ int time_passed_check(char *starttime) { time_t now, t; now = time(NULL); t = ja_str2timestamp(starttime); if (t - now < 60) return FAIL; return SUCCEED; }
/****************************************************************************** * * * Function: * * * * Purpose: * * * * Parameters: * * * * Return value: * * * * Comments: * * * ******************************************************************************/ static void process_monitor() { DB_RESULT result; DB_ROW row; DB_RESULT result_load; DB_ROW row_load; char *schedule_id, *jobnet_id, *update_date; char sch_time[13], s_date[9], s_time[5]; struct tm *tm; time_t now, t, start_time, schedule_time; const char *__function_name = "process_monitor"; now = time(NULL); /* check loader */ t = now + (CONFIG_SPAN_TIME - CONFIG_LOAD_SHIFT_TIME - 1) * 60; tm = localtime(&t); zbx_snprintf(s_date, sizeof(s_date), "%.4d%.2d%.2d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); zbx_snprintf(s_time, sizeof(s_time), "%.2d%.2d", tm->tm_hour, tm->tm_min); result = DBselect("select schedule_id, jobnet_id, update_date from ja_schedule_jobnet_table"); while (NULL != (row = DBfetch(result))) { schedule_id = row[0]; jobnet_id = row[1]; update_date = row[2]; if (ja_schedule_check_time(schedule_id, update_date, s_date, s_time) == FAIL) { continue; } zabbix_log(LOG_LEVEL_DEBUG, "In %s() schedule_id: %s, jobnet_id: %s, date: %s, time: %s", __function_name, schedule_id, jobnet_id, s_date, s_time); result_load = DBselect("select start_time from ja_run_jobnet_summary_table" " where jobnet_id = '%s' and scheduled_time = '%s%s' and run_type = %d", jobnet_id, s_date, s_time, JA_JOBNET_RUN_TYPE_NORMAL); if ((row_load = DBfetch(result_load)) == NULL) { zbx_snprintf(sch_time, sizeof(sch_time), "%s%s", s_date, s_time); ja_sender(1, schedule_id, jobnet_id, sch_time, ""); } DBfree_result(result_load); } DBfree_result(result); /* check jarun */ t = now - (1 + CONFIG_RUN_SHIFT_TIME) * 60; result = DBselect("select start_time, scheduled_time, jobnet_id, schedule_id from ja_run_jobnet_summary_table" " where run_type = %d and start_pending_flag = %d", JA_JOBNET_RUN_TYPE_NORMAL, JA_SUMMARY_START_PENDING_NONE); while (NULL != (row = DBfetch(result))) { start_time = ja_str2timestamp(row[0]); schedule_time = ja_str2timestamp(row[1]); jobnet_id = row[2]; schedule_id = row[3]; if (t >= schedule_time && t < schedule_time + 60) { if (start_time == 0) { ja_sender(2, schedule_id, jobnet_id, row[1], row[0]); } } } DBfree_result(result); }