status = getaddrinfo(node, service, &ai_hints, &ai_return);
if (status != 0) {
- char errbuf[1024];
INFO("apcups plugin: getaddrinfo failed: %s",
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return -1;
}
if (status != 0) /* `connect(2)' failed */
{
- char errbuf[1024];
- INFO("apcups plugin: connect failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ INFO("apcups plugin: connect failed: %s", STRERRNO);
close(sd);
return -1;
}
int status = apc_query_server(conf_node, conf_service, &apcups_detail);
if (status != 0) {
- DEBUG("apcups plugin: apc_query_server (\"%s\", \"%s\") = %d",
- conf_node, conf_service, status);
+ DEBUG("apcups plugin: apc_query_server (\"%s\", \"%s\") = %d", conf_node,
+ conf_service, status);
return status;
}
char type_instance[DATA_MAX_NAME_LEN];
if (libaquaero5_poll(conf_device, &aq_data, &err_msg) < 0) {
- char errbuf[1024];
ERROR("aquaero plugin: Failed to poll device \"%s\": %s (%s)",
- conf_device ? conf_device : "default", err_msg,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ conf_device ? conf_device : "default", err_msg, STRERRNO);
return -1;
}
if (libaquaero5_getsettings(conf_device, &aq_sett, &err_msg) < 0) {
- char errbuf[1024];
ERROR("aquaero plugin: Failed to get settings "
"for device \"%s\": %s (%s)",
- conf_device ? conf_device : "default", err_msg,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ conf_device ? conf_device : "default", err_msg, STRERRNO);
return -1;
}
*/
static int MPL115_detect(void) {
__s32 res;
- char errbuf[1024];
if (ioctl(i2c_bus_fd, I2C_SLAVE_FORCE, MPL115_I2C_ADDRESS) < 0) {
ERROR("barometer: MPL115_detect problem setting i2c slave address to "
"0x%02X: %s",
- MPL115_I2C_ADDRESS, sstrerror(errno, errbuf, sizeof(errbuf)));
+ MPL115_I2C_ADDRESS, STRERRNO);
return 0;
}
int8_t sic12MSB, sic12LSB, sic11MSB, sic11LSB, sic22MSB, sic22LSB;
int16_t sia0, sib1, sib2, sic12, sic11, sic22;
- char errbuf[1024];
res = i2c_smbus_read_i2c_block_data(i2c_bus_fd, MPL115_ADDR_COEFFS,
STATIC_ARRAY_SIZE(mpl115_coeffs),
mpl115_coeffs);
if (res < 0) {
- ERROR("barometer: MPL115_read_coeffs - problem reading data: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("barometer: MPL115_read_coeffs - problem reading data: %s", STRERRNO);
return -1;
}
int conv_temperature;
double adc_pressure;
double adc_temperature;
- char errbuf[1024];
*pressure = 0.0;
*temperature = 0.0;
if (retries > 0) {
ERROR("barometer: MPL115_read_averaged - requesting conversion: %s, "
"will retry at most %d more times",
- sstrerror(errno, errbuf, sizeof(errbuf)), retries);
+ STRERRNO, retries);
} else {
ERROR("barometer: MPL115_read_averaged - requesting conversion: %s, "
"too many failed retries",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
}
if (retries > 0) {
ERROR("barometer: MPL115_read_averaged - reading conversion: %s, "
"will retry at most %d more times",
- sstrerror(errno, errbuf, sizeof(errbuf)), retries);
+ STRERRNO, retries);
} else {
ERROR("barometer: MPL115_read_averaged - reading conversion: %s, "
"too many failed retries",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
}
*/
static int MPL3115_detect(void) {
__s32 res;
- char errbuf[1024];
if (ioctl(i2c_bus_fd, I2C_SLAVE_FORCE, MPL3115_I2C_ADDRESS) < 0) {
ERROR("barometer: MPL3115_detect problem setting i2c slave address to "
"0x%02X: %s",
- MPL3115_I2C_ADDRESS, sstrerror(errno, errbuf, sizeof(errbuf)));
+ MPL3115_I2C_ADDRESS, STRERRNO);
return 0;
}
__s32 ctrl;
__u8 data[MPL3115_NUM_CONV_VALS];
long int tmp_value = 0;
- char errbuf[1024];
/* Set Active - activate the device from standby */
res = i2c_smbus_read_byte_data(i2c_bus_fd, MPL3115_REG_CTRL_REG1);
if (res < 0) {
- ERROR("barometer: MPL3115_read - cannot read CTRL_REG1: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("barometer: MPL3115_read - cannot read CTRL_REG1: %s", STRERRNO);
return 1;
}
ctrl = res;
res = i2c_smbus_write_byte_data(i2c_bus_fd, MPL3115_REG_CTRL_REG1,
ctrl | MPL3115_CTRL_REG1_SBYB);
if (res < 0) {
- ERROR("barometer: MPL3115_read - problem activating: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("barometer: MPL3115_read - problem activating: %s", STRERRNO);
return 1;
}
res = i2c_smbus_read_byte_data(i2c_bus_fd, MPL3115_REG_STATUS);
if (res < 0) {
ERROR("barometer: MPL3115_read - cannot read status register: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
res = i2c_smbus_read_byte_data(i2c_bus_fd, MPL3115_REG_STATUS);
if (res < 0) {
ERROR("barometer: MPL3115_read - cannot read status register: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
}
res = i2c_smbus_read_i2c_block_data(i2c_bus_fd, MPL3115_REG_OUT_P_MSB,
MPL3115_NUM_CONV_VALS, data);
if (res < 0) {
- ERROR("barometer: MPL3115_read - cannot read data registers: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("barometer: MPL3115_read - cannot read data registers: %s", STRERRNO);
return 1;
}
static int MPL3115_init_sensor(void) {
__s32 res;
__s8 offset;
- char errbuf[1024];
/* Reset the sensor. It will reset immediately without ACKing */
/* the transaction, so no error handling here. */
res = i2c_smbus_write_byte_data(i2c_bus_fd, MPL3115_REG_OFF_T, offset);
if (res < 0) {
ERROR("barometer: MPL3115_init_sensor - problem setting temp offset: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
if (res < 0) {
ERROR(
"barometer: MPL3115_init_sensor - problem setting pressure offset: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
MPL3115_PT_DATA_TDEF);
if (res < 0) {
ERROR("barometer: MPL3115_init_sensor - problem setting PT_DATA_CFG: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
mpl3115_oversample);
if (res < 0) {
ERROR("barometer: MPL3115_init_sensor - problem configuring CTRL_REG1: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
*/
static int BMP085_detect(void) {
__s32 res;
- char errbuf[1024];
if (ioctl(i2c_bus_fd, I2C_SLAVE_FORCE, BMP085_I2C_ADDRESS) < 0) {
ERROR("barometer: BMP085_detect - problem setting i2c slave address to "
"0x%02X: %s",
- BMP085_I2C_ADDRESS, sstrerror(errno, errbuf, sizeof(errbuf)));
+ BMP085_I2C_ADDRESS, STRERRNO);
return 0;
}
res = i2c_smbus_read_byte_data(i2c_bus_fd, BMP085_ADDR_VERSION);
if (res < 0) {
ERROR("barometer: BMP085_detect - problem checking chip version: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 0;
}
DEBUG("barometer: BMP085_detect - chip version ML:0x%02X AL:0x%02X",
static int BMP085_read_coeffs(void) {
__s32 res;
__u8 coeffs[BMP085_NUM_COEFFS];
- char errbuf[1024];
res = i2c_smbus_read_i2c_block_data(i2c_bus_fd, BMP085_ADDR_COEFFS,
BMP085_NUM_COEFFS, coeffs);
if (res < 0) {
- ERROR("barometer: BMP085_read_coeffs - problem reading data: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("barometer: BMP085_read_coeffs - problem reading data: %s", STRERRNO);
return -1;
}
long adc_pressure;
long adc_temperature;
- char errbuf[1024];
/* start conversion of temperature */
res = i2c_smbus_write_byte_data(i2c_bus_fd, BMP085_ADDR_CTRL_REG,
if (res < 0) {
ERROR("barometer: BMP085_read - problem requesting temperature conversion: "
"%s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
i2c_smbus_read_i2c_block_data(i2c_bus_fd, BMP085_ADDR_CONV, 2, measBuff);
if (res < 0) {
ERROR("barometer: BMP085_read - problem reading temperature data: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
bmp085_cmdCnvPress);
if (res < 0) {
ERROR("barometer: BMP085_read - problem requesting pressure conversion: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
i2c_smbus_read_i2c_block_data(i2c_bus_fd, BMP085_ADDR_CONV, 3, measBuff);
if (res < 0) {
ERROR("barometer: BMP085_read - problem reading pressure data: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
* @return Zero when successful.
*/
static int collectd_barometer_init(void) {
- char errbuf[1024];
DEBUG("barometer: collectd_barometer_init");
if (i2c_bus_fd < 0) {
ERROR("barometer: collectd_barometer_init problem opening I2C bus device "
"\"%s\": %s (is loaded mod i2c-dev?)",
- config_device, sstrerror(errno, errbuf, sizeof(errbuf)));
+ config_device, STRERRNO);
return -1;
}
#if HAVE_TIMEGM
time_t t = timegm(&tm);
if (t == ((time_t)-1)) {
- char errbuf[1024];
- ERROR("bind plugin: timegm() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("bind plugin: timegm() failed: %s", STRERRNO);
return -1;
}
*ret_value = t;
#else
time_t t = mktime(&tm);
if (t == ((time_t)-1)) {
- char errbuf[1024];
- ERROR("bind plugin: mktime() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("bind plugin: mktime() failed: %s", STRERRNO);
return -1;
}
/* mktime assumes that tm is local time. Luckily, it also sets timezone to
cgroup_name);
fh = fopen(abs_path, "r");
if (fh == NULL) {
- char errbuf[1024];
- ERROR("cgroups plugin: fopen (\"%s\") failed: %s", abs_path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cgroups plugin: fopen (\"%s\") failed: %s", abs_path, STRERRNO);
return -1;
}
fh = fopen("/proc/stat", "r");
if (fh == NULL) {
- ERROR("contextswitch plugin: unable to open /proc/stat: %s",
- sstrerror(errno, buffer, sizeof(buffer)));
+ ERROR("contextswitch plugin: unable to open /proc/stat: %s", STRERRNO);
return -1;
}
status =
perfstat_cpu_total(NULL, &perfcputotal, sizeof(perfstat_cpu_total_t), 1);
if (status < 0) {
- char errbuf[1024];
- ERROR("contextswitch plugin: perfstat_cpu_total: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("contextswitch plugin: perfstat_cpu_total: %s", STRERRNO);
return -1;
}
#define COLLECTD_CPU_STATE_GUEST_NICE 9
#define COLLECTD_CPU_STATE_IDLE 10
#define COLLECTD_CPU_STATE_ACTIVE 11 /* sum of (!idle) */
-#define COLLECTD_CPU_STATE_MAX 12 /* #states */
+#define COLLECTD_CPU_STATE_MAX 12 /* #states */
#if HAVE_STATGRAB_H
#include <statgrab.h>
#error "No applicable input method."
#endif
-static const char *cpu_state_names[] = {"user", "system", "wait", "nice",
- "swap", "interrupt", "softirq", "steal",
- "guest", "guest_nice", "idle", "active"};
+static const char *cpu_state_names[] = {
+ "user", "system", "wait", "nice", "swap", "interrupt",
+ "softirq", "steal", "guest", "guest_nice", "idle", "active"};
#ifdef PROCESSOR_CPU_LOAD_INFO
static mach_port_t port_host;
static _Bool report_guest = 0;
static _Bool subtract_guest = 1;
-static const char *config_keys[] = {"ReportByCpu", "ReportByState",
- "ReportNumCpu", "ValuesPercentage",
+static const char *config_keys[] = {"ReportByCpu", "ReportByState",
+ "ReportNumCpu", "ValuesPercentage",
"ReportGuestState", "SubtractGuestState"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
status = sysctl(mib, STATIC_ARRAY_SIZE(mib), &numcpu, &numcpu_size, NULL, 0);
if (status == -1) {
- char errbuf[1024];
- WARNING("cpu plugin: sysctl: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("cpu plugin: sysctl: %s", STRERRNO);
return -1;
}
/* #endif CAN_USE_SYSCTL */
numcpu_size = sizeof(numcpu);
if (sysctlbyname("hw.ncpu", &numcpu, &numcpu_size, NULL, 0) < 0) {
- char errbuf[1024];
- WARNING("cpu plugin: sysctlbyname(hw.ncpu): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("cpu plugin: sysctlbyname(hw.ncpu): %s", STRERRNO);
return -1;
}
numcpu_size = sizeof(maxcpu);
if (sysctlbyname("kern.smp.maxcpus", &maxcpu, &numcpu_size, NULL, 0) < 0) {
- char errbuf[1024];
- WARNING("cpu plugin: sysctlbyname(kern.smp.maxcpus): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("cpu plugin: sysctlbyname(kern.smp.maxcpus): %s", STRERRNO);
return -1;
}
#else
perfstat_cpu_total_t cputotal = {0};
if (!perfstat_cpu_total(NULL, &cputotal, sizeof(cputotal), 1)) {
- char errbuf[1024];
- WARNING("cpu plugin: perfstat_cpu_total: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("cpu plugin: perfstat_cpu_total: %s", STRERRNO);
return;
}
for (size_t cpu_num = 0; cpu_num < global_cpu_num; cpu_num++) {
cpu_state_t *this_cpu_states = get_cpu_state(cpu_num, 0);
- gauge_t local_rates[COLLECTD_CPU_STATE_MAX] = {NAN, NAN, NAN, NAN, NAN,
- NAN, NAN, NAN, NAN, NAN,
- NAN, NAN };
+ gauge_t local_rates[COLLECTD_CPU_STATE_MAX] = {
+ NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN};
for (size_t state = 0; state < COLLECTD_CPU_STATE_MAX; state++)
if (this_cpu_states[state].has_value)
int numfields;
if ((fh = fopen("/proc/stat", "r")) == NULL) {
- char errbuf[1024];
- ERROR("cpu plugin: fopen (/proc/stat) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cpu plugin: fopen (/proc/stat) failed: %s", STRERRNO);
return -1;
}
cpu = atoi(fields[0] + 3);
- /* Do not stage User and Nice immediately: we may need to alter them later: */
+ /* Do not stage User and Nice immediately: we may need to alter them later:
+ */
long long user_value = atoll(fields[1]);
long long nice_value = atoll(fields[2]);
cpu_stage(cpu, COLLECTD_CPU_STATE_SYSTEM, (derive_t)atoll(fields[3]), now);
now);
cpu_stage(cpu, COLLECTD_CPU_STATE_SOFTIRQ, (derive_t)atoll(fields[7]),
now);
- }
+ }
if (numfields >= 9) { /* Steal (since Linux 2.6.11) */
cpu_stage(cpu, COLLECTD_CPU_STATE_STEAL, (derive_t)atoll(fields[8]), now);
/* Guest is included in User; optionally subtract Guest from User: */
if (subtract_guest) {
user_value -= value;
- if (user_value < 0) user_value = 0;
+ if (user_value < 0)
+ user_value = 0;
}
}
}
Nice: */
if (subtract_guest) {
nice_value -= value;
- if (nice_value < 0) nice_value = 0;
+ if (nice_value < 0)
+ nice_value = 0;
}
}
}
status = sysctl(mib, STATIC_ARRAY_SIZE(mib), cpuinfo[i], &cpuinfo_size,
NULL, 0);
if (status == -1) {
- char errbuf[1024];
- ERROR("cpu plugin: sysctl failed: %s.",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cpu plugin: sysctl failed: %s.", STRERRNO);
return -1;
}
}
status = sysctl(mib, STATIC_ARRAY_SIZE(mib), &cpuinfo_tmp, &cpuinfo_size,
NULL, 0);
if (status == -1) {
- char errbuf[1024];
- ERROR("cpu plugin: sysctl failed: %s.",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cpu plugin: sysctl failed: %s.", STRERRNO);
return -1;
}
cpuinfo_size = sizeof(cpuinfo);
if (sysctlbyname("kern.cp_times", &cpuinfo, &cpuinfo_size, NULL, 0) < 0) {
- char errbuf[1024];
- ERROR("cpu plugin: sysctlbyname failed: %s.",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cpu plugin: sysctlbyname failed: %s.", STRERRNO);
return -1;
}
cpuinfo_size = sizeof(cpuinfo);
if (sysctlbyname("kern.cp_time", &cpuinfo, &cpuinfo_size, NULL, 0) < 0) {
- char errbuf[1024];
- ERROR("cpu plugin: sysctlbyname failed: %s.",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cpu plugin: sysctlbyname failed: %s.", STRERRNO);
return -1;
}
numcpu = perfstat_cpu(NULL, NULL, sizeof(perfstat_cpu_t), 0);
if (numcpu == -1) {
- char errbuf[1024];
- WARNING("cpu plugin: perfstat_cpu: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("cpu plugin: perfstat_cpu: %s", STRERRNO);
return -1;
}
id.name[0] = '\0';
if ((cpus = perfstat_cpu(&id, perfcpu, sizeof(perfstat_cpu_t), numcpu)) < 0) {
- char errbuf[1024];
- WARNING("cpu plugin: perfstat_cpu: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("cpu plugin: perfstat_cpu: %s", STRERRNO);
return -1;
}
csv = fopen(filename, "w");
if (csv == NULL) {
- char errbuf[1024];
- ERROR("csv plugin: fopen (%s) failed: %s", filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("csv plugin: fopen (%s) failed: %s", filename, STRERRNO);
return -1;
}
if (csv_create_file(filename, ds))
return -1;
} else {
- char errbuf[1024];
- ERROR("stat(%s) failed: %s", filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("stat(%s) failed: %s", filename, STRERRNO);
return -1;
}
} else if (!S_ISREG(statbuf.st_mode)) {
csv = fopen(filename, "a");
if (csv == NULL) {
- char errbuf[1024];
- ERROR("csv plugin: fopen (%s) failed: %s", filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("csv plugin: fopen (%s) failed: %s", filename, STRERRNO);
return -1;
}
csv_fd = fileno(csv);
status = fcntl(csv_fd, F_SETLK, &fl);
if (status != 0) {
- char errbuf[1024];
- ERROR("csv plugin: flock (%s) failed: %s", filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("csv plugin: flock (%s) failed: %s", filename, STRERRNO);
fclose(csv);
return -1;
}
static int cj_sock_perform(cj_t *db) /* {{{ */
{
- char errbuf[1024];
struct sockaddr_un sa_unix = {
.sun_family = AF_UNIX,
};
return -1;
if (connect(fd, (struct sockaddr *)&sa_unix, sizeof(sa_unix)) < 0) {
ERROR("curl_json plugin: connect(%s) failed: %s",
- (db->sock != NULL) ? db->sock : "<null>",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ (db->sock != NULL) ? db->sock : "<null>", STRERRNO);
close(fd);
return -1;
}
red = read(fd, buffer, sizeof(buffer));
if (red < 0) {
ERROR("curl_json plugin: read(%s) failed: %s",
- (db->sock != NULL) ? db->sock : "<null>",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ (db->sock != NULL) ? db->sock : "<null>", STRERRNO);
close(fd);
return -1;
}
dir = strdup(orig_dir);
if (dir == NULL) {
- char errbuf[1024];
- ERROR("strdup failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("strdup failed: %s", STRERRNO);
return -1;
}
free(dir);
return 0;
} else if (!create || (errno != ENOENT)) {
- char errbuf[1024];
- ERROR("change_basedir: chdir (%s): %s", dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("change_basedir: chdir (%s): %s", dir, STRERRNO);
free(dir);
return -1;
}
status = mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO);
if (status != 0) {
- char errbuf[1024];
- ERROR("change_basedir: mkdir (%s): %s", dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("change_basedir: mkdir (%s): %s", dir, STRERRNO);
free(dir);
return -1;
}
status = chdir(dir);
if (status != 0) {
- char errbuf[1024];
- ERROR("change_basedir: chdir (%s): %s", dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("change_basedir: chdir (%s): %s", dir, STRERRNO);
free(dir);
return -1;
}
while ((loop == 0) && (nanosleep(&ts_wait, &ts_wait) != 0)) {
if (errno != EINTR) {
- char errbuf[1024];
- ERROR("nanosleep failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("nanosleep failed: %s", STRERRNO);
return -1;
}
}
const char *file = global_option_get("PIDFile");
if ((fh = fopen(file, "w")) == NULL) {
- char errbuf[1024];
- ERROR("fopen (%s): %s", file, sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("fopen (%s): %s", file, STRERRNO);
return 1;
}
fd = socket(AF_UNIX, SOCK_DGRAM, /* protocol = */ 0);
#endif
if (fd < 0) {
- char errbuf[1024];
- ERROR("creating UNIX socket failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("creating UNIX socket failed: %s", STRERRNO);
return 0;
}
if (sendto(fd, buffer, strlen(buffer), MSG_NOSIGNAL, (void *)&su,
(socklen_t)su_size) < 0) {
- char errbuf[1024];
- ERROR("sendto(\"%s\") failed: %s", notifysocket,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("sendto(\"%s\") failed: %s", notifysocket, STRERRNO);
close(fd);
return 0;
}
if ((pid = fork()) == -1) {
/* error */
- char errbuf[1024];
- fprintf(stderr, "fork: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ fprintf(stderr, "fork: %s", STRERRNO);
return 1;
} else if (pid != 0) {
/* parent */
struct sigaction sig_int_action = {.sa_handler = sig_int_handler};
if (0 != sigaction(SIGINT, &sig_int_action, NULL)) {
- char errbuf[1024];
ERROR("Error: Failed to install a signal handler for signal INT: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
struct sigaction sig_term_action = {.sa_handler = sig_term_handler};
if (0 != sigaction(SIGTERM, &sig_term_action, NULL)) {
- char errbuf[1024];
ERROR("Error: Failed to install a signal handler for signal TERM: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
struct sigaction sig_usr1_action = {.sa_handler = sig_usr1_handler};
if (0 != sigaction(SIGUSR1, &sig_usr1_action, NULL)) {
- char errbuf[1024];
ERROR("Error: Failed to install a signal handler for signal USR1: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return 1;
}
if (EEXIST == errno)
continue;
- char errbuf[1024];
- ERROR("check_create_dir: mkdir (%s): %s", dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("check_create_dir: mkdir (%s): %s", dir, STRERRNO);
return -1;
} else {
- char errbuf[1024];
- ERROR("check_create_dir: stat (%s): %s", dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("check_create_dir: stat (%s): %s", dir, STRERRNO);
return -1;
}
} else if (!S_ISDIR(statbuf.st_mode)) {
failure = 0;
if ((dh = opendir(dir)) == NULL) {
- char errbuf[1024];
- ERROR("walk_directory: Cannot open '%s': %s", dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("walk_directory: Cannot open '%s': %s", dir, STRERRNO);
return -1;
}
return 0;
}
- temp = realloc(dst->children,
- sizeof(oconfig_item_t) *
- (dst->children_num + src->children_num - 1));
+ temp =
+ realloc(dst->children, sizeof(oconfig_item_t) *
+ (dst->children_num + src->children_num - 1));
if (temp == NULL) {
ERROR("configfile: realloc failed.");
return -1;
if ((src == NULL) || (src->children_num == 0))
return 0;
- temp =
- realloc(dst->children,
- sizeof(oconfig_item_t) * (dst->children_num + src->children_num));
+ temp = realloc(dst->children, sizeof(oconfig_item_t) *
+ (dst->children_num + src->children_num));
if (temp == NULL) {
ERROR("configfile: realloc failed.");
return -1;
dh = opendir(dir);
if (dh == NULL) {
- char errbuf[1024];
- ERROR("configfile: opendir failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("configfile: opendir failed: %s", STRERRNO);
return NULL;
}
status = stat(path_ptr, &statbuf);
if (status != 0) {
- char errbuf[1024];
- WARNING("configfile: stat (%s) failed: %s", path_ptr,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("configfile: stat (%s) failed: %s", path_ptr, STRERRNO);
continue;
}
status = stat(path, &statbuf);
if (status != 0) {
- char errbuf[1024];
- ERROR("configfile: stat (%s) failed: %s", path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("configfile: stat (%s) failed: %s", path, STRERRNO);
return NULL;
}
}
if ((dh = opendir(dir)) == NULL) {
- char errbuf[1024];
- ERROR("plugin_load: opendir (%s) failed: %s", dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("plugin_load: opendir (%s) failed: %s", dir, STRERRNO);
return -1;
}
}
if (lstat(filename, &statbuf) == -1) {
- char errbuf[1024];
- WARNING("plugin_load: stat (\"%s\") failed: %s", filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("plugin_load: stat (\"%s\") failed: %s", filename, STRERRNO);
continue;
} else if (!S_ISREG(statbuf.st_mode)) {
/* don't follow symlinks */
ctx = malloc(sizeof(*ctx));
if (ctx == NULL) {
- char errbuf[1024];
- ERROR("Failed to allocate plugin context: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("Failed to allocate plugin context: %s", STRERRNO);
return NULL;
}
fh = fopen(file, "r");
if (fh == NULL) {
- char errbuf[1024];
fprintf(stderr, "Failed to open types database `%s': %s.\n", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
- ERROR("Failed to open types database `%s': %s", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
+ ERROR("Failed to open types database `%s': %s", file, STRERRNO);
return -1;
}
status = clock_gettime(CLOCK_REALTIME, &ts);
if (status != 0) {
- char errbuf[1024];
- ERROR("cdtime: clock_gettime failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cdtime: clock_gettime failed: %s", STRERRNO);
return 0;
}
status = gettimeofday(&tv, /* struct timezone = */ NULL);
if (status != 0) {
- char errbuf[1024];
- ERROR("cdtime: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cdtime: gettimeofday failed: %s", STRERRNO);
return 0;
}
NORMALIZE_TIMESPEC(t_spec);
if (gmtime_r(&t_spec.tv_sec, t_tm) == NULL) {
- char errbuf[1024];
int status = errno;
- ERROR("get_utc_time: gmtime_r failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("get_utc_time: gmtime_r failed: %s", STRERRNO);
return status;
}
NORMALIZE_TIMESPEC(t_spec);
if (localtime_r(&t_spec.tv_sec, t_tm) == NULL) {
- char errbuf[1024];
int status = errno;
- ERROR("get_local_time: localtime_r failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("get_local_time: localtime_r failed: %s", STRERRNO);
return status;
}
continue;
if (STATANYFS(mnt_ptr->dir, &statbuf) < 0) {
- char errbuf[1024];
- ERROR(STATANYFS_STR "(%s) failed: %s", mnt_ptr->dir,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR(STATANYFS_STR "(%s) failed: %s", mnt_ptr->dir, STRERRNO);
continue;
}
int rnumdisk;
if ((numdisk = perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0)) < 0) {
- char errbuf[1024];
- WARNING("disk plugin: perfstat_disk: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("disk plugin: perfstat_disk: %s", STRERRNO);
return -1;
}
firstpath.name[0] = '\0';
if ((rnumdisk = perfstat_disk(&firstpath, stat_disk, sizeof(perfstat_disk_t),
numdisk)) < 0) {
- char errbuf[1024];
- WARNING("disk plugin: perfstat_disk : %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("disk plugin: perfstat_disk : %s", STRERRNO);
return -1;
}
status = plugin_thread_create(&listen_thread, NULL, dns_child_loop, (void *)0,
"dns listen");
if (status != 0) {
- char errbuf[1024];
- ERROR("dns plugin: pthread_create failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("dns plugin: pthread_create failed: %s", STRERRNO);
return -1;
}
shm_name);
}
- char errbuf[ERR_BUF_SIZE];
int fd = shm_open(shm_name, O_RDONLY, 0);
if (fd < 0) {
ERROR(DPDK_EVENTS_PLUGIN ": Failed to open %s as SHM:%s. Is DPDK KA "
"primary application running?",
- shm_name, sstrerror(errno, errbuf, sizeof(errbuf)));
+ shm_name, STRERRNO);
return errno;
}
ec->config.keep_alive.shm = (dpdk_keepalive_shm_t *)mmap(
0, sizeof(*(ec->config.keep_alive.shm)), PROT_READ, MAP_SHARED, fd, 0);
if (ec->config.keep_alive.shm == MAP_FAILED) {
- ERROR(DPDK_EVENTS_PLUGIN ": Failed to mmap KA SHM:%s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR(DPDK_EVENTS_PLUGIN ": Failed to mmap KA SHM:%s", STRERRNO);
close(fd);
return errno;
}
if (ret != 0) {
char errbuf[ERR_BUF_SIZE];
ERROR("%s: failed to initialize %s helper(error: %s)", DPDK_STATS_PLUGIN,
- g_shm_name, sstrerror(errno, errbuf, sizeof(errbuf)));
+ g_shm_name, STRERRNO);
return ret;
}
if (ret != 0) {
char errbuf[ERR_BUF_SIZE];
ERROR("%s: failed to initialize %s helper(error: %s)", DPDK_STATS_PLUGIN,
- g_shm_name, sstrerror(errno, errbuf, sizeof(errbuf)));
+ g_shm_name, STRERRNO);
return ret;
}
errno = 0;
if (fgets(line, sizeof(line), this->socket) == NULL) {
if (errno != 0) {
- char errbuf[1024];
log_err("collect: reading from socket (fd #%i) "
"failed: %s",
- fileno(this->socket),
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ fileno(this->socket), STRERRNO);
}
break;
}
/* create UNIX socket */
errno = 0;
if ((connector_socket = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
- char errbuf[1024];
disabled = 1;
- log_err("socket() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("socket() failed: %s", STRERRNO);
pthread_exit((void *)1);
}
- struct sockaddr_un addr = {
- .sun_family = AF_UNIX
- };
+ struct sockaddr_un addr = {.sun_family = AF_UNIX};
sstrncpy(addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
errno = 0;
if (bind(connector_socket, (struct sockaddr *)&addr,
- offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)) == -1) {
- char errbuf[1024];
+ offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)) ==
+ -1) {
disabled = 1;
close(connector_socket);
connector_socket = -1;
- log_err("bind() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("bind() failed: %s", STRERRNO);
pthread_exit((void *)1);
}
errno = 0;
if (listen(connector_socket, 5) == -1) {
- char errbuf[1024];
disabled = 1;
close(connector_socket);
connector_socket = -1;
- log_err("listen() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("listen() failed: %s", STRERRNO);
pthread_exit((void *)1);
}
} else {
status = chown(path, (uid_t)-1, grp->gr_gid);
if (status != 0) {
- char errbuf[1024];
log_warn("chown (%s, -1, %i) failed: %s", path, (int)grp->gr_gid,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
}
}
}
errno = 0;
if (chmod(path, sock_perms) != 0) {
- char errbuf[1024];
- log_warn("chmod() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_warn("chmod() failed: %s", STRERRNO);
}
{ /* initialize collector threads */
if (plugin_thread_create(&collectors[i]->thread, &ptattr, collect,
collectors[i], "email collector") != 0) {
- char errbuf[1024];
- log_err("plugin_thread_create() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("plugin_thread_create() failed: %s", STRERRNO);
collectors[i]->thread = (pthread_t)0;
}
}
remote = accept(connector_socket, NULL, NULL);
if (remote == -1) {
- char errbuf[1024];
-
if (errno == EINTR)
continue;
disabled = 1;
close(connector_socket);
connector_socket = -1;
- log_err("accept() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("accept() failed: %s", STRERRNO);
pthread_exit((void *)1);
}
static int email_init(void) {
if (plugin_thread_create(&connector, NULL, open_connection, NULL,
"email listener") != 0) {
- char errbuf[1024];
disabled = 1;
- log_err("plugin_thread_create() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("plugin_thread_create() failed: %s", STRERRNO);
return -1;
}
fd = socket(AF_INET, SOCK_DGRAM, /* protocol = */ 0);
if (fd < 0) {
- char errbuf[1024];
- ERROR("ethstat plugin: Failed to open control socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ethstat plugin: Failed to open control socket: %s", STRERRNO);
return 1;
}
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
- char errbuf[1024];
close(fd);
ERROR("ethstat plugin: Failed to get driver information "
"from %s: %s",
- device, sstrerror(errno, errbuf, sizeof(errbuf)));
+ device, STRERRNO);
return -1;
}
req.ifr_data = (void *)strings;
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
- char errbuf[1024];
close(fd);
free(strings);
free(stats);
- ERROR("ethstat plugin: Cannot get strings from %s: %s", device,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ethstat plugin: Cannot get strings from %s: %s", device, STRERRNO);
return -1;
}
req.ifr_data = (void *)stats;
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
- char errbuf[1024];
close(fd);
free(strings);
free(stats);
ERROR("ethstat plugin: Reading statistics from %s failed: %s", device,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
int gid, int egid) /* {{{ */
{
int status;
- char errbuf[1024];
#if HAVE_SETGROUPS
if (getuid() == 0) {
status = setgid(gid);
if (status != 0) {
- ERROR("exec plugin: setgid (%i) failed: %s", gid,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("exec plugin: setgid (%i) failed: %s", gid, STRERRNO);
exit(-1);
}
if (egid != -1) {
status = setegid(egid);
if (status != 0) {
- ERROR("exec plugin: setegid (%i) failed: %s", egid,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("exec plugin: setegid (%i) failed: %s", egid, STRERRNO);
exit(-1);
}
}
status = setuid(uid);
if (status != 0) {
- ERROR("exec plugin: setuid (%i) failed: %s", uid,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("exec plugin: setuid (%i) failed: %s", uid, STRERRNO);
exit(-1);
}
execvp(pl->exec, pl->argv);
- ERROR("exec plugin: Failed to execute ``%s'': %s", pl->exec,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("exec plugin: Failed to execute ``%s'': %s", pl->exec, STRERRNO);
exit(-1);
} /* void exec_child }}} */
static int create_pipe(int fd_pipe[2]) /* {{{ */
{
- char errbuf[1024];
int status;
status = pipe(fd_pipe);
if (status != 0) {
- ERROR("exec plugin: pipe failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("exec plugin: pipe failed: %s", STRERRNO);
return -1;
}
pid = fork();
if (pid < 0) {
- ERROR("exec plugin: fork failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("exec plugin: fork failed: %s", STRERRNO);
goto failed;
} else if (pid == 0) {
int fd_num;
fh = fdopen(fd, "w");
if (fh == NULL) {
- char errbuf[1024];
- ERROR("exec plugin: fdopen (%i) failed: %s", fd,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("exec plugin: fdopen (%i) failed: %s", fd, STRERRNO);
kill(pid, SIGTERM);
close(fd);
sfree(arg);
int prc_used, prc_unused;
char *fields[3];
char buffer[buffer_len];
- char errbuf[1024];
FILE *fp;
// Open file
fp = fopen("/proc/sys/fs/file-nr", "r");
if (fp == NULL) {
- ERROR("fhcount: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("fhcount: fopen: %s", STRERRNO);
return EXIT_FAILURE;
}
if (fgets(buffer, buffer_len, fp) == NULL) {
- ERROR("fhcount: fgets: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("fhcount: fgets: %s", STRERRNO);
fclose(fp);
return EXIT_FAILURE;
}
ai_return = getaddrinfo(node, service, &ai_hints, &ai_list);
if (ai_return != 0) {
- char errbuf[1024];
ERROR("gmond plugin: getaddrinfo (%s, %s) failed: %s",
(node == NULL) ? "(null)" : node,
(service == NULL) ? "(null)" : service,
- (ai_return == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(ai_return));
+ (ai_return == EAI_SYSTEM) ? STRERRNO : gai_strerror(ai_return));
return -1;
}
sockets[sockets_num].fd =
socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (sockets[sockets_num].fd < 0) {
- char errbuf[1024];
- ERROR("gmond plugin: socket failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("gmond plugin: socket failed: %s", STRERRNO);
continue;
}
status = setsockopt(sockets[sockets_num].fd, SOL_SOCKET, SO_REUSEADDR,
(void *)&yes, sizeof(yes));
if (status != 0) {
- char errbuf[1024];
- WARNING("gmond plugin: setsockopt(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("gmond plugin: setsockopt(2) failed: %s", STRERRNO);
}
}
status = bind(sockets[sockets_num].fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
- ERROR("gmond plugin: bind failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("gmond plugin: bind failed: %s", STRERRNO);
close(sockets[sockets_num].fd);
continue;
}
status = setsockopt(sockets[sockets_num].fd, IPPROTO_IP,
IP_MULTICAST_LOOP, (void *)&loop, sizeof(loop));
if (status != 0) {
- char errbuf[1024];
- WARNING("gmond plugin: setsockopt(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("gmond plugin: setsockopt(2) failed: %s", STRERRNO);
}
struct ip_mreq mreq = {.imr_multiaddr.s_addr = addr->sin_addr.s_addr,
status = setsockopt(sockets[sockets_num].fd, IPPROTO_IP,
IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq));
if (status != 0) {
- char errbuf[1024];
- WARNING("gmond plugin: setsockopt(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("gmond plugin: setsockopt(2) failed: %s", STRERRNO);
}
} /* if (ai_ptr->ai_family == AF_INET) */
else if (ai_ptr->ai_family == AF_INET6) {
status = setsockopt(sockets[sockets_num].fd, IPPROTO_IPV6,
IPV6_MULTICAST_LOOP, (void *)&loop, sizeof(loop));
if (status != 0) {
- char errbuf[1024];
- WARNING("gmond plugin: setsockopt(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("gmond plugin: setsockopt(2) failed: %s", STRERRNO);
}
struct ipv6_mreq mreq = {
status = setsockopt(sockets[sockets_num].fd, IPPROTO_IPV6,
IPV6_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq));
if (status != 0) {
- char errbuf[1024];
- WARNING("gmond plugin: setsockopt(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("gmond plugin: setsockopt(2) failed: %s", STRERRNO);
}
} /* if (ai_ptr->ai_family == AF_INET6) */
/* flags = */ 0, (struct sockaddr *)&mc_send_sockets[i].addr,
mc_send_sockets[i].addrlen);
if (status == -1) {
- char errbuf[1024];
- ERROR("gmond plugin: sendto(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("gmond plugin: sendto(2) failed: %s", STRERRNO);
continue;
}
}
buffer_size = recv(p->fd, buffer, sizeof(buffer), /* flags = */ 0);
if (buffer_size <= 0) {
- char errbuf[1024];
- ERROR("gmond plugin: recv failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("gmond plugin: recv failed: %s", STRERRNO);
p->revents = 0;
return -1;
}
while (mc_receive_thread_loop != 0) {
status = poll(mc_receive_sockets, mc_receive_sockets_num, -1);
if (status <= 0) {
- char errbuf[1024];
if (errno == EINTR)
continue;
- ERROR("gmond plugin: poll failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("gmond plugin: poll failed: %s", STRERRNO);
break;
}
.ai_socktype = SOCK_STREAM};
if ((ai_return = getaddrinfo(host, port, &ai_hints, &ai_list)) != 0) {
- char errbuf[1024];
ERROR("hddtemp plugin: getaddrinfo (%s, %s): %s", host, port,
- (ai_return == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(ai_return));
+ (ai_return == EAI_SYSTEM) ? STRERRNO : gai_strerror(ai_return));
return NULL;
}
/* create our socket descriptor */
fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (fd < 0) {
- char errbuf[1024];
- ERROR("hddtemp plugin: socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("hddtemp plugin: socket: %s", STRERRNO);
continue;
}
/* connect to the hddtemp daemon */
if (connect(fd, (struct sockaddr *)ai_ptr->ai_addr, ai_ptr->ai_addrlen)) {
- char errbuf[1024];
- INFO("hddtemp plugin: connect (%s, %s) failed: %s", host, port,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ INFO("hddtemp plugin: connect (%s, %s) failed: %s", host, port, STRERRNO);
close(fd);
fd = -1;
continue;
if (status == 0) {
break;
} else if (status == -1) {
- char errbuf[1024];
if ((errno == EAGAIN) || (errno == EINTR))
continue;
- ERROR("hddtemp plugin: Error reading from socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("hddtemp plugin: Error reading from socket: %s", STRERRNO);
close(fd);
free(buffer);
return NULL;
long page_size = strtol(result->d_name + strlen(hugepages_dir),
/* endptr = */ NULL, /* base = */ 10);
if (errno != 0) {
- char errbuf[1024];
ERROR("%s: failed to determine page size from directory name \"%s\": %s",
- g_plugin_name, result->d_name,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ g_plugin_name, result->d_name, STRERRNO);
continue;
}
int numfields;
if ((fh = fopen("/proc/net/dev", "r")) == NULL) {
- char errbuf[1024];
- WARNING("interface plugin: fopen: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("interface plugin: fopen: %s", STRERRNO);
return -1;
}
if ((nif = perfstat_netinterface(NULL, NULL, sizeof(perfstat_netinterface_t),
0)) < 0) {
- char errbuf[1024];
- WARNING("interface plugin: perfstat_netinterface: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("interface plugin: perfstat_netinterface: %s", STRERRNO);
return -1;
}
id.name[0] = '\0';
if ((ifs = perfstat_netinterface(&id, ifstat, sizeof(perfstat_netinterface_t),
nif)) < 0) {
- char errbuf[1024];
WARNING("interface plugin: perfstat_netinterface (interfaces=%d): %s", nif,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
status = semctl(/* id = */ 0, /* num = */ 0, SEM_INFO, arg);
if (status == -1) {
- char errbuf[1024];
ERROR("ipc plugin: semctl(2) failed: %s. "
"Maybe the kernel is not configured for semaphores?",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
status = shmctl(/* id = */ 0, SHM_INFO, (void *)&shm_info);
if (status == -1) {
- char errbuf[1024];
ERROR("ipc plugin: shmctl(2) failed: %s. "
"Maybe the kernel is not configured for shared memory?",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
if (get_ipc_info(cid, cmd, version, buff, &size) < 0) {
if (errno != ENOSPC) {
- char errbuf[1024];
- WARNING("ipc plugin: get_ipc_info: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("ipc plugin: get_ipc_info: %s", STRERRNO);
return NULL;
}
}
}
if (get_ipc_info(cid, cmd, version, buff, &size) < 0) {
- char errbuf[1024];
- WARNING("ipc plugin: get_ipc_info: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("ipc plugin: get_ipc_info: %s", STRERRNO);
free(buff);
return NULL;
}
return 1;
ip_chain_t temp = {0};
- ip_chain_t *final, **list;
+ ip_chain_t * final, **list;
char *table;
int table_len;
char *chain;
value_copy = strdup(value);
if (value_copy == NULL) {
- char errbuf[1024];
- ERROR("strdup failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("strdup failed: %s", STRERRNO);
return 1;
}
list = realloc(chain_list, (chain_num + 1) * sizeof(ip_chain_t *));
if (list == NULL) {
- char errbuf[1024];
- ERROR("realloc failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("realloc failed: %s", STRERRNO);
sfree(temp.rule.comment);
return 1;
}
chain_list = list;
- final = malloc(sizeof(*final));
+ final = malloc(sizeof(* final));
if (final == NULL) {
- char errbuf[1024];
- ERROR("malloc failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("malloc failed: %s", STRERRNO);
sfree(temp.rule.comment);
return 1;
}
if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, &ipvs_info, &len) ==
-1) {
- char errbuf[1024];
- log_err("ip_vs_get_services: getsockopt() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("ip_vs_get_services: getsockopt() failed: %s", STRERRNO);
return NULL;
}
if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_SERVICES, services, &len) ==
-1) {
- char errbuf[1024];
- log_err("ipvs_get_services: getsockopt failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("ipvs_get_services: getsockopt failed: %s", STRERRNO);
free(services);
return NULL;
dests->num_dests = se->num_dests;
if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_DESTS, dests, &len) == -1) {
- char errbuf[1024];
- log_err("ipvs_get_dests: getsockopt() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("ipvs_get_dests: getsockopt() failed: %s", STRERRNO);
free(dests);
return NULL;
}
struct ip_vs_getinfo ipvs_info;
if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) == -1) {
- char errbuf[1024];
- log_err("cipvs_init: socket() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("cipvs_init: socket() failed: %s", STRERRNO);
return -1;
}
if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, &ipvs_info, &len) ==
-1) {
- char errbuf[1024];
- log_err("cipvs_init: getsockopt() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("cipvs_init: getsockopt() failed: %s", STRERRNO);
close(sockfd);
sockfd = -1;
return -1;
*/
fh = fopen("/proc/interrupts", "r");
if (fh == NULL) {
- char errbuf[1024];
- ERROR("irq plugin: fopen (/proc/interrupts): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("irq plugin: fopen (/proc/interrupts): %s", STRERRNO);
return -1;
}
}
static void load_submit(gauge_t snum, gauge_t mnum, gauge_t lnum) {
int cores = 0;
- char errbuf[1024];
#ifdef _SC_NPROCESSORS_ONLN
if (report_relative_load) {
if ((cores = sysconf(_SC_NPROCESSORS_ONLN)) < 1) {
- WARNING("load: sysconf failed : %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: sysconf failed : %s", STRERRNO);
}
}
#endif
if (getloadavg(load, 3) == 3)
load_submit(load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
else {
- char errbuf[1024];
- WARNING("load: getloadavg failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: getloadavg failed: %s", STRERRNO);
}
/* #endif HAVE_GETLOADAVG */
int numfields;
if ((loadavg = fopen("/proc/loadavg", "r")) == NULL) {
- char errbuf[1024];
- WARNING("load: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: fopen: %s", STRERRNO);
return -1;
}
if (fgets(buffer, 16, loadavg) == NULL) {
- char errbuf[1024];
- WARNING("load: fgets: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: fgets: %s", STRERRNO);
fclose(loadavg);
return -1;
}
if (fclose(loadavg)) {
- char errbuf[1024];
- WARNING("load: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: fclose: %s", STRERRNO);
}
numfields = strsplit(buffer, fields, 8);
if (perfstat_cpu_total(NULL, &cputotal, sizeof(perfstat_cpu_total_t), 1) <
0) {
- char errbuf[1024];
- WARNING("load: perfstat_cpu : %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: perfstat_cpu : %s", STRERRNO);
return -1;
}
}
if (fh == NULL) {
- char errbuf[1024];
fprintf(stderr, "log_logstash plugin: fopen (%s) failed: %s\n", log_file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
} else {
fprintf(fh, "%s\n", buf);
if (do_close) {
}
if (fh == NULL) {
- char errbuf[1024];
fprintf(stderr, "logfile plugin: fopen (%s) failed: %s\n", log_file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
} else {
if (print_timestamp)
fprintf(fh, "[%s] %s%s\n", timestamp_str, level_str, msg);
sizeof(perfstat_partition_total_t),
/* number = */ 1 /* (must be 1) */);
if (status != 1) {
- char errbuf[1024];
- ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)",
- sstrerror(errno, errbuf, sizeof(errbuf)), status);
+ ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)", STRERRNO,
+ status);
return -1;
}
&lparstats, sizeof(perfstat_partition_total_t),
/* number = */ 1 /* (must be 1) */);
if (status != 1) {
- char errbuf[1024];
- ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)",
- sstrerror(errno, errbuf, sizeof(errbuf)), status);
+ ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)", STRERRNO,
+ status);
return -1;
}
.ai_socktype = SOCK_STREAM};
if ((ai_return = getaddrinfo(host, port, &ai_hints, &ai_list)) != 0) {
- char errbuf[1024];
ERROR("mbmon: getaddrinfo (%s, %s): %s", host, port,
- (ai_return == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(ai_return));
+ (ai_return == EAI_SYSTEM) ? STRERRNO : gai_strerror(ai_return));
return -1;
}
/* create our socket descriptor */
if ((fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype,
ai_ptr->ai_protocol)) < 0) {
- char errbuf[1024];
- ERROR("mbmon: socket: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("mbmon: socket: %s", STRERRNO);
continue;
}
/* connect to the mbmon daemon */
if (connect(fd, (struct sockaddr *)ai_ptr->ai_addr, ai_ptr->ai_addrlen)) {
- char errbuf[1024];
- INFO("mbmon: connect (%s, %s): %s", host, port,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ INFO("mbmon: connect (%s, %s): %s", host, port, STRERRNO);
close(fd);
fd = -1;
continue;
while ((status = read(fd, buffer + buffer_fill, buffer_size - buffer_fill)) !=
0) {
if (status == -1) {
- char errbuf[1024];
if ((errno == EAGAIN) || (errno == EINTR))
continue;
- ERROR("mbmon: Error reading from socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("mbmon: Error reading from socket: %s", STRERRNO);
close(fd);
return -1;
}
#define MCELOG_UNCORRECTED_ERR_TYPE_INS "uncorrected_memory_errors"
typedef struct mcelog_config_s {
- char logfile[PATH_MAX]; /* mcelog logfile */
- pthread_t tid; /* poll thread id */
- llist_t *dimms_list; /* DIMMs list */
+ char logfile[PATH_MAX]; /* mcelog logfile */
+ pthread_t tid; /* poll thread id */
+ llist_t *dimms_list; /* DIMMs list */
pthread_mutex_t dimms_lock; /* lock for dimms cache */
_Bool persist;
} mcelog_config_t;
int ret = 0;
pthread_rwlock_rdlock(&self->lock);
if (fcntl(self->sock_fd, F_GETFL) != -1) {
- char errbuf[MCELOG_BUFF_SIZE];
if (shutdown(self->sock_fd, SHUT_RDWR) != 0) {
- ERROR(MCELOG_PLUGIN ": Socket shutdown failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR(MCELOG_PLUGIN ": Socket shutdown failed: %s", STRERRNO);
ret = -1;
}
if (close(self->sock_fd) != 0) {
- ERROR(MCELOG_PLUGIN ": Socket close failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR(MCELOG_PLUGIN ": Socket close failed: %s", STRERRNO);
ret = -1;
}
}
}
static int socket_reinit(socket_adapter_t *self) {
- char errbuff[MCELOG_BUFF_SIZE];
int ret = -1;
cdtime_t interval = plugin_get_interval();
struct timeval socket_timeout = CDTIME_T_TO_TIMEVAL(interval);
self->sock_fd =
socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
if (self->sock_fd < 0) {
- ERROR(MCELOG_PLUGIN ": Could not create a socket. %s",
- sstrerror(errno, errbuff, sizeof(errbuff)));
+ ERROR(MCELOG_PLUGIN ": Could not create a socket. %s", STRERRNO);
pthread_rwlock_unlock(&self->lock);
return ret;
}
pthread_rwlock_rdlock(&self->lock);
if (connect(self->sock_fd, (struct sockaddr *)&(self->unix_sock),
sizeof(self->unix_sock)) < 0) {
- ERROR(MCELOG_PLUGIN ": Failed to connect to mcelog server. %s",
- sstrerror(errno, errbuff, sizeof(errbuff)));
+ ERROR(MCELOG_PLUGIN ": Failed to connect to mcelog server. %s", STRERRNO);
self->close(self);
ret = -1;
} else {
if ((res = poll(&poll_fd, 1, MCELOG_POLL_TIMEOUT)) <= 0) {
if (res != 0 && errno != EINTR) {
- char errbuf[MCELOG_BUFF_SIZE];
- ERROR("mcelog: poll failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("mcelog: poll failed: %s", STRERRNO);
}
pthread_rwlock_unlock(&self->lock);
return res;
}
static void *poll_worker(__attribute__((unused)) void *arg) {
- char errbuf[MCELOG_BUFF_SIZE];
mcelog_thread_running = 1;
FILE **pp_file = calloc(1, sizeof(*pp_file));
if (pp_file == NULL) {
- ERROR("mcelog: memory allocation failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("mcelog: memory allocation failed: %s", STRERRNO);
pthread_exit((void *)1);
}
} /* void md_submit */
static void md_process(const int minor, const char *path) {
- char errbuf[1024];
int fd;
struct stat st;
mdu_array_info_t array;
fd = open(path, O_RDONLY);
if (fd < 0) {
- WARNING("md: open(%s): %s", path, sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("md: open(%s): %s", path, STRERRNO);
return;
}
if (fstat(fd, &st) < 0) {
- WARNING("md: Unable to fstat file descriptor for %s: %s", path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("md: Unable to fstat file descriptor for %s: %s", path, STRERRNO);
close(fd);
return;
}
/* Retrieve md information */
if (ioctl(fd, GET_ARRAY_INFO, &array) < 0) {
- WARNING("md: Unable to retrieve array info from %s: %s", path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("md: Unable to retrieve array info from %s: %s", path, STRERRNO);
close(fd);
return;
}
fh = fopen(PROC_DISKSTATS, "r");
if (fh == NULL) {
- char errbuf[1024];
- WARNING("md: Unable to open %s: %s", PROC_DISKSTATS,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("md: Unable to open %s: %s", PROC_DISKSTATS, STRERRNO);
return -1;
}
/* create our socket descriptor */
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
- char errbuf[1024];
ERROR("memcached plugin: memcached_connect_unix: socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
int status = getaddrinfo(st->connhost, st->connport, &ai_hints, &ai_list);
if (status != 0) {
- char errbuf[1024];
ERROR("memcached plugin: memcached_connect_inet: "
"getaddrinfo(%s,%s) failed: %s",
st->connhost, st->connport,
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return -1;
}
/* create our socket descriptor */
fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (fd < 0) {
- char errbuf[1024];
WARNING("memcached plugin: memcached_connect_inet: "
"socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
continue;
}
status = (int)swrite(st->fd, "stats\r\n", strlen("stats\r\n"));
if (status != 0) {
- char errbuf[1024];
ERROR("memcached plugin: Instance \"%s\": write(2) failed: %s", st->name,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
shutdown(st->fd, SHUT_RDWR);
close(st->fd);
st->fd = -1;
char const end_token[5] = {'E', 'N', 'D', '\r', '\n'};
if (status < 0) {
- char errbuf[1024];
if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
continue;
ERROR("memcached plugin: Instance \"%s\": Error reading from socket: %s",
- st->name, sstrerror(errno, errbuf, sizeof(errbuf)));
+ st->name, STRERRNO);
shutdown(st->fd, SHUT_RDWR);
close(st->fd);
st->fd = -1;
/* group = */ "memcached",
/* name = */ callback_name,
/* callback = */ memcached_read,
- /* interval = */ 0,
- &(user_data_t){
- .data = st, .free_func = memcached_free,
- });
+ /* interval = */ 0, &(user_data_t){
+ .data = st, .free_func = memcached_free,
+ });
} /* int memcached_add_read_callback */
/* Configuration handling functiions
gauge_t mem_slab_unreclaimable = 0;
if ((fh = fopen("/proc/meminfo", "r")) == NULL) {
- char errbuf[1024];
- WARNING("memory: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("memory: fopen: %s", STRERRNO);
return -1;
}
}
if (fclose(fh)) {
- char errbuf[1024];
- WARNING("memory: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("memory: fclose: %s", STRERRNO);
}
if (mem_total < (mem_free + mem_buffered + mem_cached + mem_slab_total))
size = sizeof(vmtotal);
if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0) {
- char errbuf[1024];
- WARNING("memory plugin: sysctl failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("memory plugin: sysctl failed: %s", STRERRNO);
return -1;
}
perfstat_memory_total_t pmemory = {0};
if (perfstat_memory_total(NULL, &pmemory, sizeof(pmemory), 1) < 0) {
- char errbuf[1024];
- WARNING("memory plugin: perfstat_memory_total failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("memory plugin: perfstat_memory_total failed: %s", STRERRNO);
return -1;
}
status = getaddrinfo(address, /* service = */ NULL, &ai_hints, &ai_list);
if (status != 0) {
- char errbuf[1024];
ERROR("Modbus plugin: getaddrinfo failed: %s",
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return status;
}
status = mosquitto_reconnect(conf->mosq);
if (status != MOSQ_ERR_SUCCESS) {
- char errbuf[1024];
ERROR("mqtt_connect_broker: mosquitto_connect failed: %s",
- (status == MOSQ_ERR_ERRNO) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : mosquitto_strerror(status));
+ (status == MOSQ_ERR_ERRNO) ? STRERRNO : mosquitto_strerror(status));
return -1;
}
status =
mosquitto_username_pw_set(conf->mosq, conf->username, conf->password);
if (status != MOSQ_ERR_SUCCESS) {
- char errbuf[1024];
ERROR("mqtt plugin: mosquitto_username_pw_set failed: %s",
- (status == MOSQ_ERR_ERRNO)
- ? sstrerror(errno, errbuf, sizeof(errbuf))
- : mosquitto_strerror(status));
+ (status == MOSQ_ERR_ERRNO) ? STRERRNO : mosquitto_strerror(status));
mosquitto_destroy(conf->mosq);
conf->mosq = NULL;
mosquitto_connect(conf->mosq, conf->host, conf->port, MQTT_KEEPALIVE);
#endif
if (status != MOSQ_ERR_SUCCESS) {
- char errbuf[1024];
ERROR("mqtt plugin: mosquitto_connect failed: %s",
- (status == MOSQ_ERR_ERRNO) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : mosquitto_strerror(status));
+ (status == MOSQ_ERR_ERRNO) ? STRERRNO : mosquitto_strerror(status));
mosquitto_destroy(conf->mosq);
conf->mosq = NULL;
#endif
conf->qos, conf->retain);
if (status != MOSQ_ERR_SUCCESS) {
- char errbuf[1024];
c_complain(LOG_ERR, &conf->complaint_cantpublish,
"mqtt plugin: mosquitto_publish failed: %s",
- (status == MOSQ_ERR_ERRNO)
- ? sstrerror(errno, errbuf, sizeof(errbuf))
- : mosquitto_strerror(status));
+ (status == MOSQ_ERR_ERRNO) ? STRERRNO
+ : mosquitto_strerror(status));
/* Mark our connection "down" regardless of the error as a safety
* measure; we will try to reconnect the next time we have to publish a
* message */
}
snprintf(cb_name, sizeof(cb_name), "mqtt/%s", conf->name);
- plugin_register_write(cb_name, mqtt_write,
- &(user_data_t){
- .data = conf,
- });
+ plugin_register_write(cb_name, mqtt_write, &(user_data_t){
+ .data = conf,
+ });
return 0;
} /* mqtt_config_publisher */
/* args = */ subscribers[i],
/* name = */ "mqtt");
if (status != 0) {
- char errbuf[1024];
- ERROR("mqtt plugin: pthread_create failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("mqtt plugin: pthread_create failed: %s", STRERRNO);
continue;
}
}
tcflush(fd, TCIFLUSH);
if (gettimeofday(&time_end, NULL) < 0) {
- char errbuf[1024];
- ERROR("multimeter plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("multimeter plugin: gettimeofday failed: %s", STRERRNO);
return -1;
}
time_end.tv_sec++;
FD_SET(fd, &rfds);
if (gettimeofday(&time_now, NULL) < 0) {
- char errbuf[1024];
ERROR("multimeter plugin: "
"gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
if (timeval_cmp(time_end, time_now, &timeout) < 0)
continue;
} else /* status == -1 */
{
- char errbuf[1024];
ERROR("multimeter plugin: "
"select failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
break;
}
}
if (setsockopt(se->data.client.fd, IPPROTO_IP, optname, &network_config_ttl,
sizeof(network_config_ttl)) != 0) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (ipv4-ttl): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (ipv4-ttl): %s", STRERRNO);
return -1;
}
} else if (ai->ai_family == AF_INET6) {
if (setsockopt(se->data.client.fd, IPPROTO_IPV6, optname,
&network_config_ttl, sizeof(network_config_ttl)) != 0) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt(ipv6-ttl): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt(ipv6-ttl): %s", STRERRNO);
return -1;
}
}
if (setsockopt(se->data.client.fd, IPPROTO_IP, IP_MULTICAST_IF, &mreq,
sizeof(mreq)) != 0) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (ipv4-multicast-if): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (ipv4-multicast-if): %s", STRERRNO);
return -1;
}
if (IN6_IS_ADDR_MULTICAST(&addr->sin6_addr)) {
if (setsockopt(se->data.client.fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
&se->interface, sizeof(se->interface)) != 0) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (ipv6-multicast-if): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (ipv6-multicast-if): %s", STRERRNO);
return -1;
}
if (setsockopt(se->data.client.fd, SOL_SOCKET, SO_BINDTODEVICE,
interface_name, sizeof(interface_name)) == -1) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (bind-if): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (bind-if): %s", STRERRNO);
return -1;
}
/* #endif HAVE_IF_INDEXTONAME && SO_BINDTODEVICE */
/* allow multiple sockets to use the same PORT number */
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (reuseaddr): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (reuseaddr): %s", STRERRNO);
return -1;
}
DEBUG("fd = %i; calling `bind'", fd);
if (bind(fd, ai->ai_addr, ai->ai_addrlen) == -1) {
- char errbuf[1024];
- ERROR("bind: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("bind: %s", STRERRNO);
return -1;
}
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) ==
-1) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (multicast-loop): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (multicast-loop): %s", STRERRNO);
return -1;
}
if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) ==
-1) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (add-membership): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (add-membership): %s", STRERRNO);
return -1;
}
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &loop,
sizeof(loop)) == -1) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (ipv6-multicast-loop): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (ipv6-multicast-loop): %s", STRERRNO);
return -1;
}
if (setsockopt(fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq,
sizeof(mreq)) == -1) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (ipv6-add-membership): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (ipv6-add-membership): %s", STRERRNO);
return -1;
}
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, interface_name,
sizeof(interface_name)) == -1) {
- char errbuf[1024];
- ERROR("network plugin: setsockopt (bind-if): %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: setsockopt (bind-if): %s", STRERRNO);
return -1;
}
}
client->fd =
socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (client->fd < 0) {
- char errbuf[1024];
- ERROR("network plugin: socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: socket(2) failed: %s", STRERRNO);
continue;
}
*tmp = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (*tmp < 0) {
- char errbuf[1024];
- ERROR("network plugin: socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: socket(2) failed: %s", STRERRNO);
continue;
}
while (listen_loop == 0) {
status = poll(listen_sockets_pollfd, listen_sockets_num, -1);
if (status <= 0) {
- char errbuf[1024];
if (errno == EINTR)
continue;
- ERROR("network plugin: poll(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: poll(2) failed: %s", STRERRNO);
break;
}
buffer_len = recv(listen_sockets_pollfd[i].fd, buffer, sizeof(buffer),
0 /* no flags */);
if (buffer_len < 0) {
- char errbuf[1024];
status = (errno != 0) ? errno : -1;
- ERROR("network plugin: recv(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network plugin: recv(2) failed: %s", STRERRNO);
break;
}
/* flags = */ 0, (struct sockaddr *)se->data.client.addr,
se->data.client.addrlen);
if (status < 0) {
- char errbuf[1024];
-
if ((errno == EINTR) || (errno == EAGAIN))
continue;
ERROR("network plugin: sendto failed: %s. Closing sending socket.",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
sockent_client_disconnect(se);
return;
}
dispatch_thread, NULL /* no argument */,
"network disp");
if (status != 0) {
- char errbuf[1024];
- ERROR("network: pthread_create failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network: pthread_create failed: %s", STRERRNO);
} else {
dispatch_thread_running = 1;
}
receive_thread, NULL /* no argument */,
"network recv");
if (status != 0) {
- char errbuf[1024];
- ERROR("network: pthread_create failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("network: pthread_create failed: %s", STRERRNO);
} else {
receive_thread_running = 1;
}
fd = open(file, O_WRONLY | O_APPEND);
if (fd < 0) {
- char errbuf[1024];
status = errno;
- ERROR("notify_nagios plugin: Opening \"%s\" failed: %s", file,
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("notify_nagios plugin: Opening \"%s\" failed: %s", file, STRERRNO);
return status;
}
status = fcntl(fd, F_GETLK, &lock);
if (status != 0) {
- char errbuf[1024];
status = errno;
ERROR("notify_nagios plugin: Failed to acquire write lock on \"%s\": %s",
- file, sstrerror(status, errbuf, sizeof(errbuf)));
+ file, STRERRNO);
close(fd);
return status;
}
status = (int)lseek(fd, 0, SEEK_END);
if (status == -1) {
- char errbuf[1024];
status = errno;
ERROR("notify_nagios plugin: Seeking to end of \"%s\" failed: %s", file,
- sstrerror(status, errbuf, sizeof(errbuf)));
+ STRERRNO);
close(fd);
return status;
}
status = (int)swrite(fd, buffer, strlen(buffer));
if (status != 0) {
- char errbuf[1024];
status = errno;
- ERROR("notify_nagios plugin: Writing to \"%s\" failed: %s", file,
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("notify_nagios plugin: Writing to \"%s\" failed: %s", file, STRERRNO);
close(fd);
return status;
}
.ai_socktype = SOCK_DGRAM};
if ((status = getaddrinfo(host, port, &ai_hints, &ai_list)) != 0) {
- char errbuf[1024];
ERROR("ntpd plugin: getaddrinfo (%s, %s): %s", host, port,
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return -1;
}
*res_data = NULL;
if (gettimeofday(&time_end, NULL) < 0) {
- char errbuf[1024];
- ERROR("ntpd plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ntpd plugin: gettimeofday failed: %s", STRERRNO);
return -1;
}
time_end.tv_sec++; /* wait for a most one second */
struct timeval time_left;
if (gettimeofday(&time_now, NULL) < 0) {
- char errbuf[1024];
- ERROR("ntpd plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ntpd plugin: gettimeofday failed: %s", STRERRNO);
return -1;
}
continue;
if (status < 0) {
- char errbuf[1024];
- ERROR("ntpd plugin: poll failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ntpd plugin: poll failed: %s", STRERRNO);
return -1;
}
continue;
if (status < 0) {
- char errbuf[1024];
- INFO("recv(2) failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ INFO("recv(2) failed: %s", STRERRNO);
DEBUG("Closing socket #%i", sd);
close(sd);
sock_descr = sd = -1;
buffer_size, NULL, 0, /* No port name */
flags);
if (status != 0) {
- char errbuf[1024];
ERROR("ntpd plugin: getnameinfo failed: %s",
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return -1;
}
fh = fopen(path, "r");
if (fh == NULL) {
- char errbuf[1024];
ERROR("numa plugin: Reading node %i failed: open(%s): %s", node, path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
break;
} else /* ((status != 0) && (errno != ENOENT)) */
{
- char errbuf[1024];
- ERROR("numa plugin: stat(%s) failed: %s", path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("numa plugin: stat(%s) failed: %s", path, STRERRNO);
return -1;
}
}
ai_ptr = ai_ptr->ai_next) {
int fd;
int status;
- char errbuf[1024];
fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (fd < 0) {
- ERROR("olsrd plugin: socket failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("olsrd plugin: socket failed: %s", STRERRNO);
continue;
}
status = connect(fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
- ERROR("olsrd plugin: connect failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("olsrd plugin: connect failed: %s", STRERRNO);
close(fd);
continue;
}
char *buffer;
size_t buffer_size;
int status;
- char errbuf[1024];
char file[4096];
char *endptr;
status = OW_get(file, &buffer, &buffer_size);
if (status < 0) {
ERROR("onewire plugin: OW_get (%s/%s) failed. error = %s;", path,
- family_info->features[i].filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ family_info->features[i].filename, STRERRNO);
return -1;
}
DEBUG("Read onewire device %s as %s", file, buffer);
char *buffer;
size_t buffer_size;
int status;
- char errbuf[1024];
char *buffer_ptr;
char *dummy;
status = OW_get(path, &buffer, &buffer_size);
if (status < 0) {
- ERROR("onewire plugin: OW_get (%s) failed. error = %s;", path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("onewire plugin: OW_get (%s) failed. error = %s;", path, STRERRNO);
return -1;
}
DEBUG("onewire plugin: OW_get (%s) returned: %s", path, buffer);
char *buffer;
size_t buffer_size;
int status;
- char errbuf[1024];
char *endptr;
direct_access_element_t *traverse;
status = OW_get(traverse->path, &buffer, &buffer_size);
if (status < 0) {
ERROR("onewire plugin: OW_get (%s) failed. status = %s;", traverse->path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
DEBUG("onewire plugin: Read onewire device %s as %s", traverse->path,
static int cow_init(void) {
int status;
- char errbuf[1024];
if (device_g == NULL) {
ERROR("onewire plugin: cow_init: No device configured.");
DEBUG("onewire plugin: about to init device <%s>.", device_g);
status = (int)OW_init(device_g);
if (status != 0) {
- ERROR("onewire plugin: OW_init(%s) failed: %s.", device_g,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("onewire plugin: OW_init(%s) failed: %s.", device_g, STRERRNO);
return 1;
}
FILE *fh = fopen(st->file, "r");
if (fh == NULL) {
- char errbuf[1024];
- WARNING("openvpn plugin: fopen(%s) failed: %s", st->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("openvpn plugin: fopen(%s) failed: %s", st->file, STRERRNO);
return -1;
}
char *status_file = strdup(value);
if (status_file == NULL) {
- char errbuf[1024];
- ERROR("openvpn plugin: strdup failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("openvpn plugin: strdup failed: %s", STRERRNO);
return 1;
}
/* create a new vpn element */
vpn_status_t *instance = calloc(1, sizeof(*instance));
if (instance == NULL) {
- char errbuf[1024];
- ERROR("openvpn plugin: malloc failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("openvpn plugin: malloc failed: %s", STRERRNO);
sfree(status_file);
return 1;
}
/* group = */ "openvpn",
/* name = */ callback_name,
/* callback = */ openvpn_read,
- /* interval = */ 0,
- &(user_data_t){
- .data = instance, .free_func = openvpn_free,
- });
+ /* interval = */ 0, &(user_data_t){
+ .data = instance, .free_func = openvpn_free,
+ });
if (status == EINVAL) {
WARNING("openvpn plugin: status filename \"%s\" "
fd = open(pf_device, O_RDONLY);
if (fd < 0) {
- char errbuf[1024];
- ERROR("pf plugin: Unable to open %s: %s", pf_device,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pf plugin: Unable to open %s: %s", pf_device, STRERRNO);
return -1;
}
status = ioctl(fd, DIOCGETSTATUS, &state);
if (status != 0) {
- char errbuf[1024];
- ERROR("pf plugin: ioctl(DIOCGETSTATUS) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pf plugin: ioctl(DIOCGETSTATUS) failed: %s", STRERRNO);
close(fd);
return -1;
}
fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (fd < 0) {
- char errbuf[1024];
- ERROR("pinba plugin: socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: socket(2) failed: %s", STRERRNO);
return 0;
}
tmp = 1;
status = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
if (status != 0) {
- char errbuf[1024];
- WARNING("pinba plugin: setsockopt(SO_REUSEADDR) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("pinba plugin: setsockopt(SO_REUSEADDR) failed: %s", STRERRNO);
}
status = bind(fd, ai->ai_addr, ai->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
- ERROR("pinba plugin: bind(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: bind(2) failed: %s", STRERRNO);
close(fd);
return 0;
}
status = recvfrom(sock, buffer, buffer_size - 1, MSG_DONTWAIT,
/* from = */ NULL, /* from len = */ 0);
if (status < 0) {
- char errbuf[1024];
if ((errno == EINTR)
#ifdef EWOULDBLOCK
continue;
}
- WARNING("pinba plugin: recvfrom(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("pinba plugin: recvfrom(2) failed: %s", STRERRNO);
return -1;
} else if (status == 0) {
DEBUG("pinba plugin: recvfrom(2) returned unexpected status zero.");
{
continue;
} else if (status < 0) {
- char errbuf[1024];
-
if ((errno == EINTR) || (errno == EAGAIN))
continue;
- ERROR("pinba plugin: poll(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: poll(2) failed: %s", STRERRNO);
pinba_socket_free(s);
return -1;
}
/* attrs = */ NULL, collector_thread,
/* args = */ NULL, "pinba collector");
if (status != 0) {
- char errbuf[1024];
- ERROR("pinba plugin: pthread_create(3) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("pinba plugin: pthread_create(3) failed: %s", STRERRNO);
return -1;
}
collector_thread_running = 1;
_Bool send_successful = 0;
if (gettimeofday(&tv_begin, NULL) < 0) {
- char errbuf[1024];
- ERROR("ping plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ping plugin: gettimeofday failed: %s", STRERRNO);
ping_thread_error = 1;
break;
}
(void)ping_dispatch_all(pingobj);
if (gettimeofday(&tv_end, NULL) < 0) {
- char errbuf[1024];
- ERROR("ping plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ping plugin: gettimeofday failed: %s", STRERRNO);
ping_thread_error = 1;
break;
}
tmp = strdup(value);
if (tmp == NULL) {
- char errbuf[1024];
ERROR("ping plugin: Setting `%s' to `%s' failed: strdup failed: %s", name,
- value, sstrerror(errno, errbuf, sizeof(errbuf)));
+ value, STRERRNO);
return 1;
}
hl = malloc(sizeof(*hl));
if (hl == NULL) {
- char errbuf[1024];
- ERROR("ping plugin: malloc failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ping plugin: malloc failed: %s", STRERRNO);
return 1;
}
host = strdup(value);
if (host == NULL) {
- char errbuf[1024];
sfree(hl);
- ERROR("ping plugin: strdup failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ping plugin: strdup failed: %s", STRERRNO);
return 1;
}
#endif
#define FUNC_ERROR(func) \
do { \
- char errbuf[1024]; \
- ERROR("powerdns plugin: %s failed: %s", func, \
- sstrerror(errno, errbuf, sizeof(errbuf))); \
+ ERROR("powerdns plugin: %s failed: %s", func, STRERRNO); \
} while (0)
#define SOCK_ERROR(func, sockpath) \
do { \
- char errbuf[1024]; \
ERROR("powerdns plugin: Socket `%s` %s failed: %s", sockpath, func, \
- sstrerror(errno, errbuf, sizeof(errbuf))); \
+ STRERRNO); \
} while (0)
#define SERVER_SOCKET LOCALSTATEDIR "/run/pdns.controlsocket"
} /* while (fgets) */
if (fclose(fh)) {
- char errbuf[1024];
- WARNING("processes: fclose: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("processes: fclose: %s", STRERRNO);
}
}
closedir(dh);
} /* while (fgets) */
if (fclose(fh)) {
- char errbuf[1024];
- WARNING("processes: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("processes: fclose: %s", STRERRNO);
}
ps->vmem_data = data * 1024;
} /* while (fgets) */
if (fclose(fh)) {
- char errbuf[1024];
- WARNING("processes: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("processes: fclose: %s", STRERRNO);
}
return 0;
} /* int ps_read_io (...) */
} /* while (fgets) */
if (fclose(fh)) {
- char errbuf[1024];
- WARNING("processes: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("processes: fclose: %s", STRERRNO);
}
return count;
} /* int ps_count_maps (...) */
errno = 0;
fd = open(file, O_RDONLY);
if (fd < 0) {
- char errbuf[4096];
/* ENOENT means the process exited while we were handling it.
* Don't complain about this, it only fills the logs. */
if (errno != ENOENT)
- WARNING("processes plugin: Failed to open `%s': %s.", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("processes plugin: Failed to open `%s': %s.", file, STRERRNO);
return NULL;
}
status = read(fd, (void *)buf_ptr, len);
if (status < 0) {
- char errbuf[1024];
if ((EAGAIN == errno) || (EINTR == errno))
continue;
WARNING("processes plugin: Failed to read from `%s': %s.", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
close(fd);
return NULL;
}
proc_stat = fopen("/proc/stat", "r");
if (proc_stat == NULL) {
- char errbuf[1024];
- ERROR("processes plugin: fopen (/proc/stat) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("processes plugin: fopen (/proc/stat) failed: %s", STRERRNO);
return -1;
}
ps_list_reset();
if ((proc = opendir("/proc")) == NULL) {
- char errbuf[1024];
- ERROR("Cannot open `/proc': %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("Cannot open `/proc': %s", STRERRNO);
return -1;
}
fh = fopen(path, "r");
if (fh == NULL) {
- ERROR("protocols plugin: fopen (%s) failed: %s.", path,
- sstrerror(errno, key_buffer, sizeof(key_buffer)));
+ ERROR("protocols plugin: fopen (%s) failed: %s.", path, STRERRNO);
return -1;
}
static int handle_interface(__attribute__((unused))
ros_connection_t *c, /* {{{ */
- const ros_interface_t *i, void *user_data) {
+ const ros_interface_t *i,
+ void *user_data) {
if ((i == NULL) || (user_data == NULL))
return EINVAL;
static int handle_regtable(__attribute__((unused))
ros_connection_t *c, /* {{{ */
- const ros_registration_table_t *r, void *user_data) {
+ const ros_registration_table_t *r,
+ void *user_data) {
if ((r == NULL) || (user_data == NULL))
return EINVAL;
rd->connection =
ros_connect(rd->node, rd->service, rd->username, rd->password);
if (rd->connection == NULL) {
- char errbuf[128];
- ERROR("routeros plugin: ros_connect failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("routeros plugin: ros_connect failed: %s", STRERRNO);
return -1;
}
}
status = stat(filename, &statbuf);
if (status != 0) {
if (errno != ENOENT) {
- char errbuf[1024];
- ERROR("rrdcached plugin: stat (%s) failed: %s", filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("rrdcached plugin: stat (%s) failed: %s", filename, STRERRNO);
return -1;
}
{
char **tmp = realloc(keys, (keys_num + 1) * sizeof(char *));
if (tmp == NULL) {
- char errbuf[1024];
- ERROR("rrdtool plugin: "
- "realloc failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("rrdtool plugin: realloc failed: %s", STRERRNO);
c_avl_iterator_destroy(iter);
sfree(keys);
return;
values_new =
realloc((void *)rc->values, (rc->values_num + 1) * sizeof(char *));
if (values_new == NULL) {
- char errbuf[1024];
void *cache_key = NULL;
- sstrerror(errno, errbuf, sizeof(errbuf));
-
c_avl_remove(cache, filename, &cache_key, NULL);
pthread_mutex_unlock(&cache_lock);
- ERROR("rrdtool plugin: realloc failed: %s", errbuf);
+ ERROR("rrdtool plugin: realloc failed: %s", STRERRNO);
sfree(cache_key);
sfree(rc->values);
void *cache_key = strdup(filename);
if (cache_key == NULL) {
- char errbuf[1024];
- sstrerror(errno, errbuf, sizeof(errbuf));
-
pthread_mutex_unlock(&cache_lock);
- ERROR("rrdtool plugin: strdup failed: %s", errbuf);
+ ERROR("rrdtool plugin: strdup failed: %s", STRERRNO);
sfree(rc->values[0]);
sfree(rc->values);
return 0;
}
} else {
- char errbuf[1024];
- ERROR("rrdtool plugin: stat(%s) failed: %s", filename,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("rrdtool plugin: stat(%s) failed: %s", filename, STRERRNO);
return -1;
}
} else if (!S_ISREG(statbuf.st_mode)) {
if (conffile != NULL) {
fh = fopen(conffile, "r");
if (fh == NULL) {
- char errbuf[1024];
- ERROR("sensors plugin: fopen(%s) failed: %s", conffile,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("sensors plugin: fopen(%s) failed: %s", conffile, STRERRNO);
return -1;
}
}
/* there are a variety of names for the serial device */
if ((fh = fopen("/proc/tty/driver/serial", "r")) == NULL &&
(fh = fopen("/proc/tty/driver/ttyS", "r")) == NULL) {
- char errbuf[1024];
- WARNING("serial: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("serial: fopen: %s", STRERRNO);
return -1;
}
status = plugin_thread_create(&sr_thread, NULL, sigrok_read_thread, NULL,
"sigrok read");
if (status != 0) {
- char errbuf[1024];
- ERROR("sigrok plugin: Failed to create thread: %s.",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("sigrok plugin: Failed to create thread: %s.", STRERRNO);
return -1;
}
sr_thread_running = TRUE;
status = recv(fd, buffer, sizeof(buffer), /* flags = */ MSG_DONTWAIT);
if (status < 0) {
- char errbuf[1024];
if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
return;
- ERROR("statsd plugin: recv(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("statsd plugin: recv(2) failed: %s", STRERRNO);
return;
}
fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (fd < 0) {
- char errbuf[1024];
- ERROR("statsd plugin: socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("statsd plugin: socket(2) failed: %s", STRERRNO);
continue;
}
status = bind(fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
- ERROR("statsd plugin: bind(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("statsd plugin: bind(2) failed: %s", STRERRNO);
close(fd);
continue;
}
while (!network_thread_shutdown) {
status = poll(fds, (nfds_t)fds_num, /* timeout = */ -1);
if (status < 0) {
- char errbuf[1024];
if ((errno == EINTR) || (errno == EAGAIN))
continue;
- ERROR("statsd plugin: poll(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("statsd plugin: poll(2) failed: %s", STRERRNO);
break;
}
return ERANGE;
}
- tmp =
- realloc(conf_timer_percentile,
- sizeof(*conf_timer_percentile) * (conf_timer_percentile_num + 1));
+ tmp = realloc(conf_timer_percentile, sizeof(*conf_timer_percentile) *
+ (conf_timer_percentile_num + 1));
if (tmp == NULL) {
ERROR("statsd plugin: realloc failed.");
return ENOMEM;
/* attr = */ NULL, statsd_network_thread,
/* args = */ NULL);
if (status != 0) {
- char errbuf[1024];
pthread_mutex_unlock(&metrics_lock);
- ERROR("statsd plugin: pthread_create failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("statsd plugin: pthread_create failed: %s", STRERRNO);
return status;
}
}
fh = fopen("/proc/swaps", "r");
if (fh == NULL) {
- char errbuf[1024];
- WARNING("swap plugin: fopen (/proc/swaps) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("swap plugin: fopen (/proc/swaps) failed: %s", STRERRNO);
return -1;
}
fh = fopen("/proc/meminfo", "r");
if (fh == NULL) {
- char errbuf[1024];
- WARNING("swap plugin: fopen (/proc/meminfo) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("swap plugin: fopen (/proc/meminfo) failed: %s", STRERRNO);
return -1;
}
/* /proc/vmstat does not exist in kernels <2.6 */
fh = fopen("/proc/stat", "r");
if (fh == NULL) {
- char errbuf[1024];
- WARNING("swap: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("swap: fopen: %s", STRERRNO);
return -1;
} else
old_kernel = 1;
return 0;
} /* }}} int swap_read */
-/* #endif KERNEL_LINUX */
+ /* #endif KERNEL_LINUX */
/*
* Under Solaris, two mechanisms can be used to read swap statistics, swapctl
struct anoninfo ai;
if (swapctl(SC_AINFO, &ai) == -1) {
- char errbuf[1024];
- ERROR("swap plugin: swapctl failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("swap plugin: swapctl failed: %s", STRERRNO);
return -1;
}
status = swapctl(SC_LIST, s);
if (status < 0) {
- char errbuf[1024];
- ERROR("swap plugin: swapctl (SC_LIST) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("swap plugin: swapctl (SC_LIST) failed: %s", STRERRNO);
sfree(s_paths);
sfree(s);
return -1;
status =
perfstat_memory_total(NULL, &pmemory, sizeof(perfstat_memory_total_t), 1);
if (status < 0) {
- char errbuf[1024];
- WARNING("swap plugin: perfstat_memory_total failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("swap plugin: perfstat_memory_total failed: %s", STRERRNO);
return -1;
}
tmp = realloc(*var, ((*len) + num) * sizeof(**var));
if (NULL == tmp) {
- char errbuf[1024];
- log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("realloc failed: %s.", STRERRNO);
return -1;
}
*var = tmp;
res = realloc(tbl->results, (tbl->results_num + 1) * sizeof(*tbl->results));
if (res == NULL) {
- char errbuf[1024];
- log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("realloc failed: %s.", STRERRNO);
return -1;
}
tbl = realloc(tables, (tables_num + 1) * sizeof(*tables));
if (NULL == tbl) {
- char errbuf[1024];
- log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("realloc failed: %s.", STRERRNO);
return -1;
}
fh = fopen(tbl->file, "r");
if (NULL == fh) {
- char errbuf[1024];
- log_err("Failed to open file \"%s\": %s.", tbl->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("Failed to open file \"%s\": %s.", tbl->file, STRERRNO);
return -1;
}
}
if (0 != ferror(fh)) {
- char errbuf[1024];
- log_err("Failed to read from file \"%s\": %s.", tbl->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("Failed to read from file \"%s\": %s.", tbl->file, STRERRNO);
fclose(fh);
return -1;
}
if (fd < 0) {
ERROR("tcpconns plugin: conn_read_netlink: socket(AF_NETLINK, SOCK_RAW, "
"NETLINK_INET_DIAG) failed: %s",
- sstrerror(errno, buf, sizeof(buf)));
+ STRERRNO);
return -1;
}
if (sendmsg(fd, &msg, 0) < 0) {
ERROR("tcpconns plugin: conn_read_netlink: sendmsg(2) failed: %s",
- sstrerror(errno, buf, sizeof(buf)));
+ STRERRNO);
close(fd);
return -1;
}
continue;
ERROR("tcpconns plugin: conn_read_netlink: recvmsg(2) failed: %s",
- sstrerror(errno, buf, sizeof(buf)));
+ STRERRNO);
close(fd);
return -1;
} else if (status == 0) {
/* Create socket */
sd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (sd < 0) {
- char errbuf[1024];
- WARNING("teamspeak2 plugin: socket failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("teamspeak2 plugin: socket failed: %s", STRERRNO);
continue;
}
/* Try to connect */
status = connect(sd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
- WARNING("teamspeak2 plugin: connect failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("teamspeak2 plugin: connect failed: %s", STRERRNO);
close(sd);
sd = -1;
continue;
/* Create file objects from sockets */
global_read_fh = fdopen(sd, "r");
if (global_read_fh == NULL) {
- char errbuf[1024];
- ERROR("teamspeak2 plugin: fdopen failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("teamspeak2 plugin: fdopen failed: %s", STRERRNO);
close(sd);
return -1;
}
global_write_fh = fdopen(sd, "w");
if (global_write_fh == NULL) {
- char errbuf[1024];
- ERROR("teamspeak2 plugin: fdopen failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("teamspeak2 plugin: fdopen failed: %s", STRERRNO);
tss2_close_socket();
return -1;
}
*/
temp = fgets(buffer, buffer_size, fh);
if (temp == NULL) {
- char errbuf[1024];
- ERROR("teamspeak2 plugin: fgets failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("teamspeak2 plugin: fgets failed: %s", STRERRNO);
tss2_close_socket();
return -1;
}
/* Some signal or something. Start over.. */
continue;
} else if (status < 0) {
- char errbuf[1024];
- ERROR("ted plugin: select failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ted plugin: select failed: %s", STRERRNO);
return -1;
}
receive_buffer_length = read(fd, receive_buffer, sizeof(receive_buffer));
if (receive_buffer_length < 0) {
- char errbuf[1024];
if ((errno == EAGAIN) || (errno == EINTR))
continue;
- ERROR("ted plugin: read(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ted plugin: read(2) failed: %s", STRERRNO);
return -1;
} else if (receive_buffer_length == 0) {
/* Should we close the FD in this case? */
sock_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (sock_fd < 0) {
- char errbuf[1024];
- ERROR("unixsock plugin: socket failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: socket failed: %s", STRERRNO);
return -1;
}
errno = 0;
status = unlink(sa.sun_path);
if ((status != 0) && (errno != ENOENT)) {
- char errbuf[1024];
WARNING("unixsock plugin: Deleting socket file \"%s\" failed: %s",
- sa.sun_path, sstrerror(errno, errbuf, sizeof(errbuf)));
+ sa.sun_path, STRERRNO);
} else if (status == 0) {
INFO("unixsock plugin: Successfully deleted socket file \"%s\".",
sa.sun_path);
status = bind(sock_fd, (struct sockaddr *)&sa, sizeof(sa));
if (status != 0) {
- char errbuf[1024];
- sstrerror(errno, errbuf, sizeof(errbuf));
- ERROR("unixsock plugin: bind failed: %s", errbuf);
+ ERROR("unixsock plugin: bind failed: %s", STRERRNO);
close(sock_fd);
sock_fd = -1;
return -1;
status = chmod(sa.sun_path, sock_perms);
if (status == -1) {
- char errbuf[1024];
- ERROR("unixsock plugin: chmod failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: chmod failed: %s", STRERRNO);
close(sock_fd);
sock_fd = -1;
return -1;
status = listen(sock_fd, 8);
if (status != 0) {
- char errbuf[1024];
- ERROR("unixsock plugin: listen failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: listen failed: %s", STRERRNO);
close(sock_fd);
sock_fd = -1;
return -1;
if (chown((sock_file != NULL) ? sock_file : US_DEFAULT_PATH, (uid_t)-1,
g->gr_gid) != 0) {
- char errbuf[1024];
WARNING("unixsock plugin: chown (%s, -1, %i) failed: %s",
(sock_file != NULL) ? sock_file : US_DEFAULT_PATH, (int)g->gr_gid,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
}
} while (0);
fdout = dup(fdin);
if (fdout < 0) {
- char errbuf[1024];
- ERROR("unixsock plugin: dup failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: dup failed: %s", STRERRNO);
close(fdin);
pthread_exit((void *)1);
}
fhin = fdopen(fdin, "r");
if (fhin == NULL) {
- char errbuf[1024];
- ERROR("unixsock plugin: fdopen failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: fdopen failed: %s", STRERRNO);
close(fdin);
close(fdout);
pthread_exit((void *)1);
fhout = fdopen(fdout, "w");
if (fhout == NULL) {
- char errbuf[1024];
- ERROR("unixsock plugin: fdopen failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: fdopen failed: %s", STRERRNO);
fclose(fhin); /* this closes fdin as well */
close(fdout);
pthread_exit((void *)1);
/* change output buffer to line buffered mode */
if (setvbuf(fhout, NULL, _IOLBF, 0) != 0) {
- char errbuf[1024];
- ERROR("unixsock plugin: setvbuf failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: setvbuf failed: %s", STRERRNO);
fclose(fhin);
fclose(fhout);
pthread_exit((void *)1);
continue;
if (errno != 0) {
- char errbuf[1024];
WARNING("unixsock plugin: failed to read from socket #%i: %s",
- fileno(fhin), sstrerror(errno, errbuf, sizeof(errbuf)));
+ fileno(fhin), STRERRNO);
}
break;
}
cmd_handle_flush(fhout, buffer);
} else {
if (fprintf(fhout, "-1 Unknown command: %s\n", fields[0]) < 0) {
- char errbuf[1024];
WARNING("unixsock plugin: failed to write to socket #%i: %s",
- fileno(fhout), sstrerror(errno, errbuf, sizeof(errbuf)));
+ fileno(fhout), STRERRNO);
break;
}
}
DEBUG("unixsock plugin: Calling accept..");
status = accept(sock_fd, NULL, NULL);
if (status < 0) {
- char errbuf[1024];
if (errno == EINTR)
continue;
- ERROR("unixsock plugin: accept failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: accept failed: %s", STRERRNO);
close(sock_fd);
sock_fd = -1;
pthread_attr_destroy(&th_attr);
remote_fd = malloc(sizeof(*remote_fd));
if (remote_fd == NULL) {
- char errbuf[1024];
- WARNING("unixsock plugin: malloc failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("unixsock plugin: malloc failed: %s", STRERRNO);
close(status);
continue;
}
status = plugin_thread_create(&th, &th_attr, us_handle_client,
(void *)remote_fd, "unixsock conn");
if (status != 0) {
- char errbuf[1024];
- WARNING("unixsock plugin: pthread_create failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("unixsock plugin: pthread_create failed: %s", STRERRNO);
close(*remote_fd);
free(remote_fd);
continue;
status = unlink((sock_file != NULL) ? sock_file : US_DEFAULT_PATH);
if (status != 0) {
- char errbuf[1024];
NOTICE("unixsock plugin: unlink (%s) failed: %s",
- (sock_file != NULL) ? sock_file : US_DEFAULT_PATH,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ (sock_file != NULL) ? sock_file : US_DEFAULT_PATH, STRERRNO);
}
return (void *)0;
status = plugin_thread_create(&listen_thread, NULL, us_server_thread, NULL,
"unixsock listen");
if (status != 0) {
- char errbuf[1024];
- ERROR("unixsock plugin: pthread_create failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("unixsock plugin: pthread_create failed: %s", STRERRNO);
return -1;
}
status = sysinfo(&info);
if (status != 0) {
- char errbuf[1024];
- ERROR("uptime plugin: Error calling sysinfo: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("uptime plugin: Error calling sysinfo: %s", STRERRNO);
return -1;
}
status = sysctl(mib, STATIC_ARRAY_SIZE(mib), &boottv, &boottv_len,
/* new_value = */ NULL, /* new_length = */ 0);
if (status != 0) {
- char errbuf[1024];
- ERROR("uptime plugin: No value read from sysctl interface: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("uptime plugin: No value read from sysctl interface: %s", STRERRNO);
return -1;
}
status = perfstat_cpu_total(NULL, &cputotal, sizeof(perfstat_cpu_total_t), 1);
if (status < 0) {
- char errbuf[1024];
- ERROR("uptime plugin: perfstat_cpu_total: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("uptime plugin: perfstat_cpu_total: %s", STRERRNO);
return -1;
}
#define print_to_socket(fh, ...) \
if (fprintf(fh, __VA_ARGS__) < 0) { \
- char errbuf[1024]; \
WARNING("handle_getthreshold: failed to write to socket #%i: %s", \
- fileno(fh), sstrerror(errno, errbuf, sizeof(errbuf))); \
+ fileno(fh), STRERRNO); \
return -1; \
}
#define print_to_socket(fh, ...) \
do { \
if (fprintf(fh, __VA_ARGS__) < 0) { \
- char errbuf[1024]; \
WARNING("cmd_handle_getval: failed to write to socket #%i: %s", \
- fileno(fh), sstrerror(errno, errbuf, sizeof(errbuf))); \
+ fileno(fh), STRERRNO); \
return -1; \
} \
fflush(fh); \
#define print_to_socket(fh, ...) \
do { \
if (fprintf(fh, __VA_ARGS__) < 0) { \
- char errbuf[1024]; \
WARNING("handle_listval: failed to write to socket #%i: %s", fileno(fh), \
- sstrerror(errno, errbuf, sizeof(errbuf))); \
+ STRERRNO); \
free_everything_and_return(CMD_ERROR); \
} \
fflush(fh); \
#define print_to_socket(fh, ...) \
do { \
if (fprintf(fh, __VA_ARGS__) < 0) { \
- char errbuf[1024]; \
WARNING("handle_putnotif: failed to write to socket #%i: %s", \
- fileno(fh), sstrerror(errno, errbuf, sizeof(errbuf))); \
+ fileno(fh), STRERRNO); \
return -1; \
} \
fflush(fh); \
vsnprintf(buf, sizeof(buf), format, ap);
buf[sizeof(buf) - 1] = '\0';
if (fprintf(fh, "%i %s\n", code, buf) < 0) {
- char errbuf[1024];
WARNING("utils_cmds: failed to write to file-handle #%i: %s", fileno(fh),
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return;
}
static int dpdk_shm_init(const char *name, size_t size, void **map) {
DPDK_HELPER_TRACE(name);
- char errbuf[ERR_BUF_SIZE];
-
int fd = shm_open(name, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd < 0) {
- WARNING("dpdk_shm_init: Failed to open %s as SHM:%s", name,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("dpdk_shm_init: Failed to open %s as SHM:%s", name, STRERRNO);
*map = NULL;
return -1;
}
int ret = ftruncate(fd, size);
if (ret != 0) {
- WARNING("dpdk_shm_init: Failed to resize SHM:%s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("dpdk_shm_init: Failed to resize SHM:%s", STRERRNO);
close(fd);
*map = NULL;
dpdk_shm_cleanup(name, size, NULL);
*map = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (*map == MAP_FAILED) {
- WARNING("dpdk_shm_init:Failed to mmap SHM:%s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("dpdk_shm_init:Failed to mmap SHM:%s", STRERRNO);
close(fd);
*map = NULL;
dpdk_shm_cleanup(name, size, NULL);
static void dpdk_shm_cleanup(const char *name, size_t size, void *map) {
DPDK_HELPER_TRACE(name);
- char errbuf[ERR_BUF_SIZE];
/*
* Call shm_unlink first, as 'name' might be no longer accessible after munmap
*/
if (shm_unlink(name))
- ERROR("shm_unlink failure %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("shm_unlink failure %s", STRERRNO);
if (map != NULL) {
if (munmap(map, size))
- ERROR("munmap failure %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("munmap failure %s", STRERRNO);
}
}
dpdk_helper_ctx_t **pphc) {
dpdk_helper_ctx_t *phc = NULL;
size_t shm_size = sizeof(dpdk_helper_ctx_t) + data_size;
- char errbuf[ERR_BUF_SIZE];
if (pphc == NULL) {
ERROR("%s:Invalid argument(pphc)", __FUNCTION__);
err = sem_init(&phc->sema_cmd_start, 1, 0);
if (err != 0) {
- ERROR("sema_cmd_start semaphore init failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("sema_cmd_start semaphore init failed: %s", STRERRNO);
int errno_m = errno;
dpdk_shm_cleanup(name, shm_size, (void *)phc);
return -errno_m;
err = sem_init(&phc->sema_cmd_complete, 1, 0);
if (err != 0) {
- ERROR("sema_cmd_complete semaphore init failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("sema_cmd_complete semaphore init failed: %s", STRERRNO);
sem_destroy(&phc->sema_cmd_start);
int errno_m = errno;
dpdk_shm_cleanup(name, shm_size, (void *)phc);
}
static int dpdk_helper_spawn(dpdk_helper_ctx_t *phc) {
- char errbuf[ERR_BUF_SIZE];
if (phc == NULL) {
ERROR("Invalid argument(phc)");
return -EINVAL;
}
if (pipe(phc->pipes) != 0) {
- DEBUG("dpdk_helper_spawn: Could not create helper pipe: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ DEBUG("dpdk_helper_spawn: Could not create helper pipe: %s", STRERRNO);
return -1;
}
int pipe0_flags = fcntl(phc->pipes[0], F_GETFL, 0);
int pipe1_flags = fcntl(phc->pipes[1], F_GETFL, 0);
if (pipe0_flags == -1 || pipe1_flags == -1) {
- WARNING("dpdk_helper_spawn: error setting up pipe flags: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("dpdk_helper_spawn: error setting up pipe flags: %s", STRERRNO);
}
int pipe0_err = fcntl(phc->pipes[0], F_SETFL, pipe1_flags | O_NONBLOCK);
int pipe1_err = fcntl(phc->pipes[1], F_SETFL, pipe0_flags | O_NONBLOCK);
if (pipe0_err == -1 || pipe1_err == -1) {
- WARNING("dpdk_helper_spawn: error setting up pipes: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("dpdk_helper_spawn: error setting up pipes: %s", STRERRNO);
}
pid_t pid = fork();
dpdk_helper_worker(phc);
exit(0);
} else {
- ERROR("dpdk_helper_start: Failed to fork helper process: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("dpdk_helper_start: Failed to fork helper process: %s", STRERRNO);
return -1;
}
static int dpdk_helper_exit_command(dpdk_helper_ctx_t *phc,
enum DPDK_HELPER_STATUS status) {
- char errbuf[ERR_BUF_SIZE];
DPDK_HELPER_TRACE(phc->shm_name);
close(phc->pipes[1]);
int err = kill(phc->pid, SIGKILL);
if (err) {
- ERROR("%s error sending kill to helper: %s", __FUNCTION__,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("%s error sending kill to helper: %s", __FUNCTION__, STRERRNO);
}
}
} else {
int err = kill(phc->pid, SIGKILL);
if (err) {
- ERROR("%s error sending kill to helper: %s", __FUNCTION__,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("%s error sending kill to helper: %s", __FUNCTION__, STRERRNO);
}
}
DPDK_CHILD_LOG("%s:%s:%d post sema_cmd_complete (pid=%lu)\n", phc->shm_name,
__FUNCTION__, __LINE__, (long)getpid());
if (err) {
- char errbuf[ERR_BUF_SIZE];
DPDK_CHILD_LOG("dpdk_helper_worker: error posting sema_cmd_complete "
"semaphore (%s)\n",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
}
#if COLLECT_DEBUG
static int dpdk_helper_status_check(dpdk_helper_ctx_t *phc) {
DEBUG("%s:%s:%d pid=%u %s", phc->shm_name, __FUNCTION__, __LINE__, getpid(),
dpdk_helper_status_str(phc->status));
- char errbuf[ERR_BUF_SIZE];
if (phc->status == DPDK_HELPER_GRACEFUL_QUIT) {
return 0;
__LINE__);
int err = dpdk_helper_spawn(phc);
if (err) {
- ERROR("dpdkstat: error spawning helper %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("dpdkstat: error spawning helper %s", STRERRNO);
}
return -1;
}
__LINE__);
int err = dpdk_helper_spawn(phc);
if (err) {
- ERROR("dpdkstat: error spawning helper %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("dpdkstat: error spawning helper %s", STRERRNO);
}
return -1;
}
data_avail);
if (data_avail < 0) {
if (errno != EINTR || errno != EAGAIN) {
- char errbuf[ERR_BUF_SIZE];
- ERROR("%s: poll(2) failed: %s", phc->shm_name,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("%s: poll(2) failed: %s", phc->shm_name, STRERRNO);
}
}
while (data_avail) {
/* kick helper to process command */
int err = sem_post(&phc->sema_cmd_start);
if (err) {
- char errbuf[ERR_BUF_SIZE];
ERROR("dpdk_helper_worker: error posting sema_cmd_start semaphore (%s)",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
}
#if COLLECT_DEBUG
struct tabmntent *mntlist;
if (listmntent(&mntlist, COLLECTD_MNTTAB, NULL, NULL) < 0) {
#if COLLECT_DEBUG
- char errbuf[1024];
- DEBUG("utils_mount: calling listmntent() failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ DEBUG("utils_mount: calling listmntent() failed: %s", STRERRNO);
#endif /* COLLECT_DEBUG */
}
/* Get the number of mounted file systems */
if ((bufsize = CMD_STATFS(NULL, 0, FLAGS_STATFS)) < 1) {
#if COLLECT_DEBUG
- char errbuf[1024];
- DEBUG("utils_mount: getv?fsstat failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ DEBUG("utils_mount: getv?fsstat failed: %s", STRERRNO);
#endif /* COLLECT_DEBUG */
return NULL;
}
if ((num = CMD_STATFS(buf, bufsize * sizeof(STRUCT_STATFS), FLAGS_STATFS)) <
1) {
#if COLLECT_DEBUG
- char errbuf[1024];
- DEBUG("utils_mount: getv?fsstat failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ DEBUG("utils_mount: getv?fsstat failed: %s", STRERRNO);
#endif /* COLLECT_DEBUG */
free(buf);
return NULL;
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = fopen(COLLECTD_MNTTAB, "r")) == NULL) {
- char errbuf[1024];
- ERROR("fopen (%s): %s", COLLECTD_MNTTAB,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("fopen (%s): %s", COLLECTD_MNTTAB, STRERRNO);
return NULL;
}
return first;
} /* static cu_mount_t *cu_mount_gen_getmntent (void) */
- /* #endif HAVE_TWO_GETMNTENT || HAVE_GEN_GETMNTENT || HAVE_SUN_GETMNTENT */
+/* #endif HAVE_TWO_GETMNTENT || HAVE_GEN_GETMNTENT || HAVE_SUN_GETMNTENT */
#elif HAVE_SEQ_GETMNTENT
#warn "This version of `getmntent' hat not yet been implemented!"
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = setmntent(COLLECTD_MNTTAB, "r")) == NULL) {
- char errbuf[1024];
- ERROR("setmntent (%s): %s", COLLECTD_MNTTAB,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("setmntent (%s): %s", COLLECTD_MNTTAB, STRERRNO);
return NULL;
}
DEBUG("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
if ((fp = setmntent(COLLECTD_MNTTAB, "r")) == NULL) {
- char errbuf[1024];
- ERROR("setmntent (%s): %s", COLLECTD_MNTTAB,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("setmntent (%s): %s", COLLECTD_MNTTAB, STRERRNO);
return NULL;
}
}
/* try to connect to the server */
for (struct addrinfo *rp = result; rp != NULL; rp = rp->ai_next) {
- char errbuff[OVS_ERROR_BUFF_SIZE];
int sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (sock < 0) {
- sstrerror(errno, errbuff, sizeof(errbuff));
- OVS_DEBUG("socket(): %s", errbuff);
+ OVS_DEBUG("socket(): %s", STRERRNO);
continue;
}
if (connect(sock, rp->ai_addr, rp->ai_addrlen) < 0) {
close(sock);
- sstrerror(errno, errbuff, sizeof(errbuff));
- OVS_DEBUG("connect(): %s [family=%d]", errbuff, rp->ai_family);
+ OVS_DEBUG("connect(): %s [family=%d]", STRERRNO, rp->ai_family);
} else {
/* send notification to event thread */
ovs_db_event_post(pdb, OVS_DB_EVENT_CONN_ESTABLISHED);
/* poll data */
while (ovs_db_poll_is_running(pdb)) {
- char errbuff[OVS_ERROR_BUFF_SIZE];
poll_fd.fd = pdb->sock;
int poll_ret = poll(&poll_fd, 1, /* ms */ OVS_DB_POLL_TIMEOUT * 1000);
if (poll_ret < 0) {
- sstrerror(errno, errbuff, sizeof(errbuff));
- OVS_ERROR("poll(): %s", errbuff);
+ OVS_ERROR("poll(): %s", STRERRNO);
break;
} else if (poll_ret == 0) {
OVS_DEBUG("poll(): timeout");
char buff[OVS_DB_POLL_READ_BLOCK_SIZE];
ssize_t nbytes = recv(poll_fd.fd, buff, sizeof(buff), 0);
if (nbytes < 0) {
- sstrerror(errno, errbuff, sizeof(errbuff));
- OVS_ERROR("recv(): %s", errbuff);
+ OVS_ERROR("recv(): %s", STRERRNO);
/* read error? Try to reconnect */
close(poll_fd.fd);
continue;
ds_def = calloc(ds->ds_num, sizeof(*ds_def));
if (ds_def == NULL) {
- char errbuf[1024];
- ERROR("rrdtool plugin: calloc failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("rrdtool plugin: calloc failed: %s", STRERRNO);
return -1;
}
} else
snprintf(max, sizeof(max), "%f", d->max);
- status = snprintf(
- buffer, sizeof(buffer), "DS:%s:%s:%i:%s:%s", d->name, type,
- (cfg->heartbeat > 0) ? cfg->heartbeat
- : (int)CDTIME_T_TO_TIME_T(2 * vl->interval),
- min, max);
+ status = snprintf(buffer, sizeof(buffer), "DS:%s:%s:%i:%s:%s", d->name,
+ type, (cfg->heartbeat > 0)
+ ? cfg->heartbeat
+ : (int)CDTIME_T_TO_TIME_T(2 * vl->interval),
+ min, max);
if ((status < 1) || ((size_t)status >= sizeof(buffer)))
break;
status = rename(tmpfile, args->filename);
if (status != 0) {
- char errbuf[1024];
ERROR("srrd_create_thread: rename (\"%s\", \"%s\") failed: %s", tmpfile,
- args->filename, sstrerror(errno, errbuf, sizeof(errbuf)));
+ args->filename, STRERRNO);
unlink(tmpfile);
unlock_file(args->filename);
srrd_create_args_destroy(args);
argc = ds_num + rra_num;
if ((argv = malloc(sizeof(*argv) * (argc + 1))) == NULL) {
- char errbuf[1024];
- ERROR("cu_rrd_create_file failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("cu_rrd_create_file failed: %s", STRERRNO);
rra_free(rra_num, rra_def);
ds_free(ds_num, ds_def);
return -1;
status = stat(obj->file, &stat_buf);
if (status != 0) {
- char errbuf[1024];
- ERROR("utils_tail: stat (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("utils_tail: stat (%s) failed: %s", obj->file, STRERRNO);
return -1;
}
INFO("utils_tail: File `%s' was truncated.", obj->file);
status = fseek(obj->fh, 0, SEEK_SET);
if (status != 0) {
- char errbuf[1024];
- ERROR("utils_tail: fseek (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
fclose(obj->fh);
obj->fh = NULL;
return -1;
fh = fopen(obj->file, "r");
if (fh == NULL) {
- char errbuf[1024];
- ERROR("utils_tail: fopen (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("utils_tail: fopen (%s) failed: %s", obj->file, STRERRNO);
return -1;
}
if (seek_end != 0) {
status = fseek(fh, 0, SEEK_END);
if (status != 0) {
- char errbuf[1024];
- ERROR("utils_tail: fseek (%s) failed: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("utils_tail: fseek (%s) failed: %s", obj->file, STRERRNO);
fclose(fh);
return -1;
}
}
if (ferror(obj->fh) != 0) {
- char errbuf[1024];
WARNING("utils_tail: fgets (%s) returned an error: %s", obj->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
fclose(obj->fh);
obj->fh = NULL;
return -1;
fh = fopen("/proc/vmstat", "r");
if (fh == NULL) {
- char errbuf[1024];
- ERROR("vmem plugin: fopen (/proc/vmstat) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("vmem plugin: fopen (/proc/vmstat) failed: %s", STRERRNO);
return -1;
}
errno = 0;
proc = opendir(PROCDIR);
if (proc == NULL) {
- char errbuf[1024];
- ERROR("vserver plugin: fopen (%s): %s", PROCDIR,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("vserver plugin: fopen (%s): %s", PROCDIR, STRERRNO);
return -1;
}
errno = 0;
dent = readdir(proc);
if (dent == NULL) {
- char errbuf[4096];
-
if (errno == 0) /* end of directory */
break;
ERROR("vserver plugin: failed to read directory %s: %s", PROCDIR,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
closedir(proc);
return -1;
}
status = stat(file, &statbuf);
if (status != 0) {
- char errbuf[4096];
- WARNING("vserver plugin: stat (%s) failed: %s", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("vserver plugin: stat (%s) failed: %s", file, STRERRNO);
continue;
}
continue;
if (NULL == (fh = fopen(file, "r"))) {
- char errbuf[1024];
- ERROR("Cannot open '%s': %s", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("Cannot open '%s': %s", file, STRERRNO);
}
while ((fh != NULL) && (NULL != fgets(buffer, BUFSIZE, fh))) {
continue;
if (NULL == (fh = fopen(file, "r"))) {
- char errbuf[1024];
- ERROR("Cannot open '%s': %s", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("Cannot open '%s': %s", file, STRERRNO);
}
while ((fh != NULL) && (NULL != fgets(buffer, BUFSIZE, fh))) {
continue;
if (NULL == (fh = fopen(file, "r"))) {
- char errbuf[1024];
- ERROR("Cannot open '%s': %s", file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("Cannot open '%s': %s", file, STRERRNO);
}
while ((fh != NULL) && (NULL != fgets(buffer, BUFSIZE, fh))) {
/* there are a variety of names for the wireless device */
if ((fh = fopen(WIRELESS_PROC_FILE, "r")) == NULL) {
- char errbuf[1024];
- WARNING("wireless: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("wireless: fopen: %s", STRERRNO);
return -1;
}
status = swrite(cb->sock_fd, cb->send_buf, strlen(cb->send_buf));
if (status != 0) {
if (cb->log_send_errors) {
- char errbuf[1024];
ERROR("write_graphite plugin: send to %s:%s (%s) failed with status %zi "
"(%s)",
- cb->node, cb->service, cb->protocol, status,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ cb->node, cb->service, cb->protocol, status, STRERRNO);
}
close(cb->sock_fd);
cb->sock_fd =
socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
if (cb->sock_fd < 0) {
- char errbuf[1024];
- snprintf(connerr, sizeof(connerr), "failed to open socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ snprintf(connerr, sizeof(connerr), "failed to open socket: %s", STRERRNO);
continue;
}
status = connect(cb->sock_fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
- snprintf(connerr, sizeof(connerr), "failed to connect to remote "
- "host: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ snprintf(connerr, sizeof(connerr), "failed to connect to remote host: %s",
+ STRERRNO);
close(cb->sock_fd);
cb->sock_fd = -1;
continue;
freeaddrinfo(ai_list);
if (cb->sock_fd < 0) {
- if (connerr[0] == '\0')
- /* this should not happen but try to get a message anyway */
- sstrerror(errno, connerr, sizeof(connerr));
c_complain(LOG_ERR, &cb->init_complaint,
"write_graphite plugin: Connecting to %s:%s via %s failed. "
"The last error was: %s",
sensu_close_socket(host);
if (status != 0) {
- char errbuf[1024];
ERROR("write_sensu plugin: Sending to Sensu at %s:%s failed: %s",
(host->node != NULL) ? host->node : SENSU_HOST,
- (host->service != NULL) ? host->service : SENSU_PORT,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ (host->service != NULL) ? host->service : SENSU_PORT, STRERRNO);
return -1;
}
status = swrite(cb->sock_fd, cb->send_buf, strlen(cb->send_buf));
if (status != 0) {
- char errbuf[1024];
ERROR("write_tsdb plugin: send failed with status %zi (%s)", status,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
close(cb->sock_fd);
cb->sock_fd = -1;
}
if (cb->sock_fd < 0) {
- char errbuf[1024];
ERROR("write_tsdb plugin: Connecting to %s:%s failed. "
"The last error was: %s",
- node, service, sstrerror(errno, errbuf, sizeof(errbuf)));
+ node, service, STRERRNO);
return -1;
}
fh = fopen(ZOL_ARCSTATS_FILE, "r");
if (fh == NULL) {
- char errbuf[1024];
ERROR("zfs_arc plugin: Opening \"%s\" failed: %s", ZOL_ARCSTATS_FILE,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
return -1;
}
}
if (sread(fd, buf, bufsize) != 0) {
- char errbuf[1024];
- ERROR("zone plugin: Reading \"%s\" failed: %s", procfile,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("zone plugin: Reading \"%s\" failed: %s", procfile, STRERRNO);
close(fd);
return 1;
}
status = getaddrinfo(host, port, &ai_hints, &ai_list);
if (status != 0) {
- char errbuf[1024];
INFO("getaddrinfo failed: %s",
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return -1;
}
for (struct addrinfo *ai = ai_list; ai != NULL; ai = ai->ai_next) {
sk = socket(ai->ai_family, SOCK_STREAM, 0);
if (sk < 0) {
- char errbuf[1024];
- WARNING("zookeeper: socket(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("zookeeper: socket(2) failed: %s", STRERRNO);
continue;
}
status = (int)connect(sk, ai->ai_addr, ai->ai_addrlen);
if (status != 0) {
- char errbuf[1024];
close(sk);
sk = -1;
- WARNING("zookeeper: connect(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("zookeeper: connect(2) failed: %s", STRERRNO);
continue;
}
status = (int)swrite(sk, "mntr\r\n", strlen("mntr\r\n"));
if (status != 0) {
- char errbuf[1024];
- ERROR("zookeeper: write(2) failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("zookeeper: write(2) failed: %s", STRERRNO);
close(sk);
return -1;
}
buffer_size - buffer_fill, /* flags = */ 0)) !=
0) {
if (status < 0) {
- char errbuf[1024];
if ((errno == EAGAIN) || (errno == EINTR))
continue;
- ERROR("zookeeper: Error reading from socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("zookeeper: Error reading from socket: %s", STRERRNO);
close(sk);
return -1;
}