Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions reboot-reason-fetcher/src/bootup_reason_checker.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ int find_previous_reboot_log(char *out_path, size_t len)
if (!log_base || log_base[0] == '\0') {
log_base = "/opt/logs";
}
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","LOG PATH: %s\n", log_base);
if (logfile_path_check(prev_logs, sizeof(prev_logs), log_base, "PreviousLogs") != SUCCESS) {
RDK_LOG(RDK_LOG_ERROR,"LOG.RDK.REBOOTINFO","Path too long for PreviousLogs under %s\n", log_base);
return ERROR_GENERAL;
Expand Down Expand Up @@ -148,6 +149,7 @@ int find_previous_reboot_log(char *out_path, size_t len)
return ERROR_GENERAL;
}
if (access(candidate, F_OK) == 0) {
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Reading Reboot information from rebootInfo.log file\n");
Comment thread
Saranya2421 marked this conversation as resolved.
for (i = 1; i <= 3; i++) {
char bak[MAX_PATH_LENGTH];
char bak_name[] = "bak1_rebootInfo.log";
Expand All @@ -158,13 +160,13 @@ int find_previous_reboot_log(char *out_path, size_t len)
if (access(bak, F_OK) == 0) {
strncpy(out_path, bak, len - 1);
out_path[len - 1] = '\0';
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Previous reboot log (bak%d fallback): %s\n", i, out_path);
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Last reboot File = %s\n", out_path);
return SUCCESS;
}
}
strncpy(out_path, candidate, len - 1);
out_path[len - 1] = '\0';
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Previous reboot log (flat fallback): %s\n", out_path);
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Last reboot File = %s\n", out_path);
return SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion reboot-reason-fetcher/src/log_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int update_reboot_info(const EnvContext *ctx)
{
if (!ctx) return 0;
if (access(STT_FLAG, F_OK) != 0) {
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","STT flag missing; skip update\n");
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","STT flag missing; skip update\n");
return 0;
}
return 1;
Expand Down
23 changes: 16 additions & 7 deletions reboot-reason-fetcher/src/parodus_log_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@

static void get_timestamp_string(char *buffer, size_t size)
{
time_t now = time(NULL);
struct tm *tm_info = localtime(&now);
strftime(buffer, size, "%y%m%d-%H:%M:%S", tm_info);
struct timespec ts;
struct tm tm_info;
clock_gettime(CLOCK_REALTIME, &ts);
gmtime_r(&ts.tv_sec, &tm_info);
Comment thread
Saranya2421 marked this conversation as resolved.
snprintf(buffer, size, "%04d-%02d-%02dT%02d:%02d:%02d.%03ldZ",
Comment thread
Saranya2421 marked this conversation as resolved.
tm_info.tm_year + 1900,
tm_info.tm_mon + 1,
tm_info.tm_mday,
tm_info.tm_hour,
tm_info.tm_min,
tm_info.tm_sec,
ts.tv_nsec / 1000000);
}

int append_kernel_reason(const EnvContext *ctx, const RebootInfo *info)
Expand Down Expand Up @@ -78,10 +87,10 @@ int update_parodus_log(const RebootInfo *info)
RDK_LOG(RDK_LOG_ERROR,"LOG.RDK.REBOOTINFO","Failed to open Parodus log %s: %s\n", PARODUS_LOG, strerror(errno));
return ERROR_GENERAL;
}
fprintf(fp, "%s: %s: Updating previous reboot info to Parodus\n", timestamp, "update_previous_reboot_info");
fprintf(fp, "%s: %s: PreviousRebootInfo:%s,%s,%s,%s\n",
fprintf(fp, "%s %s: Updating previous reboot info to Parodus\n", timestamp, "update_previous_reboot_info");
fprintf(fp, "%s %s: PreviousRebootInfo:%s,%s,%s,%s\n",
timestamp,
"update_previous_reboot_info",
"update_previous_reboot_info",
info->timestamp,
info->reason,
info->customReason,
Expand Down Expand Up @@ -157,7 +166,7 @@ int handle_parodus_reboot_file(const RebootInfo *info, const char *destPath)
}
fprintf(out, "PreviousRebootInfo:%s,%s,%s,%s\n",
info->timestamp,
info->reason,
info->reason,
info->customReason,
info->source);
fflush(out);
Expand Down
18 changes: 13 additions & 5 deletions reboot-reason-fetcher/src/rebootreason_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ int main(void)
return ERROR_LOCK_FAILED;
}
lock_acquired = true;
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Acquired rebootInfo lock\n");

RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Loading environment context \n");
if (parse_device_properties(&ctx) != SUCCESS) {
Expand All @@ -106,8 +107,9 @@ int main(void)
goto cleanup;
}

RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Checking flags to update reboot reason \n");
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Checking /tmp/stt_received and /tmp/rebootInfo_Updated flag to update the reboot reason\n");
if (!update_reboot_info(&ctx)) {
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Exiting since /tmp/stt_received or /tmp/rebootInfo_Updated flag is not available\n");
Comment thread
Saranya2421 marked this conversation as resolved.
Comment thread
Saranya2421 marked this conversation as resolved.
ret = SUCCESS;
goto cleanup;
}
Expand All @@ -124,14 +126,15 @@ int main(void)

RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Checking for new reboot.info file \n");
if (access(REBOOT_INFO_FILE, F_OK) == 0) {
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","New %s file found, Creating previous reboot info file...\n",REBOOT_INFO_FILE);
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","New %s file found, Creating previous reboot info file...\n",REBOOT_INFO_FILE);
log_reason(REBOOT_INFO_FILE);
if (rename(REBOOT_INFO_FILE, PREVIOUS_REBOOT_INFO_FILE) != 0) {
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Failed to rename reboot.info: %s\n", strerror(errno));
} else {
has_reboot_info = true;
}
if (access(PARODUS_REBOOT_INFO_FILE, F_OK) == 0) {
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","New %s file found, updating parodus logfile...\n", PARODUS_REBOOT_INFO_FILE);
handle_parodus_reboot_file(&rebootInfo, PREVIOUS_PARODUSREBOOT_INFO_FILE);
}
}
Expand Down Expand Up @@ -162,6 +165,8 @@ int main(void)

if (update_previous_reboot_log_fields(has_reboot_info ? PREVIOUS_REBOOT_INFO_FILE : NULL, &rebootInfo) != SUCCESS) {
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Skipping PreviousReboot* update in %s due to missing reboot info fields\n", REBOOT_INFO_LOG_FILE);
} else if (has_reboot_info) {
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Get previous reboot reason from %s - prevrebootreason: %s\n", PREVIOUS_REBOOT_INFO_FILE, rebootInfo.reason);
Comment thread
Saranya2421 marked this conversation as resolved.
}

if (!has_reboot_info) {
Expand All @@ -180,13 +185,16 @@ int main(void)
}
}
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Copying keypress info \n");
if (access(KEYPRESS_INFO_FILE, F_OK) != 0) {
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Unable to find the %s file\n", KEYPRESS_INFO_FILE);
}
Comment thread
Saranya2421 marked this conversation as resolved.
copy_keypress_info(KEYPRESS_INFO_FILE, PREVIOUS_KEYPRESS_INFO_FILE);

RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Reboot reason processing completed successfully \n");
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","End of Reboot Reason \n");

cleanup:
if (lock_acquired) {
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Releasing lock \n");
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Releasing rebootInfo lock\n");
if (release_lock(LOCK_DIR) != SUCCESS) {
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Failed to release lock \n");
if (ret == SUCCESS) {
Expand All @@ -195,6 +203,6 @@ int main(void)
}
}

RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Reboot Reason Update completed with status: %d \n", ret);
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Reboot Reason Update completed with status: %d \n", ret);
return ret;
}
4 changes: 2 additions & 2 deletions scripts/update_previous_reboot_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ setPreviousRebootInfo()
existing_reboot_info=$(grep "PreviousRebootInfo" "$PARODUS_LOG" 2>/dev/null | tail -1)
Comment thread
Saranya2421 marked this conversation as resolved.
Outdated

if [ -z "$existing_reboot_info" ]; then
echo "$(/bin/timestamp): $0: Updating previous reboot info to Parodus" >> "$PARODUS_LOG"
echo "$(/bin/timestamp): $0: PreviousRebootInfo:$timestamp,$reason,$custom,$source" >> "$PARODUS_LOG"
echo "$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") $0: Updating previous reboot info to Parodus" >> "$PARODUS_LOG"
echo "$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ") $0: PreviousRebootInfo:$timestamp,$reason,$custom,$source" >> "$PARODUS_LOG"
Comment thread
Saranya2421 marked this conversation as resolved.
Outdated
rebootLog "Reboot Information Updated to parodus log:$timestamp,$reason,$custom,$source"
else
rebootLog "${FUNCNAME[0]}: Reboot info already present in $PARODUS_LOG as $existing_reboot_info, skipping update"
Expand Down
Loading