.. which internally uses the thread-safe function `strerror_r'.
status = getaddrinfo (host, port_str, &ai_hints, &ai_return);
if (status != 0)
{
- DEBUG ("getaddrinfo failed: %s", status == EAI_SYSTEM ? strerror (errno) : gai_strerror (status));
+ char errbuf[1024];
+ DEBUG ("getaddrinfo failed: %s",
+ (status == EAI_SYSTEM)
+ ? sstrerror (errno, errbuf, sizeof (errbuf))
+ : gai_strerror (status));
return (-1);
}
if (status != 0) /* `connect(2)' failed */
{
- DEBUG ("connect failed: %s", strerror (errno));
+ char errbuf[1024];
+ DEBUG ("connect failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (sd);
return (-1);
}
if ((dh = opendir ("/proc/acpi/battery")) == NULL)
{
- ERROR ("Cannot open `/proc/acpi/battery': %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("Cannot open `/proc/acpi/battery': %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if ((fh = fopen (filename, "r")) == NULL)
{
- ERROR ("Cannot open `%s': %s", filename, strerror (errno));
+ char errbuf[1024];
+ ERROR ("Cannot open `%s': %s", filename,
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
continue;
}
if (dir == NULL)
{
- ERROR ("strdup failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("strdup failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
{
if (mkdir (orig_dir, 0755) == -1)
{
+ char errbuf[1024];
ERROR ("mkdir (%s): %s", orig_dir,
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
else if (chdir (orig_dir) == -1)
{
+ char errbuf[1024];
ERROR ("chdir (%s): %s", orig_dir,
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
else
{
+ char errbuf[1024];
ERROR ("chdir (%s): %s", orig_dir,
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
{
if (gettimeofday (&tv_next, NULL) < 0)
{
- ERROR ("gettimeofday failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("gettimeofday failed: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
tv_next.tv_sec += interval_g;
if (gettimeofday (&tv_now, NULL) < 0)
{
+ char errbuf[1024];
ERROR ("gettimeofday failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
{
if (errno != EINTR)
{
- ERROR ("nanosleep failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("nanosleep failed: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
if ((fh = fopen (file, "w")) == NULL)
{
- ERROR ("fopen (%s): %s", file, strerror (errno));
+ char errbuf[1024];
+ ERROR ("fopen (%s): %s", file,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (1);
}
if ((pid = fork ()) == -1)
{
/* error */
- fprintf (stderr, "fork: %s", strerror (errno));
+ char errbuf[1024];
+ fprintf (stderr, "fork: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (1);
}
else if (pid != 0)
return (r);
}
+/* Don't use the return value of `strerror_r', because the GNU-people got
+ * inventive there.. -octo */
+char *sstrerror (int errnum, char *buf, size_t buflen)
+{
+ buf[0] = '\0';
+ strerror_r (errnum, buf, buflen);
+ return (buf);
+} /* char *sstrerror */
+
void *smalloc (size_t size)
{
void *r;
{
if (mkdir (dir, 0755) == -1)
{
- ERROR ("mkdir (%s): %s", dir, strerror (errno));
+ char errbuf[1024];
+ ERROR ("mkdir (%s): %s", dir,
+ sstrerror (errno,
+ errbuf, sizeof (errbuf)));
return (-1);
}
}
else
{
- ERROR ("stat (%s): %s", dir, strerror (errno));
+ char errbuf[1024];
+ ERROR ("stat (%s): %s", dir,
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
void sstrncpy(char *d, const char *s, int len);
char *sstrdup(const char *s);
void *smalloc(size_t size);
+char *sstrerror (int errnum, char *buf, size_t buflen);
/*
* NAME
if (sysctlbyname ("hw.ncpu", &numcpu, &numcpu_size, NULL, 0) < 0)
{
- WARNING ("cpu: sysctlbyname: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("cpu plugin: sysctlbyname: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if ((fh = fopen ("/proc/stat", "r")) == NULL)
{
+ char errbuf[1024];
plugin_complain (LOG_ERR, &complain_obj, "cpu plugin: "
"fopen (/proc/stat) failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if (sysctlbyname("kern.cp_time", &cpuinfo, &cpuinfo_size, NULL, 0) < 0)
{
+ char errbuf[1024];
plugin_complain (LOG_ERR, &complain_obj, "cpu plugin: "
"sysctlbyname failed: %s.",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return;
}
if ((fp = fopen (filename, "r")) == NULL)
{
- WARNING ("cpufreq: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("cpufreq: fopen (%s): %s", filename,
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
if (fgets (buffer, 16, fp) == NULL)
{
- WARNING ("cpufreq: fgets: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("cpufreq: fgets: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
fclose (fp);
return (-1);
}
if (fclose (fp))
- WARNING ("cpufreq: fclose: %s", strerror (errno));
+ {
+ char errbuf[1024];
+ WARNING ("cpufreq: fclose: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
+ }
+
/* You're seeing correctly: The file is reporting kHz values.. */
val = atoll (buffer) * 1000;
csv = fopen (filename, "w");
if (csv == NULL)
{
+ char errbuf[1024];
ERROR ("csv plugin: fopen (%s) failed: %s",
- filename, strerror(errno));
+ filename,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
}
else
{
- ERROR ("stat(%s) failed: %s",
- filename, strerror (errno));
+ char errbuf[1024];
+ ERROR ("stat(%s) failed: %s", filename,
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
csv = fopen (filename, "a");
if (csv == NULL)
{
- ERROR ("csv plugin: fopen (%s) failed: %s",
- filename, strerror (errno));
+ char errbuf[1024];
+ ERROR ("csv plugin: fopen (%s) failed: %s", filename,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
csv_fd = fileno (csv);
status = fcntl (csv_fd, F_SETLK, &fl);
if (status != 0)
{
- ERROR ("csv plugin: flock (%s) failed: %s",
- filename, strerror (errno));
+ char errbuf[1024];
+ ERROR ("csv plugin: flock (%s) failed: %s", filename,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
fclose (csv);
return (-1);
}
{
if (STATANYFS (mnt_ptr->dir, &statbuf) < 0)
{
- ERROR ("statv?fs failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("statv?fs failed: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
continue;
}
(void *) 0);
if (status != 0)
{
+ char errbuf[1024];
ERROR ("dns plugin: pthread_create failed: %s",
- strerror (status));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
FD_SET (src->socket, &fdset);
if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
- log_err ("select() failed: %s", strerror (errno));
+ char errbuf[1024];
+ log_err ("select() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return '\0';
}
errno = 0;
if (0 > (len = read (src->socket, (void *)&ret, 1))) {
if (EINTR != errno) {
- log_err ("read() failed: %s", strerror (errno));
+ char errbuf[1024];
+ log_err ("read() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return '\0';
}
}
FD_SET (src->socket, &fdset);
if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
- log_err ("select() failed: %s", strerror (errno));
+ char errbuf[1024];
+ log_err ("select() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return NULL;
}
(void *)(src->buffer + src->idx),
BUFSIZE - src->idx))) {
if (EINTR != errno) {
- log_err ("read() failed: %s", strerror (errno));
+ char errbuf[1024];
+ log_err ("read() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return NULL;
}
}
errno = 0;
if (-1 == fcntl (connection->socket, F_GETFL, &flags)) {
- log_err ("fcntl() failed: %s", strerror (errno));
+ char errbuf[1024];
+ log_err ("fcntl() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
loop = 0;
}
errno = 0;
if (-1 == fcntl (connection->socket, F_SETFL, flags | O_NONBLOCK)) {
- log_err ("fcntl() failed: %s", strerror (errno));
+ char errbuf[1024];
+ log_err ("fcntl() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
loop = 0;
}
}
/* create UNIX socket */
errno = 0;
if (-1 == (connector_socket = socket (PF_UNIX, SOCK_STREAM, 0))) {
+ char errbuf[1024];
disabled = 1;
- log_err ("socket() failed: %s", strerror (errno));
+ log_err ("socket() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
pthread_exit ((void *)1);
}
if (-1 == bind (connector_socket, (struct sockaddr *)&addr,
offsetof (struct sockaddr_un, sun_path)
+ strlen(addr.sun_path))) {
+ char errbuf[1024];
disabled = 1;
- log_err ("bind() failed: %s", strerror (errno));
+ log_err ("bind() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
pthread_exit ((void *)1);
}
errno = 0;
if (-1 == listen (connector_socket, 5)) {
+ char errbuf[1024];
disabled = 1;
- log_err ("listen() failed: %s", strerror (errno));
+ log_err ("listen() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
pthread_exit ((void *)1);
}
status = getgrnam_r (sock_group, &sg, grbuf, sizeof (grbuf), &grp);
if (status != 0)
{
- log_warn ("getgrnam_r (%s) failed: %s", sock_group, strerror (status));
+ char errbuf[1024];
+ log_warn ("getgrnam_r (%s) failed: %s", sock_group,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
}
else if (grp == NULL)
{
{
status = chown (SOCK_PATH, (uid_t) -1, grp->gr_gid);
if (status != 0)
+ {
+ char errbuf[1024];
log_warn ("chown (%s, -1, %i) failed: %s",
- SOCK_PATH, (int) grp->gr_gid, strerror (errno));
+ SOCK_PATH, (int) grp->gr_gid,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
}
}
else /* geteuid != 0 */
errno = 0;
if (0 != chmod (SOCK_PATH, sock_perms)) {
- log_warn ("chmod() failed: %s", strerror (errno));
+ char errbuf[1024];
+ log_warn ("chmod() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
}
{ /* initialize collector threads */
if (0 != (err = pthread_create (&collectors[i]->thread, &ptattr,
collect, collectors[i]))) {
- log_err ("pthread_create() failed: %s", strerror (err));
+ char errbuf[1024];
+ log_err ("pthread_create() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
}
}
errno = 0;
if (-1 == (remote = accept (connector_socket, NULL, NULL))) {
if (EINTR != errno) {
+ char errbuf[1024];
disabled = 1;
- log_err ("accept() failed: %s", strerror (errno));
+ log_err ("accept() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
pthread_exit ((void *)1);
}
}
if (0 != (err = pthread_create (&connector, NULL,
open_connection, NULL))) {
+ char errbuf[1024];
disabled = 1;
- log_err ("pthread_create() failed: %s", strerror (err));
+ log_err ("pthread_create() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
struct passwd *sp_ptr;
struct passwd sp;
char pwnambuf[2048];
+ char errbuf[1024];
sp_ptr = NULL;
status = getpwnam_r (pl->user, &sp, pwnambuf, sizeof (pwnambuf), &sp_ptr);
if (status != 0)
{
- ERROR ("exec plugin: getpwnam_r failed: %s", strerror (status));
+ ERROR ("exec plugin: getpwnam_r failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
if (sp_ptr == NULL)
status = setuid (uid);
if (status != 0)
{
- ERROR ("exec plugin: setuid failed: %s", strerror (errno));
+ ERROR ("exec plugin: setuid failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
status = execlp (pl->exec, arg0, (char *) 0);
- ERROR ("exec plugin: exec failed: %s", strerror (errno));
+ ERROR ("exec plugin: exec failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
} /* void exec_child */
status = pipe (fd_pipe);
if (status != 0)
{
- ERROR ("exec plugin: pipe failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("exec plugin: pipe failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
pl->pid = fork ();
if (pl->pid < 0)
{
- ERROR ("exec plugin: fork failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("exec plugin: fork failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
else if (pl->pid == 0)
fh = fdopen (fd, "r");
if (fh == NULL)
{
+ char errbuf[1024];
ERROR ("exec plugin: fdopen (%i) failed: %s", fd,
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
kill (pl->pid, SIGTERM);
close (fd);
pthread_exit ((void *) 1);
if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
+ char errbuf[1024];
ERROR ("hddtemp: getaddrinfo (%s, %s): %s",
host, port,
- ai_return == EAI_SYSTEM ? strerror (errno) : gai_strerror (ai_return));
+ (ai_return == EAI_SYSTEM)
+ ? sstrerror (errno, errbuf, sizeof (errbuf))
+ : 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 ("hddtemp: socket: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
/* connect to the hddtemp daemon */
if (connect (fd, (struct sockaddr *) ai_ptr->ai_addr, ai_ptr->ai_addrlen))
{
+ char errbuf[1024];
DEBUG ("hddtemp: connect (%s, %s): %s", host, port,
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (fd);
fd = -1;
continue;
{
if (status == -1)
{
+ char errbuf[1024];
+
if ((errno == EAGAIN) || (errno == EINTR))
continue;
ERROR ("hddtemp: Error reading from socket: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (fd);
return (-1);
}
}
fclose (fh);
}
+#if COLLECT_DEBUG
else
+ {
+ char errbuf[1024];
DEBUG ("Could not open /proc/partitions: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
+#endif /* COLLECT_DEBUG */
#endif /* KERNEL_LINUX */
return (0);
value_copy = strdup (value);
if (value_copy == NULL)
{
- ERROR ("strdup failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("strdup failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (1);
}
list = (ip_chain_t **) realloc (chain_list, (chain_num + 1) * sizeof (ip_chain_t *));
if (list == NULL)
{
- ERROR ("realloc failed: %s", strerror (errno));
- return (1);
+ char errbuf[1024];
+ ERROR ("realloc failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (1);
}
chain_list = list;
final = (ip_chain_t *) malloc( sizeof(temp) );
if (final == NULL)
{
- ERROR ("malloc failed: %s", strerror (errno));
- return (1);
+ char errbuf[1024];
+ ERROR ("malloc failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (1);
}
memcpy (final, &temp, sizeof (temp));
chain_list[chain_num] = final;
if ((fh = fopen ("/proc/interrupts", "r")) == NULL)
{
+ char errbuf[1024];
WARNING ("irq plugin: fopen (/proc/interrupts): %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
while (fgets (buffer, BUFSIZE, fh) != NULL)
if (getloadavg (load, 3) == 3)
load_submit (load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
else
- WARNING ("load: getloadavg failed: %s", strerror (errno));
+ {
+ char errbuf[1024];
+ WARNING ("load: getloadavg failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
/* #endif HAVE_GETLOADAVG */
#elif defined(KERNEL_LINUX)
if ((loadavg = fopen ("/proc/loadavg", "r")) == NULL)
{
- WARNING ("load: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("load: fopen: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return;
}
if (fgets (buffer, 16, loadavg) == NULL)
{
- WARNING ("load: fgets: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("load: fgets: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
fclose (loadavg);
return;
}
if (fclose (loadavg))
- WARNING ("load: fclose: %s", strerror (errno));
+ {
+ char errbuf[1024];
+ WARNING ("load: fclose: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
numfields = strsplit (buffer, fields, 8);
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 ? strerror (errno) : gai_strerror (ai_return));
+ (ai_return == EAI_SYSTEM)
+ ? sstrerror (errno, errbuf, sizeof (errbuf))
+ : 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",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
continue;
}
/* connect to the mbmon daemon */
if (connect (fd, (struct sockaddr *) ai_ptr->ai_addr, ai_ptr->ai_addrlen))
{
+ char errbuf[1024];
DEBUG ("mbmon: connect (%s, %s): %s", host, port,
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
close (fd);
fd = -1;
continue;
{
if (status == -1)
{
+ char errbuf[1024];
+
if ((errno == EAGAIN) || (errno == EINTR))
continue;
ERROR ("mbmon: Error reading from socket: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
close (fd);
return (-1);
}
(void *) &sysctl_vals[i], &len,
NULL, 0)) < 0)
{
+ char errbuf[1024];
ERROR ("memory plugin: sysctlbyname (%s): %s",
- sysctl_keys[i], strerror (errno));
+ sysctl_keys[i],
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
DEBUG ("%26s: %6i", sysctl_keys[i], sysctl_vals[i]);
if ((fh = fopen ("/proc/meminfo", "r")) == NULL)
{
- WARNING ("memory: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("memory: fopen: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
}
if (fclose (fh))
- WARNING ("memory: fclose: %s", strerror (errno));
+ {
+ char errbuf[1024];
+ WARNING ("memory: fclose: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
if (mem_used >= (mem_free + mem_buffered + mem_cached))
{
if (gettimeofday (&time_end, NULL) < 0)
{
+ char errbuf[1024];
ERROR ("multimeter plugin: gettimeofday failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
time_end.tv_sec++;
if (gettimeofday (&time_now, NULL) < 0)
{
+ char errbuf[1024];
ERROR ("multimeter plugin: "
"gettimeofday failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
if (multimeter_timeval_sub (&time_end, &time_now, &timeout) == -1)
}
else /* status == -1 */
{
+ char errbuf[1024];
ERROR ("multimeter plugin: "
"select failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
break;
}
}
&network_config_ttl,
sizeof (network_config_ttl)) == -1)
{
- ERROR ("setsockopt: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("setsockopt: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
}
&network_config_ttl,
sizeof (network_config_ttl)) == -1)
{
- ERROR ("setsockopt: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("setsockopt: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
if (bind (se->fd, ai->ai_addr, ai->ai_addrlen) == -1)
{
- ERROR ("bind: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("bind: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if (setsockopt (se->fd, IPPROTO_IP, IP_MULTICAST_LOOP,
&loop, sizeof (loop)) == -1)
{
- ERROR ("setsockopt: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("setsockopt: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
if (setsockopt (se->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&mreq, sizeof (mreq)) == -1)
{
- ERROR ("setsockopt: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("setsockopt: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
if (setsockopt (se->fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
&loop, sizeof (loop)) == -1)
{
- ERROR ("setsockopt: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("setsockopt: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
if (setsockopt (se->fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
&mreq, sizeof (mreq)) == -1)
{
- ERROR ("setsockopt: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("setsockopt: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
ai_return = getaddrinfo (node, service, &ai_hints, &ai_list);
if (ai_return != 0)
{
+ char errbuf[1024];
ERROR ("getaddrinfo (%s, %s): %s",
(node == NULL) ? "(null)" : node,
(service == NULL) ? "(null)" : service,
(ai_return == EAI_SYSTEM)
- ? strerror (errno)
+ ? sstrerror (errno, errbuf, sizeof (errbuf))
: gai_strerror (ai_return));
return (NULL);
}
if ((se = (sockent_t *) malloc (sizeof (sockent_t))) == NULL)
{
- ERROR ("malloc: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("malloc: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
continue;
}
if ((se->addr = (struct sockaddr_storage *) malloc (sizeof (struct sockaddr_storage))) == NULL)
{
- ERROR ("malloc: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("malloc: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
free (se);
continue;
}
if (se->fd == -1)
{
- ERROR ("socket: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("socket: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
free (se->addr);
free (se);
continue;
if (status <= 0)
{
+ char errbuf[1024];
if (errno == EINTR)
continue;
ERROR ("poll failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
0 /* no flags */);
if (buffer_len < 0)
{
- ERROR ("recv failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("recv failed: %s",
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
(struct sockaddr *) se->addr, se->addrlen);
if (status < 0)
{
+ char errbuf[1024];
if (errno == EINTR)
continue;
ERROR ("network plugin: sendto failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
break;
}
receive_thread, NULL /* no argument */);
if (status != 0)
+ {
+ char errbuf[1024];
ERROR ("network: pthread_create failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
+ }
}
return (0);
} /* int network_init */
values = (unsigned long long *) malloc (nfs2_procedures_names_num * sizeof (unsigned long long));
if (values == NULL)
{
+ char errbuf[1024];
ERROR ("nfs plugin: malloc "
"failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
values = (unsigned long long *) malloc (nfs3_procedures_names_num * sizeof (unsigned long long));
if (values == NULL)
{
+ char errbuf[1024];
ERROR ("nfs plugin: malloc "
"failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
if ((status = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
- DEBUG ("getaddrinfo (%s, %s): %s",
- host, port,
- status == EAI_SYSTEM ? strerror (errno) : gai_strerror (status));
+ char errbuf[1024];
ERROR ("ntpd plugin: getaddrinfo (%s, %s): %s",
host, port,
- status == EAI_SYSTEM ? strerror (errno) : gai_strerror (status));
+ (status == EAI_SYSTEM)
+ ? sstrerror (errno, errbuf, sizeof (errbuf))
+ : gai_strerror (status));
return (-1);
}
if (gettimeofday (&time_end, NULL) < 0)
{
+ char errbuf[1024];
ERROR ("ntpd plugin: gettimeofday failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
time_end.tv_sec++; /* wait for a most one second */
{
if (gettimeofday (&time_now, NULL) < 0)
{
+ char errbuf[1024];
ERROR ("ntpd plugin: gettimeofday failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if (status < 0)
{
- DEBUG ("poll failed: %s", strerror (errno));
+ char errbuf[1024];
ERROR ("ntpd plugin: poll failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if (status < 0)
{
- DEBUG ("recv(2) failed: %s", strerror (errno));
+ char errbuf[1024];
+ DEBUG ("recv(2) failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
DEBUG ("Closing socket #%i", sd);
close (sd);
sock_descr = sd = -1;
NULL, 0, 0 /* no flags */);
if (status != 0)
{
+ char errbuf[1024];
ERROR ("ntpd plugin: getnameinfo failed: %s",
- status == EAI_SYSTEM
- ? strerror (errno)
+ (status == EAI_SYSTEM)
+ ? sstrerror (errno, errbuf, sizeof (errbuf))
: gai_strerror (status));
continue;
}
if ((hl = (hostlist_t *) malloc (sizeof (hostlist_t))) == NULL)
{
+ char errbuf[1024];
ERROR ("ping plugin: malloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (1);
}
if ((host = strdup (value)) == NULL)
{
+ char errbuf[1024];
free (hl);
ERROR ("ping plugin: strdup failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (1);
}
#include <ltdl.h>
+#include "common.h"
#include "plugin.h"
#include "configfile.h"
#include "utils_llist.h"
if (dir == NULL)
plugindir = NULL;
else if ((plugindir = strdup (dir)) == NULL)
- ERROR ("strdup failed: %s", strerror (errno));
+ {
+ char errbuf[1024];
+ ERROR ("strdup failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
}
#define BUFSIZE 512
if ((dh = opendir (dir)) == NULL)
{
- ERROR ("opendir (%s): %s", dir, strerror (errno));
+ char errbuf[1024];
+ ERROR ("opendir (%s): %s", dir,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if (lstat (filename, &statbuf) == -1)
{
- WARNING ("stat %s: %s", filename, strerror (errno));
+ char errbuf[1024];
+ WARNING ("stat %s: %s", filename,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
else if (!S_ISREG (statbuf.st_mode))
rf = (read_func_t *) malloc (sizeof (read_func_t));
if (rf == NULL)
{
+ char errbuf[1024];
ERROR ("plugin_register_read: malloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
plugin_log (level, message);
}
+
+const data_set_t *plugin_get_ds (const char *name)
+{
+ data_set_t *ds;
+ llentry_t *le;
+
+ le = llist_search (list_data_set, name);
+ if (le == NULL)
+ {
+ DEBUG ("No such dataset registered: %s", name);
+ return (NULL);
+ }
+
+ ds = (data_set_t *) le->value;
+
+ return (ds);
+} /* data_set_t *plugin_get_ds */
void plugin_complain (int level, complain_t *c, const char *format, ...);
void plugin_relief (int level, complain_t *c, const char *format, ...);
+const data_set_t *plugin_get_ds (const char *name);
+
#endif /* PLUGIN_H */
if ((proc = opendir ("/proc")) == NULL)
{
- ERROR ("Cannot open `/proc': %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("Cannot open `/proc': %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
ds_def = (char **) malloc (ds->ds_num * sizeof (char *));
if (ds_def == NULL)
{
+ char errbuf[1024];
ERROR ("rrdtool plugin: malloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
memset (ds_def, '\0', ds->ds_num * sizeof (char *));
if ((argv = (char **) malloc (sizeof (char *) * (argc + 1))) == NULL)
{
- ERROR ("rrd_create failed: %s", strerror (errno));
+ char errbuf[1024];
+ ERROR ("rrd_create failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
(rc->values_num + 1) * sizeof (char *));
if (rc->values == NULL)
{
+ char errbuf[1024];
ERROR ("rrdtool plugin: realloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
if (cache != NULL)
{
void *cache_key = NULL;
if (cache_key == NULL)
{
+ char errbuf[1024];
ERROR ("rrdtool plugin: strdup failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
sfree (rc->values[0]);
sfree (rc->values);
sfree (rc);
(keys_num + 1) * sizeof (char *));
if (keys == NULL)
{
- DEBUG ("realloc failed: %s", strerror (errno));
+ char errbuf[1024];
ERROR ("rrdtool plugin: "
"realloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
avl_iterator_destroy (iter);
return;
}
}
else
{
- ERROR ("stat(%s) failed: %s",
- filename, strerror (errno));
+ char errbuf[1024];
+ ERROR ("stat(%s) failed: %s", filename,
+ sstrerror (errno, errbuf,
+ sizeof (errbuf)));
return (-1);
}
}
status = stat (conffile, &statbuf);
if (status != 0)
{
- ERROR ("sensors plugin: stat (%s) failed: %s",
- conffile, strerror (errno));
+ char errbuf[1024];
+ ERROR ("sensors plugin: stat (%s) failed: %s", conffile,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
sensors_config_mtime = 0;
}
fh = fopen (conffile, "r");
if (fh == NULL)
{
- ERROR ("sensors plugin: fopen(%s) failed: %s",
- conffile, strerror(errno));
+ char errbuf[1024];
+ ERROR ("sensors plugin: fopen(%s) failed: %s", conffile,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return;
}
if ((new_feature = (featurelist_t *) malloc (sizeof (featurelist_t))) == NULL)
{
- DEBUG ("malloc: %s", strerror (errno));
- ERROR ("sensors plugin: malloc: %s",
- strerror (errno));
+ char errbuf[1024];
+ ERROR ("sensors plugin: malloc: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
break;
}
if ((fh = fopen ("/proc/tty/driver/serial", "r")) == NULL &&
(fh = fopen ("/proc/tty/driver/ttyS", "r")) == NULL)
{
- WARNING ("serial: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("serial: fopen: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if ((fh = fopen ("/proc/meminfo", "r")) == NULL)
{
- WARNING ("memory: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("memory: fopen: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
}
if (fclose (fh))
- WARNING ("memory: fclose: %s", strerror (errno));
+ {
+ char errbuf[1024];
+ WARNING ("memory: fclose: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
if ((swap_total == 0LL) || ((swap_free + swap_cached) > swap_total))
return (-1);
if (swapctl (SC_AINFO, &ai) == -1)
{
+ char errbuf[1024];
ERROR ("swap plugin: swapctl failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
if ((fh = fopen ("/proc/net/dev", "r")) == NULL)
{
- WARNING ("traffic: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("traffic: fopen: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
/*
* Functions
*/
+static int parse_identifier (char *str, char **ret_host,
+ char **ret_plugin, char **ret_plugin_instance,
+ char **ret_type, char **ret_type_instance)
+{
+ char *hostname = NULL;
+ char *plugin = NULL;
+ char *plugin_instance = NULL;
+ char *type = NULL;
+ char *type_instance = NULL;
+
+ hostname = str;
+ if (hostname == NULL)
+ return (-1);
+
+ plugin = strchr (hostname, '/');
+ if (plugin == NULL)
+ return (-1);
+ *plugin = '\0'; plugin++;
+
+ type = strchr (plugin, '/');
+ if (type == NULL)
+ return (-1);
+ *type = '\0'; type++;
+
+ plugin_instance = strchr (plugin, '-');
+ if (plugin_instance != NULL)
+ {
+ *plugin_instance = '\0';
+ plugin_instance++;
+ }
+
+ type_instance = strchr (type, '-');
+ if (type_instance != NULL)
+ {
+ *type_instance = '\0';
+ type_instance++;
+ }
+
+ *ret_host = hostname;
+ *ret_plugin = plugin;
+ *ret_plugin_instance = plugin_instance;
+ *ret_type = type;
+ *ret_type_instance = type_instance;
+ return (0);
+} /* int parse_identifier */
+
static value_cache_t *cache_search (const char *name)
{
value_cache_t *vc;
vc = (value_cache_t *) malloc (sizeof (value_cache_t));
if (vc == NULL)
{
+ char errbuf[1024];
pthread_mutex_unlock (&cache_lock);
ERROR ("unixsock plugin: malloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
vc->gauge = (gauge_t *) malloc (sizeof (gauge_t) * vl->values_len);
if (vc->gauge == NULL)
{
+ char errbuf[1024];
pthread_mutex_unlock (&cache_lock);
ERROR ("unixsock plugin: malloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
free (vc);
return (-1);
}
vc->counter = (counter_t *) malloc (sizeof (counter_t) * vl->values_len);
if (vc->counter == NULL)
{
+ char errbuf[1024];
pthread_mutex_unlock (&cache_lock);
ERROR ("unixsock plugin: malloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
free (vc->gauge);
free (vc);
return (-1);
sock_fd = socket (PF_UNIX, SOCK_STREAM, 0);
if (sock_fd < 0)
{
+ char errbuf[1024];
ERROR ("unixsock plugin: socket failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
status = bind (sock_fd, (struct sockaddr *) &sa, sizeof (sa));
if (status != 0)
{
- DEBUG ("bind failed: %s; sa.sun_path = %s",
- strerror (errno), sa.sun_path);
- ERROR ("unixsock plugin: bind failed: %s",
- strerror (errno));
+ char errbuf[1024];
+ sstrerror (errno, errbuf, sizeof (errbuf));
+ DEBUG ("bind failed: %s; sa.sun_path = %s", errbuf, sa.sun_path);
+ ERROR ("unixsock plugin: bind failed: %s", errbuf);
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",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (sock_fd);
sock_fd = -1;
return (-1);
status = getgrnam_r (grpname, &sg, grbuf, sizeof (grbuf), &g);
if (status != 0)
{
- WARNING ("unixsock plugin: getgrnam_r (%s) failed: %s",
- grpname, strerror (status));
+ char errbuf[1024];
+ WARNING ("unixsock plugin: getgrnam_r (%s) failed: %s", grpname,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
break;
}
if (g == NULL)
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,
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
}
} while (0);
static int us_handle_getval (FILE *fh, char **fields, int fields_num)
{
- char *hostname = fields[1];
+ char *hostname;
char *plugin;
char *plugin_instance;
char *type;
if (fields_num != 2)
return (-1);
- plugin = strchr (hostname, '/');
- if (plugin == NULL)
- return (-1);
- *plugin = '\0'; plugin++;
-
- type = strchr (plugin, '/');
- if (type == NULL)
+ status = parse_identifier (fields[1], &hostname,
+ &plugin, &plugin_instance,
+ &type, &type_instance);
+ if (status != 0)
return (-1);
- *type = '\0'; type++;
-
- plugin_instance = strchr (plugin, '-');
- if (plugin_instance != NULL)
- {
- *plugin_instance = '\0';
- plugin_instance++;
- }
-
- type_instance = strchr (type, '-');
- if (type_instance != NULL)
- {
- *type_instance = '\0';
- type_instance++;
- }
status = cache_alloc_name (name, sizeof (name),
hostname, plugin, plugin_instance, type, type_instance);
return (0);
} /* int us_handle_getval */
+static int us_handle_putval (FILE *fh, char **fields, int fields_num)
+{
+ char *hostname;
+ char *plugin;
+ char *plugin_instance;
+ char *type;
+ char *type_instance;
+ int status;
+ int i;
+
+ const data_set_t *ds;
+ value_list_t vl = VALUE_LIST_INIT;
+
+ char **value_ptr;
+
+ if (fields_num != 3)
+ return (-1);
+
+ status = parse_identifier (fields[1], &hostname,
+ &plugin, &plugin_instance,
+ &type, &type_instance);
+ if (status != 0)
+ return (-1);
+
+ if ((strlen (hostname) > sizeof (vl.host))
+ || (strlen (plugin) > sizeof (vl.plugin))
+ || (strlen (plugin_instance) > sizeof (vl.plugin_instance))
+ || (strlen (type_instance) > sizeof (vl.type_instance)))
+ return (-1);
+
+ strcpy (vl.host, hostname);
+ strcpy (vl.plugin, plugin);
+ strcpy (vl.plugin_instance, plugin_instance);
+ strcpy (vl.type_instance, type_instance);
+
+ { /* parse the time */
+ char *t = fields[2];
+ char *v = strchr (t, ':');
+ if (v == NULL)
+ return (-1);
+ *v = '\0'; v++;
+
+ vl.time = (time_t) atoi (t);
+ if (vl.time == 0)
+ vl.time = time (NULL);
+
+ fields[2] = v;
+ }
+
+ ds = plugin_get_ds (type);
+ if (ds == NULL)
+ return (-1);
+
+ value_ptr = (char **) calloc (ds->ds_num, sizeof (char *));
+ if (value_ptr == NULL)
+ return (-1);
+
+
+ { /* parse the value-list. It's colon-separated. */
+ char *dummy;
+ char *ptr;
+ char *saveptr;
+
+ i = 0;
+ dummy = fields[2];
+ saveptr = NULL;
+ while ((ptr = strtok_r (dummy, ":", &saveptr)) != NULL)
+ {
+ dummy = NULL;
+ if (i >= ds->ds_num)
+ {
+ i = ds->ds_num + 1;
+ break;
+ }
+ value_ptr[i] = ptr;
+ i++;
+ }
+
+ if (i != ds->ds_num)
+ {
+ free (value_ptr);
+ return (-1);
+ }
+ } /* done parsing the value-list */
+
+ vl.values_len = fields_num - 2;
+ vl.values = (value_t *) malloc (vl.values_len * sizeof (value_t));
+ if (vl.values == NULL)
+ {
+ free (value_ptr);
+ return (-1);
+ }
+ vl.values_len = ds->ds_num;
+
+ for (i = 0; i < ds->ds_num; i++)
+ {
+ if (strcmp (value_ptr[i], "U") == 0)
+ vl.values[i].gauge = NAN;
+ else if (ds->ds[i].type == DS_TYPE_COUNTER)
+ vl.values[i].counter = atoll (value_ptr[i]);
+ else if (ds->ds[i].type == DS_TYPE_GAUGE)
+ vl.values[i].gauge = atof (value_ptr[i]);
+ } /* for (i = 2 .. fields_num) */
+ sfree (value_ptr);
+
+ plugin_dispatch_values (type, &vl);
+
+ sfree (vl.values);
+
+ return (0);
+} /* int us_handle_putval */
+
static void *us_handle_client (void *arg)
{
int fd;
fh = fdopen (fd, "r+");
if (fh == NULL)
{
+ char errbuf[1024];
ERROR ("unixsock plugin: fdopen failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (fd);
pthread_exit ((void *) 1);
}
{
us_handle_getval (fh, fields, fields_num);
}
+ else if (strcasecmp (fields[0], "putval") == 0)
+ {
+ us_handle_putval (fh, fields, fields_num);
+ }
else
{
fprintf (fh, "Unknown command: %s\n", fields[0]);
status = accept (sock_fd, NULL, NULL);
if (status < 0)
{
+ char errbuf[1024];
+
if (errno == EINTR)
continue;
ERROR ("unixsock plugin: accept failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (sock_fd);
sock_fd = -1;
pthread_exit ((void *) 1);
remote_fd = (int *) malloc (sizeof (int));
if (remote_fd == NULL)
{
+ char errbuf[1024];
WARNING ("unixsock plugin: malloc failed: %s",
- strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (status);
continue;
}
status = pthread_create (&th, &th_attr, us_handle_client, (void *) remote_fd);
if (status != 0)
{
+ char errbuf[1024];
WARNING ("unixsock plugin: pthread_create failed: %s",
- strerror (status));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
close (*remote_fd);
free (remote_fd);
continue;
status = pthread_create (&listen_thread, NULL, us_server_thread, NULL);
if (status != 0)
{
+ char errbuf[1024];
ERROR ("unixsock plugin: pthread_create failed: %s",
- strerror (status));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
struct tabmntent *mntlist;
if(listmntent(&mntlist, COLLECTD_MNTTAB, NULL, NULL) < 0) {
- DEBUG("calling listmntent() failed: %s", strerror(errno));
+ char errbuf[1024];
+ DEBUG("calling listmntent() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
}
for(p = mntlist; p; p = p->next) {
/* Get the number of mounted file systems */
if ((bufsize = CMD_STATFS (NULL, 0, FLAGS_STATFS)) < 1)
{
- DEBUG ("getv?fsstat failed: %s", strerror (errno));
+ char errbuf[1024];
+ DEBUG ("getv?fsstat failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (NULL);
}
* manpage.. -octo */
if ((num = CMD_STATFS (buf, bufsize * sizeof (STRUCT_STATFS), FLAGS_STATFS)) < 1)
{
- DEBUG ("getv?fsstat failed: %s", strerror (errno));
+ char errbuf[1024];
+ DEBUG ("getv?fsstat failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
free (buf);
return (NULL);
}
if ((fp = fopen (COLLECTD_MNTTAB, "r")) == NULL)
{
- ERROR ("fopen (%s): %s", COLLECTD_MNTTAB, strerror (errno));
+ char errbuf[1024];
+ ERROR ("fopen (%s): %s", COLLECTD_MNTTAB,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (NULL);
}
if ((fp = setmntent (COLLECTD_MNTTAB, "r")) == NULL)
{
- ERROR ("setmntent (%s): %s", COLLECTD_MNTTAB, strerror (errno));
+ char errbuf[1024];
+ ERROR ("setmntent (%s): %s", COLLECTD_MNTTAB,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (NULL);
}
DIR *proc;
struct dirent *dent; /* 42 */
- static complain_t complain_obj;
-
errno = 0;
if (NULL == (proc = opendir (PROCDIR)))
{
- plugin_complain (LOG_ERR, &complain_obj, "vserver plugin: "
- "fopen (%s) failed: %s", PROCDIR, strerror (errno));
+ char errbuf[1024];
+ ERROR ("vserver plugin: fopen (%s): %s", PROCDIR,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
- plugin_relief (LOG_NOTICE, &complain_obj, "vserver plugin: "
- "fopen (%s) succeeded.", PROCDIR);
while (NULL != (dent = readdir (proc)))
{
continue;
if (NULL == (fh = fopen (file, "r")))
- ERROR ("Cannot open '%s': %s", file, strerror (errno));
+ {
+ char errbuf[1024];
+ ERROR ("Cannot open '%s': %s", file,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
continue;
if (NULL == (fh = fopen (file, "r")))
- ERROR ("Cannot open '%s': %s", file, strerror (errno));
+ {
+ char errbuf[1024];
+ ERROR ("Cannot open '%s': %s", file,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh)))
{
continue;
if (NULL == (fh = fopen (file, "r")))
- ERROR ("Cannot open '%s': %s", file, strerror (errno));
+ {
+ char errbuf[1024];
+ ERROR ("Cannot open '%s': %s", file,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
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)
{
- WARNING ("wireless: fopen: %s", strerror (errno));
+ char errbuf[1024];
+ WARNING ("wireless: fopen: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}