~ubuntu-branches/ubuntu/vivid/monit/vivid-proposed

« back to all changes in this revision

Viewing changes to libmonit/src/system/NetStatistics.h

  • Committer: Package Import Robot
  • Author(s): Sergey B Kirpichev
  • Date: 2014-12-28 17:32:53 UTC
  • mfrom: (1.1.25)
  • Revision ID: package-import@ubuntu.com-20141228173253-mxmq0pc92jzcyjv2
Tags: 1:5.11-1
* Imported Upstream version 5.11
* Refresh patches
* Comment for rsyslog plugin (Closes: #771322).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) Tildeslash Ltd. All rights reserved.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Affero General Public License version 3.
 
6
 *
 
7
 * This program is distributed in the hope that it will be useful,
 
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
 * GNU Affero General Public License for more details.
 
11
 *
 
12
 * You should have received a copy of the GNU Affero General Public License
 
13
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
14
 *
 
15
 * In addition, as a special exception, the copyright holders give
 
16
 * permission to link the code of portions of this program with the
 
17
 * OpenSSL library under certain conditions as described in each
 
18
 * individual source file, and distribute linked combinations
 
19
 * including the two.
 
20
 *
 
21
 * You must obey the GNU Affero General Public License in all respects
 
22
 * for all of the code used other than OpenSSL.  
 
23
 */
 
24
 
 
25
 
 
26
#ifndef NETSTATISTICS_INCLUDED
 
27
#define NETSTATISTICS_INCLUDED
 
28
 
 
29
 
 
30
/**
 
31
 * Facade for system specific network statistics.
 
32
 *
 
33
 * @author http://www.tildeslash.com/
 
34
 * @see http://www.mmonit.com/
 
35
 * @file
 
36
 */
 
37
 
 
38
 
 
39
#define T NetStatistics_T
 
40
typedef struct T *T;
 
41
 
 
42
 
 
43
/**
 
44
 * Test if network statistics by IP address is supported.
 
45
 * @return true if supported, false if not
 
46
 */
 
47
int NetStatistics_isGetByAddressSupported();
 
48
 
 
49
 
 
50
/**
 
51
 * Get network statistics object for IP address. The object must be destroyed
 
52
 * with NetStatistics_free() if no longer necessary.
 
53
 * @param address IP address (e.g. "127.0.0.1" or "::1")
 
54
 * @return Network statistics object. Use NetStatistics_update() to get the data.
 
55
 */
 
56
T NetStatistics_createForAddress(const char *address);
 
57
 
 
58
 
 
59
/**
 
60
 * Get network statistics object for interface name. The object must be destroyed
 
61
 * with NetStatistics_free() if no longer necessary.
 
62
 * @param interface Network interface name (e.g. "eth0")
 
63
 * @return Network statistics object. Use NetStatistics_update() to get the data.
 
64
 */
 
65
T NetStatistics_createForInterface(const char *interface);
 
66
 
 
67
 
 
68
/**
 
69
 * Destroy a network statistics object and release allocated resources. 
 
70
 * @param S A network statistics object reference
 
71
 */
 
72
void NetStatistics_free(T *S);
 
73
 
 
74
 
 
75
/**
 
76
 * Reset a network statistics object data.
 
77
 * @param S A network statistics object
 
78
 */
 
79
void NetStatistics_reset(T S);
 
80
 
 
81
 
 
82
/**
 
83
 * Update network statistics for object.
 
84
 * @param S A network statistics object
 
85
 * @exception AssertException If statistics cannot be fetched or the address/interface
 
86
 * is invalid.
 
87
 */
 
88
void NetStatistics_update(T S);
 
89
 
 
90
 
 
91
/**
 
92
 * Get incoming bytes per second statistics.
 
93
 * @param S A network statistics object
 
94
 * @return Incoming bytes per second statistics.
 
95
 */
 
96
long long NetStatistics_getBytesInPerSecond(T S);
 
97
 
 
98
 
 
99
/**
 
100
 * Get incoming bytes per minute statistics.
 
101
 * @param S A network statistics object
 
102
 * @param count Number of minutes, the returned statistics will be for range given by 'now - count' (count max = 60m)
 
103
 * @return Incoming bytes per minute statistics.
 
104
 */
 
105
long long NetStatistics_getBytesInPerMinute(T S, int count);
 
106
 
 
107
 
 
108
/**
 
109
 * Get total incoming bytes statistics.
 
110
 * @param S A network statistics object
 
111
 * @return Incoming bytes total.
 
112
 */
 
113
long long NetStatistics_getBytesInTotal(T S);
 
114
 
 
115
 
 
116
/**
 
117
 * Get incoming link saturation.
 
118
 * @param S A network statistics object
 
119
 * @return Incoming link saturation percent or -1 the link has unknown speed.
 
120
 */
 
121
double NetStatistics_getSaturationInPerSecond(T S);
 
122
 
 
123
 
 
124
/**
 
125
 * Get incoming bytes per hour statistics.
 
126
 * @param S A network statistics object
 
127
 * @param count Number of hours, the returned statistics will be for range given by 'now - count' (count max = 24h)
 
128
 * @return Incoming bytes per hour statistics.
 
129
 */
 
130
long long NetStatistics_getBytesInPerHour(T S, int count);
 
131
 
 
132
 
 
133
/**
 
134
 * Get incoming packets per second statistics.
 
135
 * @param S A network statistics object
 
136
 * @return Incoming packets per second statistics.
 
137
 */
 
138
long long NetStatistics_getPacketsInPerSecond(T S);
 
139
 
 
140
 
 
141
/**
 
142
 * Get incoming packets per minute statistics.
 
143
 * @param S A network statistics object
 
144
 * @param count Number of minutes, the returned statistics will be for range given by 'now - count' (count max = 60m)
 
145
 * @return Incoming packets per minute statistics.
 
146
 */
 
147
long long NetStatistics_getPacketsInPerMinute(T S, int count);
 
148
 
 
149
 
 
150
/**
 
151
 * Get incoming packets per hour statistics.
 
152
 * @param S A network statistics object
 
153
 * @param count Number of hours, the returned statistics will be for range given by 'now - count' (count max = 24h)
 
154
 * @return Incoming packets per hour statistics.
 
155
 */
 
156
long long NetStatistics_getPacketsInPerHour(T S, int count);
 
157
 
 
158
 
 
159
/**
 
160
 * Get total incoming packets statistics.
 
161
 * @param S A network statistics object
 
162
 * @return Incoming packets total.
 
163
 */
 
164
long long NetStatistics_getPacketsInTotal(T S);
 
165
 
 
166
 
 
167
/**
 
168
 * Get incoming errors per second statistics.
 
169
 * @param S A network statistics object
 
170
 * @return Incoming errors per second statistics.
 
171
 */
 
172
long long NetStatistics_getErrorsInPerSecond(T S);
 
173
 
 
174
 
 
175
/**
 
176
 * Get incoming errors per minute statistics.
 
177
 * @param S A network statistics object
 
178
 * @param count Number of minutes, the returned statistics will be for range given by 'now - count' (count max = 60m)
 
179
 * @return Incoming errors per minute statistics.
 
180
 */
 
181
long long NetStatistics_getErrorsInPerMinute(T S, int count);
 
182
 
 
183
 
 
184
/**
 
185
 * Get incoming errors per hour statistics.
 
186
 * @param S A network statistics object
 
187
 * @param count Number of hours, the returned statistics will be for range given by 'now - count' (count max = 24h)
 
188
 * @return Incoming errors per hour statistics.
 
189
 */
 
190
long long NetStatistics_getErrorsInPerHour(T S, int count);
 
191
 
 
192
 
 
193
/**
 
194
 * Get total incoming errors statistics.
 
195
 * @param S A network statistics object
 
196
 * @return Incoming errors total.
 
197
 */
 
198
long long NetStatistics_getErrorsInTotal(T S);
 
199
 
 
200
 
 
201
/**
 
202
 * Get outgoing bytes per second statistics.
 
203
 * @param S A network statistics object
 
204
 * @return Outgoing bytes per second statistics.
 
205
 */
 
206
long long NetStatistics_getBytesOutPerSecond(T S);
 
207
 
 
208
 
 
209
/**
 
210
 * Get outgoing bytes per minute statistics.
 
211
 * @param S A network statistics object
 
212
 * @param count Number of minutes, the returned statistics will be for range given by 'now - count' (count max = 60m)
 
213
 * @return Outgoing bytes per minute statistics.
 
214
 */
 
215
long long NetStatistics_getBytesOutPerMinute(T S, int count);
 
216
 
 
217
 
 
218
/**
 
219
 * Get outgoing bytes per hour statistics.
 
220
 * @param S A network statistics object
 
221
 * @param count Number of hours, the returned statistics will be for range given by 'now - count' (count max = 24h)
 
222
 * @return Outgoing bytes per hour statistics.
 
223
 */
 
224
long long NetStatistics_getBytesOutPerHour(T S, int count);
 
225
 
 
226
 
 
227
/**
 
228
 * Get total outgoing bytes statistics.
 
229
 * @param S A network statistics object
 
230
 * @return Outgoing bytes total.
 
231
 */
 
232
long long NetStatistics_getBytesOutTotal(T S);
 
233
 
 
234
 
 
235
/**
 
236
 * Get outgoing link saturation.
 
237
 * @param S A network statistics object
 
238
 * @return Outgoing link saturation percent or -1 the link has unknown speed.
 
239
 */
 
240
double NetStatistics_getSaturationOutPerSecond(T S);
 
241
 
 
242
 
 
243
/**
 
244
 * Get outgoing packets per second statistics.
 
245
 * @param S A network statistics object
 
246
 * @return Outgoing packets per second statistics.
 
247
 */
 
248
long long NetStatistics_getPacketsOutPerSecond(T S);
 
249
 
 
250
 
 
251
/**
 
252
 * Get outgoing packets per minute statistics.
 
253
 * @param S A network statistics object
 
254
 * @param count Number of minutes, the returned statistics will be for range given by 'now - count' (count max = 60m)
 
255
 * @return Outgoing packets per minute statistics.
 
256
 */
 
257
long long NetStatistics_getPacketsOutPerMinute(T S, int count);
 
258
 
 
259
 
 
260
/**
 
261
 * Get outgoing packets per hour statistics.
 
262
 * @param S A network statistics object
 
263
 * @param count Number of hours, the returned statistics will be for range given by 'now - count' (count max = 24h)
 
264
 * @return Outgoing packets per hour statistics.
 
265
 */
 
266
long long NetStatistics_getPacketsOutPerHour(T S, int count);
 
267
 
 
268
 
 
269
/**
 
270
 * Get total outgoing packets statistics.
 
271
 * @param S A network statistics object
 
272
 * @return Outgoing packets total.
 
273
 */
 
274
long long NetStatistics_getPacketsOutTotal(T S);
 
275
 
 
276
 
 
277
/**
 
278
 * Get outgoing errors per second statistics.
 
279
 * @param S A network statistics object
 
280
 * @return Outgoing errors per second.
 
281
 */
 
282
long long NetStatistics_getErrorsOutPerSecond(T S);
 
283
 
 
284
 
 
285
/**
 
286
 * Get outgoing errors per minute statistics.
 
287
 * @param S A network statistics object
 
288
 * @param count Number of minutes, the returned statistics will be for range given by 'now - count' (count max = 60m)
 
289
 * @return Outgoing errors per minute.
 
290
 */
 
291
long long NetStatistics_getErrorsOutPerMinute(T S, int count);
 
292
 
 
293
 
 
294
/**
 
295
 * Get outgoing errors per hour statistics.
 
296
 * @param S A network statistics object
 
297
 * @param count Number of hours, the returned statistics will be for range given by 'now - count' (count max = 24h)
 
298
 * @return Outgoing errors per hour.
 
299
 */
 
300
long long NetStatistics_getErrorsOutPerHour(T S, int count);
 
301
 
 
302
 
 
303
/**
 
304
 * Get total outgoing errors statistics.
 
305
 * @param S A network statistics object
 
306
 * @return Outgoing errors total
 
307
 */
 
308
long long NetStatistics_getErrorsOutTotal(T S);
 
309
 
 
310
 
 
311
/**
 
312
 * Get interface state.
 
313
 * @param S A network statistics object
 
314
 * @return Interface state (0 = down, 1 = up)
 
315
 */
 
316
int NetStatistics_getState(T S);
 
317
 
 
318
 
 
319
/**
 
320
 * Get interface speed (note: not all interface types support speed)
 
321
 * @param S A network statistics object
 
322
 * @return Interface speed [bps] (-1 = N/A)
 
323
 */
 
324
long long NetStatistics_getSpeed(T S);
 
325
 
 
326
 
 
327
/**
 
328
 * Get interface duplex state (note: not all interface types support duplex)
 
329
 * @param S A network statistics object
 
330
 * @return Duplex state (-1 = N/A, 0 = half, 1 = full)
 
331
 */
 
332
int NetStatistics_getDuplex(T S);
 
333
 
 
334
 
 
335
#undef T
 
336
#endif