]> granicus.if.org Git - sysstat/blob - mpstat.h
mpstat: Add "-o JSON" option
[sysstat] / mpstat.h
1 /*
2  * mpstat: per-processor statistics
3  * (C) 2000-2016 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _MPSTAT_H
7 #define _MPSTAT_H
8
9 /*
10  ***************************************************************************
11  * mpstat's specific system files.
12  ***************************************************************************
13  */
14
15 #define SOFTIRQS        "/proc/softirqs"
16
17 /*
18  ***************************************************************************
19  * Activities definitions.
20  ***************************************************************************
21  */
22
23 #define M_D_CPU         0x0001
24 #define M_D_IRQ_SUM     0x0002
25 #define M_D_IRQ_CPU     0x0004
26 #define M_D_SOFTIRQS    0x0008
27
28 #define DISPLAY_CPU(m)          (((m) & M_D_CPU) == M_D_CPU)
29 #define DISPLAY_IRQ_SUM(m)      (((m) & M_D_IRQ_SUM) == M_D_IRQ_SUM)
30 #define DISPLAY_IRQ_CPU(m)      (((m) & M_D_IRQ_CPU) == M_D_IRQ_CPU)
31 #define DISPLAY_SOFTIRQS(m)     (((m) & M_D_SOFTIRQS) == M_D_SOFTIRQS)
32
33 /*
34  ***************************************************************************
35  * Keywords and constants.
36  ***************************************************************************
37  */
38
39 /* Indicate that option -P has been used */
40 #define F_P_OPTION      0x01
41 /* Indicate that stats should be displayed on for online CPU ("-P ON") */
42 #define F_P_ON          0x02
43 /* JSON output */
44 #define F_JSON_OUTPUT   0x04
45
46 #define USE_P_OPTION(m)         (((m) & F_P_OPTION) == F_P_OPTION)
47 #define DISPLAY_ONLINE_CPU(m)   (((m) & F_P_ON) == F_P_ON)
48 #define DISPLAY_JSON_OUTPUT(m)  (((m) & F_JSON_OUTPUT) == F_JSON_OUTPUT)
49
50 #define K_SUM   "SUM"
51 #define K_CPU   "CPU"
52 #define K_SCPU  "SCPU"
53 #define K_ON    "ON"
54
55 #define NR_IRQCPU_PREALLOC      3
56
57 #define MAX_IRQ_LEN             16
58
59 /*
60  ***************************************************************************
61  * Structures used to store statistics.
62  ***************************************************************************
63  */
64
65 /*
66  * stats_irqcpu->irq_name:  IRQ#-A
67  * stats_irqcpu->interrupt: number of IRQ#-A for proc 0
68  * stats_irqcpu->irq_name:  IRQ#-B
69  * stats_irqcpu->interrupt: number of IRQ#-B for proc 0
70  * ...
71  * stats_irqcpu->irq_name:  (undef'd)
72  * stats_irqcpu->interrupt: number of IRQ#-A for proc 1
73  * stats_irqcpu->irq_name:  (undef'd)
74  * stats_irqcpu->interrupt: number of IRQ#-B for proc 1
75  * ...
76  */
77 struct stats_irqcpu {
78         unsigned int interrupt        __attribute__ ((aligned (4)));
79         char         irq_name[MAX_IRQ_LEN];
80 };
81
82 #define STATS_IRQCPU_SIZE      (sizeof(struct stats_irqcpu))
83
84 #endif