1 |
pajs |
1.1 |
/* |
2 |
|
|
* i-scream central monitoring system |
3 |
tdb |
1.13 |
* http://www.i-scream.org |
4 |
|
|
* Copyright (C) 2000-2003 i-scream |
5 |
pajs |
1.1 |
* |
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 |
ats |
1.15 |
#ifdef NETBSD |
23 |
|
|
#include <limits.h> |
24 |
|
|
#endif |
25 |
tdb |
1.16 |
#ifdef CYGWIN |
26 |
|
|
#include <sys/unistd.h> |
27 |
|
|
#endif |
28 |
pajs |
1.1 |
|
29 |
|
|
typedef struct{ |
30 |
pajs |
1.9 |
long long user; |
31 |
|
|
long long kernel; |
32 |
|
|
long long idle; |
33 |
|
|
long long iowait; |
34 |
|
|
long long swap; |
35 |
|
|
long long nice; |
36 |
|
|
long long total; |
37 |
pajs |
1.1 |
time_t systime; |
38 |
|
|
}cpu_states_t; |
39 |
|
|
|
40 |
|
|
typedef struct{ |
41 |
|
|
float user; |
42 |
|
|
float kernel; |
43 |
|
|
float idle; |
44 |
|
|
float iowait; |
45 |
|
|
float swap; |
46 |
|
|
float nice; |
47 |
|
|
time_t time_taken; |
48 |
|
|
}cpu_percent_t; |
49 |
|
|
|
50 |
|
|
typedef struct{ |
51 |
|
|
long long total; |
52 |
|
|
long long free; |
53 |
|
|
long long used; |
54 |
|
|
long long cache; |
55 |
|
|
}mem_stat_t; |
56 |
|
|
|
57 |
|
|
typedef struct{ |
58 |
|
|
double min1; |
59 |
|
|
double min5; |
60 |
|
|
double min15; |
61 |
|
|
}load_stat_t; |
62 |
|
|
|
63 |
|
|
typedef struct{ |
64 |
pajs |
1.8 |
char *name_list; |
65 |
pajs |
1.1 |
int num_entries; |
66 |
|
|
}user_stat_t; |
67 |
|
|
|
68 |
|
|
typedef struct{ |
69 |
|
|
long long total; |
70 |
|
|
long long used; |
71 |
|
|
long long free; |
72 |
|
|
}swap_stat_t; |
73 |
|
|
|
74 |
|
|
typedef struct{ |
75 |
|
|
char *os_name; |
76 |
|
|
char *os_release; |
77 |
|
|
char *os_version; |
78 |
|
|
char *platform; |
79 |
|
|
char *hostname; |
80 |
|
|
time_t uptime; |
81 |
|
|
}general_stat_t; |
82 |
|
|
|
83 |
|
|
typedef struct { |
84 |
|
|
char *device_name; |
85 |
|
|
char *fs_type; |
86 |
|
|
char *mnt_point; |
87 |
|
|
long long size; |
88 |
|
|
long long used; |
89 |
|
|
long long avail; |
90 |
|
|
long long total_inodes; |
91 |
|
|
long long used_inodes; |
92 |
|
|
long long free_inodes; |
93 |
|
|
}disk_stat_t; |
94 |
|
|
|
95 |
|
|
typedef struct{ |
96 |
pajs |
1.4 |
char *disk_name; |
97 |
|
|
long long read_bytes; |
98 |
|
|
long long write_bytes; |
99 |
|
|
time_t systime; |
100 |
|
|
}diskio_stat_t; |
101 |
|
|
|
102 |
|
|
typedef struct{ |
103 |
pajs |
1.1 |
int total; |
104 |
|
|
int running; |
105 |
|
|
int sleeping; |
106 |
|
|
int stopped; |
107 |
|
|
int zombie; |
108 |
|
|
}process_stat_t; |
109 |
|
|
|
110 |
|
|
typedef struct{ |
111 |
|
|
char *interface_name; |
112 |
|
|
long long tx; |
113 |
|
|
long long rx; |
114 |
|
|
time_t systime; |
115 |
|
|
}network_stat_t; |
116 |
|
|
|
117 |
|
|
typedef struct{ |
118 |
pajs |
1.2 |
long long pages_pagein; |
119 |
|
|
long long pages_pageout; |
120 |
pajs |
1.1 |
time_t systime; |
121 |
|
|
}page_stat_t; |
122 |
|
|
|
123 |
|
|
cpu_states_t *get_cpu_totals(); |
124 |
|
|
cpu_states_t *get_cpu_diff(); |
125 |
|
|
cpu_percent_t *cpu_percent_usage(); |
126 |
|
|
|
127 |
|
|
mem_stat_t *get_memory_stats(); |
128 |
|
|
|
129 |
|
|
load_stat_t *get_load_stats(); |
130 |
|
|
|
131 |
|
|
user_stat_t *get_user_stats(); |
132 |
|
|
|
133 |
|
|
swap_stat_t *get_swap_stats(); |
134 |
|
|
|
135 |
|
|
general_stat_t *get_general_stats(); |
136 |
|
|
|
137 |
|
|
disk_stat_t *get_disk_stats(int *entries); |
138 |
pajs |
1.5 |
diskio_stat_t *get_diskio_stats(int *entries); |
139 |
pajs |
1.7 |
diskio_stat_t *get_diskio_stats_diff(int *entries); |
140 |
pajs |
1.1 |
|
141 |
|
|
process_stat_t *get_process_stats(); |
142 |
|
|
|
143 |
|
|
network_stat_t *get_network_stats(int *entries); |
144 |
pajs |
1.4 |
network_stat_t *get_network_stats_diff(int *entries); |
145 |
pajs |
1.2 |
|
146 |
|
|
page_stat_t *get_page_stats(); |
147 |
pajs |
1.3 |
page_stat_t *get_page_stats_diff(); |
148 |
pajs |
1.14 |
|
149 |
|
|
int statgrab_init(void); |
150 |
ats |
1.18 |
int statgrab_drop_privileges(void); |
151 |
|
|
|