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

tcptxthandler.h File Reference


Detailed Description

Many tcp based services use a text based protocol (e.g., ftp, smtp). This handler parameterizes service checks for these simple servers. It will write() a specified text command to the server and regex match the reply, including any banners. Specifying the proper text command and regex can be used as a service check for these tcp based servers. Only 1 text line will be matched, matching indicates success.

Using the triptime: option events with the round trip time will be generated.

This handler is more useful than the vanilla tcphandler in that it can distinguish between failure to connect() and proper server responses. A 'noservice' event indicates that there does exists a running server on that port yet no service is available. This may indicate a misbehaving processes or incorrect program bound to the port.

Regex's are POSIX 1003.2 "extended" form.

Wire keywords (standard handler keywords documented in Wire )

Example:
set noconnect create event { name: "noconnect" priority: 1 } set noservice create event { name: "noservice" priority: 1 }

create handler tcptxt { url: ftp://ftp.mydomain.com cmd: "QUIT\r\n" regexp: "^221" defaultport: 21 noconnect: $noconnect noservice: $noservice timeout: 5 cycletime: 60 }

Events generated:
Event NameTypeDescription
connect AW_EVENT_TYPE_STRING Was able to connect, send string of "url"
noconnect AW_EVENT_TYPE_STRING Was NOT able to connect, send string of "url"
service AW_EVENT_TYPE_STRING Regex match in line of return text indicating success of cmd, send string of "url"
noservice AW_EVENT_TYPE_STRING No regex match in any line of return text indicating NO success, send string of "url"
triptime AW_EVENT_TYPE_INT32 Estimated round trip time in usec

#include <regex.h>
#include "sysnet.h"
#include "monitor.h"
#include "wire.h"

Go to the source code of this file.

Data Structures

struct  aw_tcptxthandler_events_t
 Events generated. More...

struct  aw_tcptxthandler_state_t
 State of handler during probing. More...

struct  aw_tcptxthandler_t
 Handler object. More...


Defines

#define AW_TCPTXTHANDLER_READ_BUFFER_SIZE   4096

Enumerations

enum  aw_tcptxthandler_state_cd_t {
  AW_TCPTXTHANDLER_IDLE, AW_TCPTXTHANDLER_WAIT_CONNECT, AW_TCPTXTHANDLER_WAIT_WRITE, AW_TCPTXTHANDLER_WAIT_READ,
  AW_TCPTXTHANDLER_DONE
}
 The state codes for each state on handler. More...


Functions

aw_tcptxthandler_t * aw_create_tcptxthandler (const aw_tcptxthandler_events_t *events, const byte_t *url, const u_int32_t default_port, const byte_t *cmd, const byte_t *regexp, const aw_timestamp_t timeout, 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 tcptxt handler.

void aw_free_tcptxthandler (aw_tcptxthandler_t *p)
 Free handler and all associated resources.

int32_t aw_init_tcptxthandler (aw_tcptxthandler_t *h, const aw_tcptxthandler_events_t *events, const byte_t *url, const u_int32_t default_port, const byte_t *cmd, const byte_t *regexp, const aw_timestamp_t timeout, 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)
 Init a tcptxt handler.

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

aw_handler_t * aw_wire_tcptxthandler_wrapper (const u_int32_t default_port, const byte_t *cmd, const byte_t *regexp, aw_wire_mkhandler_args_t *args)
 Create a tcptxt handler from a wrapper (e.g., ftp) using "wire". See header doc for keyword documentation.


Define Documentation

#define AW_TCPTXTHANDLER_READ_BUFFER_SIZE   4096
 


Enumeration Type Documentation

enum aw_tcptxthandler_state_cd_t
 

The state codes for each state on handler.

Enumeration values:
AW_TCPTXTHANDLER_IDLE 
AW_TCPTXTHANDLER_WAIT_CONNECT 
AW_TCPTXTHANDLER_WAIT_WRITE 
AW_TCPTXTHANDLER_WAIT_READ 
AW_TCPTXTHANDLER_DONE 


Function Documentation

aw_tcptxthandler_t* aw_create_tcptxthandler (  const aw_tcptxthandler_events_t *  events,
const byte_t *  url,
const u_int32_t  default_port,
const byte_t *  cmd,
const byte_t *  regexp,
const aw_timestamp_t  timeout,
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 tcptxt handler.

aw_create_tcptxthandler

Parameters:
events Events to generate
url Url (gives us host and port)
default_port Port used if none supplied in url
cmd Command to execute
regexp Regex string to match
timeout Max time to run
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_tcptxthandler (  aw_tcptxthandler_t *  p  ) 
 

Free handler and all associated resources.

aw_free_tcptxthandler

Parameters:
p The handler

int32_t aw_init_tcptxthandler (  aw_tcptxthandler_t *  h,
const aw_tcptxthandler_events_t *  events,
const byte_t *  url,
const u_int32_t  default_port,
const byte_t *  cmd,
const byte_t *  regexp,
const aw_timestamp_t  timeout,
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
) 
 

Init a tcptxt handler.

aw_init_tcptxthandler

Parameters:
h Handler
events Events to generate
url Url (gives us host and port)
default_port Port used if none supplied in url
cmd Command to execute
regexp Regex string to match
timeout Max time to run
regevent Function pointer for event registration
regmaskevent Function pointer for event mask registration
sched Run schedule
logger Logger object
Returns:
Non-zero on error

aw_handler_t* aw_wire_tcptxthandler (  aw_wire_mkhandler_args_t *  args  ) 
 

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

aw_wire_tcptxthandler

aw_handler_t* aw_wire_tcptxthandler_wrapper (  const u_int32_t  default_port,
const byte_t *  cmd,
const byte_t *  regexp,
aw_wire_mkhandler_args_t *  args
) 
 

Create a tcptxt handler from a wrapper (e.g., ftp) using "wire". See header doc for keyword documentation.

aw_wire_tcptxthandler_wrapper

Parameters:
default_port Port used if none supplied in url
cmd Command to execute
regexp Regex string to match
args Std wire args

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