pmon.h File Reference

Process monitoring client/server communication APIs. More...


Defines

#define PMON_CONTEXT_INVALID   ((junos_pmon_context_t) NULL)
 Invalid context handle.
#define PMON_BACKEND_LOCAL   "local"
 Local backend.
#define PMON_BACKEND_NULL   "null"
 Null backend (just returns success).
#define PMON_BACKEND_UNIX_DOMAIN   "unix domain"
 Unix domain sockets backend.
#define PMON_HEARTBEAT_MIN   2
 Minimum interval timer setting (2 seconds).
#define PMON_HEARTBEAT_MAX   900
 Maximum interval timer setting (15 minutes).
#define PMON_HEARTBEAT_DEFAULT   10
 Default internal timer setting (10 seconds).
#define PMON_HEARTBEAT_GRACE_MIN   1
 Minimum setting for number of consecutive missed heartbeats.
#define PMON_HEARTBEAT_GRACE_MAX   64
 Maximum setting for number of consecutive missed heartbeats.
#define PMON_HEARTBEAT_GRACE_DEFAULT   3
 Default setting for number of consecutive missed heartbeats.
#define PATH_PMON_HEARTBEAT_UNIX_DOMAIN   "/var/run/pmond_hb"
 Path of the unix domain socket used by the "unix domain" backend.

Typedefs

typedef void * junos_pmon_context_t
 Process monitoring context.
typedef junos_pmon_client_s junos_pmon_client_t
 Process monitor client.
typedef int(* junos_pmon_heartbeat_callback_t )(junos_pmon_context_t ctx, const junos_pmon_client_t *client)
 Callback function to call when a heartbeat update is received.

Functions

junos_pmon_context_t junos_pmon_create_context (void)
 Create a process monitor context.
int junos_pmon_accept (junos_pmon_context_t ctx, const junos_pmon_client_t **client_p)
 Accept a heartbeat update from a client.
int junos_pmon_destroy_context (junos_pmon_context_t *ctx_p)
 Destroy a process monitor context.
int junos_pmon_get_client_address (junos_pmon_context_t ctx, const junos_pmon_client_t *client, struct sockaddr *sa, socklen_t *len_p)
 Get the address of the process monitor client.
int junos_pmon_get_client_heartbeat_grace_period (junos_pmon_context_t ctx, const junos_pmon_client_t *client, int *grace_p)
 Get the heartbeat grace period for the process monitor client.
int junos_pmon_get_client_heartbeat_interval (junos_pmon_context_t ctx, const junos_pmon_client_t *client, struct timespec *interval)
 Get the heartbeat interval time for the process monitor client.
int junos_pmon_get_client_pid (junos_pmon_context_t ctx, const junos_pmon_client_t *client, pid_t *pid_p)
 Get the process ID of the process monitor client.
int junos_pmon_heartbeat (junos_pmon_context_t ctx, struct timespec *interval, int grace)
 Set up an interval heartbeat.
int junos_pmon_heartbeat_pulse (junos_pmon_context_t ctx)
 Pulse a heartbeat update to the process monitor server.
int junos_pmon_listen (junos_pmon_context_t ctx, junos_pmon_heartbeat_callback_t cb)
 Listen for heartbeat updates using the selected backend.
int junos_pmon_select_backend (junos_pmon_context_t ctx, const char *name, void *args)
 Select a specific backend to use.
int junos_pmon_set_event_context (junos_pmon_context_t ctx, evContext ev_ctx)
 Set the event context to use for operations.


Detailed Description

Process monitoring client/server communication APIs.


Function Documentation

int junos_pmon_accept junos_pmon_context_t  ctx,
const junos_pmon_client_t **  client_p
 

Accept a heartbeat update from a client.

This function will block until it receives a heartbeat update from a process monitor client.

Parameters:
[in] ctx Handle of process monitor context
[in,out] client_p Pointer to client structure to return for the accepted heartbeat
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument
Note:
The selected backend may return additional status codes.

junos_pmon_context_t junos_pmon_create_context void   ) 
 

Create a process monitor context.

Returns:
Handle of process monitor context; PMON_CONTEXT_INVALID if unable to create context
See also:
junos_pmon_destroy_context

int junos_pmon_destroy_context junos_pmon_context_t ctx_p  ) 
 

Destroy a process monitor context.

