Update files included in source files.
Update Makefile to be consistent with files dependencies.
Move also some code from common.c to rd_stats.c.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
all: sadc sar sadf iostat tapestat mpstat pidstat cifsiostat locales
-common.o: common.c version.h common.h ioconf.h sysconfig.h
+common.o: common.c version.h common.h
-sa_common.o: sa_common.c sa.h common.h ioconf.h sysconfig.h rd_stats.h
+sa_common.o: sa_common.c version.h sa.h common.h rd_stats.h rd_sensors.h ioconf.h sysconfig.h
ioconf.o: ioconf.c ioconf.h common.h sysconfig.h
-act_sadc.o: activity.c sa.h rd_stats.h rd_sensors.h
+act_sadc.o: activity.c sa.h common.h rd_stats.h rd_sensors.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SADC $(DFLAGS) $<
-act_sar.o: activity.c sa.h rd_stats.h rd_sensors.h pr_stats.h
+act_sar.o: activity.c sa.h common.h rd_stats.h rd_sensors.h pr_stats.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SAR $(DFLAGS) $<
-act_sadf.o: activity.c sa.h rd_stats.h rd_sensors.h rndr_stats.h xml_stats.h json_stats.h svg_stats.h raw_stats.h
+act_sadf.o: activity.c sa.h common.h rd_stats.h rd_sensors.h rndr_stats.h xml_stats.h json_stats.h svg_stats.h raw_stats.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SADF $(DFLAGS) $<
-rd_stats.o: rd_stats.c common.h rd_stats.h ioconf.h sysconfig.h
+rd_stats.o: rd_stats.c common.h rd_stats.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SADC $(DFLAGS) $<
rd_stats_light.o: rd_stats.c common.h rd_stats.h ioconf.h sysconfig.h
count_light.o: count.c common.h rd_stats.h
$(CC) -o $@ -c $(CFLAGS) $(DFLAGS) $<
-rd_sensors.o: rd_sensors.c common.h rd_sensors.h rd_stats.h sysconfig.h
+rd_sensors.o: rd_sensors.c common.h rd_sensors.h rd_stats.h
-pr_stats.o: pr_stats.c sa.h ioconf.h sysconfig.h pr_stats.h
+pr_stats.o: pr_stats.c sa.h common.h rd_stats.h rd_sensors.h ioconf.h sysconfig.h pr_stats.h
-rndr_stats.o: rndr_stats.c sa.h ioconf.h sysconfig.h rndr_stats.h
+rndr_stats.o: rndr_stats.c sa.h common.h rd_stats.h rd_sensors.h ioconf.h sysconfig.h rndr_stats.h
-xml_stats.o: xml_stats.c sa.h sadf.h ioconf.h sysconfig.h xml_stats.h
+xml_stats.o: xml_stats.c sa.h common.h rd_stats.h rd_sensors.h ioconf.h sysconfig.h xml_stats.h
-json_stats.o: json_stats.c sa.h sadf.h ioconf.h sysconfig.h json_stats.h
+json_stats.o: json_stats.c sa.h common.h rd_stats.h rd_sensors.h ioconf.h sysconfig.h json_stats.h
-svg_stats.o: svg_stats.c sa.h sadf.h ioconf.h sysconfig.h svg_stats.h
+svg_stats.o: svg_stats.c sa.h common.h rd_stats.h rd_sensors.h ioconf.h sysconfig.h svg_stats.h
-raw_stats.o: raw_stats.c sa.h sadf.h ioconf.h sysconfig.h raw_stats.h
+raw_stats.o: raw_stats.c sa.h common.h rd_stats.h rd_sensors.h ioconf.h sysconfig.h raw_stats.h
-sa_wrap.o: sa_wrap.c sa.h rd_stats.h count.h rd_sensors.h
+sa_wrap.o: sa_wrap.c sa.h common.h rd_stats.h count.h rd_sensors.h
+ $(CC) -o $@ -c $(CFLAGS) -DSOURCE_SADC $(DFLAGS) $<
-format_sadf.o: format.c sadf.h
+format_sadf.o: format.c sadf.h sa.h common.h rd_stats.h rd_sensors.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SADF $(DFLAGS) $<
-format_sar.o: format.c sa.h
+format_sar.o: format.c sa.h common.h rd_stats.h rd_sensors.h
$(CC) -o $@ -c $(CFLAGS) -DSOURCE_SAR $(DFLAGS) $<
-sadf_misc.o: sadf_misc.c sadf.h sa.h
+sadf_misc.o: sadf_misc.c sadf.h sa.h common.h rd_stats.h rd_sensors.h
-sa_conv.o: sa_conv.c sadf.h sa.h sa_conv.h
+sa_conv.o: sa_conv.c version.h sadf.h sa.h common.h rd_stats.h rd_sensors.h sa_conv.h
# Explicit rules needed to prevent possible file corruption
# when using parallel execution.
librdsensors.a: rd_sensors.o
$(AR) rvs $@ $?
-sadc.o: sadc.c sa.h version.h common.h ioconf.h sysconfig.h rd_stats.h rd_sensors.h
+sadc.o: sadc.c sa.h version.h common.h rd_stats.h rd_sensors.h
sadc: LFLAGS += $(LFSENSORS)
sadc: sadc.o act_sadc.o sa_wrap.o sa_common.o librdstats.a librdsensors.a libsyscom.a
-sar.o: sar.c sa.h version.h common.h ioconf.h pr_stats.h sysconfig.h
+sar.o: sar.c sa.h version.h common.h rd_stats.h rd_sensors.h
-sar: sar.o act_sar.o format_sar.o sa_common.o pr_stats.o libsyscom.a
+sar: sar.o act_sar.o format_sar.o sa_common.o pr_stats.o librdstats_light.a libsyscom.a
-sadf.o: sadf.c sadf.h version.h sa.h common.h ioconf.h sysconfig.h
+sadf.o: sadf.c sadf.h version.h sa.h common.h rd_stats.h rd_sensors.h
-sadf: sadf.o act_sadf.o format_sadf.o sadf_misc.o sa_conv.o rndr_stats.o xml_stats.o json_stats.o svg_stats.o raw_stats.o sa_common.o libsyscom.a
+sadf: sadf.o act_sadf.o format_sadf.o sadf_misc.o sa_conv.o rndr_stats.o xml_stats.o json_stats.o svg_stats.o raw_stats.o sa_common.o librdstats_light.a libsyscom.a
iostat.o: iostat.c iostat.h version.h common.h ioconf.h sysconfig.h rd_stats.h count.h
iostat: iostat.o librdstats_light.a libsyscom.a
-tapestat.o: tapestat.c tapestat.h version.h common.h count.h
+tapestat.o: tapestat.c tapestat.h version.h common.h count.h rd_stats.h
tapestat: tapestat.o librdstats_light.a libsyscom.a
mpstat: mpstat.o librdstats_light.a libsyscom.a
-cifsiostat.o: cifsiostat.c cifsiostat.h count.h version.h common.h
+cifsiostat.o: cifsiostat.c cifsiostat.h count.h rd_stats.h version.h common.h
cifsiostat: cifsiostat.o librdstats_light.a libsyscom.a
#include "sa.h"
-#include "rd_stats.h"
-#include "rd_sensors.h"
-
#ifdef SOURCE_SAR
#include "pr_stats.h"
#endif
#include "version.h"
#include "cifsiostat.h"
+#include "rd_stats.h"
#include "count.h"
-#include "common.h"
#ifdef USE_NLS
#include <locale.h>
#include "version.h"
#include "common.h"
-#include "ioconf.h"
-#include "rd_stats.h"
#ifdef USE_NLS
#include <locale.h>
return itv;
}
-/*
- ***************************************************************************
- * Since ticks may vary slightly from CPU to CPU, we'll want
- * to recalculate itv based on this CPU's tick count, rather
- * than that reported by the "cpu" line. Otherwise we
- * occasionally end up with slightly skewed figures, with
- * the skew being greater as the time interval grows shorter.
- *
- * IN:
- * @scc Current sample statistics for current CPU.
- * @scp Previous sample statistics for current CPU.
- *
- * RETURNS:
- * Interval of time based on current CPU, expressed in jiffies.
- ***************************************************************************
- */
-unsigned long long get_per_cpu_interval(struct stats_cpu *scc,
- struct stats_cpu *scp)
-{
- unsigned long long ishift = 0LL;
-
- if ((scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest)) {
- /*
- * Sometimes the nr of jiffies spent in guest mode given by the guest
- * counter in /proc/stat is slightly higher than that included in
- * the user counter. Update the interval value accordingly.
- */
- ishift += (scp->cpu_user - scp->cpu_guest) -
- (scc->cpu_user - scc->cpu_guest);
- }
- if ((scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice)) {
- /*
- * Idem for nr of jiffies spent in guest_nice mode.
- */
- ishift += (scp->cpu_nice - scp->cpu_guest_nice) -
- (scc->cpu_nice - scc->cpu_guest_nice);
- }
-
- /*
- * Workaround for CPU coming back online: With recent kernels
- * some fields (user, nice, system) restart from their previous value,
- * whereas others (idle, iowait) restart from zero.
- * For the latter we need to set their previous value to zero to
- * avoid getting an interval value < 0.
- * (I don't know how the other fields like hardirq, steal... behave).
- * Don't assume the CPU has come back from offline state if previous
- * value was greater than ULLONG_MAX & 0x80000 (the counter probably
- * overflew).
- */
- if ((scc->cpu_idle < scp->cpu_idle) && (scp->cpu_idle < (ULLONG_MAX & 0x80000))) {
- scp->cpu_idle = 0;
- }
- if ((scc->cpu_iowait < scp->cpu_iowait) && (scp->cpu_iowait < (ULLONG_MAX & 0x80000))) {
- scp->cpu_iowait = 0;
- }
-
- /*
- * Don't take cpu_guest and cpu_guest_nice into account
- * because cpu_user and cpu_nice already include them.
- */
- return ((scc->cpu_user + scc->cpu_nice +
- scc->cpu_sys + scc->cpu_iowait +
- scc->cpu_idle + scc->cpu_steal +
- scc->cpu_hardirq + scc->cpu_softirq) -
- (scp->cpu_user + scp->cpu_nice +
- scp->cpu_sys + scp->cpu_iowait +
- scp->cpu_idle + scp->cpu_steal +
- scp->cpu_hardirq + scp->cpu_softirq) +
- ishift);
-}
-
/*
***************************************************************************
* Unhandled situation: Panic and exit. Should never happen.
return nr;
}
-/*
- ***************************************************************************
- * Compute "extended" device statistics (service time, etc.).
- *
- * IN:
- * @sdc Structure with current device statistics.
- * @sdp Structure with previous device statistics.
- * @itv Interval of time in 1/100th of a second.
- *
- * OUT:
- * @xds Structure with extended statistics.
- ***************************************************************************
-*/
-void compute_ext_disk_stats(struct stats_disk *sdc, struct stats_disk *sdp,
- unsigned long long itv, struct ext_disk_stats *xds)
-{
- double tput
- = ((double) (sdc->nr_ios - sdp->nr_ios)) * 100 / itv;
-
- xds->util = S_VALUE(sdp->tot_ticks, sdc->tot_ticks, itv);
- xds->svctm = tput ? xds->util / tput : 0.0;
- /*
- * Kernel gives ticks already in milliseconds for all platforms
- * => no need for further scaling.
- */
- xds->await = (sdc->nr_ios - sdp->nr_ios) ?
- ((sdc->rd_ticks - sdp->rd_ticks) + (sdc->wr_ticks - sdp->wr_ticks)) /
- ((double) (sdc->nr_ios - sdp->nr_ios)) : 0.0;
- xds->arqsz = (sdc->nr_ios - sdp->nr_ios) ?
- ((sdc->rd_sect - sdp->rd_sect) + (sdc->wr_sect - sdp->wr_sect)) /
- ((double) (sdc->nr_ios - sdp->nr_ios)) : 0.0;
-}
-
/*
***************************************************************************
* Convert in-place input string to lowercase.
#include <sys/sysmacros.h>
#endif
-#include "rd_stats.h"
-
/*
***************************************************************************
* Various keywords and constants
***************************************************************************
*/
-void compute_ext_disk_stats
- (struct stats_disk *, struct stats_disk *, unsigned long long,
- struct ext_disk_stats *);
int count_bits
(void *, int);
int count_csvalues
(struct tm *, int);
time_t get_time
(struct tm *, int);
-unsigned long long get_per_cpu_interval
- (struct stats_cpu *, struct stats_cpu *);
char *get_persistent_name_from_pretty
(char *);
char *get_persistent_type_dir
#include "version.h"
#include "iostat.h"
-#include "common.h"
#include "ioconf.h"
#include "rd_stats.h"
#include "count.h"
#include <stdarg.h>
#include "sa.h"
-#include "sadf.h"
#include "ioconf.h"
#include "json_stats.h"
#include <string.h>
#include "common.h"
+#include "rd_stats.h"
#include "rd_sensors.h"
#ifdef USE_NLS
#ifndef _RD_SENSORS_H
#define _RD_SENSORS_H
-#include "common.h"
-#include "rd_stats.h"
-
/*
***************************************************************************
* Definitions of structures for sensors statistics
#include "common.h"
#include "rd_stats.h"
-#include "ioconf.h"
#ifdef USE_NLS
#include <locale.h>
}
}
+/*
+ ***************************************************************************
+ * Compute "extended" device statistics (service time, etc.).
+ *
+ * IN:
+ * @sdc Structure with current device statistics.
+ * @sdp Structure with previous device statistics.
+ * @itv Interval of time in 1/100th of a second.
+ *
+ * OUT:
+ * @xds Structure with extended statistics.
+ ***************************************************************************
+*/
+void compute_ext_disk_stats(struct stats_disk *sdc, struct stats_disk *sdp,
+ unsigned long long itv, struct ext_disk_stats *xds)
+{
+ double tput
+ = ((double) (sdc->nr_ios - sdp->nr_ios)) * 100 / itv;
+
+ xds->util = S_VALUE(sdp->tot_ticks, sdc->tot_ticks, itv);
+ xds->svctm = tput ? xds->util / tput : 0.0;
+ /*
+ * Kernel gives ticks already in milliseconds for all platforms
+ * => no need for further scaling.
+ */
+ xds->await = (sdc->nr_ios - sdp->nr_ios) ?
+ ((sdc->rd_ticks - sdp->rd_ticks) + (sdc->wr_ticks - sdp->wr_ticks)) /
+ ((double) (sdc->nr_ios - sdp->nr_ios)) : 0.0;
+ xds->arqsz = (sdc->nr_ios - sdp->nr_ios) ?
+ ((sdc->rd_sect - sdp->rd_sect) + (sdc->wr_sect - sdp->wr_sect)) /
+ ((double) (sdc->nr_ios - sdp->nr_ios)) : 0.0;
+}
+
+/*
+ ***************************************************************************
+ * Since ticks may vary slightly from CPU to CPU, we'll want
+ * to recalculate itv based on this CPU's tick count, rather
+ * than that reported by the "cpu" line. Otherwise we
+ * occasionally end up with slightly skewed figures, with
+ * the skew being greater as the time interval grows shorter.
+ *
+ * IN:
+ * @scc Current sample statistics for current CPU.
+ * @scp Previous sample statistics for current CPU.
+ *
+ * RETURNS:
+ * Interval of time based on current CPU, expressed in jiffies.
+ ***************************************************************************
+ */
+unsigned long long get_per_cpu_interval(struct stats_cpu *scc,
+ struct stats_cpu *scp)
+{
+ unsigned long long ishift = 0LL;
+
+ if ((scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest)) {
+ /*
+ * Sometimes the nr of jiffies spent in guest mode given by the guest
+ * counter in /proc/stat is slightly higher than that included in
+ * the user counter. Update the interval value accordingly.
+ */
+ ishift += (scp->cpu_user - scp->cpu_guest) -
+ (scc->cpu_user - scc->cpu_guest);
+ }
+ if ((scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice)) {
+ /*
+ * Idem for nr of jiffies spent in guest_nice mode.
+ */
+ ishift += (scp->cpu_nice - scp->cpu_guest_nice) -
+ (scc->cpu_nice - scc->cpu_guest_nice);
+ }
+
+ /*
+ * Workaround for CPU coming back online: With recent kernels
+ * some fields (user, nice, system) restart from their previous value,
+ * whereas others (idle, iowait) restart from zero.
+ * For the latter we need to set their previous value to zero to
+ * avoid getting an interval value < 0.
+ * (I don't know how the other fields like hardirq, steal... behave).
+ * Don't assume the CPU has come back from offline state if previous
+ * value was greater than ULLONG_MAX & 0x80000 (the counter probably
+ * overflew).
+ */
+ if ((scc->cpu_idle < scp->cpu_idle) && (scp->cpu_idle < (ULLONG_MAX & 0x80000))) {
+ scp->cpu_idle = 0;
+ }
+ if ((scc->cpu_iowait < scp->cpu_iowait) && (scp->cpu_iowait < (ULLONG_MAX & 0x80000))) {
+ scp->cpu_iowait = 0;
+ }
+
+ /*
+ * Don't take cpu_guest and cpu_guest_nice into account
+ * because cpu_user and cpu_nice already include them.
+ */
+ return ((scc->cpu_user + scc->cpu_nice +
+ scc->cpu_sys + scc->cpu_iowait +
+ scc->cpu_idle + scc->cpu_steal +
+ scc->cpu_hardirq + scc->cpu_softirq) -
+ (scp->cpu_user + scp->cpu_nice +
+ scp->cpu_sys + scp->cpu_iowait +
+ scp->cpu_idle + scp->cpu_steal +
+ scp->cpu_hardirq + scp->cpu_softirq) +
+ ishift);
+}
+
#ifdef SOURCE_SADC
/*---------------- BEGIN: FUNCTIONS USED BY SADC ONLY ---------------------*/
***************************************************************************
*/
-void oct2chr
- (char *);
+void compute_ext_disk_stats
+ (struct stats_disk *, struct stats_disk *, unsigned long long,
+ struct ext_disk_stats *);
+unsigned long long get_per_cpu_interval
+ (struct stats_cpu *, struct stats_cpu *);
__nr_t read_stat_cpu
(struct stats_cpu *, __nr_t);
__nr_t read_stat_irq
(struct stats_memory *);
void read_uptime
(unsigned long long *);
+#ifdef SOURCE_SADC
+void oct2chr
+ (char *);
__nr_t read_stat_pcsw
(struct stats_pcsw *);
__nr_t read_loadavg
(struct stats_fchost *, __nr_t);
__nr_t read_softnet
(struct stats_softnet *, __nr_t);
+#endif /* SOURCE_SADC */
#endif /* _RD_STATS_H */
#include "version.h"
#include "sa.h"
-#include "common.h"
#include "ioconf.h"
-#include "rd_stats.h"
#ifdef USE_NLS
#include <locale.h>
#include "version.h"
#include "sadf.h"
-#include "sa.h"
#include "sa_conv.h"
#ifdef USE_NLS
#include <string.h>
#include "sa.h"
-#include "rd_stats.h"
#include "count.h"
-#include "rd_sensors.h"
extern unsigned int flags;
extern struct record_header record_hdr;
#include "version.h"
#include "sa.h"
-#include "rd_stats.h"
-#include "common.h"
-#include "ioconf.h"
#ifdef USE_NLS
#include <locale.h>
#include "version.h"
#include "sadf.h"
-#include "sa.h"
-#include "common.h"
-#include "ioconf.h"
# include <locale.h> /* For setlocale() */
#ifdef USE_NLS
#include <string.h>
#include "sadf.h"
-#include "sa.h"
#ifdef USE_NLS
#include <locale.h>
#include "version.h"
#include "sa.h"
-#include "common.h"
-#include "ioconf.h"
-#include "pr_stats.h"
#ifdef USE_NLS
#include <locale.h>
#include <float.h>
#include "sa.h"
-#include "sadf.h"
#include "ioconf.h"
#include "svg_stats.h"
#include "version.h"
#include "tapestat.h"
#include "common.h"
+#include "rd_stats.h"
#include "count.h"
#ifdef USE_NLS
#include <stdarg.h>
#include "sa.h"
-#include "sadf.h"
#include "ioconf.h"
#include "xml_stats.h"