vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "apache");
- strcpy (vl.plugin_instance, "");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "apache", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
- {
- strncpy (vl.type_instance, type_instance,
+ sstrncpy (vl.type_instance, type_instance,
sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- }
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void submit_counter */
static void submit_gauge (const char *type, const char *type_instance,
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "apache");
- strcpy (vl.plugin_instance, "");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "apache", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
- {
- strncpy (vl.type_instance, type_instance,
+ sstrncpy (vl.type_instance, type_instance,
sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- }
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void submit_counter */
static void submit_scoreboard (char *buf)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "apcups");
- strcpy (vl.plugin_instance, "");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "apcups", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
}
static void apc_submit (struct apc_detail_s *apcups_detail)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "apple_sensors");
- strcpy (vl.plugin_instance, "");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "apple_sensors", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type))
sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
}
static int as_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "battery");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "battery", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void battery_submit */
#if HAVE_IOKIT_PS_IOPOWERSOURCES_H || HAVE_IOKIT_IOKITLIB_H
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "cpu");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "cpu", sizeof (vl.plugin));
- snprintf (vl.plugin_instance, sizeof (vl.type_instance),
+ ssnprintf (vl.plugin_instance, sizeof (vl.type_instance),
"%i", cpu_num);
- strcpy (vl.type, "cpu");
- vl.plugin_instance[DATA_MAX_NAME_LEN - 1] = '\0';
++ sstrncpy (vl.type, "cpu", sizeof (vl.type));
sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values ("cpu", &vl);
+ plugin_dispatch_values (&vl);
}
static int cpu_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "cpufreq");
- strcpy (vl.type, "cpufreq");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "cpufreq", sizeof (vl.plugin));
- snprintf (vl.type_instance, sizeof (vl.type_instance),
++ sstrncpy (vl.type, "cpufreq", sizeof (vl.type));
+ ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%i", cpu_num);
- plugin_dispatch_values ("cpufreq", &vl);
+ plugin_dispatch_values (&vl);
}
static int cpufreq_read (void)
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "df");
- strcpy (vl.plugin_instance, "");
- strcpy (vl.type, "df");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "df", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, df_name, sizeof (vl.type_instance));
++ sstrncpy (vl.type, "df", sizeof (vl.host));
+ sstrncpy (vl.type_instance, df_name, sizeof (vl.type_instance));
- plugin_dispatch_values ("df", &vl);
+ plugin_dispatch_values (&vl);
} /* void df_submit */
static int df_read (void)
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "disk");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, plugin_instance,
+ sstrncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void disk_submit */
#if HAVE_IOKIT_IOKITLIB_H
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "dns");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void submit_counter */
static void submit_octets (counter_t queries, counter_t responses)
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "dns");
- strcpy (vl.type, "dns_octets");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
++ sstrncpy (vl.type, "dns_octets", sizeof (vl.type));
- plugin_dispatch_values ("dns_octets", &vl);
+ plugin_dispatch_values (&vl);
} /* void submit_counter */
static int dns_read (void)
}
addr.sun_family = AF_UNIX;
--
- strncpy (addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
- addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
+ sstrncpy (addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
- unlink (addr.sun_path);
errno = 0;
if (-1 == bind (connector_socket, (struct sockaddr *)&addr,
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "email");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "email", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void email_submit */
/* Copy list l1 to list l2. l2 may partly exist already, but it is assumed
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "entropy");
- strcpy (vl.plugin_instance, "");
- strcpy (vl.type, "entropy");
- strcpy (vl.type_instance, "");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin));
- sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
- sstrncpy (vl.type_instance, "", sizeof (vl.type_instance));
++ sstrncpy (vl.type, "entropy", sizeof (vl.type));
- plugin_dispatch_values ("entropy", &vl);
+ plugin_dispatch_values (&vl);
}
static int entropy_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "hddtemp");
- strcpy (vl.type, "temperature");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "hddtemp", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
++ sstrncpy (vl.type, "temperature", sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values ("temperature", &vl);
+ plugin_dispatch_values (&vl);
}
static int hddtemp_read (void)
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "interface");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "interface", sizeof (vl.plugin));
- strncpy (vl.type_instance, dev, sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, dev, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void if_submit */
static int interface_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "iptables");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "iptables", sizeof (vl.plugin));
- status = snprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
+ status = ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
"%s-%s", chain->table, chain->chain);
if ((status < 1) || ((unsigned int)status >= sizeof (vl.plugin_instance)))
return (0);
else
{
if (chain->rule_type == RTYPE_NUM)
- snprintf (vl.type_instance, sizeof (vl.type_instance),
+ ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%i", chain->rule.num);
else
- strncpy (vl.type_instance, (char *) match->data,
+ sstrncpy (vl.type_instance, (char *) match->data,
sizeof (vl.type_instance));
}
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- strcpy (vl.type, "ipt_bytes");
++ sstrncpy (vl.type, "ipt_bytes", sizeof (vl.type));
values[0].counter = (counter_t) entry->counters.bcnt;
- plugin_dispatch_values ("ipt_bytes", &vl);
+ plugin_dispatch_values (&vl);
- strcpy (vl.type, "ipt_packets");
++ sstrncpy (vl.type, "ipt_packets", sizeof (vl.type));
values[0].counter = (counter_t) entry->counters.pcnt;
- plugin_dispatch_values ("ipt_packets", &vl);
+ plugin_dispatch_values (&vl);
return (0);
} /* void submit_match */
vl.time = time (NULL);
vl.interval = interval_g;
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "ipvs");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "ipvs", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance));
- strcpy (vl.type, "connections");
- sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total", sizeof (vl.type_instance));
++ sstrncpy (vl.type, "connections", sizeof (vl.type));
+ sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total",
+ sizeof (vl.type_instance));
- plugin_dispatch_values ("connections", &vl);
+ plugin_dispatch_values (&vl);
return;
} /* cipvs_submit_connections */
vl.time = time (NULL);
vl.interval = interval_g;
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "ipvs");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "ipvs", sizeof (vl.plugin));
sstrncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance));
- sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total", sizeof (vl.type_instance));
+ sstrncpy (vl.type, t, sizeof (vl.type));
+ sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total",
+ sizeof (vl.type_instance));
- plugin_dispatch_values (t, &vl);
+ plugin_dispatch_values (&vl);
return;
} /* cipvs_submit_if */
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "irq");
- strcpy (vl.type, "irq");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "irq", sizeof (vl.plugin));
++ sstrncpy (vl.type, "irq", sizeof (vl.type));
- status = snprintf (vl.type_instance, sizeof (vl.type_instance),
+ status = ssnprintf (vl.type_instance, sizeof (vl.type_instance),
"%u", irq);
if ((status < 1) || ((unsigned int)status >= sizeof (vl.type_instance)))
return;
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "load");
- strcpy (vl.type, "load");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "load", sizeof (vl.plugin));
++ sstrncpy (vl.type, "load", sizeof (vl.type));
- plugin_dispatch_values ("load", &vl);
+ plugin_dispatch_values (&vl);
}
static int load_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "mbmon");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "mbmon", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void mbmon_submit */
/* Trim trailing whitespace from a string. */
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "memcached");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
- {
- strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- }
+ sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void memcached_submit_cmd */
/* }}} */
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "memcached");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
- {
- strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- }
+ sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void memcached_submit_cmd */
/* }}} */
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "memcached");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
- {
- strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- }
+ sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
}
/* }}} */
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "memcached");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_inst != NULL)
- {
- strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- }
+ sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
}
/* }}} */
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "memory");
- strcpy (vl.type, "memory");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "memory", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
++ sstrncpy (vl.type, "memory", sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values ("memory", &vl);
+ plugin_dispatch_values (&vl);
}
static int memory_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "multimeter");
- strcpy (vl.type, "multimeter");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "multimeter", sizeof (vl.plugin));
++ sstrncpy (vl.type, "multimeter", sizeof (vl.type));
- plugin_dispatch_values ("multimeter", &vl);
+ plugin_dispatch_values (&vl);
}
static int multimeter_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "mysql");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void counter_submit */
static void qcache_submit (counter_t hits, counter_t inserts,
vl.values = values;
vl.values_len = 5;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "mysql");
- strcpy (vl.type, "mysql_qcache");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
++ sstrncpy (vl.type, "mysql_qcache", sizeof (vl.type));
- plugin_dispatch_values ("mysql_qcache", &vl);
+ plugin_dispatch_values (&vl);
} /* void qcache_submit */
static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached,
vl.values = values;
vl.values_len = 4;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "mysql");
- strcpy (vl.type, "mysql_threads");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
++ sstrncpy (vl.type, "mysql_threads", sizeof (vl.type));
- plugin_dispatch_values ("mysql_threads", &vl);
+ plugin_dispatch_values (&vl);
} /* void threads_submit */
static void traffic_submit (counter_t rx, counter_t tx)
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "mysql");
- strcpy (vl.type, "mysql_octets");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin));
++ sstrncpy (vl.type, "mysql_octets", sizeof (vl.type));
- plugin_dispatch_values ("mysql_octets", &vl);
+ plugin_dispatch_values (&vl);
} /* void traffic_submit */
static int mysql_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "netlink");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
+ sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void submit_one */
static void submit_two (const char *dev, const char *type,
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "netlink");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
+ sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void submit_two */
static int link_filter (const struct sockaddr_nl *sa,
vl->plugin_instance,
strlen (vl->plugin_instance)) != 0)
return (-1);
- strcpy (vl_def->plugin_instance, vl->plugin_instance);
+ sstrncpy (vl_def->plugin_instance, vl->plugin_instance, sizeof (vl_def->plugin_instance));
}
- if (strcmp (type_def, ds->type) != 0)
+ if (strcmp (type_def, vl->type) != 0)
{
if (write_part_string (&buffer, &buffer_size, TYPE_TYPE,
- ds->type, strlen (ds->type)) != 0)
+ vl->type, strlen (vl->type)) != 0)
return (-1);
- strcpy (type_def, vl->type);
- sstrncpy (type_def, ds->type, sizeof (type_def));
++ sstrncpy (type_def, vl->type, sizeof (type_def));
}
if (strcmp (vl_def->type_instance, vl->type_instance) != 0)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "nfs");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "nfs", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, plugin_instance,
+ sstrncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
- strcpy (vl.type, "nfs_procedure");
++ sstrncpy (vl.type, "nfs_procedure", sizeof (vl.type));
for (i = 0; i < len; i++)
{
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "nginx");
- strcpy (vl.plugin_instance, "");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "nginx", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (inst != NULL)
- {
- strncpy (vl.type_instance, inst, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
- }
+ sstrncpy (vl.type_instance, inst, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void submit */
static int nginx_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "ntpd");
- strcpy (vl.plugin_instance, "");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "ntpd", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
}
/* returns `tv0 - tv1' in milliseconds or 0 if `tv1 > tv0' */
? hostname_g
: ups->hostname,
sizeof (vl.host));
- strcpy (vl.plugin, "nut");
+ sstrncpy (vl.plugin, "nut", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, ups->upsname, sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.plugin_instance, ups->upsname, sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- vl.host[sizeof (vl.host) - 1] = '\0';
- vl.plugin_instance[sizeof (vl.plugin_instance) - 1] = '\0';
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
-
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void nut_submit */
static int nut_read_one (nut_ups_t *ups)
}
if (NULL != (tmp = hv_fetch (values, "host", 4, 0))) {
- strncpy (list.host, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN);
- list.host[DATA_MAX_NAME_LEN - 1] = '\0';
+ sstrncpy (list.host, SvPV_nolen (*tmp), sizeof (list.host));
}
else {
- strcpy (list.host, hostname_g);
+ sstrncpy (list.host, hostname_g, sizeof (list.host));
}
- if (NULL != (tmp = hv_fetch (values, "plugin", 6, 0))) {
- strncpy (list.plugin, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN);
- list.plugin[DATA_MAX_NAME_LEN - 1] = '\0';
- }
+ if (NULL != (tmp = hv_fetch (values, "plugin", 6, 0)))
+ sstrncpy (list.plugin, SvPV_nolen (*tmp), sizeof (list.plugin));
- if (NULL != (tmp = hv_fetch (values, "plugin_instance", 15, 0))) {
- strncpy (list.plugin_instance, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN);
- list.plugin_instance[DATA_MAX_NAME_LEN - 1] = '\0';
- }
+ if (NULL != (tmp = hv_fetch (values, "plugin_instance", 15, 0)))
+ sstrncpy (list.plugin_instance, SvPV_nolen (*tmp),
+ sizeof (list.plugin_instance));
- if (NULL != (tmp = hv_fetch (values, "type_instance", 13, 0))) {
- strncpy (list.type_instance, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN);
- list.type_instance[DATA_MAX_NAME_LEN - 1] = '\0';
- }
+ if (NULL != (tmp = hv_fetch (values, "type_instance", 13, 0)))
+ sstrncpy (list.type_instance, SvPV_nolen (*tmp),
+ sizeof (list.type_instance));
- ret = plugin_dispatch_values (name, &list);
+ ret = plugin_dispatch_values (&list);
sfree (val);
return ret;
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "ping");
- strcpy (vl.plugin_instance, "");
- strcpy (vl.type, "ping");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "ping", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, host, sizeof (vl.type_instance));
+ sstrncpy (vl.type_instance, host, sizeof (vl.type_instance));
++ sstrncpy (vl.type, "ping", sizeof (vl.type));
- plugin_dispatch_values ("ping", &vl);
+ plugin_dispatch_values (&vl);
}
static int ping_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "processes");
- strcpy (vl.plugin_instance, "");
- strcpy (vl.type, "ps_state");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "processes", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, state, sizeof (vl.type_instance));
++ sstrncpy (vl.type, "ps_state", sizeof (vl.type));
+ sstrncpy (vl.type_instance, state, sizeof (vl.type_instance));
- plugin_dispatch_values ("ps_state", &vl);
+ plugin_dispatch_values (&vl);
}
+/* submit info about specific process (e.g.: memory taken, cpu usage, etc..) */
static void ps_submit_proc_list (procstat_t *ps)
{
value_t values[2];
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "processes");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "processes", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance));
+ sstrncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance));
- strcpy (vl.type, "ps_rss");
++ sstrncpy (vl.type, "ps_rss", sizeof (vl.type));
vl.values[0].gauge = ps->vmem_rss;
vl.values_len = 1;
- plugin_dispatch_values ("ps_rss", &vl);
+ plugin_dispatch_values (&vl);
- strcpy (vl.type, "ps_cputime");
++ sstrncpy (vl.type, "ps_cputime", sizeof (vl.type));
vl.values[0].counter = ps->cpu_user_counter;
vl.values[1].counter = ps->cpu_system_counter;
vl.values_len = 2;
- plugin_dispatch_values ("ps_cputime", &vl);
+ plugin_dispatch_values (&vl);
- strcpy (vl.type, "ps_count");
++ sstrncpy (vl.type, "ps_count", sizeof (vl.type));
vl.values[0].gauge = ps->num_proc;
vl.values[1].gauge = ps->num_lwp;
vl.values_len = 2;
- plugin_dispatch_values ("ps_count", &vl);
+ plugin_dispatch_values (&vl);
- strcpy (vl.type, "ps_pagefaults");
++ sstrncpy (vl.type, "ps_pagefaults", sizeof (vl.type));
vl.values[0].counter = ps->vmem_minflt_counter;
vl.values[1].counter = ps->vmem_majflt_counter;
vl.values_len = 2;
}
if (isnan (d->min))
- strcpy (min, "U");
+ {
+ sstrncpy (min, "U", sizeof (min));
+ }
else
- {
- snprintf (min, sizeof (min), "%lf", d->min);
- min[sizeof (min) - 1] = '\0';
- }
+ ssnprintf (min, sizeof (min), "%lf", d->min);
if (isnan (d->max))
- strcpy (max, "U");
+ {
+ sstrncpy (max, "U", sizeof (max));
+ }
else
- {
- snprintf (max, sizeof (max), "%lf", d->max);
- max[sizeof (max) - 1] = '\0';
- }
+ ssnprintf (max, sizeof (max), "%lf", d->max);
- status = snprintf (buffer, sizeof (buffer),
+ status = ssnprintf (buffer, sizeof (buffer),
"DS:%s:%s:%i:%s:%s",
d->name, type,
(heartbeat > 0) ? heartbeat : (2 * vl->interval),
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "serial");
- strcpy (vl.type, "serial_octets");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "serial", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance,
++ sstrncpy (vl.type, "serial_octets", sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance,
sizeof (vl.type_instance));
- plugin_dispatch_values ("serial_octets", &vl);
+ plugin_dispatch_values (&vl);
}
static int serial_read (void)
return (-1);
}
- strncpy (vl.host, host->name, sizeof (vl.host));
- vl.host[sizeof (vl.host) - 1] = '\0';
+ sstrncpy (vl.host, host->name, sizeof (vl.host));
- strcpy (vl.plugin, "snmp");
+ sstrncpy (vl.plugin, "snmp", sizeof (vl.plugin));
vl.interval = host->interval;
vl.time = time (NULL);
vl.values[i].gauge = NAN;
}
- strncpy (vl.host, host->name, sizeof (vl.host));
- vl.host[sizeof (vl.host) - 1] = '\0';
+ sstrncpy (vl.host, host->name, sizeof (vl.host));
- strcpy (vl.plugin, "snmp");
+ sstrncpy (vl.plugin, "snmp", sizeof (vl.plugin));
- strncpy (vl.type_instance, data->instance.string, sizeof (vl.type_instance));
- vl.type_instance[sizeof (vl.type_instance) - 1] = '\0';
+ sstrncpy (vl.type, data->type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, data->instance.string, sizeof (vl.type_instance));
vl.interval = host->interval;
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "swap");
- strcpy (vl.type, "swap");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "swap", sizeof (vl.plugin));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
++ sstrncpy (vl.type, "swap", sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values ("swap", &vl);
+ plugin_dispatch_values (&vl);
} /* void swap_submit */
static int swap_read (void)
vl.values = values;
vl.values_len = 2;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "tape");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "tape", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, plugin_instance,
+ sstrncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void tape_submit */
static int tape_read (void)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "tcpconns");
- strcpy (vl.type, "tcp_connections");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "tcpconns", sizeof (vl.plugin));
++ sstrncpy (vl.type, "tcp_connections", sizeof (vl.type));
if (((port_collect_listening != 0) && (pe->flags & PORT_IS_LISTENING))
|| (pe->flags & PORT_COLLECT_LOCAL))
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "users");
- strcpy (vl.type, "users");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "users", sizeof (vl.plugin));
++ sstrncpy (vl.type, "users", sizeof (vl.plugin));
- plugin_dispatch_values ("users", &vl);
+ plugin_dispatch_values (&vl);
} /* void users_submit */
static int users_read (void)
return (-1);
}
- strcpy (vl.host, hostname);
- strcpy (vl.plugin, plugin);
+ sstrncpy (vl.host, hostname, sizeof (vl.host));
+ sstrncpy (vl.plugin, plugin, sizeof (vl.plugin));
++ sstrncpy (vl.type, type, sizeof (vl.type));
if (plugin_instance != NULL)
- strcpy (vl.plugin_instance, plugin_instance);
- strcpy (vl.type, type);
+ sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
if (type_instance != NULL)
- strcpy (vl.type_instance, type_instance);
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
ds = plugin_get_ds (type);
if (ds == NULL) {
if (0 != x)
return 0;
if ('\0' == qh.qname[0])
- strcpy(qh.qname, ".");
- strncpy (qh.qname, ".", sizeof (qh.qname));
++ sstrncpy (qh.qname, ".", sizeof (qh.qname));
while ((t = strchr(qh.qname, '\n')))
*t = ' ';
while ((t = strchr(qh.qname, '\r')))
vl.values_len = values_len;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "vmem");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "vmem", sizeof (vl.plugin));
if (plugin_instance != NULL)
sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
if (type_instance != NULL)
sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "vserver");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
- strcpy (vl.type, "if_octets");
++ sstrncpy (vl.type, "if_octets", sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values ("if_octets", &vl);
+ plugin_dispatch_values (&vl);
} /* void traffic_submit */
static void load_submit (const char *plugin_instance,
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "vserver");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+ sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
- strcpy (vl.type, "load");
++ sstrncpy (vl.type, "load", sizeof (vl.type));
- plugin_dispatch_values ("load", &vl);
+ plugin_dispatch_values (&vl);
}
static void submit_gauge (const char *plugin_instance, const char *type,
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "vserver");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
- strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
+ sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void submit_gauge */
static inline long long __get_sock_bytes(const char *s)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "wireless");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "wireless", sizeof (vl.plugin));
- strncpy (vl.plugin_instance, plugin_instance,
+ sstrncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void wireless_submit */
#define POWER_MIN -90.0
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "xmms");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "xmms", sizeof (vl.plugin));
+ sstrncpy (vl.type, type, sizeof (vl.type));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void cxmms_submit */
int cxmms_read (void)