Any pending operations are flushed, communications channels to the process monitor server are closed, any memory used is freed, and the handle in ctx_p is invalidated.

Parameters:
[in] ctx_p Pointer to process monitor context
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument
See also:
junos_pmon_create_context

int junos_pmon_get_client_address junos_pmon_context_t  ctx,
const junos_pmon_client_t client,
struct sockaddr *  sa,
socklen_t *  len_p
 

Get the address of the process monitor client.

Parameters:
[in] ctx Handle of process monitor context
[in] client Pointer to client structure
[out] sa Pointer to socket address structure
[in,out] len_p Length of socket address structure
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument

int junos_pmon_get_client_heartbeat_grace_period junos_pmon_context_t  ctx,
const junos_pmon_client_t client,
int *  grace_p
 

Get the heartbeat grace period for the process monitor client.

Parameters:
[in] ctx Handle of process monitor context
[in] client Pointer to client structure
[out] grace_p Pointer to location to store heartbeat grace period
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument

int junos_pmon_get_client_heartbeat_interval junos_pmon_context_t  ctx,
const junos_pmon_client_t client,
struct timespec *  interval
 

Get the heartbeat interval time for the process monitor client.

Parameters:
[in] ctx Handle of process monitor context
[in] client Pointer to client structure
[out] interval Pointer to time specification for heartbeat interval
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument

int junos_pmon_get_client_pid junos_pmon_context_t  ctx,
const junos_pmon_client_t client,
pid_t *  pid_p
 

Get the process ID of the process monitor client.

Parameters:
[in] ctx Handle of process monitor context
[in] client Pointer to client structure
[out] pid_p Pointer to location to store the process ID
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument

int junos_pmon_heartbeat junos_pmon_context_t  ctx,
struct timespec *  interval,
int  grace
 

Set up an interval heartbeat.

If an event context has not been registered, only interval time and grace period specifics will be relayed to the process monitoring server. Otherwise, an interval timer is set up to pulse the heartbeat at the specified interval.

Parameters:
[in] ctx Handle of process monitor context
[in] interval Pointer to interval to use for heartbeat timer If NULL or the tv_sec and tv_nsec values are set to 0, a default interval time of PMON_HEARTBEAT_DEFAULT seconds will be used.
[in] grace Grace period (number of consecutive missed heartbeats allowed) If zero, the default grace period specified in PMON_HEARTBEAT_GRACE_DEFAULT will be used.
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument
Note:
The selected backend may return additional status codes.
See also:
junos_pmon_set_event_context

int junos_pmon_heartbeat_pulse junos_pmon_context_t  ctx  ) 
 

Pulse a heartbeat update to the process monitor server.

Parameters:
[in] ctx Handle of process monitor context
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument
Note:
The selected backend may return additional status codes.

int junos_pmon_listen junos_pmon_context_t  ctx,
junos_pmon_heartbeat_callback_t  cb
 

Listen for heartbeat updates using the selected backend.

Note:
An event context must have already been set on the context.
Parameters:
[in] ctx Handle of process monitor context
[in] cb Callback function to call when a heartbeat update is received
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EINVAL invalid argument
Note:
The selected backend may return additional status codes.
See also:
junos_pmon_set_event_context

int junos_pmon_select_backend junos_pmon_context_t  ctx,
const char *  name,
void *  args
 

Select a specific backend to use.

Any backend-specific intialization is passed on to the backend via the selection arguments in args.

Parameters:
[in] ctx Handle of process monitor context
[in] name Name of backend to use
[in] args Pointer to backend-specific selection arguments
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EEXIST backend has already been selected
  • EFAULT backend structure has an invalid size (internal error)
  • ENOENT unable to locate a backend with the specified name
  • ENOMEM out of memory
Note:
The specific backend may return other status codes

int junos_pmon_set_event_context junos_pmon_context_t  ctx,
evContext  ev_ctx
 

Set the event context to use for operations.

Parameters:
[in] ctx Handle to process monitor context
[in] ev_ctx Event context
Returns:
0 on success; -1 on error On error, errno will be set to one of the following status codes:
  • EEXIST an event context has already been set
  • EINVAL invalid argument
See also:
junos_pmon_heartbeat junos_pmon_listen


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:24:03 2010 for libpmon by Doxygen 1.4.5