Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

pshandler.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "pshandler.h"
#include "fast_merge_sort.h"
#include "sysinfo.h"

Defines

#define LESS_THAN_OR_EQUAL_PID(a, b)   ( (a)->pid <= (b)->pid )
#define MEMINFO_FILE   "/proc/meminfo"
 Method:.


Functions

aw_pshandler_t * aw_create_pshandler (u_int32_t nregexs, aw_pshandler_regex_t *regexs, aw_pshandler_memfilter_t *memfilter, aw_pshandler_cpufilter_t *cpufilter, int32_t(*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index), int32_t(*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index), const aw_alarm_sched_t *sched, aw_logger_t *logger)
 Create a ps handler.

void aw_free_pshandler (aw_pshandler_t *h)
 Free handler and all associated resources.

aw_handler_t * aw_wire_pshandler (aw_wire_mkhandler_args_t *args)
 Create a ps handler using "wire". See header doc for keyword documentation.


Define Documentation

#define LESS_THAN_OR_EQUAL_PID (  a,
b   )     ( (a)->pid <= (b)->pid )
 

#define MEMINFO_FILE   "/proc/meminfo"
 

Method:.

At start, create a sorted list of all pids, these become the 'up' list.

Check for any mem or cpu events

Regex match the 'up' list, remember those that matched and their 'command' in a 'watch' list.

Each poll interval:

  • get an update of the sorted group of all pids, call it 'new up' list

  • compute the set difference of a='up' and b='new up'
    • pid in a && in b -> still up, call this the 'old pid' list
    • pid in a && ! in b -> was up, now down, call this the 'dead pid' list
    • pid ! in a && in b -> new up, call this the 'new pid' list

  • loop thru 'dead pid' list, for every pid in 'watch' list, generate an event, use stored 'command', remove from watch list

  • regex match the 'new pid' list, generate events if regex matches, add to 'watch' list

  • set 'up' to be 'new up'

  • free list elements in 'old pid' and 'dead pid'


Function Documentation

aw_pshandler_t* aw_create_pshandler (  u_int32_t  nregexs,
aw_pshandler_regex_t *  regexs,
aw_pshandler_memfilter_t *  memfilter,
aw_pshandler_cpufilter_t *  cpufilter,
int32_t(*  regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
int32_t(*  regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
const aw_alarm_sched_t *  sched,
aw_logger_t *  logger
) 
 

Create a ps handler.

aw_create_pshandler

Parameters:
nregexs How many regex strings
regexs Array of regex strings
memfilter Filter for those processes with mem in range
cpufilter Filter for those processes with cpu in range
regevent Function pointer for event registration
regmaskevent Function pointer for event mask registration
sched Run schedule
logger Logger object
Returns:
Handler object

void aw_free_pshandler (  aw_pshandler_t *  p  ) 
 

Free handler and all associated resources.

aw_free_pshandler

Parameters:
p The handler

aw_handler_t* aw_wire_pshandler (  aw_wire_mkhandler_args_t *  args  ) 
 

Create a ps handler using "wire". See header doc for keyword documentation.

aw_wire_pshandler

Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)