diff --git a/include/ipmitool/ipmi.h b/include/ipmitool/ipmi.h index 78bb689..584f1ab 100644 --- a/include/ipmitool/ipmi.h +++ b/include/ipmitool/ipmi.h @@ -67,6 +67,7 @@ #define IPMI_PAYLOAD_TYPE_RAKP_4 0x15 extern int verbose; +extern int time_in_utc; extern int csv_output; struct ipmi_rq { diff --git a/lib/ipmi_chassis.c b/lib/ipmi_chassis.c index 7b5c2a8..b034364 100644 --- a/lib/ipmi_chassis.c +++ b/lib/ipmi_chassis.c @@ -704,6 +704,7 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg) unsigned long timestamp; char time_buf[40]; time_t out_time; + struct tm *strtm; session_id = ((unsigned long) rsp->data[3]); session_id |= (((unsigned long) rsp->data[4])<<8); @@ -716,10 +717,15 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg) timestamp |= (((unsigned long) rsp->data[10])<<24); memset(time_buf, 0, 40); + if(time_in_utc) + strtm = gmtime(&out_time); + else + strtm = localtime(&out_time); + strftime( time_buf, sizeof(time_buf), - "%m/%d/%Y %H:%M:%S", localtime(&out_time) + "%m/%d/%Y %H:%M:%S", strtm ); printf(" Boot Initiator Info :\n"); diff --git a/lib/ipmi_ekanalyzer.c b/lib/ipmi_ekanalyzer.c index f6d8b90..76049cf 100644 --- a/lib/ipmi_ekanalyzer.c +++ b/lib/ipmi_ekanalyzer.c @@ -2420,6 +2420,7 @@ ipmi_ek_display_fru_header_detail(char *filename) unsigned char lan_code = 0; unsigned char mfg_date[SIZE_MFG_DATE]; unsigned int board_length = 0; + struct tm *strtm; input_file = fopen(filename, "r"); if (input_file == NULL) { @@ -2546,8 +2547,11 @@ ipmi_ek_display_fru_header_detail(char *filename) + (mfg_date[0])); tval = tval * 60; tval = tval + secs_from_1970_1996; - printf("Board Mfg Date: %ld, %s", tval, - asctime(localtime(&tval))); + if(time_in_utc) + strtm = gmtime(&tval); + else + strtm = localtime(&tval); + printf("Board Mfg Date: %ld, %s", tval, asctime(strtm)); board_length -= SIZE_MFG_DATE; /* Board Mfg */ file_offset = ipmi_ek_display_board_info_area( diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c index 6115ae6..429a0f4 100644 --- a/lib/ipmi_fru.c +++ b/lib/ipmi_fru.c @@ -997,6 +997,7 @@ fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru, uint32_t i; time_t tval; uint8_t tmp[2]; + struct tm *strtm; fru_len = 0; @@ -1034,7 +1035,11 @@ fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru, tval=((fru_data[i+2] << 16) + (fru_data[i+1] << 8) + (fru_data[i])); tval=tval * 60; tval=tval + secs_from_1970_1996; - printf(" Board Mfg Date : %s", asctime(localtime(&tval))); + if(time_in_utc) + strtm = gmtime(&tval); + else + strtm = localtime(&tval); + printf(" Board Mfg Date : %s", asctime(strtm)); i += 3; /* skip mfg. date time */ fru_area = get_fru_area_str(fru_data, &i); diff --git a/lib/ipmi_main.c b/lib/ipmi_main.c index 811c80b..273a80a 100644 --- a/lib/ipmi_main.c +++ b/lib/ipmi_main.c @@ -81,7 +81,7 @@ #endif #ifdef ENABLE_ALL_OPTIONS -# define OPTION_STRING "I:46hVvcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:z:S:l:b:B:e:k:y:O:R:N:D:" +# define OPTION_STRING "I:46hVvcgsEKYao:H:d:P:f:U:p:C:L:A:t:T:m:z:S:l:b:B:e:k:y:O:R:N:D:Z" #else # define OPTION_STRING "I:46hVvcH:f:U:p:d:S:D:" #endif @@ -90,8 +90,6 @@ void ipmi_intf_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size); -extern int verbose; -extern int csv_output; extern const struct valstr ipmi_privlvl_vals[]; extern const struct valstr ipmi_authtype_session_vals[]; @@ -263,6 +261,7 @@ ipmi_option_usage(const char * progname, struct ipmi_cmd * cmdlist, struct ipmi_ lprintf(LOG_NOTICE, " -O seloem Use file for OEM SEL event descriptions"); lprintf(LOG_NOTICE, " -N seconds Specify timeout for lan [default=2] / lanplus [default=1] interface"); lprintf(LOG_NOTICE, " -R retry Set the number of retries for lan/lanplus interface [default=4]"); + lprintf(LOG_NOTICE, " -Z Display all dates in UTC"); #endif lprintf(LOG_NOTICE, ""); @@ -763,6 +762,9 @@ ipmi_main(int argc, char ** argv, goto out_free; } break; + case 'Z': + time_in_utc = 1; + break; #endif default: ipmi_option_usage(progname, cmdlist, intflist); diff --git a/lib/ipmi_mc.c b/lib/ipmi_mc.c index 3cbcd40..1875dd8 100644 --- a/lib/ipmi_mc.c +++ b/lib/ipmi_mc.c @@ -531,6 +531,8 @@ ipmi_mc_print_guid(struct ipmi_guid_t guid) char tbuf[40]; time_t s; memset(tbuf, 0, 40); + struct tm *strtm; + /* Kipp - changed order of last field (node) to follow specification */ printf("System GUID : %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x\n", guid.time_low, guid.time_mid, guid.time_hi_and_version, @@ -539,6 +541,10 @@ ipmi_mc_print_guid(struct ipmi_guid_t guid) guid.node[3], guid.node[4], guid.node[5]); s = (time_t)guid.time_low; /* Kipp - removed the BSWAP_32, it was not needed here */ + if(time_in_utc) + strtm = gmtime(&s); + else + strtm = localtime(&s); strftime(tbuf, sizeof(tbuf), "%m/%d/%Y %H:%M:%S", localtime(&s)); printf("Timestamp : %s\n", tbuf); return 0; diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c index 8b0395e..ab4fb76 100644 --- a/lib/ipmi_sel.c +++ b/lib/ipmi_sel.c @@ -51,7 +51,6 @@ #include #include -extern int verbose; static int sel_extended = 0; static int sel_oem_nrecs = 0; @@ -2802,7 +2801,10 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string) gt_hour=tm_tmp->tm_hour; gt_min=tm_tmp->tm_min; memset(&*tm_tmp, 0, sizeof(struct tm)); - tm_tmp=localtime(&t); + if(time_in_utc) + tm_tmp=gmtime(&t); + else + tm_tmp=localtime(&t); lt_year=tm_tmp->tm_year; lt_yday=tm_tmp->tm_yday; lt_hour=tm_tmp->tm_hour; diff --git a/src/ipmievd.c b/src/ipmievd.c index 67788e5..870bc9d 100644 --- a/src/ipmievd.c +++ b/src/ipmievd.c @@ -90,6 +90,7 @@ char pidfile[64]; /* global variables */ int verbose = 0; int csv_output = 0; +int time_in_utc = 0; uint16_t selwatch_count = 0; /* number of entries in the SEL */ uint16_t selwatch_lastid = 0; /* current last entry in the SEL */ int selwatch_pctused = 0; /* current percent usage in the SEL */ diff --git a/src/ipmitool.c b/src/ipmitool.c index 5e19c6e..762c75e 100644 --- a/src/ipmitool.c +++ b/src/ipmitool.c @@ -81,6 +81,7 @@ extern int ipmi_lan6_main(struct ipmi_intf *intf, int argc, char **argv); int csv_output = 0; +int time_in_utc = 0; int verbose = 0; struct ipmi_cmd ipmitool_cmd_list[] = {