1 |
pajs |
1.1 |
/* |
2 |
|
|
* i-scream central monitoring system |
3 |
|
|
* http://www.i-scream.org.uk |
4 |
|
|
* Copyright (C) 2000-2002 i-scream |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program 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 |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include <sys/types.h> |
22 |
|
|
|
23 |
|
|
typedef struct{ |
24 |
pajs |
1.9 |
long long user; |
25 |
|
|
long long kernel; |
26 |
|
|
long long idle; |
27 |
|
|
long long iowait; |
28 |
|
|
long long swap; |
29 |
|
|
long long nice; |
30 |
|
|
long long total; |
31 |
pajs |
1.1 |
time_t systime; |
32 |
|
|
}cpu_states_t; |
33 |
|
|
|
34 |
|
|
typedef struct{ |
35 |
|
|
float user; |
36 |
|
|
float kernel; |
37 |
|
|
float idle; |
38 |
|
|
float iowait; |
39 |
|
|
float swap; |
40 |
|
|
float nice; |
41 |
|
|
time_t time_taken; |
42 |
|
|
}cpu_percent_t; |
43 |
|
|
|
44 |
|
|
typedef struct{ |
45 |
|
|
long long total; |
46 |
|
|
long long free; |
47 |
|
|
long long used; |
48 |
|
|
long long cache; |
49 |
|
|
}mem_stat_t; |
50 |
|
|
|
51 |
|
|
typedef struct{ |
52 |
|
|
double min1; |
53 |
|
|
double min5; |
54 |
|
|
double min15; |
55 |
|
|
}load_stat_t; |
56 |
|
|
|
57 |
|
|
#ifdef SOLARIS |
58 |
|
|
#define MAX_LOGIN_NAME_SIZE 8 |
59 |
|
|
#endif |
60 |
pajs |
1.12 |
#if defined(LINUX) || defined(FREEBSD) |
61 |
pajs |
1.10 |
#define MAX_LOGIN_NAME_SIZE UT_NAMESIZE |
62 |
|
|
#endif |
63 |
pajs |
1.1 |
|
64 |
|
|
typedef struct{ |
65 |
pajs |
1.8 |
char *name_list; |
66 |
pajs |
1.1 |
int num_entries; |
67 |
|
|
}user_stat_t; |
68 |
|
|
|
69 |
|
|
typedef struct{ |
70 |
|
|
long long total; |
71 |
|
|
long long used; |
72 |
|
|
long long free; |
73 |
|
|
}swap_stat_t; |
74 |
|
|
|
75 |
|
|
typedef struct{ |
76 |
|
|
char *os_name; |
77 |
|
|
char *os_release; |
78 |
|
|
char *os_version; |
79 |
|
|
char *platform; |
80 |
|
|
char *hostname; |
81 |
|
|
time_t uptime; |
82 |
|
|
}general_stat_t; |
83 |
|
|
|
84 |
|
|
typedef struct { |
85 |
|
|
char *device_name; |
86 |
|
|
char *fs_type; |
87 |
|
|
char *mnt_point; |
88 |
|
|
long long size; |
89 |
|
|
long long used; |
90 |
|
|
long long avail; |
91 |
|
|
long long total_inodes; |
92 |
|
|
long long used_inodes; |
93 |
|
|
long long free_inodes; |
94 |
|
|
}disk_stat_t; |
95 |
|
|
|
96 |
|
|
typedef struct{ |
97 |
pajs |
1.4 |
char *disk_name; |
98 |
|
|
long long read_bytes; |
99 |
|
|
long long write_bytes; |
100 |
|
|
time_t systime; |
101 |
|
|
}diskio_stat_t; |
102 |
|
|
|
103 |
|
|
typedef struct{ |
104 |
pajs |
1.1 |
int total; |
105 |
|
|
int running; |
106 |
|
|
int sleeping; |
107 |
|
|
int stopped; |
108 |
|
|
int zombie; |
109 |
|
|
}process_stat_t; |
110 |
|
|
|
111 |
|
|
typedef struct{ |
112 |
|
|
char *interface_name; |
113 |
|
|
long long tx; |
114 |
|
|
long long rx; |
115 |
|
|
time_t systime; |
116 |
|
|
}network_stat_t; |
117 |
|
|
|
118 |
|
|
typedef struct{ |
119 |
pajs |
1.2 |
long long pages_pagein; |
120 |
|
|
long long pages_pageout; |
121 |
pajs |
1.1 |
time_t systime; |
122 |
|
|
}page_stat_t; |
123 |
|
|
|
124 |
|
|
cpu_states_t *get_cpu_totals(); |
125 |
|
|
cpu_states_t *get_cpu_diff(); |
126 |
|
|
cpu_percent_t *cpu_percent_usage(); |
127 |
|
|
|
128 |
|
|
mem_stat_t *get_memory_stats(); |
129 |
|
|
|
130 |
|
|
load_stat_t *get_load_stats(); |
131 |
|
|
|
132 |
|
|
user_stat_t *get_user_stats(); |
133 |
|
|
|
134 |
|
|
swap_stat_t *get_swap_stats(); |
135 |
|
|
|
136 |
|
|
general_stat_t *get_general_stats(); |
137 |
|
|
|
138 |
|
|
disk_stat_t *get_disk_stats(int *entries); |
139 |
pajs |
1.5 |
diskio_stat_t *get_diskio_stats(int *entries); |
140 |
pajs |
1.7 |
diskio_stat_t *get_diskio_stats_diff(int *entries); |
141 |
pajs |
1.1 |
|
142 |
|
|
process_stat_t *get_process_stats(); |
143 |
|
|
|
144 |
|
|
network_stat_t *get_network_stats(int *entries); |
145 |
pajs |
1.4 |
network_stat_t *get_network_stats_diff(int *entries); |
146 |
pajs |
1.2 |
|
147 |
|
|
page_stat_t *get_page_stats(); |
148 |
pajs |
1.3 |
page_stat_t *get_page_stats_diff(); |