00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __AWHANDLER_PS__
00023 #define __AWHANDLER_PS__
00024
00025 #include <dirent.h>
00026
00027 #include "monitor.h"
00028 #include "wire.h"
00029
00030 #include "regexmatch.h"
00031
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00204 typedef enum {
00205
00206 AW_PSHANDLER_GROUP = 0x1,
00207 AW_PSHANDLER_COUNTONCHANGE = 0x2,
00208
00209 } aw_pshandler_flag_t;
00210
00211
00215 #define AW_PSHANDLER_DEFAULT_FLAGS ( AW_PSHANDLER_GROUP | AW_PSHANDLER_COUNTONCHANGE)
00216
00220 typedef struct aw_pshandler_pidlist_s {
00221
00222 struct aw_pshandler_pidlist_s
00223 *next;
00224
00225 u_int32_t
00226 pid;
00227
00228
00229 float64_t
00230 percentmem;
00231
00232
00233 aw_timestamp_t
00234 totaltime;
00235
00236 } aw_pshandler_pidlist_t;
00237
00241 typedef struct aw_pshandler_watchlist_s {
00242
00243 struct aw_pshandler_watchlist_s
00244 *next;
00245
00246 u_int32_t
00247 pid;
00248
00249 byte_t
00250 *cmdline;
00251
00252 } aw_pshandler_watchlist_t;
00253
00254
00258 typedef struct {
00259
00260 aw_event_sig_t
00261 up,
00262 down,
00263 count;
00264
00265 } aw_pshandler_events_t;
00266
00270 typedef struct {
00271
00272
00273 u_int32_t
00274 memtotal;
00275
00276
00277 DIR
00278 *dir;
00279
00280
00281 aw_pshandler_pidlist_t
00282 *up;
00283
00284 aw_cache_allocator_t
00285 pidlist_factory;
00286
00287
00288 aw_timestamp_t
00289 last_handler_timestamp;
00290
00291 } aw_pshandler_state_t;
00292
00293
00294
00298 typedef struct {
00299
00300 aw_pshandler_flag_t
00301 flags;
00302
00303 aw_pshandler_events_t
00304 events;
00305
00306
00307 const byte_t
00308 *regex;
00309
00310
00311 const byte_t
00312 *subst;
00313
00314 } aw_pshandler_regex_t;
00315
00319 typedef struct {
00320
00321 aw_pshandler_flag_t
00322 flags;
00323
00324 aw_pshandler_events_t
00325 events;
00326
00327
00328 regex_t
00329 pattern;
00330
00331
00332 byte_t
00333 *subst;
00334
00335 aw_pshandler_watchlist_t
00336 *watch;
00337
00338 u_int32_t
00339 watchcount;
00340
00341 } aw_pshandler_watcher_t;
00342
00346 typedef struct {
00347
00348
00349 float64_t
00350 min,max;
00351
00352 aw_event_sig_t
00353 memevent;
00354
00355 } aw_pshandler_memfilter_t;
00356
00357
00361 typedef struct {
00362
00363
00364 float64_t
00365 min,max;
00366
00367 aw_event_sig_t
00368 cpuevent;
00369
00370 } aw_pshandler_cpufilter_t;
00371
00372
00376 typedef struct {
00377
00378 aw_handler_t
00379 handler_header;
00380
00381 u_int32_t
00382 nwatchers;
00383
00384 aw_pshandler_watcher_t
00385 *watchers;
00386
00387 aw_pshandler_memfilter_t
00388 memfilter;
00389
00390 aw_pshandler_cpufilter_t
00391 cpufilter;
00392
00393 aw_pshandler_state_t
00394 state;
00395
00396 } aw_pshandler_t ;
00397
00398
00411 aw_pshandler_t *aw_create_pshandler(u_int32_t nregexs,
00412 aw_pshandler_regex_t *regexs,
00413 aw_pshandler_memfilter_t *memfilter,
00414 aw_pshandler_cpufilter_t *cpufilter,
00415 int32_t (*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00416 int32_t (*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00417 const aw_alarm_sched_t *sched,
00418 aw_logger_t *logger
00419 );
00420
00425 void aw_free_pshandler(aw_pshandler_t *p);
00426
00430 aw_handler_t *aw_wire_pshandler(aw_wire_mkhandler_args_t *args);
00431
00432 #endif
00433