if BUILD_IRQTOP
usrbin_exec_PROGRAMS += irqtop
-irqtop_SOURCES = sys-utils/irqtop.c
-irqtop_LDADD = $(LDADD) libcommon.la $(NCURSES_LIBS)
+irqtop_SOURCES = sys-utils/irqtop.c \
+ lib/monotonic.c
+irqtop_LDADD = $(LDADD) libcommon.la $(NCURSES_LIBS) $(REALTIME_LIBS)
irqtop_CFLAGS = $(AM_CFLAGS) $(NCURSES_CFLAGS)
endif
#include "c.h"
#include "closestream.h"
+#include "monotonic.h"
#include "nls.h"
#include "pathnames.h"
#include "ttyutils.h"
get_terminal_dimension(&cols, &rows);
}
-static int uptime(double *uptime_secs, double *idle_secs)
-{
- double up, idle;
- FILE *f;
- char buf[64];
-
- f = fopen(_PATH_PROC_UPTIME, "r");
- if (!f)
- return errno;
-
- if (!fgets(buf, sizeof(buf), f)) {
- fclose(f);
- return errno;
- }
-
- if (sscanf(buf, "%lf %lf", &up, &idle) < 2) {
- fclose(f);
- return errno;
- }
-
- if (uptime_secs)
- *uptime_secs = up;
-
- if (idle_secs)
- *idle_secs = idle;
-
- fclose(f);
- return 0;
-}
-
static void sigint_handler(int unused __attribute__((__unused__)))
{
delay = 0;
int is_tty, o;
unsigned short old_rows;
struct irq_stat *stat, *last_stat = NULL;
- double uptime_secs = 1;
+ struct timeval uptime_tv;
int retval = EXIT_SUCCESS;
static const struct option longopts[] = {
signal(SIGINT, sigint_handler);
smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
- if (uptime(&uptime_secs, NULL))
- errx(EXIT_FAILURE, _("could not read uptime"));
+ gettime_monotonic(&uptime_tv);
do {
struct timeval tv;
for (index = 0; index < stat->nr_irq; index++) {
curr = result + index;
- curr->count /= uptime_secs;
+ curr->count /= uptime_tv.tv_sec;
}
last_stat = stat;
} else {