projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
collectd.conf.in: Added the `df' and `email' plugins.
[collectd.git]
/
src
/
exec.c
diff --git
a/src/exec.c
b/src/exec.c
index
63401be
..
c7c7202
100644
(file)
--- a/
src/exec.c
+++ b/
src/exec.c
@@
-22,7
+22,6
@@
#include "collectd.h"
#include "common.h"
#include "plugin.h"
#include "collectd.h"
#include "common.h"
#include "plugin.h"
-#include "utils_debug.h"
#include <sys/types.h>
#include <pwd.h>
#include <sys/types.h>
#include <pwd.h>
@@
-129,7
+128,7
@@
static void submit_counter (const char *type_instance, counter_t value)
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- D
B
G ("type_instance = %s; value = %llu;", type_instance, value);
+ D
EBU
G ("type_instance = %s; value = %llu;", type_instance, value);
values[0].counter = value;
values[0].counter = value;
@@
-149,7
+148,7
@@
static void submit_gauge (const char *type_instance, gauge_t value)
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- D
B
G ("type_instance = %s; value = %lf;", type_instance, value);
+ D
EBU
G ("type_instance = %s; value = %lf;", type_instance, value);
values[0].gauge = value;
values[0].gauge = value;
@@
-173,31
+172,34
@@
static void exec_child (program_list_t *pl)
struct passwd *sp_ptr;
struct passwd sp;
char pwnambuf[2048];
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)
{
sp_ptr = NULL;
status = getpwnam_r (pl->user, &sp, pwnambuf, sizeof (pwnambuf), &sp_ptr);
if (status != 0)
{
- syslog (LOG_ERR, "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)
{
exit (-1);
}
if (sp_ptr == NULL)
{
-
syslog (LOG_ERR,
"exec plugin: No such user: `%s'", pl->user);
+
ERROR (
"exec plugin: No such user: `%s'", pl->user);
exit (-1);
}
uid = sp.pw_uid;
if (uid == 0)
{
exit (-1);
}
uid = sp.pw_uid;
if (uid == 0)
{
-
syslog (LOG_ERR,
"exec plugin: Cowardly refusing to exec program as root.");
+
ERROR (
"exec plugin: Cowardly refusing to exec program as root.");
exit (-1);
}
status = setuid (uid);
if (status != 0)
{
exit (-1);
}
status = setuid (uid);
if (status != 0)
{
- syslog (LOG_ERR, "exec plugin: setuid failed: %s", strerror (errno));
+ ERROR ("exec plugin: setuid failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
exit (-1);
}
@@
-209,7
+211,8
@@
static void exec_child (program_list_t *pl)
status = execlp (pl->exec, arg0, (char *) 0);
status = execlp (pl->exec, arg0, (char *) 0);
- syslog (LOG_ERR, "exec plugin: exec failed: %s", strerror (errno));
+ ERROR ("exec plugin: exec failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
} /* void exec_child */
exit (-1);
} /* void exec_child */
@@
-224,14
+227,18
@@
static int fork_child (program_list_t *pl)
status = pipe (fd_pipe);
if (status != 0)
{
status = pipe (fd_pipe);
if (status != 0)
{
- syslog (LOG_ERR, "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)
{
return (-1);
}
pl->pid = fork ();
if (pl->pid < 0)
{
- syslog (LOG_ERR, "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)
return (-1);
}
else if (pl->pid == 0)
@@
-270,8
+277,9
@@
static void *exec_read_one (void *arg)
fh = fdopen (fd, "r");
if (fh == NULL)
{
fh = fdopen (fd, "r");
if (fh == NULL)
{
- syslog (LOG_ERR, "exec plugin: fdopen (%i) failed: %s", fd,
- strerror (errno));
+ char errbuf[1024];
+ ERROR ("exec plugin: fdopen (%i) failed: %s", fd,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
kill (pl->pid, SIGTERM);
close (fd);
pthread_exit ((void *) 1);
kill (pl->pid, SIGTERM);
close (fd);
pthread_exit ((void *) 1);
@@
-284,7
+292,7
@@
static void *exec_read_one (void *arg)
char *type_instance;
char *value;
char *type_instance;
char *value;
- D
B
G ("buffer = %s", buffer);
+ D
EBU
G ("buffer = %s", buffer);
len = strlen (buffer);
if (len < 5)
len = strlen (buffer);
if (len < 5)
@@
-304,7
+312,7
@@
static void *exec_read_one (void *arg)
if ((strcasecmp ("counter", type) != 0)
&& (strcasecmp ("gauge", type) != 0))
{
if ((strcasecmp ("counter", type) != 0)
&& (strcasecmp ("gauge", type) != 0))
{
-
syslog (LOG_WARNING,
"exec plugin: Received invalid type: %s", type);
+
WARNING (
"exec plugin: Received invalid type: %s", type);
continue;
}
continue;
}
@@
-314,7
+322,7
@@
static void *exec_read_one (void *arg)
*value = '\0';
value++;
*value = '\0';
value++;
- D
B
G ("value = %s", value);
+ D
EBU
G ("value = %s", value);
if (strcasecmp ("counter", type) == 0)
submit_counter (type_instance, atoll (value));
if (strcasecmp ("counter", type) == 0)
submit_counter (type_instance, atoll (value));