/****************************************************************************** * * * Function: * * * * Purpose: * * * * Parameters: * * * * Return value: * * * * Comments: * * * ******************************************************************************/ int jarun_icon_info_get_calendar(const char *get_calendar_id, const zbx_uint64_t inner_job_id) { int status; char today[9]; DB_RESULT result; DB_ROW row; char *update_date; const char *__function_name = "jarun_icon_info_get_calendar"; zabbix_log(LOG_LEVEL_DEBUG, "In %s() get_calendar_id: %s", __function_name, get_calendar_id); status = -1; update_date = NULL; zbx_snprintf(today, sizeof(today), "%s", ja_timestamp2str(time(NULL))); result = DBselect ("select update_date from ja_calendar_control_table where calendar_id = '%s' and valid_flag = 1", get_calendar_id); if (NULL != (row = DBfetch(result))) { update_date = zbx_strdup(NULL, row[0]); } DBfree_result(result); if (update_date == NULL) { ja_log("JARUNICONINFO200004", 0, NULL, inner_job_id, __function_name, get_calendar_id); return -1; } result = DBselect ("select operating_date from ja_calendar_detail_table where calendar_id = '%s' and update_date = %s and operating_date = %s", get_calendar_id, update_date, today); if (NULL != (row = DBfetch(result))) { status = 1; } else { status = 0; } DBfree_result(result); zbx_free(update_date); return status; }
/****************************************************************************** * * * Function: * * * * Purpose: * * * * Parameters: * * * * Return value: * * * * Comments: * * * ******************************************************************************/ int jajobnet_ready(const zbx_uint64_t inner_jobnet_id) { DB_RESULT result; DB_ROW row; zbx_uint64_t icon_start_id; int count; char time_str[13]; const char *__function_name = "jajobnet_ready"; zabbix_log(LOG_LEVEL_DEBUG, "In %s() inner_jobnet_id: " ZBX_FS_UI64, __function_name, inner_jobnet_id); // set jobnet before value result = DBselect ("select jobnet_id, jobnet_name, user_name, inner_jobnet_id from ja_run_jobnet_table" " where inner_jobnet_id = " ZBX_FS_UI64, inner_jobnet_id); if (NULL != (row = DBfetch(result))) { ja_set_value_jobnet_before(inner_jobnet_id, "JOBNET_ID", row[0]); ja_set_value_jobnet_before(inner_jobnet_id, "JOBNET_NAME", row[1]); ja_set_value_jobnet_before(inner_jobnet_id, "USER_NAME", row[2]); ja_set_value_jobnet_before(inner_jobnet_id, "MANAGEMENT_ID", row[3]); } else { ja_log("JAJOBNETREADY200001", inner_jobnet_id, NULL, 0, __function_name, inner_jobnet_id); DBfree_result(result); return ja_set_enderr_jobnet(inner_jobnet_id); } DBfree_result(result); zbx_snprintf(time_str, sizeof(time_str), "%s", ja_timestamp2str(time(NULL))); ja_set_value_jobnet_before(inner_jobnet_id, "JOBNET_BOOT_TIME", time_str); // set jobnet status if (ja_set_run_jobnet(inner_jobnet_id) == FAIL) return FAIL; // search start icon count = 0; icon_start_id = 0; result = DBselect ("select inner_job_id from ja_run_job_table" " where inner_jobnet_id = " ZBX_FS_UI64 " and job_type = %d ", inner_jobnet_id, JA_JOB_TYPE_START); while (NULL != (row = DBfetch(result))) { count++; if (count == 1) ZBX_STR2UINT64(icon_start_id, row[0]); else icon_start_id = 0; } DBfree_result(result); if (icon_start_id == 0) { ja_log("JAJOBNETREADY200002", inner_jobnet_id, NULL, 0, __function_name, count, inner_jobnet_id); return ja_set_enderr_jobnet(inner_jobnet_id); } else { if (ja_value_before_jobnet_out(inner_jobnet_id, icon_start_id) == FAIL) return FAIL; if (ja_set_status_job (icon_start_id, JA_JOB_STATUS_READY, 0, 0) == FAIL) return FAIL; } return SUCCEED; }