author | Florian Forster <octo@noris.net> | |
Tue, 1 Apr 2008 13:05:45 +0000 (15:05 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Tue, 1 Apr 2008 13:05:45 +0000 (15:05 +0200) |
Conflicts:
configure.in
src/plugin.c
configure.in
src/plugin.c
configure.in | patch | blob | history | |
contrib/collection.cgi | patch | blob | history | |
src/apache.c | patch | blob | history | |
src/collectd.h | patch | blob | history | |
src/common.c | patch | blob | history | |
src/hddtemp.c | patch | blob | history | |
src/plugin.c | patch | blob | history | |
src/unixsock.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 952f5c5d12bfd1966c7ce81e17fcd77a0125f63e..766b6d6b554118ccd9311a9c80a05b1528c824c3 100644 (file)
--- a/configure.in
+++ b/configure.in
AC_HEADER_SYS_WAIT
AC_HEADER_DIRENT
-AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h)
+AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h)
# For ping library
AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
then
with_libcurl="no ($with_curl_config failed)"
else
- SAVE_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS $with_curl_cflags"
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_curl_cflags"
AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
- CFLAGS="$SAVE_CFLAGS"
+ CPPFLAGS="$SAVE_CPPFLAGS"
fi
fi
if test "x$with_libcurl" = "xyes"
then
with_libmysql="no"
else
- SAVE_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS $with_mysql_cflags"
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
- CFLAGS="$SAVE_CFLAGS"
+ CPPFLAGS="$SAVE_CPPFLAGS"
fi
fi
if test "x$with_libmysql" = "xyes"
then
with_libnetsnmp="no ($with_snmp_config failed)"
else
- SAVE_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS $with_snmp_cflags"
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
- CFLAGS="$SAVE_CFLAGS"
+ CPPFLAGS="$SAVE_CPPFLAGS"
fi
fi
if test "x$with_libnetsnmp" = "xyes"
fi
if test "x$with_libupsclient" = "xyes"
then
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $with_upsclient_cflags"
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_upsclient_cflags"
AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
- CFLAGS="$SAVE_CFLAGS"
+ CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libupsclient" = "xyes"
then
fi
if test "x$with_libupsclient" = "xyes"
then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_upsclient_cflags"
+
AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
[#include <stdlib.h>
#include <stdio.h>
#include <upsclient.h>])
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
fi
AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
diff --git a/contrib/collection.cgi b/contrib/collection.cgi
index 7da7e1c62f857a8bd9d1be956e51ff102d6da64e..e82388b0d79ab405b43587e3e880841486404743 100755 (executable)
--- a/contrib/collection.cgi
+++ b/contrib/collection.cgi
return ([$r, $g, $b]);
} # _get_random_color
+sub _get_n_colors
+{
+ my $instances = shift;
+ my $num = scalar @$instances;
+ my $ret = {};
+
+ for (my $i = 0; $i < $num; $i++)
+ {
+ my $pos = 6 * $i / $num;
+ my $n = int ($pos);
+ my $p = $pos - $n;
+ my $q = 1 - $p;
+
+ my $red = 0;
+ my $green = 0;
+ my $blue = 0;
+
+ my $color;
+
+ if ($n == 0)
+ {
+ $red = 255;
+ $blue = 255 * $p;
+ }
+ elsif ($n == 1)
+ {
+ $red = 255 * $q;
+ $blue = 255;
+ }
+ elsif ($n == 2)
+ {
+ $green = 255 * $p;
+ $blue = 255;
+ }
+ elsif ($n == 3)
+ {
+ $green = 255;
+ $blue = 255 * $q;
+ }
+ elsif ($n == 4)
+ {
+ $red = 255 * $p;
+ $green = 255;
+ }
+ elsif ($n == 5)
+ {
+ $red = 255;
+ $green = 255 * $q;
+ }
+ else { die; }
+
+ $color = sprintf ("%02x%02x%02x", $red, $green, $blue);
+ $ret->{$instances->[$i]} = $color;
+ }
+
+ return ($ret);
+} # _get_n_colors
+
sub _get_faded_color
{
my $fg = shift;
'GPRINT:inc_max:MAX:%5.1lf%ss Max,',
'GPRINT:inc_avg:LAST:%5.1lf%ss Last\l'
],
- dns_traffic => ['DEF:rsp_min_raw={file}:responses:MIN',
+ dns_octets => ['DEF:rsp_min_raw={file}:responses:MIN',
'DEF:rsp_avg_raw={file}:responses:AVERAGE',
'DEF:rsp_max_raw={file}:responses:MAX',
'DEF:qry_min_raw={file}:queries:MIN',
'GPRINT:qry_avg:LAST:%5.1lf%s Last',
'GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
],
+ dns_opcode => [
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
+ "AREA:max#$HalfBlue",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullBlue:Queries/s",
+ 'GPRINT:min:MIN:%9.3lf Min,',
+ 'GPRINT:avg:AVERAGE:%9.3lf Average,',
+ 'GPRINT:max:MAX:%9.3lf Max,',
+ 'GPRINT:avg:LAST:%9.3lf Last\l'
+ ],
email_count => ['-v', 'Mails',
'DEF:avg={file}:value:AVERAGE',
'DEF:min={file}:value:MIN',
'GPRINT:read_avg:AVERAGE:%5.1lf Avg,',
'GPRINT:read_avg:LAST:%5.1lf Last\l'
],
- opcode => [
- 'DEF:avg={file}:value:AVERAGE',
- 'DEF:min={file}:value:MIN',
- 'DEF:max={file}:value:MAX',
- "AREA:max#$HalfBlue",
- "AREA:min#$Canvas",
- "LINE1:avg#$FullBlue:Queries/s",
- 'GPRINT:min:MIN:%9.3lf Min,',
- 'GPRINT:avg:AVERAGE:%9.3lf Average,',
- 'GPRINT:max:MAX:%9.3lf Max,',
- 'GPRINT:avg:LAST:%9.3lf Last\l'
- ],
partition => [
"DEF:rbyte_avg={file}:rbytes:AVERAGE",
"DEF:rbyte_min={file}:rbytes:MIN",
'GPRINT:max:MAX:%6.2lf Max,',
'GPRINT:avg:LAST:%6.2lf Last\l'
],
- qtype => [
+ signal_noise => ['-v', 'dBm',
'DEF:avg={file}:value:AVERAGE',
'DEF:min={file}:value:MIN',
'DEF:max={file}:value:MAX',
"AREA:max#$HalfBlue",
"AREA:min#$Canvas",
- "LINE1:avg#$FullBlue:Queries/s",
- 'GPRINT:min:MIN:%9.3lf Min,',
- 'GPRINT:avg:AVERAGE:%9.3lf Average,',
- 'GPRINT:max:MAX:%9.3lf Max,',
- 'GPRINT:avg:LAST:%9.3lf Last\l'
+ "LINE1:avg#$FullBlue:Noise",
+ 'GPRINT:min:MIN:%5.1lf%sdBm Min,',
+ 'GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,',
+ 'GPRINT:max:MAX:%5.1lf%sdBm Max,',
+ 'GPRINT:avg:LAST:%5.1lf%sdBm Last\l'
],
- rcode => [
+ signal_power => ['-v', 'dBm',
'DEF:avg={file}:value:AVERAGE',
'DEF:min={file}:value:MIN',
'DEF:max={file}:value:MAX',
"AREA:max#$HalfBlue",
"AREA:min#$Canvas",
- "LINE1:avg#$FullBlue:Queries/s",
- 'GPRINT:min:MIN:%9.3lf Min,',
- 'GPRINT:avg:AVERAGE:%9.3lf Average,',
- 'GPRINT:max:MAX:%9.3lf Max,',
- 'GPRINT:avg:LAST:%9.3lf Last\l'
+ "LINE1:avg#$FullBlue:Power",
+ 'GPRINT:min:MIN:%5.1lf%sdBm Min,',
+ 'GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,',
+ 'GPRINT:max:MAX:%5.1lf%sdBm Max,',
+ 'GPRINT:avg:LAST:%5.1lf%sdBm Last\l'
+ ],
+ signal_quality => ['-v', '%',
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
+ "AREA:max#$HalfBlue",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullBlue:Quality",
+ 'GPRINT:min:MIN:%5.1lf%s%% Min,',
+ 'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
+ 'GPRINT:max:MAX:%5.1lf%s%% Max,',
+ 'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
],
swap => ['-v', 'Bytes', '-b', '1024',
'DEF:avg={file}:value:AVERAGE',
};
$GraphDefs->{'if_multicast'} = $GraphDefs->{'ipt_packets'};
$GraphDefs->{'if_tx_errors'} = $GraphDefs->{'if_rx_errors'};
+ $GraphDefs->{'dns_qtype'} = $GraphDefs->{'dns_opcode'};
+ $GraphDefs->{'dns_rcode'} = $GraphDefs->{'dns_opcode'};
$MetaGraphDefs->{'cpu'} = \&meta_graph_cpu;
+ $MetaGraphDefs->{'dns_qtype'} = \&meta_graph_dns;
+ $MetaGraphDefs->{'dns_rcode'} = \&meta_graph_dns;
$MetaGraphDefs->{'if_rx_errors'} = \&meta_graph_if_rx_errors;
$MetaGraphDefs->{'if_tx_errors'} = \&meta_graph_if_rx_errors;
$MetaGraphDefs->{'memory'} = \&meta_graph_memory;
@RRDDefaultArgs, @{$opts->{'rrd_opts'}});
my $max_inst_name = 0;
+ my @vnames = ();
+
+ for ($i = 0; $i < @$sources; $i++)
+ {
+ my $tmp = $sources->[$i]->{'name'};
+ $tmp =~ tr/A-Za-z0-9\-_/_/c;
+ $vnames[$i] = $i . $tmp;
+ }
for ($i = 0; $i < @$sources; $i++)
{
my $inst_data = $sources->[$i];
my $inst_name = $inst_data->{'name'} || confess;
my $file = $inst_data->{'file'} || confess;
+ my $vname = $vnames[$i];
if (length ($inst_name) > $max_inst_name)
{
confess ("No such file: $file") if (!-e $file);
push (@cmd,
- qq#DEF:${inst_name}_min=$file:value:MIN#,
- qq#DEF:${inst_name}_avg=$file:value:AVERAGE#,
- qq#DEF:${inst_name}_max=$file:value:MAX#,
- qq#CDEF:${inst_name}_nnl=${inst_name}_avg,UN,0,${inst_name}_avg,IF#);
+ qq#DEF:${vname}_min=$file:value:MIN#,
+ qq#DEF:${vname}_avg=$file:value:AVERAGE#,
+ qq#DEF:${vname}_max=$file:value:MAX#,
+ qq#CDEF:${vname}_nnl=${vname}_avg,UN,0,${vname}_avg,IF#);
}
{
- my $inst_data = $sources->[@$sources - 1];
- my $inst_name = $inst_data->{'name'};
+ my $vname = $vnames[@vnames - 1];
- push (@cmd, qq#CDEF:${inst_name}_stk=${inst_name}_nnl#);
+ push (@cmd, qq#CDEF:${vname}_stk=${vname}_nnl#);
}
for (my $i = 1; $i < @$sources; $i++)
{
- my $inst_data0 = $sources->[@$sources - ($i + 1)];
- my $inst_data1 = $sources->[@$sources - $i];
+ my $vname0 = $vnames[@vnames - ($i + 1)];
+ my $vname1 = $vnames[@vnames - $i];
- my $inst_name0 = $inst_data0->{'name'};
- my $inst_name1 = $inst_data1->{'name'};
-
- push (@cmd, qq#CDEF:${inst_name0}_stk=${inst_name0}_nnl,${inst_name1}_stk,+#);
+ push (@cmd, qq#CDEF:${vname0}_stk=${vname0}_nnl,${vname1}_stk,+#);
}
for (my $i = 0; $i < @$sources; $i++)
my $inst_data = $sources->[$i];
my $inst_name = $inst_data->{'name'};
+ my $vname = $vnames[$i];
+
my $legend = sprintf ('%-*s', $max_inst_name, $inst_name);
my $line_color;
}
$area_color = _color_to_string (_get_faded_color ($area_color));
- push (@cmd, qq(AREA:${inst_name}_stk#$area_color),
- qq(LINE1:${inst_name}_stk#$line_color:$legend),
- qq(GPRINT:${inst_name}_min:MIN:$number_format Min,),
- qq(GPRINT:${inst_name}_avg:AVERAGE:$number_format Avg,),
- qq(GPRINT:${inst_name}_max:MAX:$number_format Max,),
- qq(GPRINT:${inst_name}_avg:LAST:$number_format Last\\l),
+ push (@cmd, qq(AREA:${vname}_stk#$area_color),
+ qq(LINE1:${vname}_stk#$line_color:$legend),
+ qq(GPRINT:${vname}_min:MIN:$number_format Min,),
+ qq(GPRINT:${vname}_avg:AVERAGE:$number_format Avg,),
+ qq(GPRINT:${vname}_max:MAX:$number_format Max,),
+ qq(GPRINT:${vname}_avg:LAST:$number_format Last\\l),
);
}
return (meta_graph_generic_stack ($opts, $sources));
} # meta_graph_cpu
+sub meta_graph_dns
+{
+ confess ("Wrong number of arguments") if (@_ != 5);
+
+ my $host = shift;
+ my $plugin = shift;
+ my $plugin_instance = shift;
+ my $type = shift;
+ my $type_instances = shift;
+
+ my $opts = {};
+ my $sources = [];
+
+ $opts->{'title'} = "$host/$plugin"
+ . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
+
+ $opts->{'rrd_opts'} = ['-v', 'Queries/s'];
+
+ my @files = ();
+
+ @$type_instances = sort @$type_instances;
+
+ $opts->{'colors'} = _get_n_colors ($type_instances);
+
+ for (@$type_instances)
+ {
+ my $inst = $_;
+ my $file = '';
+ my $title = $opts->{'title'};
+
+ for (@DataDirs)
+ {
+ if (-e "$_/$title-$inst.rrd")
+ {
+ $file = "$_/$title-$inst.rrd";
+ last;
+ }
+ }
+ confess ("No file found for $title") if ($file eq '');
+
+ push (@$sources,
+ {
+ name => $inst,
+ file => $file
+ }
+ );
+ } # for (@$type_instances)
+
+ return (meta_graph_generic_stack ($opts, $sources));
+} # meta_graph_dns
+
sub meta_graph_memory
{
confess ("Wrong number of arguments") if (@_ != 5);
} # for (@$type_instances)
return (meta_graph_generic_stack ($opts, $sources));
-} # meta_graph_cpu
+} # meta_graph_memory
sub meta_graph_if_rx_errors
{
diff --git a/src/apache.c b/src/apache.c
index 280c687feebd79dcbb5c36ed80bce50d3c4ae844..2a7e0b80cc41ef0e0bf912dab58895bb88b8ee56 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
static CURL *curl = NULL;
-#define ABUFFER_SIZE 16384
-static char apache_buffer[ABUFFER_SIZE];
-static int apache_buffer_len = 0;
-static char apache_curl_error[CURL_ERROR_SIZE];
+static char *apache_buffer = NULL;
+static size_t apache_buffer_size = 0;
+static size_t apache_buffer_fill = 0;
+static char apache_curl_error[CURL_ERROR_SIZE];
static const char *config_keys[] =
{
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
-static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, void *stream)
+static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb,
+ void *stream)
{
size_t len = size * nmemb;
- if ((apache_buffer_len + len) >= ABUFFER_SIZE)
- {
- len = (ABUFFER_SIZE - 1) - apache_buffer_len;
- }
-
if (len <= 0)
return (len);
- memcpy (apache_buffer + apache_buffer_len, (char *) buf, len);
- apache_buffer_len += len;
- apache_buffer[apache_buffer_len] = '\0';
+ if ((apache_buffer_fill + len) >= apache_buffer_size)
+ {
+ char *temp;
+
+ temp = (char *) realloc (apache_buffer,
+ apache_buffer_fill + len + 1);
+ if (temp == NULL)
+ {
+ ERROR ("apache plugin: realloc failed.");
+ return (0);
+ }
+ apache_buffer = temp;
+ apache_buffer_size = apache_buffer_fill + len + 1;
+ }
+
+ memcpy (apache_buffer + apache_buffer_fill, (char *) buf, len);
+ apache_buffer_fill += len;
+ apache_buffer[apache_buffer_fill] = 0;
return (len);
}
if (url == NULL)
return (-1);
- apache_buffer_len = 0;
+ apache_buffer_fill = 0;
if (curl_easy_perform (curl) != 0)
{
ERROR ("apache: curl_easy_perform failed: %s",
}
}
- apache_buffer_len = 0;
+ apache_buffer_fill = 0;
return (0);
} /* int apache_read */
diff --git a/src/collectd.h b/src/collectd.h
index 9951d8a91013d929bc831a4e40ad49b9bce08893..59dc5d20a10e5e1d02b288c200f81925b44fe204 100644 (file)
--- a/src/collectd.h
+++ b/src/collectd.h
# endif /* !defined(isnan) */
#endif /* NAN_ZERO_ZERO */
+#if HAVE_ENDIAN_H
+# include <endian.h>
+#endif
+
+#ifndef BYTE_ORDER
+# ifdef __BYTE_ORDER
+# define BYTE_ORDER __BYTE_ORDER
+# endif
+#endif
+#ifndef BIG_ENDIAN
+# ifdef __BIG_ENDIAN
+# define BIG_ENDIAN __BIG_ENDIAN
+# endif
+#endif
+#if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN)
+# error "Cannot determine byte order"
+#endif
+
#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
diff --git a/src/common.c b/src/common.c
index a2c4794d6d4642dfd2da75eef7747e87849904ca..5c3db5ddacb53677d83e4d519f8b0c7331852449 100644 (file)
--- a/src/common.c
+++ b/src/common.c
# include "config.h"
#endif
+#include "collectd.h"
#include "common.h"
#include "plugin.h"
unsigned long long ntohll (unsigned long long n)
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
return (n);
#else
return (((unsigned long long) ntohl (n)) << 32) + ntohl (n >> 32);
unsigned long long htonll (unsigned long long n)
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
return (n);
#else
return (((unsigned long long) htonl (n)) << 32) + htonl (n >> 32);
diff --git a/src/hddtemp.c b/src/hddtemp.c
index 651de298877a3c9848f05e17d79ea7a67e34ebaa..36ada53c4b2b673375e9a7982f3b62dd7dff383b 100644 (file)
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
char errbuf[1024];
- ERROR ("hddtemp: getaddrinfo (%s, %s): %s",
+ ERROR ("hddtemp plugin: getaddrinfo (%s, %s): %s",
host, port,
(ai_return == EAI_SYSTEM)
? sstrerror (errno, errbuf, sizeof (errbuf))
for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
{
/* create our socket descriptor */
- if ((fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol)) < 0)
+ fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype,
+ ai_ptr->ai_protocol);
+ if (fd < 0)
{
char errbuf[1024];
- ERROR ("hddtemp: socket: %s",
+ ERROR ("hddtemp plugin: socket: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
/* connect to the hddtemp daemon */
- if (connect (fd, (struct sockaddr *) ai_ptr->ai_addr, ai_ptr->ai_addrlen))
+ if (connect (fd, (struct sockaddr *) ai_ptr->ai_addr,
+ ai_ptr->ai_addrlen))
{
char errbuf[1024];
- INFO ("hddtemp: connect (%s, %s): %s", host, port,
+ INFO ("hddtemp plugin: connect (%s, %s) failed: %s",
+ host, port,
sstrerror (errno, errbuf, sizeof (errbuf)));
close (fd);
fd = -1;
if (fd < 0)
{
- ERROR ("hddtemp: Could not connect to daemon.");
+ ERROR ("hddtemp plugin: Could not connect to daemon.");
return (-1);
}
if ((errno == EAGAIN) || (errno == EINTR))
continue;
- ERROR ("hddtemp: Error reading from socket: %s",
+ ERROR ("hddtemp plugin: Error reading from socket: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
close (fd);
return (-1);
if (buffer_fill >= buffer_size)
{
buffer[buffer_size - 1] = '\0';
- WARNING ("hddtemp: Message from hddtemp has been truncated.");
+ WARNING ("hddtemp plugin: Message from hddtemp has been "
+ "truncated.");
}
else if (buffer_fill == 0)
{
- WARNING ("hddtemp: Peer has unexpectedly shut down the socket. "
- "Buffer: `%s'", buffer);
+ WARNING ("hddtemp plugin: Peer has unexpectedly shut down "
+ "the socket. Buffer: `%s'", buffer);
close (fd);
return (-1);
}
if ((fh = fopen ("/proc/partitions", "r")) != NULL)
{
- DEBUG ("Looking at /proc/partitions...");
+ DEBUG ("hddtemp plugin: Looking at /proc/partitions...");
while (fgets (buf, sizeof (buf), fh) != NULL)
{
/* Skip all other majors. */
default:
- DEBUG ("Skipping unknown major %i", major);
+ DEBUG ("hddtemp plugin: Skipping unknown major %i", major);
continue;
} /* switch (major) */
if ((name = strdup (fields[3])) == NULL)
{
- ERROR ("hddtemp: strdup(%s) == NULL", fields[3]);
+ ERROR ("hddtemp plugin: strdup(%s) == NULL", fields[3]);
continue;
}
if ((entry = (hddname_t *) malloc (sizeof (hddname_t))) == NULL)
{
- ERROR ("hddtemp: malloc (%u) == NULL",
+ ERROR ("hddtemp plugin: malloc (%u) == NULL",
(unsigned int) sizeof (hddname_t));
free (name);
continue;
}
- DEBUG ("Found disk: %s (%u:%u).", name, major, minor);
+ DEBUG ("hddtemp plugin: Found disk: %s (%u:%u).", name, major, minor);
entry->major = major;
entry->minor = minor;
else
{
char errbuf[1024];
- DEBUG ("Could not open /proc/partitions: %s",
+ DEBUG ("hddtemp plugin: Could not open /proc/partitions: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
}
#endif /* COLLECT_DEBUG */
if (list == NULL)
{
- DEBUG ("Don't know %s, keeping name as-is.", drive);
+ DEBUG ("hddtemp plugin: Don't know %s, keeping name as-is.", drive);
return (strdup (drive));
}
diff --git a/src/plugin.c b/src/plugin.c
index 0570f0ee0dc37269ce66fb724fe7f6abd64ac7dc..8b2803dfa49b345b95d4da9f586740e6105af69a 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
{
DIR *dh;
const char *dir;
- char filename[BUFSIZE];
+ char filename[BUFSIZE] = "";
char typename[BUFSIZE];
int typename_len;
int ret;
closedir (dh);
+ if (filename[0] == '\0')
+ fprintf (stderr, "Could not find plugin %s.\n", type);
+
return (ret);
}
data_set_t *ds;
llentry_t *le;
- if ((list_write == NULL) || (data_sets == NULL))
+ if (list_write == NULL)
+ {
+ ERROR ("plugin_dispatch_values: No write callback has been "
+ "registered. Please load at least one plugin "
+ "that provides a write function.");
return (-1);
+ }
+
+ if (data_sets == NULL)
+ {
+ ERROR ("plugin_dispatch_values: No data sets registered. "
+ "Could the types database be read? Check "
+ "your `TypesDB' setting!");
+ return (-1);
+ }
if (c_avl_get (data_sets, name, (void *) &ds) != 0)
{
- DEBUG ("No such dataset registered: %s", name);
+ INFO ("plugin_dispatch_values: Dataset not found: %s", name);
return (-1);
}
- DEBUG ("plugin: plugin_dispatch_values: time = %u; interval = %i; "
+ DEBUG ("plugin_dispatch_values: time = %u; interval = %i; "
"host = %s; "
"plugin = %s; plugin_instance = %s; "
"type = %s; type_instance = %s;",
#else
if (ds->ds_num != vl->values_len)
{
- ERROR ("plugin: ds->type = %s: (ds->ds_num = %i) != "
+ ERROR ("plugin_dispatch_values: ds->type = %s: "
+ "(ds->ds_num = %i) != "
"(vl->values_len = %i)",
ds->type, ds->ds_num, vl->values_len);
return (-1);
diff --git a/src/unixsock.c b/src/unixsock.c
index 9fa0259685c39c90799b9963fde732dd57783605..45ed9c699b783fa9e9e10a4dfd482a594e59d1a4 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
}
plugin_unregister_init ("unixsock");
- plugin_unregister_write ("unixsock");
plugin_unregister_shutdown ("unixsock");
return (0);