libsysactivity  0.6.5
 All Data Structures Functions Variables Enumerations Enumerator Modules
cpu.h
1 /*
2  * libsysactivity
3  * http://sourceforge.net/projects/libsysactivity/
4  * Copyright (c) 2009-2011 Carlos Olmedo Escobar <carlos.olmedo.e@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
25 #ifndef SA_CPU_H_
26 #define SA_CPU_H_
27 
31 struct sa_cpu {
32 #ifdef SA_CPU_ID
33  uint16_t id;
34 #endif
35 #ifdef SA_CPU_USER
36  float user;
37 #endif
38 #ifdef SA_CPU_NICE
39  float nice;
40 #endif
41 #ifdef SA_CPU_SYSTEM
42  float system;
43 #endif
44 #ifdef SA_CPU_IDLE
45  float idle;
46 #endif
47 #ifdef SA_CPU_WAITING_FOR_IO
49 #endif
50 #ifdef SA_CPU_HARDWARE_IRQ
51  float hardware_irq;
52 #endif
53 #ifdef SA_CPU_SOFTWARE_IRQ
54  float software_irq;
55 #endif
56 #ifdef SA_CPU_STOLEN
57  float stolen;
58 #endif
59 #ifdef SA_CPU_INTR
60  float intr;
61 #endif
62 };
63 
64 #ifdef SA_OPEN_CPU
65 
70 int sa_open_cpu(void) SA_EXPORT;
71 #endif
72 
73 #ifdef SA_CLOSE_CPU
74 
79 int sa_close_cpu(void) SA_EXPORT;
80 #endif
81 
87 int sa_reset_cpus() SA_EXPORT;
88 
95 int sa_count_cpus(uint16_t* number) SA_EXPORT SA_NONNULL;
96 
105 int sa_get_cpu(uint16_t index, struct sa_cpu* dst) SA_EXPORT SA_NONNULL;
106 
116 int sa_get_cpus(struct sa_cpu* dst, uint16_t dst_size, uint16_t* written) SA_EXPORT SA_NONNULL;
117 
119 #endif /* SA_CPU_H_ */
int sa_open_cpu(void) SA_EXPORT
float idle
Percentage of time with no activity.
Definition: cpu.h:45
int sa_get_cpu(uint16_t index, struct sa_cpu *dst) SA_EXPORT SA_NONNULL
Retrieves statistics from a given cpu index. This data is an average calculated since last time it wa...
int sa_reset_cpus() SA_EXPORT
float waiting_for_io
Percentage of time spent waiting for io transferences.
Definition: cpu.h:48
float nice
Percentage of time spent on nice prioriced tasks.
Definition: cpu.h:39
int sa_get_cpus(struct sa_cpu *dst, uint16_t dst_size, uint16_t *written) SA_EXPORT SA_NONNULL
Retrieves statistics from as many processors as possible. The data of each cpu is an average calculat...
float hardware_irq
Percentage of time spent working on hardware irqs.
Definition: cpu.h:51
float system
Percentage of time spent on system tasks.
Definition: cpu.h:42
Definition: cpu.h:31
float user
Percentage of time spent on user tasks.
Definition: cpu.h:36
float stolen
Percentage of time spent in other operating systems when running in a virtualized environment...
Definition: cpu.h:57
int sa_close_cpu(void) SA_EXPORT
int sa_count_cpus(uint16_t *number) SA_EXPORT SA_NONNULL
uint16_t id
Cpu identificator. 0 is the first one.
Definition: cpu.h:33
float software_irq
Percentage of time spent working on software irqs.
Definition: cpu.h:54