HTML
}
+sub contains_invalid_chars
+{
+ my $str = shift;
+
+ for (split (m//, $str))
+ {
+ my $n = ord ($_);
+
+ # Whitespace is allowed.
+ if (($n >= 9) && ($n <= 13))
+ {
+ next;
+ }
+ elsif ($n < 32)
+ {
+ return (1);
+ }
+ }
+
+ return;
+}
+
sub show_selector
{
my $timespan_selection = get_timespan_selection ();
HTML
for (sort (keys %$host_selection))
{
+ next if contains_invalid_chars ($_);
my $host = encode_entities ($_);
my $selected = $host_selection->{$_}
? ' selected="selected"'
HTML
for (sort (keys %$plugin_selection))
{
+ next if contains_invalid_chars ($_);
my $plugin = encode_entities ($_);
my $selected = $plugin_selection->{$_}
? ' selected="selected"'
HTML
for (sort { $TimeSpans->{$a} <=> $TimeSpans->{$b} } (keys (%$TimeSpans)))
{
+ next if contains_invalid_chars ($_);
my $name = encode_entities ($_);
my $value = $TimeSpans->{$_};
my $selected = ($value == $timespan_selection)
for (sort @hosts)
{
my $url = encode_entities (script_name () . "?action=show_selection;hostname=$_");
+ next if contains_invalid_chars ($_);
my $name = encode_entities ($_);
print qq# <li><a href="$url">$name</a></li>\n#;
}
my $obj = Collectd::Graph::Type->new (@_);
$obj->{'data_sources'} = [qw(free used)];
$obj->{'rrd_opts'} = ['-v', 'Bytes'];
- $obj->{'rrd_title'} = 'Disk space ({type_instance})';
+ $obj->{'rrd_title'} = 'Disk space ({instance})';
$obj->{'rrd_format'} = '%5.1lf%sB';
$obj->{'colors'} = [qw(00b000 ff0000)];
my $faded_green = get_faded_color ('00ff00');
my $faded_red = get_faded_color ('ff0000');
- return (['-t', 'Diskspace (' . $ident->{'type_instance'} . ')', '-v', 'Bytes', '-l', '0',
+ return (['-t', $obj->getTitle ($ident), '-v', 'Bytes', '-l', '0',
"DEF:free_min=${filename}:free:MIN",
"DEF:free_avg=${filename}:free:AVERAGE",
"DEF:free_max=${filename}:free:MAX",
collectd_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL)
collectd_CFLAGS = $(AM_CFLAGS)
collectd_LDFLAGS = -export-dynamic
-collectd_LDADD =
+collectd_LDADD = -lm
collectd_DEPENDENCIES =
# Link to these libraries..
endif
if BUILD_AIX
collectd_LDFLAGS += -Wl,-bexpall,-brtllib
-collectd_LDADD += -lm
endif
# The daemon needs to call sg_init, so we need to link it against libstatgrab,
static int change_basedir (const char *orig_dir)
{
- char *dir = strdup (orig_dir);
- int dirlen;
+ char *dir;
+ size_t dirlen;
int status;
+ dir = strdup (orig_dir);
if (dir == NULL)
{
char errbuf[1024];
return (-1);
status = chdir (dir);
- free (dir);
+ if (status == 0)
+ {
+ free (dir);
+ return (0);
+ }
+ else if (errno != ENOENT)
+ {
+ char errbuf[1024];
+ ERROR ("change_basedir: chdir (%s): %s", dir,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ free (dir);
+ return (-1);
+ }
+ status = mkdir (dir, S_IRWXU | S_IRWXG | S_IRWXO);
if (status != 0)
{
- if (errno == ENOENT)
- {
- if (mkdir (orig_dir, 0755) == -1)
- {
- char errbuf[1024];
- ERROR ("change_basedir: mkdir (%s): %s", orig_dir,
- sstrerror (errno, errbuf,
- sizeof (errbuf)));
- return (-1);
- }
- else if (chdir (orig_dir) == -1)
- {
- char errbuf[1024];
- ERROR ("chdir (%s): %s", orig_dir,
- sstrerror (errno, errbuf,
- sizeof (errbuf)));
- return (-1);
- }
- }
- else
- {
- char errbuf[1024];
- ERROR ("chdir (%s): %s", orig_dir,
- sstrerror (errno, errbuf,
- sizeof (errbuf)));
- return (-1);
- }
+ char errbuf[1024];
+ ERROR ("change_basedir: mkdir (%s): %s", dir,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ 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)));
+ free (dir);
+ return (-1);
}
+ free (dir);
return (0);
} /* static int change_basedir (char *dir) */
behavior.
The syntax of this config file is similar to the config file of the famous
-B<Apache Webserver>. Each line contains either a key-value-pair or a
-section-start or -end. Empty lines and everything after the hash-symbol `#' is
-ignored. Values are either string, enclosed in double-quotes,
-(floating-point-)numbers or a boolean expression, i.E<nbsp>e. either B<true> or
-B<false>. String containing of only alphanumeric characters and underscores do
-not need to be quoted. Lines may be wrapped by using `\' as the last character
-before the newline. This allows long lines to be split into multiple lines.
-Quoted strings may be wrapped as well. However, those are treated special in
-that whitespace at the beginning of the following lines will be ignored, which
-allows for nicely indenting the wrapped lines.
-
-The configuration is read and processed in order, i.E<nbsp>e. from top to
-bottom. So the plugins are loaded in the order listed in this config file. It
-is a good idea to load any logging plugins first in order to catch messages
-from plugins during configuration. Also, the C<LoadPlugin> option B<must> occur
-B<before> the C<E<lt>Plugin ...E<gt>> block.
+I<Apache> webserver. Each line contains either an option (a key and a list of
+one or more values) or a section-start or -end. Empty lines and everything
+after a non-quoted hash-symbol (C<#>) is ignored. I<Keys> are unquoted
+strings, consisting only of alphanumeric characters and the underscore (C<_>)
+character. Keys are handled case insensitive by I<collectd> itself and all
+plugins included with it. I<Values> can either be an I<unquoted string>, a
+I<quoted string> (enclosed in double-quotes) a I<number> or a I<boolean>
+expression. I<Unquoted strings> consist of only alphanumeric characters and
+underscores (C<_>) and do not need to be quoted. I<Quoted strings> are
+enclosed in double quotes (C<">). You can use the backslash character (C<\>)
+to include double quotes as part of the string. I<Numbers> can be specified in
+decimal and floating point format (using a dot C<.> as decimal separator),
+hexadecimal when using the C<0x> prefix and octal with a leading zero (C<0>).
+I<Boolean> values are either B<true> or B<false>.
+
+Lines may be wrapped by using C<\> as the last character before the newline.
+This allows long lines to be split into multiple lines. Quoted strings may be
+wrapped as well. However, those are treated special in that whitespace at the
+beginning of the following lines will be ignored, which allows for nicely
+indenting the wrapped lines.
+
+The configuration is read and processed in order, i.e. from top to bottom. So
+the plugins are loaded in the order listed in this config file. It is a good
+idea to load any logging plugins first in order to catch messages from plugins
+during configuration. Also, the C<LoadPlugin> option B<must> occur B<before>
+the appropriate C<E<lt>Plugin ...E<gt>> block.
=head1 GLOBAL OPTIONS
{
if (errno == ENOENT)
{
- if (mkdir (dir, 0755) == 0)
+ if (mkdir (dir, S_IRWXU | S_IRWXG | S_IRWXO) == 0)
break;
/* this might happen, if a different thread created
{
if (strcmp (mnt_ptr->dir, "/") == 0)
{
+ if (strcmp (mnt_ptr->type, "rootfs") == 0)
+ continue;
sstrncpy (disk_name, "root", sizeof (disk_name));
}
else
if (strcasecmp ("Server", child->key) == 0)
status = cmc_config_add_string ("Server", &page->server, child);
- if (strcasecmp ("Key", child->key) == 0)
+ else if (strcasecmp ("Key", child->key) == 0)
status = cmc_config_add_string ("Key", &page->key, child);
else if (strcasecmp ("Match", child->key) == 0)
/* Be liberal with failing matches => don't set `status'. */
/**
* collectd - src/netapp.c
- * Copyright (C) 2009 Sven Trenkel
+ * Copyright (C) 2009,2010 Sven Trenkel
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
na_server_adminuser(host->srv, host->username, host->password);
na_server_set_timeout(host->srv, 5 /* seconds */);
- return 0;
+ return (0);
} /* }}} int cna_init_host */
static int cna_init (void) /* {{{ */
return (0);
} /* }}} cna_init */
+static int cna_read_internal (host_config_t *host) { /* {{{ */
+ int status;
+
+ status = cna_query_wafl (host);
+ if (status != 0)
+ return (status);
+
+ status = cna_query_disk (host);
+ if (status != 0)
+ return (status);
+
+ status = cna_query_volume_perf (host);
+ if (status != 0)
+ return (status);
+
+ status = cna_query_volume_usage (host);
+ if (status != 0)
+ return (status);
+
+ status = cna_query_system (host);
+ if (status != 0)
+ return (status);
+
+ return 0;
+} /* }}} int cna_read_internal */
+
static int cna_read (user_data_t *ud) { /* {{{ */
host_config_t *host;
int status;
status = cna_init_host (host);
if (status != 0)
return (status);
-
- cna_query_wafl (host);
- cna_query_disk (host);
- cna_query_volume_perf (host);
- cna_query_volume_usage (host);
- cna_query_system (host);
+
+ status = cna_read_internal (host);
+ if (status != 0)
+ {
+ if (host->srv != NULL)
+ na_server_close (host->srv);
+ host->srv = NULL;
+ }
return 0;
} /* }}} int cna_read */
* Functions
*/
static void o_report_error (const char *where, /* {{{ */
+ const char *db_name, const char *query_name,
const char *what, OCIError *eh)
{
char buffer[2048];
int status;
unsigned int record_number;
+ if (db_name == NULL)
+ db_name = "(none)";
+ if (query_name == NULL)
+ query_name = "(none)";
+
/* An operation may cause / return multiple errors. Loop until we have
* handled all errors available (with a fail-save limit of 16). */
for (record_number = 1; record_number <= 16; record_number++)
buffer[buffer_length] = 0;
}
- ERROR ("oracle plugin: %s: %s failed: %s", where, what, buffer);
+ ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed: %s",
+ where, db_name, query_name, what, buffer);
}
else
{
- ERROR ("oracle plugin: %s: %s failed. Additionally, OCIErrorGet failed with status %i.",
- where, what, status);
+ ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed. "
+ "Additionally, OCIErrorGet failed with status %i.",
+ where, db_name, query_name, what, status);
return;
}
}
OCI_HTYPE_STMT, /* user_data_size = */ 0, /* user_data = */ NULL);
if (status != OCI_SUCCESS)
{
- o_report_error ("o_read_database_query", "OCIHandleAlloc", oci_error);
+ o_report_error ("o_read_database_query", db->name,
+ udb_query_get_name (q), "OCIHandleAlloc", oci_error);
oci_statement = NULL;
return (-1);
}
/* mode = */ OCI_DEFAULT);
if (status != OCI_SUCCESS)
{
- o_report_error ("o_read_database_query", "OCIStmtPrepare", oci_error);
+ o_report_error ("o_read_database_query", db->name,
+ udb_query_get_name (q), "OCIStmtPrepare", oci_error);
OCIHandleFree (oci_statement, OCI_HTYPE_STMT);
oci_statement = NULL;
return (-1);
/* mode = */ OCI_DEFAULT);
if (status != OCI_SUCCESS)
{
- DEBUG ("oracle plugin: o_read_database_query: status = %i (%#x)", status, status);
- o_report_error ("o_read_database_query", "OCIStmtExecute", oci_error);
- ERROR ("oracle plugin: o_read_database_query: "
- "Failing statement was: %s", udb_query_get_statement (q));
+ o_report_error ("o_read_database_query", db->name, udb_query_get_name (q),
+ "OCIStmtExecute", oci_error);
return (-1);
} /* }}} */
OCI_ATTR_PARAM_COUNT, oci_error);
if (status != OCI_SUCCESS)
{
- o_report_error ("o_read_database_query", "OCIAttrGet", oci_error);
+ o_report_error ("o_read_database_query", db->name,
+ udb_query_get_name (q), "OCIAttrGet", oci_error);
return (-1);
} /* }}} */
if (status != OCI_SUCCESS)
{
/* This is probably alright */
- DEBUG ("oracle plugin: o_read_database_query: status = %#x (= %i);", status, status);
- o_report_error ("o_read_database_query", "OCIParamGet", oci_error);
+ DEBUG ("oracle plugin: o_read_database_query: status = %#x (= %i);",
+ status, status);
+ o_report_error ("o_read_database_query", db->name,
+ udb_query_get_name (q), "OCIParamGet", oci_error);
status = OCI_SUCCESS;
break;
}
if (status != OCI_SUCCESS)
{
OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM);
- o_report_error ("o_read_database_query", "OCIAttrGet (OCI_ATTR_NAME)",
- oci_error);
+ o_report_error ("o_read_database_query", db->name,
+ udb_query_get_name (q), "OCIAttrGet (OCI_ATTR_NAME)", oci_error);
continue;
}
NULL, NULL, NULL, OCI_DEFAULT);
if (status != OCI_SUCCESS)
{
- o_report_error ("o_read_database_query", "OCIDefineByPos", oci_error);
+ o_report_error ("o_read_database_query", db->name,
+ udb_query_get_name (q), "OCIDefineByPos", oci_error);
continue;
}
} /* for (j = 1; j <= param_counter; j++) */
}
else if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO))
{
- o_report_error ("o_read_database_query", "OCIStmtFetch2", oci_error);
+ o_report_error ("o_read_database_query", db->name,
+ udb_query_get_name (q), "OCIStmtFetch2", oci_error);
break;
}
OCI_ATTR_SERVER, oci_error);
if (status != OCI_SUCCESS)
{
- o_report_error ("o_read_database", "OCIAttrGet", oci_error);
+ o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet",
+ oci_error);
return (-1);
}
OCI_ATTR_SERVER_STATUS, oci_error);
if (status != OCI_SUCCESS)
{
- o_report_error ("o_read_database", "OCIAttrGet", oci_error);
+ o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet",
+ oci_error);
return (-1);
}
}
(OraText *) db->connect_id, (ub4) strlen (db->connect_id));
if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO))
{
- o_report_error ("o_read_database", "OCILogon", oci_error);
+ char errfunc[256];
+
+ ssnprintf (errfunc, sizeof (errfunc), "OCILogon(\"%s\")", db->connect_id);
+
+ o_report_error ("o_read_database", db->name, NULL, errfunc, oci_error);
DEBUG ("oracle plugin: OCILogon (%s): db->oci_service_context = %p;",
db->connect_id, db->oci_service_context);
db->oci_service_context = NULL;
if (status != 0)
{
WARNING ("rrdtool plugin: rrd_update_r failed: %s: %s",
- argv[1], rrd_get_error ());
+ filename, rrd_get_error ());
}
sfree (new_argv);
if ((ci->values_num != 1)
|| (ci->values[0].type != OCONFIG_TYPE_NUMBER))
{
- WARNING ("snmp plugin: The `Scale' config option needs exactly one number argument.");
+ WARNING ("snmp plugin: The `Shift' config option needs exactly one number argument.");
return (-1);
}
vb = vb->next_variable, i++)
{
num_checked++;
- if (snmp_oid_ncompare (data->values[i].oid,
- data->values[i].oid_len,
- vb->name, vb->name_length,
- data->values[i].oid_len) != 0)
+
+ if ((vb->type == SNMP_ENDOFMIBVIEW)
+ || (snmp_oid_ncompare (data->values[i].oid,
+ data->values[i].oid_len,
+ vb->name, vb->name_length,
+ data->values[i].oid_len) != 0))
num_left_subtree++;
}
void c_avl_destroy (c_avl_tree_t *t)
{
+ if (t == NULL)
+ return;
free_node (t->root);
free (t);
}
#if HAVE_STRUCT_UDPHDR_UH_DPORT && HAVE_STRUCT_UDPHDR_UH_SPORT
# define UDP_DEST uh_dport
-# define UDP_SRC uh_dport
+# define UDP_SRC uh_sport
#elif HAVE_STRUCT_UDPHDR_DEST && HAVE_STRUCT_UDPHDR_SOURCE
# define UDP_DEST dest
# define UDP_SRC source
unsigned int offset;
int nexthdr;
- struct in6_addr s_addr;
+ struct in6_addr c_src_addr;
uint16_t payload_len;
if (0 > len)
offset = sizeof (struct ip6_hdr);
nexthdr = ipv6->ip6_nxt;
- s_addr = ipv6->ip6_src;
+ c_src_addr = ipv6->ip6_src;
payload_len = ntohs (ipv6->ip6_plen);
- if (ignore_list_match (&s_addr))
+ if (ignore_list_match (&c_src_addr))
return (0);
/* Parse extension headers. This only handles the standard headers, as
|| (IPPROTO_HOPOPTS == nexthdr) /* Hop-by-Hop options. */
|| (IPPROTO_FRAGMENT == nexthdr) /* fragmentation header. */
|| (IPPROTO_DSTOPTS == nexthdr) /* destination options. */
- || (IPPROTO_DSTOPTS == nexthdr) /* destination options. */
|| (IPPROTO_AH == nexthdr) /* destination options. */
|| (IPPROTO_ESP == nexthdr)) /* encapsulating security payload. */
{
{
char buf[PCAP_SNAPLEN];
int offset = ip->ip_hl << 2;
- struct in6_addr s_addr;
- struct in6_addr d_addr;
+ struct in6_addr c_src_addr;
+ struct in6_addr c_dst_addr;
if (ip->ip_v == 6)
return (handle_ipv6 ((void *) ip, len));
- in6_addr_from_buffer (&s_addr, &ip->ip_src.s_addr, sizeof (ip->ip_src.s_addr), AF_INET);
- in6_addr_from_buffer (&d_addr, &ip->ip_dst.s_addr, sizeof (ip->ip_dst.s_addr), AF_INET);
- if (ignore_list_match (&s_addr))
+ in6_addr_from_buffer (&c_src_addr, &ip->ip_src.s_addr, sizeof (ip->ip_src.s_addr), AF_INET);
+ in6_addr_from_buffer (&c_dst_addr, &ip->ip_dst.s_addr, sizeof (ip->ip_dst.s_addr), AF_INET);
+ if (ignore_list_match (&c_src_addr))
return (0);
if (IPPROTO_UDP != ip->ip_p)
return 0;