Add a new option to be used with "sadf -c" (datafile conversion).
This option enables the user to specify the number of ticks per second
for the machine where the datafile to be converted was created.
E.g.:
sadf -c old_datafile -O hz=250 > new_datafile
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
#define K_CUSTOMCOL "customcol"
#define K_BWCOL "bwcol"
#define K_PCPARCHIVE "pcparchive="
+#define K_HZ "hz="
/* Environment variables */
#define ENV_COLORS_PALETTE "S_COLORS_PALETTE"
#endif
extern int endian_mismatch;
+extern unsigned int user_hz;
extern unsigned int act_types_nr[];
extern unsigned int rec_types_nr[];
extern unsigned int hdr_types_nr[];
}
file_hdr->act_size = FILE_ACTIVITY_SIZE;
file_hdr->rec_size = RECORD_HEADER_SIZE;
+
+ /*
+ * Note: @extra_next and @sa_tzname[] members are set to zero
+ * because file_hdr has been memset'd to zero.
+ */
}
/*
goto success;
}
- /* Get HZ */
- get_HZ();
+ if (!user_hz) {
+ /* Get HZ */
+ get_HZ();
+ }
+ else {
+ /* HZ set on the command line with option -O */
+ hz = user_hz;
+ }
fprintf(stderr, _("HZ: Using current value: %lu\n"), HZ);
/* Upgrade file's header section */
unsigned int format = 0; /* Output format */
unsigned int f_position = 0; /* Output format position in array */
unsigned int canvas_height = 0; /* SVG canvas height value set with option -O */
+unsigned int user_hz = 0; /* HZ value set with option -O */
/* File header */
struct file_header file_hdr;
strncpy(pcparchive, v, MAX_FILE_LEN);
pcparchive[MAX_FILE_LEN - 1] = '\0';
}
+ else if (!strncmp(t, K_HZ, strlen(K_HZ))) {
+ v = t + strlen(K_HZ);
+ if (!strlen(v) || (strspn(v, DIGITS) != strlen(v))) {
+ usage(argv[0]);
+ }
+ user_hz = atoi(v);
+ }
else {
usage(argv[0]);
}