struct cna_interval_s
{
- time_t interval;
- time_t last_read;
+ cdtime_t interval;
+ cdtime_t last_read;
};
typedef struct cna_interval_s cna_interval_t;
cna_interval_t interval;
na_elem_t *query;
- time_t timestamp;
+ cdtime_t timestamp;
uint64_t name_cache_hit;
uint64_t name_cache_miss;
uint64_t find_dir_hit;
typedef struct disk_s {
char *name;
uint32_t flags;
- time_t timestamp;
+ cdtime_t timestamp;
uint64_t disk_busy;
uint64_t base_for_disk_busy;
double disk_busy_percent;
struct data_volume_perf_s {
char *name;
uint32_t flags;
- time_t timestamp;
+ cdtime_t timestamp;
uint64_t read_bytes;
uint64_t write_bytes;
int port;
char *username;
char *password;
- int interval;
+ cdtime_t interval;
na_server_t *srv;
cfg_wafl_t *cfg_wafl;
const char *plugin_inst,
const char *type, const char *type_inst,
value_t *values, int values_len,
- time_t timestamp, int interval)
+ cdtime_t timestamp, cdtime_t interval)
{
value_list_t vl = VALUE_LIST_INIT;
return (plugin_dispatch_values (&vl));
} /* }}} int submit_uint64 */
-static int submit_two_counters (const char *host, const char *plugin_inst, /* {{{ */
- const char *type, const char *type_inst, counter_t val0, counter_t val1,
- time_t timestamp, int interval)
+static int submit_two_derive (const char *host, const char *plugin_inst, /* {{{ */
+ const char *type, const char *type_inst, derive_t val0, derive_t val1,
+ cdtime_t timestamp, cdtime_t interval)
{
value_t values[2];
- values[0].counter = val0;
- values[1].counter = val1;
+ values[0].derive = val0;
+ values[1].derive = val1;
return (submit_values (host, plugin_inst, type, type_inst,
values, 2, timestamp, interval));
-} /* }}} int submit_two_counters */
+} /* }}} int submit_two_derive */
-static int submit_counter (const char *host, const char *plugin_inst, /* {{{ */
- const char *type, const char *type_inst, counter_t counter, time_t timestamp, int interval)
+static int submit_derive (const char *host, const char *plugin_inst, /* {{{ */
+ const char *type, const char *type_inst, derive_t counter,
+ cdtime_t timestamp, cdtime_t interval)
{
value_t v;
- v.counter = counter;
+ v.derive = counter;
return (submit_values (host, plugin_inst, type, type_inst,
&v, 1, timestamp, interval));
-} /* }}} int submit_counter */
+} /* }}} int submit_derive */
static int submit_two_gauge (const char *host, const char *plugin_inst, /* {{{ */
const char *type, const char *type_inst, gauge_t val0, gauge_t val1,
- time_t timestamp, int interval)
+ cdtime_t timestamp, cdtime_t interval)
{
value_t values[2];
} /* }}} int submit_two_gauge */
static int submit_double (const char *host, const char *plugin_inst, /* {{{ */
- const char *type, const char *type_inst, double d, time_t timestamp, int interval)
+ const char *type, const char *type_inst, double d,
+ cdtime_t timestamp, cdtime_t interval)
{
value_t v;
uint64_t new_misses,
uint64_t old_hits,
uint64_t old_misses,
- time_t timestamp,
- int interval)
+ cdtime_t timestamp,
+ cdtime_t interval)
{
value_t v;
if (HAS_ALL_FLAGS (old_data->flags, CFG_VOLUME_PERF_IO)
&& HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_BYTES_READ | HAVE_VOLUME_PERF_BYTES_WRITE))
{
- submit_two_counters (hostname, plugin_instance, "disk_octets", /* type instance = */ NULL,
- (counter_t) new_data->read_bytes, (counter_t) new_data->write_bytes, new_data->timestamp, interval);
+ submit_two_derive (hostname, plugin_instance, "disk_octets", /* type instance = */ NULL,
+ (derive_t) new_data->read_bytes, (derive_t) new_data->write_bytes, new_data->timestamp, interval);
}
/* Check for and submit disk-operations values */
if (HAS_ALL_FLAGS (old_data->flags, CFG_VOLUME_PERF_OPS)
&& HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE))
{
- submit_two_counters (hostname, plugin_instance, "disk_ops", /* type instance = */ NULL,
- (counter_t) new_data->read_ops, (counter_t) new_data->write_ops, new_data->timestamp, interval);
+ submit_two_derive (hostname, plugin_instance, "disk_ops", /* type instance = */ NULL,
+ (derive_t) new_data->read_ops, (derive_t) new_data->write_ops, new_data->timestamp, interval);
}
/* Check for, calculate and submit disk-latency values */
return (0);
} /* }}} int submit_volume_perf_data */
+static cdtime_t cna_child_get_cdtime (na_elem_t *data) /* {{{ */
+{
+ time_t t;
+
+ t = (time_t) na_child_get_uint64 (data, "timestamp", /* default = */ 0);
+
+ return (TIME_T_TO_CDTIME_T (t));
+} /* }}} cdtime_t cna_child_get_cdtime */
+
+
/*
* Query functions
*
memset (&perf_data, 0, sizeof (perf_data));
- perf_data.timestamp = (time_t) na_child_get_uint64 (data, "timestamp", 0);
+ perf_data.timestamp = cna_child_get_cdtime (data);
instances = na_elem_child(na_elem_child (data, "instances"), "instance-data");
if (instances == NULL)
{
na_elem_t *data;
int status;
- time_t now;
+ cdtime_t now;
if (host == NULL)
return (EINVAL);
if (host->cfg_wafl == NULL)
return (0);
- now = time (NULL);
+ now = cdtime ();
if ((host->cfg_wafl->interval.interval + host->cfg_wafl->interval.last_read) > now)
return (0);
/* Data corresponding to <Disks /> */
static int cna_handle_disk_data (const char *hostname, /* {{{ */
- cfg_disk_t *cfg_disk, na_elem_t *data, int interval)
+ cfg_disk_t *cfg_disk, na_elem_t *data, cdtime_t interval)
{
- time_t timestamp;
+ cdtime_t timestamp;
na_elem_t *instances;
na_elem_t *instance;
na_elem_iter_t instance_iter;
if ((cfg_disk == NULL) || (data == NULL))
return (EINVAL);
- timestamp = (time_t) na_child_get_uint64(data, "timestamp", 0);
+ timestamp = cna_child_get_cdtime (data);
instances = na_elem_child (data, "instances");
if (instances == NULL)
{
na_elem_t *data;
int status;
- time_t now;
+ cdtime_t now;
if (host == NULL)
return (EINVAL);
if (host->cfg_disk == NULL)
return (0);
- now = time (NULL);
+ now = cdtime ();
if ((host->cfg_disk->interval.interval + host->cfg_disk->interval.last_read) > now)
return (0);
/* Data corresponding to <VolumePerf /> */
static int cna_handle_volume_perf_data (const char *hostname, /* {{{ */
- cfg_volume_perf_t *cvp, na_elem_t *data, int interval)
+ cfg_volume_perf_t *cvp, na_elem_t *data, cdtime_t interval)
{
- time_t timestamp;
+ cdtime_t timestamp;
na_elem_t *elem_instances;
na_elem_iter_t iter_instances;
na_elem_t *elem_instance;
- timestamp = (time_t) na_child_get_uint64(data, "timestamp", 0);
+ timestamp = cna_child_get_cdtime (data);
elem_instances = na_elem_child(data, "instances");
if (elem_instances == NULL)
{
na_elem_t *data;
int status;
- time_t now;
+ cdtime_t now;
if (host == NULL)
return (EINVAL);
if (host->cfg_volume_perf == NULL)
return (0);
- now = time (NULL);
+ now = cdtime ();
if ((host->cfg_volume_perf->interval.interval + host->cfg_volume_perf->interval.last_read) > now)
return (0);
notification_t n;
memset (&n, 0, sizeof (&n));
- n.time = time (NULL);
+ n.time = cdtime ();
sstrncpy (n.host, hostname, sizeof (n.host));
sstrncpy (n.plugin, "netapp", sizeof (n.plugin));
sstrncpy (n.plugin_instance, v->name, sizeof (n.plugin_instance));
if (sis == NULL)
continue;
+ if (na_elem_child(sis, "sis-info"))
+ sis = na_elem_child(sis, "sis-info");
+
sis_state = na_child_get_string(sis, "state");
if (sis_state == NULL)
continue;
{
na_elem_t *data;
int status;
- time_t now;
+ cdtime_t now;
if (host == NULL)
return (EINVAL);
if (host->cfg_volume_usage == NULL)
return (0);
- now = time (NULL);
+ now = cdtime ();
if ((host->cfg_volume_usage->interval.interval + host->cfg_volume_usage->interval.last_read) > now)
return (0);
na_elem_t *counter;
na_elem_iter_t counter_iter;
- counter_t disk_read = 0, disk_written = 0;
- counter_t net_recv = 0, net_sent = 0;
- counter_t cpu_busy = 0, cpu_total = 0;
+ derive_t disk_read = 0, disk_written = 0;
+ derive_t net_recv = 0, net_sent = 0;
+ derive_t cpu_busy = 0, cpu_total = 0;
uint32_t counter_flags = 0;
const char *instance;
- time_t timestamp;
+ cdtime_t timestamp;
- timestamp = (time_t) na_child_get_uint64 (data, "timestamp", 0);
+ timestamp = cna_child_get_cdtime (data);
instances = na_elem_child(na_elem_child (data, "instances"), "instance-data");
if (instances == NULL)
continue;
if (!strcmp(name, "disk_data_read")) {
- disk_read = (counter_t) (value * 1024);
+ disk_read = (derive_t) (value * 1024);
counter_flags |= 0x01;
} else if (!strcmp(name, "disk_data_written")) {
- disk_written = (counter_t) (value * 1024);
+ disk_written = (derive_t) (value * 1024);
counter_flags |= 0x02;
} else if (!strcmp(name, "net_data_recv")) {
- net_recv = (counter_t) (value * 1024);
+ net_recv = (derive_t) (value * 1024);
counter_flags |= 0x04;
} else if (!strcmp(name, "net_data_sent")) {
- net_sent = (counter_t) (value * 1024);
+ net_sent = (derive_t) (value * 1024);
counter_flags |= 0x08;
} else if (!strcmp(name, "cpu_busy")) {
- cpu_busy = (counter_t) value;
+ cpu_busy = (derive_t) value;
counter_flags |= 0x10;
} else if (!strcmp(name, "cpu_elapsed_time")) {
- cpu_total = (counter_t) value;
+ cpu_total = (derive_t) value;
counter_flags |= 0x20;
} else if ((cfg_system->flags & CFG_SYSTEM_OPS)
&& (value > 0) && (strlen(name) > 4)
&& (!strcmp(name + strlen(name) - 4, "_ops"))) {
- submit_counter (hostname, instance, "disk_ops_complex", name,
- (counter_t) value, timestamp, interval);
+ submit_derive (hostname, instance, "disk_ops_complex", name,
+ (derive_t) value, timestamp, interval);
}
} /* for (counter) */
if ((cfg_system->flags & CFG_SYSTEM_DISK)
&& (HAS_ALL_FLAGS (counter_flags, 0x01 | 0x02)))
- submit_two_counters (hostname, instance, "disk_octets", NULL,
+ submit_two_derive (hostname, instance, "disk_octets", NULL,
disk_read, disk_written, timestamp, interval);
if ((cfg_system->flags & CFG_SYSTEM_NET)
&& (HAS_ALL_FLAGS (counter_flags, 0x04 | 0x08)))
- submit_two_counters (hostname, instance, "if_octets", NULL,
+ submit_two_derive (hostname, instance, "if_octets", NULL,
net_recv, net_sent, timestamp, interval);
if ((cfg_system->flags & CFG_SYSTEM_CPU)
&& (HAS_ALL_FLAGS (counter_flags, 0x10 | 0x20)))
{
- submit_counter (hostname, instance, "cpu", "system",
+ submit_derive (hostname, instance, "cpu", "system",
cpu_busy, timestamp, interval);
- submit_counter (hostname, instance, "cpu", "idle",
+ submit_derive (hostname, instance, "cpu", "idle",
cpu_total - cpu_busy, timestamp, interval);
}
{
na_elem_t *data;
int status;
- time_t now;
+ cdtime_t now;
if (host == NULL)
return (EINVAL);
if (host->cfg_system == NULL)
return (0);
- now = time (NULL);
+ now = cdtime ();
if ((host->cfg_system->interval.interval + host->cfg_system->interval.last_read) > now)
return (0);
static int cna_config_get_interval (const oconfig_item_t *ci, /* {{{ */
cna_interval_t *out_interval)
{
- time_t tmp;
-
- if ((ci == NULL) || (out_interval == NULL))
- return (EINVAL);
-
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
- {
- WARNING ("netapp plugin: The `Interval' option needs exactly one numeric argument.");
- return (-1);
- }
+ cdtime_t tmp = 0;
+ int status;
- tmp = (time_t) (ci->values[0].value.number + .5);
- if (tmp < 1)
- {
- WARNING ("netapp plugin: The `Interval' option needs a positive integer argument.");
- return (-1);
- }
+ status = cf_util_get_cdtime (ci, &tmp);
+ if (status != 0)
+ return (status);
out_interval->interval = tmp;
out_interval->last_read = 0;
} else if (!strcasecmp(item->key, "Password")) {
status = cf_util_get_string (item, &host->password);
} else if (!strcasecmp(item->key, "Interval")) {
- if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_NUMBER || item->values[0].value.number != (int) item->values[0].value.number || item->values[0].value.number < 2) {
- WARNING("netapp plugin: \"Interval\" of host %s needs exactly one integer argument.", ci->values[0].value.string);
- continue;
- }
- host->interval = item->values[0].value.number;
+ status = cf_util_get_cdtime (item, &host->interval);
} else if (!strcasecmp(item->key, "WAFL")) {
cna_config_wafl(host, item);
} else if (!strcasecmp(item->key, "Disks")) {
ssnprintf (cb_name, sizeof (cb_name), "netapp-%s", host->name);
- memset (&interval, 0, sizeof (interval));
- interval.tv_sec = host->interval;
+ CDTIME_T_TO_TIMESPEC (host->interval, &interval);
memset (&ud, 0, sizeof (ud));
ud.data = host;
ud.free_func = (void (*) (void *)) free_host_config;
- plugin_register_complex_read (cb_name,
+ plugin_register_complex_read (/* group = */ NULL, cb_name,
/* callback = */ cna_read,
/* interval = */ (host->interval > 0) ? &interval : NULL,
/* user data = */ &ud);