Add an option to display all dates in UTC

Added an option -Z to display all dates in UTC.

Resolves ipmitool/ipmitool#19
Change-Id: Iac3a61190eefde12d95c892af26072ec01f60474
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>

Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
This commit is contained in:
Nagaraju Goruganti 2018-07-17 07:55:21 -05:00 committed by Alexander Amelkin
parent 0310208383
commit 861ffb4680
9 changed files with 37 additions and 9 deletions

View File

@ -67,6 +67,7 @@
#define IPMI_PAYLOAD_TYPE_RAKP_4 0x15 #define IPMI_PAYLOAD_TYPE_RAKP_4 0x15
extern int verbose; extern int verbose;
extern int time_in_utc;
extern int csv_output; extern int csv_output;
struct ipmi_rq { struct ipmi_rq {

View File

@ -704,6 +704,7 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg)
unsigned long timestamp; unsigned long timestamp;
char time_buf[40]; char time_buf[40];
time_t out_time; time_t out_time;
struct tm *strtm;
session_id = ((unsigned long) rsp->data[3]); session_id = ((unsigned long) rsp->data[3]);
session_id |= (((unsigned long) rsp->data[4])<<8); 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); timestamp |= (((unsigned long) rsp->data[10])<<24);
memset(time_buf, 0, 40); memset(time_buf, 0, 40);
if(time_in_utc)
strtm = gmtime(&out_time);
else
strtm = localtime(&out_time);
strftime( strftime(
time_buf, time_buf,
sizeof(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"); printf(" Boot Initiator Info :\n");

View File

@ -2420,6 +2420,7 @@ ipmi_ek_display_fru_header_detail(char *filename)
unsigned char lan_code = 0; unsigned char lan_code = 0;
unsigned char mfg_date[SIZE_MFG_DATE]; unsigned char mfg_date[SIZE_MFG_DATE];
unsigned int board_length = 0; unsigned int board_length = 0;
struct tm *strtm;
input_file = fopen(filename, "r"); input_file = fopen(filename, "r");
if (input_file == NULL) { if (input_file == NULL) {
@ -2546,8 +2547,11 @@ ipmi_ek_display_fru_header_detail(char *filename)
+ (mfg_date[0])); + (mfg_date[0]));
tval = tval * 60; tval = tval * 60;
tval = tval + secs_from_1970_1996; tval = tval + secs_from_1970_1996;
printf("Board Mfg Date: %ld, %s", tval, if(time_in_utc)
asctime(localtime(&tval))); strtm = gmtime(&tval);
else
strtm = localtime(&tval);
printf("Board Mfg Date: %ld, %s", tval, asctime(strtm));
board_length -= SIZE_MFG_DATE; board_length -= SIZE_MFG_DATE;
/* Board Mfg */ /* Board Mfg */
file_offset = ipmi_ek_display_board_info_area( file_offset = ipmi_ek_display_board_info_area(

View File

@ -997,6 +997,7 @@ fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru,
uint32_t i; uint32_t i;
time_t tval; time_t tval;
uint8_t tmp[2]; uint8_t tmp[2];
struct tm *strtm;
fru_len = 0; 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=((fru_data[i+2] << 16) + (fru_data[i+1] << 8) + (fru_data[i]));
tval=tval * 60; tval=tval * 60;
tval=tval + secs_from_1970_1996; 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 */ i += 3; /* skip mfg. date time */
fru_area = get_fru_area_str(fru_data, &i); fru_area = get_fru_area_str(fru_data, &i);

View File

@ -81,7 +81,7 @@
#endif #endif
#ifdef ENABLE_ALL_OPTIONS #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 #else
# define OPTION_STRING "I:46hVvcH:f:U:p:d:S:D:" # define OPTION_STRING "I:46hVvcH:f:U:p:d:S:D:"
#endif #endif
@ -90,8 +90,6 @@
void void
ipmi_intf_set_max_request_data_size(struct ipmi_intf * intf, uint16_t size); 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_privlvl_vals[];
extern const struct valstr ipmi_authtype_session_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, " -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, " -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, " -R retry Set the number of retries for lan/lanplus interface [default=4]");
lprintf(LOG_NOTICE, " -Z Display all dates in UTC");
#endif #endif
lprintf(LOG_NOTICE, ""); lprintf(LOG_NOTICE, "");
@ -763,6 +762,9 @@ ipmi_main(int argc, char ** argv,
goto out_free; goto out_free;
} }
break; break;
case 'Z':
time_in_utc = 1;
break;
#endif #endif
default: default:
ipmi_option_usage(progname, cmdlist, intflist); ipmi_option_usage(progname, cmdlist, intflist);

View File

@ -531,6 +531,8 @@ ipmi_mc_print_guid(struct ipmi_guid_t guid)
char tbuf[40]; char tbuf[40];
time_t s; time_t s;
memset(tbuf, 0, 40); memset(tbuf, 0, 40);
struct tm *strtm;
/* Kipp - changed order of last field (node) to follow specification */ /* Kipp - changed order of last field (node) to follow specification */
printf("System GUID : %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x\n", 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, 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]); 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 */ 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)); strftime(tbuf, sizeof(tbuf), "%m/%d/%Y %H:%M:%S", localtime(&s));
printf("Timestamp : %s\n", tbuf); printf("Timestamp : %s\n", tbuf);
return 0; return 0;

View File

@ -51,7 +51,6 @@
#include <ipmitool/ipmi_sensor.h> #include <ipmitool/ipmi_sensor.h>
#include <ipmitool/ipmi_strings.h> #include <ipmitool/ipmi_strings.h>
extern int verbose;
static int sel_extended = 0; static int sel_extended = 0;
static int sel_oem_nrecs = 0; static int sel_oem_nrecs = 0;
@ -2802,6 +2801,9 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string)
gt_hour=tm_tmp->tm_hour; gt_hour=tm_tmp->tm_hour;
gt_min=tm_tmp->tm_min; gt_min=tm_tmp->tm_min;
memset(&*tm_tmp, 0, sizeof(struct tm)); memset(&*tm_tmp, 0, sizeof(struct tm));
if(time_in_utc)
tm_tmp=gmtime(&t);
else
tm_tmp=localtime(&t); tm_tmp=localtime(&t);
lt_year=tm_tmp->tm_year; lt_year=tm_tmp->tm_year;
lt_yday=tm_tmp->tm_yday; lt_yday=tm_tmp->tm_yday;

View File

@ -90,6 +90,7 @@ char pidfile[64];
/* global variables */ /* global variables */
int verbose = 0; int verbose = 0;
int csv_output = 0; int csv_output = 0;
int time_in_utc = 0;
uint16_t selwatch_count = 0; /* number of entries in the SEL */ uint16_t selwatch_count = 0; /* number of entries in the SEL */
uint16_t selwatch_lastid = 0; /* current last entry in the SEL */ uint16_t selwatch_lastid = 0; /* current last entry in the SEL */
int selwatch_pctused = 0; /* current percent usage in the SEL */ int selwatch_pctused = 0; /* current percent usage in the SEL */

View File

@ -81,6 +81,7 @@ extern int ipmi_lan6_main(struct ipmi_intf *intf, int argc, char **argv);
int csv_output = 0; int csv_output = 0;
int time_in_utc = 0;
int verbose = 0; int verbose = 0;
struct ipmi_cmd ipmitool_cmd_list[] = { struct ipmi_cmd ipmitool_cmd_list[] = {