Skip to content

Commit

Permalink
sadf: PCP: Add support for A_IRQ activity
Browse files Browse the repository at this point in the history
Add metric displayed by "sar -I SUM" (total number of interrupts per
second) to PCP archive.
Individual interrupts are not taken into account.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
  • Loading branch information
sysstat committed Mar 20, 2019
1 parent f7faa58 commit 5ad7cbc
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions activity.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct activity irq_act = {
.f_json_print = json_print_irq_stats,
.f_svg_print = NULL,
.f_raw_print = raw_print_irq_stats,
.f_pcp_print = pcp_print_irq_stats,
.f_count_new = NULL,
.item_list = NULL,
.desc = "Interrupts statistics",
Expand Down
20 changes: 20 additions & 0 deletions pcp_def_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,26 @@ void pcp_def_pcsw_metrics(void)
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for interrupts statistics.
*
* IN:
* @a Activity structure with statistics.
***************************************************************************
*/
void pcp_def_irq_metrics(struct activity *a)
{
#ifdef HAVE_PCP
if (a->bitmap->b_array[0] & 1) {
/* Interrupt "sum" */
pmiAddMetric("kernel.all.intr",
PM_IN_NULL, PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
pmiUnits(0, -1, 1, 0, PM_TIME_SEC, PM_COUNT_ONE));
}
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Define PCP metrics for memory statistics.
Expand Down
1 change: 1 addition & 0 deletions pcp_def_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

void pcp_def_cpu_metrics(struct activity *);
void pcp_def_pcsw_metrics(void);
void pcp_def_irq_metrics(struct activity *);
void pcp_def_memory_metrics(struct activity *);
void pcp_def_queue_metrics(void);

Expand Down
26 changes: 26 additions & 0 deletions pcp_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,32 @@ __print_funct_t pcp_print_pcsw_stats(struct activity *a, int curr, unsigned long
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Display interrupts statistics in PCP format.
*
* IN:
* @a Activity structure with statistics.
* @curr Index in array for current sample statistics.
* @itv Interval of time in 1/100th of a second.
* @record_hdr Record header for current sample.
***************************************************************************
*/
__print_funct_t pcp_print_irq_stats(struct activity *a, int curr, unsigned long long itv,
struct record_header *record_hdr)
{
#ifdef HAVE_PCP
char buf[64];
struct stats_irq
*sic = (struct stats_irq *) a->buf[curr],
*sip = (struct stats_irq *) a->buf[!curr];

snprintf(buf, sizeof(buf), "%f",
S_VALUE(sip->irq_nr, sic->irq_nr, itv));
pmiPutValue("kernel.all.intr", NULL, buf);
#endif /* HAVE_PCP */
}

/*
***************************************************************************
* Display memory statistics in PCP format.
Expand Down
2 changes: 2 additions & 0 deletions pcp_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ __print_funct_t pcp_print_cpu_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_pcsw_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_irq_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_memory_stats
(struct activity *, int, unsigned long long, struct record_header *);
__print_funct_t pcp_print_queue_stats
Expand Down
4 changes: 4 additions & 0 deletions sadf_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ __printf_funct_t print_pcp_statistics(int *tab, int action, struct activity *act
pcp_def_pcsw_metrics();
break;

case A_IRQ:
pcp_def_irq_metrics(act[p]);
break;

case A_MEMORY:
pcp_def_memory_metrics(act[p]);
break;
Expand Down

0 comments on commit 5ad7cbc

Please sign in to comment.