| Mercury Monitor Reference Manual |
|---|
Concentrator APIConcentrator API — Functions for handling several channels or subscribed metrics together |
#include <monitor/concentrator.h> int monp_c10r_lib_init (void); void monp_c10r_lib_done (void); monp_c10r_host; int monp_c10r_host_get (const char *name, mon_addrlist *addr, monp_proto_module *proto, monp_c10r_host **host); int monp_c10r_host_get_url (const char *url, monp_c10r_host **host); void monp_c10r_host_done (monp_c10r_host *host); void monp_c10r_host_ref (monp_c10r_host *host); void monp_c10r_host_set_reconnect (monp_c10r_host *host, unsigned int delay); monp_c10r_metric; enum monp_c10r_flags; enum monp_c10r_metric_state; int (*monp_c10r_metric_cb) (monp_c10r_metric *metric, monp_metric_value *mv, void *user_data, void *measurement_id); enum monp_c10r_event; void (*monp_c10r_metric_notify_cb) (monp_c10r_metric *metric, monp_c10r_event event, void *user_data, void *event_data); monp_c10r_metric* monp_c10r_metric_new (monp_c10r_host *host, mon_auth_creds *creds, const char *name, mon_arg_list *args); monp_c10r_metric* monp_c10r_metric_new_ctrl (monp_c10r_host *host, mon_auth_creds *creds, const char *name, mon_arg_list *args); void monp_c10r_metric_done (monp_c10r_metric *metric); void monp_c10r_metric_ref (monp_c10r_metric *metric); void* monp_c10r_metric_get_aux (monp_c10r_metric *metric); void monp_c10r_metric_set_aux (monp_c10r_metric *metric, void *user_data, GDestroyNotify user_data_done); void monp_c10r_metric_set_cb (monp_c10r_metric *metric, monp_c10r_metric_cb cb); void monp_c10r_metric_set_notify (monp_c10r_metric *metric, monp_c10r_metric_notify_cb cb); void monp_c10r_metric_set_flags (monp_c10r_metric *metric, monp_c10r_flags flags); void monp_c10r_metric_clear_flags (monp_c10r_metric *metric, monp_c10r_flags flags); monp_c10r_flags monp_c10r_metric_get_flags (monp_c10r_metric *metric); monp_c10r_metric_state monp_c10r_metric_get_state (monp_c10r_metric *metric); void monp_c10r_metric_set_restart (monp_c10r_metric *metric, unsigned int delay); const char* monp_c10r_metric_get_name (monp_c10r_metric *metric); const char* monp_c10r_metric_get_hostname (monp_c10r_metric *metric); mon_metric_def* monp_c10r_metric_get_def (monp_c10r_metric *metric); int monp_c10r_metric_get_last_error (monp_c10r_metric *metric); int monp_c10r_metric_start (monp_c10r_metric *metric); int monp_c10r_metric_cmd_get (monp_c10r_metric *metric, void *user_data, GDestroyNotify user_data_done, mon_ctx *ctx); void monp_c10r_metric_cmd_stop (monp_c10r_metric *metric); monp_c10r_get_ctx; enum monp_c10r_get_ctx_flags; monp_c10r_get_ctx* monp_c10r_get_ctx_new (void *user_data, GDestroyNotify user_data_done, mon_ctx *ctx); void monp_c10r_get_ctx_done (monp_c10r_get_ctx *ctx); monp_c10r_handle; enum monp_c10r_hnd_flags; monp_c10r_handle* monp_c10r_handle_get (monp_c10r_host *host, mon_auth_creds *creds); void monp_c10r_handle_add (monp_c10r_handle *hnd, monp_c10r_metric *metric); void monp_c10r_handle_done (monp_c10r_handle *hnd); void monp_c10r_handle_flush (monp_c10r_handle *hnd); int monp_c10r_handle_connect (monp_c10r_handle *hnd); unsigned int monp_c10r_handle_alive (void); monp_c10r_mapping; monp_c10r_cluster; int monp_c10r_cluster_add_host (monp_c10r_cluster *cluster, const char *hname, const char *url); int monp_c10r_cluster_load (monp_c10r_cluster *cluster, const char *filename); void monp_c10r_cluster_done (monp_c10r_cluster *cluster); monp_c10r_cluster* monp_c10r_cluster_get (const char *cluster_name); int monp_c10r_cluster_metric_new (monp_c10r_cluster *cluster, mon_auth_creds *creds, const char *name, mon_arg_list *args, monp_c10r_grp *grp); int monp_c10r_cluster_ctrl_new (monp_c10r_cluster *cluster, mon_auth_creds *creds, const char *name, mon_arg_list *args, monp_c10r_grp *grp); monp_c10r_host* monp_c10r_cluster_map (monp_c10r_cluster *cluster, const char *hostname); monp_c10r_grp; void (*monp_c10r_grp_notify_cb) (monp_c10r_grp *grp, monp_c10r_event event, void *user_data, void *event_data); monp_c10r_grp* monp_c10r_grp_new (void); void monp_c10r_grp_done (monp_c10r_grp *grp); int monp_c10r_grp_add (monp_c10r_grp *grp, monp_c10r_metric *metric); int monp_c10r_grp_del (monp_c10r_grp *grp, monp_c10r_metric *metric); void monp_c10r_grp_start (monp_c10r_grp *grp); void monp_c10r_grp_set_cb (monp_c10r_grp *grp, monp_c10r_metric_cb cb); void monp_c10r_grp_set_aux (monp_c10r_grp *grp, void *user_data, GDestroyNotify user_data_done); void* monp_c10r_grp_get_aux (monp_c10r_grp *grp); void monp_c10r_grp_set_notify (monp_c10r_grp *grp, monp_c10r_grp_notify_cb cb); monp_c10r_flags monp_c10r_grp_get_flags (monp_c10r_grp *grp); void monp_c10r_grp_set_flags (monp_c10r_grp *grp, monp_c10r_flags flags); void monp_c10r_grp_clear_flags (monp_c10r_grp *grp, monp_c10r_flags flags); int monp_c10r_grp_cmd_get (monp_c10r_grp *grp, void *user_data, GDestroyNotify user_data_done, mon_ctx *ctx); void monp_c10r_grp_stop (monp_c10r_grp *grp); unsigned int monp_c10r_grp_get_total (monp_c10r_grp *grp); unsigned int monp_c10r_grp_get_running (monp_c10r_grp *grp); unsigned int monp_c10r_grp_get_failed (monp_c10r_grp *grp); int monp_c10r_grp_get_last_error (monp_c10r_grp *grp);
The concentrator API supports handling several channels or subscribed metrics together. There is support for automatic reconnecting in case of network and/or producer failures.
int monp_c10r_lib_init (void);
Initializes the concentrator library. May be called multiple times.
| Returns : | 0 if successful or an error code. |
void monp_c10r_lib_done (void);
Deallocates resources used by the concentrator library. It must be called as many times as monp_c10r_lib_init() was called.
int monp_c10r_host_get (const char *name,
mon_addrlist *addr,
monp_proto_module *proto,
monp_c10r_host **host);Retrieves a monp_c10r_host structure. If a monp_c10r_host matching the parameters has already esixted, its reference count is incremented and is returned to the caller. Otherwise a new structure is allocated.
| name : | the canonical host name. |
| addr : | the network address(es) of the host. |
| proto : | the protocol to use when connecting to this host. |
| host : | pointer to store the monp_c10r_host if successful. |
| Returns : | 0 if successful or an error code. |
int monp_c10r_host_get_url (const char *url,
monp_c10r_host **host);Retrieves a monp_c10r_host structure based on the URL of the monitoring service.
| url : | the URL of the monitoring service. |
| host : | pointer to store the monp_c10r_host if successful. |
| Returns : | 0 if successful or an error code. |
void monp_c10r_host_done (monp_c10r_host *host);
Decrements the reference count of a monp_c10r_host. If the reference count reaches zero, the structure is deallocated.
| host : | a monp_c10r_host. |
void monp_c10r_host_ref (monp_c10r_host *host);
Increases the reference count of a monp_c10r_host.
| host : | a monp_c10r_host. |
void monp_c10r_host_set_reconnect (monp_c10r_host *host, unsigned int delay);
Set the reconnect delay for a monp_c10r_host.
| host : | a monp_c10r_host. |
| delay : | the new delay before reconnect. |
typedef struct _monp_c10r_metric monp_c10r_metric;
Structure describing a subscribed metric.
typedef enum {
/* Free the metric when it has finished */
MONP_C10R_AUTOFREE = (1 << 0),
/* Automatically restart failed metric */
MONP_C10R_RESTART = (1 << 1),
/* Last COLLECT failed */
MONP_C10R_FAILED_BEFORE = (1 << 2),
/* Response for SUBSCRIBE has been received */
MONP_C10R_SUBSCRIBED = (1 << 3),
/* One-shot metric: used by EXECUTE and QUERY */
MONP_C10R_ONESHOT = (1 << 4),
MONP_C10R_STRICT = (1 << 5),
/* The STARTED notification has been passed down */
MONP_C10R_START_SENT = (1 << 6)
} monp_c10r_flags;
Flags for metrics and groups.
| MONP_C10R_AUTOFREE | automatically deallocate the structure when it is no longer alive. |
| MONP_C10R_RESTART | restart automatically if failed. |
| MONP_C10R_FAILED_BEFORE | set if the last COLLECT command failed. |
| MONP_C10R_SUBSCRIBED | response for the SUBSCRIBE command has been received. |
| MONP_C10R_ONESHOT | the metric has to be destroyed after the first metric value has been received (this is the case with EXECUTE and QUERY). |
| MONP_C10R_STRICT | report success only after all metrics in the group has been started/failed and there were at least one success. |
| MONP_C10R_START_SENT | this flag is set after the MONP_C10R_EVENT_STARTED notification is sent for a monp_c10r_grp. |
typedef enum {
/* COLLECT sent but the response has not been received yet */
MONP_C10R_STATE_COLLECT_SENT,
/* EXECUTE sent but the response has not been received yet */
MONP_C10R_STATE_EXECUTE_SENT,
/* QUERY sent but the response has not been received yet */
MONP_C10R_STATE_QUERY_SENT,
/* Response for COLLECT has been received */
MONP_C10R_STATE_RUNNING,
/* STOP was sent, but response has not been received yet. Metric
* values might still arrive */
MONP_C10R_STATE_STOPPING,
/* STOP was requested before response for COLLECT has been received */
MONP_C10R_STATE_STOPIT,
/* COLLECT failed, will be retried */
MONP_C10R_STATE_RESTARTING,
/* COLLECT failed or STOP finished, no restart */
MONP_C10R_STATE_FINISHED
} monp_c10r_metric_state;
State of a monp_c10r_metric.
| MONP_C10R_STATE_COLLECT_SENT | the COLLECT command has been sent. |
| MONP_C10R_STATE_EXECUTE_SENT | the EXECUTE command has been sent. |
| MONP_C10R_STATE_QUERY_SENT | the QUERY command has been sent. |
| MONP_C10R_STATE_RUNNING | response for COLLECT/EXECUTE has been received. |
| MONP_C10R_STATE_STOPPING | STOP was sent, but the response has not arrived yet. |
| MONP_C10R_STATE_STOPIT | STOP was requested but the response for COLLECT has not arrived yet. |
| MONP_C10R_STATE_RESTARTING | COLLECT failed, will be retried. |
| MONP_C10R_STATE_FINISHED | either STOP has finished or COLLECT has failed and automatic restart was not requested. |
int (*monp_c10r_metric_cb) (monp_c10r_metric *metric, monp_metric_value *mv, void *user_data, void *measurement_id);
Callback function that is called when new data arrives for a monp_c10r_metric.
| metric : | the monp_c10r_metric that generated the data. |
| mv : | the received metric value. |
| user_data : | user data that was set by monp_c10r_metric_set_aux(). |
| measurement_id : | user data that was passed to monp_c10r_metric_cmd_get(). |
| Returns : | 0 if the metric value was processed, MON_CONTINUE otherwise. |
typedef enum {
/* The metric started (COLLECT and SUBSCRIBE finished) */
MONP_C10R_EVENT_STARTED,
/* The metric failed (COLLECT or SUBSCRIBE failed) */
MONP_C10R_EVENT_FAILED,
/* The metric has finished (STOP returned) */
MONP_C10R_EVENT_FINISHED,
/* The metric was killed (either a MID_KILLED message was received
* or the connection broke */
MONP_C10R_EVENT_KILLED,
/* The producer dropped some messages due to resource limit
* constraints */
MONP_C10R_EVENT_DROPPED
} monp_c10r_event;
Metric events used by the notification callbacks.
| MONP_C10R_EVENT_STARTED | the COLLECT and SUBSCRIBE commands have completed successfully. |
| MONP_C10R_EVENT_FAILED | either COLLECT or SUBSCRIBE have failed. |
| MONP_C10R_EVENT_FINISHED | STOP completed. If this event is received, any references to the metric become invalid after the notify callback returns. |
| MONP_C10R_EVENT_KILLED | either the network connection to the producer is broken or a MON_MID_KILLED message is received for this metric. |
| MONP_C10R_EVENT_DROPPED | the producer has reported that metric values were dropped. The event-specific data is a pointer to a uint32_t variable containing the number of messages dropped. |
void (*monp_c10r_metric_notify_cb) (monp_c10r_metric *metric, monp_c10r_event event, void *user_data, void *event_data);
Callback function that is called when an event occurs to a metric.
| metric : | the monp_c10r_metric that generated the event. |
| event : | the monp_c10r_event that has occured |
| user_data : | user data that was set by monp_c10r_metric_set_aux(). |
| event_data : | event-specific data. Currently only MONP_C10R_EVENT_DROPPED uses it. |
monp_c10r_metric* monp_c10r_metric_new (monp_c10r_host *host, mon_auth_creds *creds, const char *name, mon_arg_list *args);
Allocates a new monp_c10r_metric.
| host : | the producer where to collect the metric from. |
| creds : | credentials to use when collecting this metric. |
| name : | the name of the metric. |
| args : | metric arguments. |
| Returns : | a monp_c10r_metric or NULL if an error occured. |
monp_c10r_metric* monp_c10r_metric_new_ctrl (monp_c10r_host *host, mon_auth_creds *creds, const char *name, mon_arg_list *args);
Allocates a new monp_c10r_metric that refers to a control instead of a metric. The allocated monp_c10r_metric works just like a regular metric except that monp_c10r_metric_cmd_get() cannot be used on it. The MONP_C10R_ONESHOT flag is automatically set on the returned metric.
| host : | the producer where to execute the control at. |
| creds : | credentials to use when executing this control. |
| name : | the name of the control. |
| args : | control arguments. |
| Returns : | a monp_c10r_metric or NULL if an error occured. |
void monp_c10r_metric_done (monp_c10r_metric *metric);
Decrements the reference count of a monp_c10r_metric. If the reference count reaches zero, the structure is deallocated.
| metric : | a monp_c10r_metric. |
void monp_c10r_metric_ref (monp_c10r_metric *metric);
Increases the reference count of a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
void* monp_c10r_metric_get_aux (monp_c10r_metric *metric);
Returns the user-private data set by monp_c10r_metric_set_aux().
| metric : | a monp_c10r_metric. |
| Returns : |
void monp_c10r_metric_set_aux (monp_c10r_metric *metric, void *user_data, GDestroyNotify user_data_done);
Sets the user-private data associated with a monp_c10r_metric. user_data will be passed to the metric and the notification callbacks.
| metric : | a monp_c10r_metric. |
| user_data : | opaque user-private data. |
| user_data_done : | destructor for user_data. |
void monp_c10r_metric_set_cb (monp_c10r_metric *metric, monp_c10r_metric_cb cb);
Sets the metric callback function for a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| cb : | the function to call when a new metric value arrives. |
void monp_c10r_metric_set_notify (monp_c10r_metric *metric, monp_c10r_metric_notify_cb cb);
Sets the notification callback function for a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| cb : | function to call when a command related to this metric completes. |
void monp_c10r_metric_set_flags (monp_c10r_metric *metric, monp_c10r_flags flags);
Sets flags for a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| flags : | the flags to set. |
void monp_c10r_metric_clear_flags (monp_c10r_metric *metric, monp_c10r_flags flags);
Clears flags for a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| flags : | the flags to clear. |
monp_c10r_flags monp_c10r_metric_get_flags (monp_c10r_metric *metric);
Returns the current flags of a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| Returns : | the flags that are currently set. |
monp_c10r_metric_state monp_c10r_metric_get_state (monp_c10r_metric *metric);
Returns the state of a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| Returns : | a monp_c10r_metric_state. |
void monp_c10r_metric_set_restart (monp_c10r_metric *metric, unsigned int delay);
Sets the restart delay for a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| delay : | delay before restarting is attempted if the previous COLLECT command had failed. |
const char* monp_c10r_metric_get_name (monp_c10r_metric *metric);
Returns the name of a monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| Returns : | the metric name. |
const char* monp_c10r_metric_get_hostname (monp_c10r_metric *metric);
Returns the host name of the producer where this metric is collected from.
| metric : | a monp_c10r_metric. |
| Returns : | the host name of the producer. |
mon_metric_def* monp_c10r_metric_get_def (monp_c10r_metric *metric);
Returns the definition of a monp_c10r_metric. This function works only if there is a live connection for this metric so it is most useful from metric callback routines.
| metric : | a monp_c10r_metric. |
| Returns : | a mon_metric_def or NULL if the definition is not known. |
int monp_c10r_metric_get_last_error (monp_c10r_metric *metric);
Returns the result of the last failed command that the concentrator library has issued for this monp_c10r_metric.
| metric : | a monp_c10r_metric. |
| Returns : | the result of the last failed command. |
int monp_c10r_metric_start (monp_c10r_metric *metric);
Starts a monp_c10r_metric. If there is currently no alive channel to the producer, a new channel is created. If the metric is not active, a COLLECT command is sent.
| metric : | a monp_c10r_metric. |
| Returns : | 0 if successful or an error code. |
int monp_c10r_metric_cmd_get (monp_c10r_metric *metric, void *user_data, GDestroyNotify user_data_done, mon_ctx *ctx);
Sends a GET command.
| metric : | a monp_c10r_metric. |
| user_data : | user-private data that will be used as the measurement_id argument of the metric callback function when a metric value resulting from this GET command arrives. |
| user_data_done : | destructor for user_data. |
| ctx : | a mon_ctx execution context. |
| Returns : | 0 if successful and ctx was NULL; MON_CONTINUE if successful and ctx was not NULL. All other values mean an error. |
void monp_c10r_metric_cmd_stop (monp_c10r_metric *metric);
Sends a STOP command.
| metric : | a monp_c10r_metric. |
typedef struct _monp_c10r_get_ctx monp_c10r_get_ctx;
Used by the monp_c10r_metric_cmd_get() function to attach internal state to the supplied mon_ctx execution context.
typedef enum {
MONP_C10R_GET_SENT = (1 << 0),
MONP_C10R_GET_READY = (1 << 1),
MONP_C10R_GET_ABORTED = (1 << 2)
} monp_c10r_get_ctx_flags;
Flags for a monp_c10r_get_ctx.
| MONP_C10R_GET_SENT | set if the GET command had been sent. |
| MONP_C10R_GET_READY | set if the response for the GET command had been received. |
| MONP_C10R_GET_ABORTED | set if the mon_ctx context was aborted. |
monp_c10r_get_ctx* monp_c10r_get_ctx_new (void *user_data, GDestroyNotify user_data_done, mon_ctx *ctx);
Allocates a new monp_c10r_get_ctx structure.
| user_data : | user-private data attached to this GET command. |
| user_data_done : | destructor for user_data. |
| ctx : | a mon_ctx. |
| Returns : | a monp_c10r_get_ctx or NULL if out of memory. |
void monp_c10r_get_ctx_done (monp_c10r_get_ctx *ctx);
Decrements the reference count of a monp_c10r_get_ctx. If it reaches zero, the structure is deallocated.
| ctx : | a monp_c10r_get_ctx. |
typedef struct _monp_c10r_handle monp_c10r_handle;
Structure defining a channel to a producer.
typedef enum {
MONP_C10R_HND_RESTART = (1 << 0),
MONP_C10R_HND_AUTH = (1 << 1),
MONP_C10R_HND_READY = (1 << 2)
} monp_c10r_hnd_flags;
Flags for a monp_c10r_handle.
| MONP_C10R_HND_RESTART | the handle is restarted if the network connection fails. |
| MONP_C10R_HND_AUTH | set if the AUTH command had been sent. |
| MONP_C10R_HND_READY | set if the underlying monp_conn is ready to accept commands. |
monp_c10r_handle* monp_c10r_handle_get (monp_c10r_host *host, mon_auth_creds *creds);
Returns a monp_c10r_handle for the given producer. If an appropriate channel already exists, it is reused. Otherwise a new channel is created.
| host : | the producer to connect to. |
| creds : | credentials to use. |
| Returns : | a monp_c10r_handle or NULL in case of an error. |
void monp_c10r_handle_add (monp_c10r_handle *hnd, monp_c10r_metric *metric);
Add a monp_c10r_metric to a monp_c10r_handle. If hnd is not connected, a reconnection will be attempted.
| hnd : | a monp_c10r_handle. |
| metric : | a monp_c10r_metric. |
void monp_c10r_handle_done (monp_c10r_handle *hnd);
Decrements the reference count of a monp_c10r_handle. If it reaches zero, the structure is deallocated.
| hnd : | a monp_c10r_handle. |
void monp_c10r_handle_flush (monp_c10r_handle *hnd);
Tries to flush data in the internal buffers of the handle.
| hnd : | a monp_c10r_handle. |
int monp_c10r_handle_connect (monp_c10r_handle *hnd);
Tries to open a new network connection for an unconnected monp_c10r_handle.
| hnd : | a monp_c10r_handle. |
| Returns : | 0 if successful or an error code. |
unsigned int monp_c10r_handle_alive (void);
Returns the number of alive monp_conn connections governed by the concentrator library.
| Returns : | the number of alive connections. |
typedef struct {
char *hostname;
mon_addrlist *addr;
monp_c10r_host *lm_addr;
} monp_c10r_mapping;
Defines a mapping from host names to producer addresses.
| char *hostname; | a host name. |
| mon_addrlist *addr; | the resolved address(es) of hostname. |
| monp_c10r_host *lm_addr; | the monp_c10r_host to use when requesting metrics about hostname. |
typedef struct {
char *name;
GList *mappings;
int refcnt;
} monp_c10r_cluster;
A group of monp_c10r_mapping definitions.
| char *name; | the name of the cluster. |
| GList *mappings; | list of monp_c10r_mapping elements. |
| int refcnt; | reference count. |
int monp_c10r_cluster_add_host (monp_c10r_cluster *cluster, const char *hname, const char *url);
Adds a new mapping to a cluster.
| cluster : | a monp_c10r_cluster. |
| hname : | |
| url : | the URL of the producer that can provide data about hname. |
| Returns : | 0 if successful or an error code. |
int monp_c10r_cluster_load (monp_c10r_cluster *cluster, const char *filename);
Loads a cluster definition from a file.
| cluster : | a monp_c10r_cluster. |
| filename : | name of the file containing the cluster definition. |
| Returns : | 0 if successful or an error code. |
void monp_c10r_cluster_done (monp_c10r_cluster *cluster);
Decrements the reference count of a monp_c10r_cluster. If it reaches zero, the cluster is deallocated.
| cluster : | a monp_c10r_cluster. |
monp_c10r_cluster* monp_c10r_cluster_get (const char *cluster_name);
Returns a monp_c10r_cluster based on its name.
| cluster_name : | the cluster name. |
| Returns : | the monp_c10r_cluster structure. |
int monp_c10r_cluster_metric_new (monp_c10r_cluster *cluster, mon_auth_creds *creds, const char *name, mon_arg_list *args, monp_c10r_grp *grp);
Creates a monp_c10r_metric for the name metric on every host in the cluster and adds them to grp.
| cluster : | a monp_c10r_cluster. |
| creds : | credentials to use for accessing the metric. |
| name : | the name of the metric. |
| args : | metric arguments. |
| grp : | a monp_c10r_grp that will hold the metrics. |
| Returns : | 0 if successful or an error code. |
int monp_c10r_cluster_ctrl_new (monp_c10r_cluster *cluster, mon_auth_creds *creds, const char *name, mon_arg_list *args, monp_c10r_grp *grp);
Creates a monp_c10r_metric for the name control on every host in the cluster and adds them to grp.
| cluster : | a monp_c10r_cluster. |
| creds : | credentials to use for accessing the control. |
| name : | the name of the control. |
| args : | control arguments. |
| grp : | a monp_c10r_grp that will hold the controls. |
| Returns : | 0 if successful or an error code. |
monp_c10r_host* monp_c10r_cluster_map (monp_c10r_cluster *cluster, const char *hostname);
Maps a hostname to a producer address.
| cluster : | a monp_c10r_cluster. |
| hostname : | a host name. |
| Returns : | a monp_c10r_host or NULL if no mapping for hostname is defined. |
void (*monp_c10r_grp_notify_cb) (monp_c10r_grp *grp, monp_c10r_event event, void *user_data, void *event_data);
Callback function that is called when an event occurs to a metric.
| grp : | the monp_c10r_grp that generated the event. |
| event : | the monp_c10r_event that has occured |
| user_data : | user data that was set by monp_c10r_grp_set_aux(). |
| event_data : | event-specific data. Currently only MONP_C10R_EVENT_DROPPED uses it. |
monp_c10r_grp* monp_c10r_grp_new (void);
Allocates a new monp_c10r_grp.
| Returns : | a new monp_c10r_grp. |
void monp_c10r_grp_done (monp_c10r_grp *grp);
Decrements the reference count of a monp_c10r_grp. If it reaches zero, all pending commands are aborted, all metrics in the group are destroyed and the group is deallocated.
| grp : | a monp_c10r_grp. |
int monp_c10r_grp_add (monp_c10r_grp *grp, monp_c10r_metric *metric);
Adds a monp_c10r_metric to a monp_c10r_grp. The metric may no longer be accessed directly after this function returns successfully.
| grp : | a monp_c10r_grp. |
| metric : | the monp_c10r_metric to add to grp. |
| Returns : | 0 if successful or an error code. |
int monp_c10r_grp_del (monp_c10r_grp *grp, monp_c10r_metric *metric);
Removes a monp_c10r_metric from a monp_c10r_grp.
| grp : | a monp_c10r_grp. |
| metric : | the monp_c10r_metric to remove. |
| Returns : | 0 if successful or an error code. |
void monp_c10r_grp_start (monp_c10r_grp *grp);
Starts all metrics that are part of a monp_c10r_grp.
| grp : | a monp_c10r_grp. |
void monp_c10r_grp_set_cb (monp_c10r_grp *grp, monp_c10r_metric_cb cb);
Sets the metric callback for a monp_c10r_grp.
| grp : | a monp_c10r_grp. |
| cb : | the metric callback. |
void monp_c10r_grp_set_aux (monp_c10r_grp *grp, void *user_data, GDestroyNotify user_data_done);
Sets the user data to be used in arguments of the metric callback and the notify callback.
| grp : | a monp_c10r_grp. |
| user_data : | the user data. |
| user_data_done : | destructor for user_data. |
void* monp_c10r_grp_get_aux (monp_c10r_grp *grp);
Retrieves the user data that was set by monp_c10r_grp_set_aux().
| grp : | a monp_c10r_grp. |
| Returns : |
void monp_c10r_grp_set_notify (monp_c10r_grp *grp, monp_c10r_grp_notify_cb cb);
Sets the notification callback of a monp_c10r_grp.
| grp : | a monp_c10r_grp. |
| cb : | the notification callback. |
monp_c10r_flags monp_c10r_grp_get_flags (monp_c10r_grp *grp);
Returns the flags of a monp_c10r_grp.
| grp : | a monp_c10r_grp. |
| Returns : | the flags that are currently set. |
void monp_c10r_grp_set_flags (monp_c10r_grp *grp, monp_c10r_flags flags);
Sets flags for a monp_c10r_grp.
| grp : | a monp_c10r_grp. |
| flags : | the flags to set. |
void monp_c10r_grp_clear_flags (monp_c10r_grp *grp, monp_c10r_flags flags);
Clears flags of a monp_c10r_grp.
| grp : | a monp_c10r_grp. |
| flags : | the flags to clear. |
int monp_c10r_grp_cmd_get (monp_c10r_grp *grp, void *user_data, GDestroyNotify user_data_done, mon_ctx *ctx);
Sends a GET command to all metrics in the group.
| grp : | a monp_c10r_grp. |
| user_data : | user data to use as the measurement_id argument of the metric callback when data generated by this GET command arrives. |
| user_data_done : | destructor for user_data. |
| ctx : | a mon_ctx to use for asynchronous execution. |
| Returns : | 0 if successful, MON_CONTINUE if asynchronous execution is being used, or an error code. |
void monp_c10r_grp_stop (monp_c10r_grp *grp);
Stops all metrics in the group. If the group has the MONP_C10R_AUTOFREE flag set, it will be deallocated when all metrics has been stopped.
| grp : | a monp_c10r_grp. |
unsigned int monp_c10r_grp_get_total (monp_c10r_grp *grp);
Returns the number of metrics in the group.
| grp : | a monp_c10r_grp. |
| Returns : | the number of metrics. |
unsigned int monp_c10r_grp_get_running (monp_c10r_grp *grp);
Returns the number of running metrics in the group.
| grp : | a monp_c10r_grp. |
| Returns : | the number of running metrics. |
unsigned int monp_c10r_grp_get_failed (monp_c10r_grp *grp);
Returns the number of failed metrics in the group.
| grp : | a monp_c10r_grp. |
| Returns : | the number of failed metrics. |
int monp_c10r_grp_get_last_error (monp_c10r_grp *grp);
Returns the error code for the last failed metric in grp.
| grp : | a monp_c10r_grp. |
| Returns : | the error code for the last failed metric. |
| << Consumer API | Producer API >> |