AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
fi
-AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
-if test "x$with_libkvm" = "xyes"
+AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
+if test "x$with_kvm_getswapinfo" = "xyes"
then
- AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
+ AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
+ [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
+AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
with_sensors_cflags=""
with_sensors_ldflags=""
Color interrupt a000a0
Color steal 000000
</Type>
+<Type current>
+ DataSources value
+ DSName value Current
+ RRDTitle "Current ({type_instance})"
+ RRDVerticalLabel "Ampere"
+ RRDFormat "%4.1lfA"
+ Color value ffb000
+</Type>
<Type df>
Module Df
DataSources free used
RRDFormat "%6.1lf"
Color value 00b000
</Type>
+<Type frequency>
+ DataSources frequency
+ DSName frequency Frequency
+ RRDTitle "Frequency ({type_instance})"
+ RRDVerticalLabel "Hertz"
+ RRDFormat "%4.1lfHz"
+ Color frequency a000a0
+</Type>
+<Type humidity>
+ DataSources value
+ DSName value Humitidy
+ RRDTitle "Humitidy ({instance})"
+ RRDVerticalLabel "Percent"
+ RRDFormat "%4.1lf%%"
+ Color value 00e000
+</Type>
<Type if_errors>
Module GenericIO
DataSources rx tx
Color buffered ffb000
Color used ff0000
</Type>
+<Type percent>
+ DataSources percent
+ DSName percent Percent
+ RRDTitle "Percent ({type_instance})"
+ RRDVerticalLabel "Percent"
+ RRDFormat "%4.1lf%%"
+ Color percent 0000ff
+</Type>
<Type ping>
DataSources ping
DSName "ping Latency"
RRDVerticalLabel "Milliseconds"
RRDFormat "%5.2lfms"
</Type>
+<Type power>
+ DataSources value
+ DSName value Watts
+ RRDTitle "Power ({type_instance})"
+ RRDVerticalLabel "Watts"
+ RRDFormat "%6.2lf%sW"
+ Color value 008080
+</Type>
<Type ps_state>
Module GenericStacked
DataSources value
Color blocked ff00ff
Color stopped a000a0
</Type>
+<Type swap>
+ Module GenericStacked
+ DataSources value
+ RRDTitle "Swap utilization on {hostname}"
+ RRDVerticalLabel "Bytes"
+ RRDFormat "%5.1lf%s"
+ RRDOptions -b 1024 -l 0
+ DSName "free Free "
+ DSName "cached Cached "
+ DSName "used Used "
+ #Order used cached free
+ Order free cached used
+ Color free 00e000
+ Color cached 0000ff
+ Color used ff0000
+</Type>
<Type tcp_connections>
Module GenericStacked
DataSources value
--- /dev/null
+package Collectd::Graph::Config;
+
+=head1 NAME
+
+Collectd::Graph::Config - Parse the collection3 config file.
+
+=cut
+
+# Copyright (C) 2008 Florian octo Forster <octo at verplant.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; only version 2 of the License is applicable.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+use strict;
+use warnings;
+
+use Carp (qw(cluck confess));
+use Exporter ();
+use Config::General ('ParseConfig');
+use Collectd::Graph::Type ();
+
+@Collectd::Graph::Config::ISA = ('Exporter');
+@Collectd::Graph::Config::EXPORT_OK = (qw(gc_read_config gc_get_config
+ gc_get_scalar));
+
+our $Configuration = undef;
+
+return (1);
+
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
+=item B<gc_read_config> (I<$file>)
+
+Reads the configuration from the file located at I<$file>. Returns B<true> when
+successfull and B<false> otherwise.
+
+=cut
+
+sub gc_read_config
+{
+ my $file = shift;
+ my %conf;
+
+ if ($Configuration)
+ {
+ return (1);
+ }
+
+ $file ||= "etc/collection.conf";
+
+ %conf = ParseConfig (-ConfigFile => $file,
+ -LowerCaseNames => 1,
+ -UseApacheInclude => 1,
+ -IncludeDirectories => 1,
+ ($Config::General::VERSION >= 2.38) ? (-IncludeAgain => 0) : (),
+ -MergeDuplicateBlocks => 1,
+ -CComments => 0);
+ if (!%conf)
+ {
+ return;
+ }
+
+ $Configuration = \%conf;
+ return (1);
+} # gc_read_config
+
+=item B<gc_get_config> ()
+
+Returns the hash as provided by L<Config::General>. The hash is returned as a
+hash reference. Don't change it!
+
+=cut
+
+sub gc_get_config
+{
+ return ($Configuration);
+} # gc_get_config
+
+=item B<gc_get_config> (I<$key>, [I<$default>])
+
+Returns the scalar value I<$key> from the config file. If the key does not
+exist, I<$default> will be returned. If no default is given, B<undef> will be
+used in this case.
+
+=cut
+
+sub gc_get_scalar
+{
+ my $key = shift;
+ my $default = (@_ != 0) ? shift : undef;
+ my $value;
+
+ if (!$Configuration)
+ {
+ return ($default);
+ }
+
+ $value = $Configuration->{lc ($key)};
+ if (!defined ($value))
+ {
+ return ($default);
+ }
+
+ if (ref ($value) ne '')
+ {
+ cluck ("Value for `$key' should be scalar, but actually is "
+ . ref ($value));
+ return ($default);
+ }
+
+ return ($value);
+} # gc_get_config
+
+=back
+
+=head1 DEPENDS ON
+
+L<Config::General>
+
+=head1 SEE ALSO
+
+L<Collectd::Graph::Type>
+
+=head1 AUTHOR AND LICENSE
+
+Copyright (c) 2008 by Florian Forster
+E<lt>octoE<nbsp>atE<nbsp>verplant.orgE<gt>. Licensed under the terms of the GNU
+General Public License, VersionE<nbsp>2 (GPLv2).
+
+=cut
+
+# vim: set shiftwidth=2 softtabstop=2 tabstop=8 et fdm=marker :
if BUILD_WITH_LIBDEVINFO
swap_la_LIBADD += -ldevinfo
endif
-if BUILD_WITH_LIBKVM
+if BUILD_WITH_LIBKVM_GETSWAPINFO
swap_la_LIBADD += -lkvm
endif
if BUILD_WITH_LIBSTATGRAB
vb = res->variables;
if (vb == NULL)
{
- if (res != NULL)
- snmp_free_pdu (res);
- res = NULL;
-
status = -1;
break;
}
* subtree */
if (csnmp_check_res_left_subtree (host, data, res) != 0)
{
- if (res != NULL)
- snmp_free_pdu (res);
- res = NULL;
-
+ status = 0;
break;
}
(vb != NULL) && (vb->next_variable != NULL);
vb = vb->next_variable)
/* do nothing */;
- if (vb == NULL)
- {
- status = -1;
- break;
- }
+ assert (vb != NULL);
/* Copy OID to oid_list[data->values_len] */
memcpy (oid_list[data->values_len].oid, vb->name,
res = NULL;
} /* while (status == 0) */
+ if (res != NULL)
+ snmp_free_pdu (res);
+ res = NULL;
+
if (status == 0)
csnmp_dispatch_table (host, data, instance_list, value_table);
/* No global variables */
/* #endif defined(VM_SWAPUSAGE) */
-#elif HAVE_LIBKVM
+#elif HAVE_LIBKVM_GETSWAPINFO
static kvm_t *kvm_obj = NULL;
int kvm_pagesize;
-/* #endif HAVE_LIBKVM */
+/* #endif HAVE_LIBKVM_GETSWAPINFO */
#elif HAVE_LIBSTATGRAB
/* No global variables */
/* No init stuff */
/* #endif defined(VM_SWAPUSAGE) */
-#elif HAVE_LIBKVM
+#elif HAVE_LIBKVM_GETSWAPINFO
if (kvm_obj != NULL)
{
kvm_close (kvm_obj);
ERROR ("swap plugin: kvm_open failed.");
return (-1);
}
-/* #endif HAVE_LIBKVM */
+/* #endif HAVE_LIBKVM_GETSWAPINFO */
#elif HAVE_LIBSTATGRAB
/* No init stuff */
swap_submit ("free", sw_usage.xsu_avail);
/* #endif VM_SWAPUSAGE */
-#elif HAVE_LIBKVM
+#elif HAVE_LIBKVM_GETSWAPINFO
struct kvm_swap data_s;
int status;
swap_submit ("used", used);
swap_submit ("free", free);
-/* #endif HAVE_LIBKVM */
+/* #endif HAVE_LIBKVM_GETSWAPINFO */
#elif HAVE_LIBSTATGRAB
sg_swap_stats *swap;
|| (pe->flags & PORT_COLLECT_LOCAL))
{
ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
- "%hu-local", pe->port);
+ "%"PRIu16"-local", pe->port);
for (i = 1; i <= TCP_STATE_MAX; i++)
{
if (pe->flags & PORT_COLLECT_REMOTE)
{
ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
- "%hu-remote", pe->port);
+ "%"PRIu16"-remote", pe->port);
for (i = 1; i <= TCP_STATE_MAX; i++)
{
port_entry_t *next = pe->next;
DEBUG ("tcpconns plugin: Removing temporary entry "
- "for listening port %hu", pe->port);
+ "for listening port %"PRIu16, pe->port);
if (prev == NULL)
port_list_head = next;
#endif
)
{
- NOTICE ("tcpconns plugin: Ignoring connection with unknown state 0x%02x.",
- state);
+ NOTICE ("tcpconns plugin: Ignoring connection with "
+ "unknown state 0x%02"PRIx8".", state);
return (-1);
}
pe->flags |= PORT_IS_LISTENING;
}
- DEBUG ("tcpconns plugin: Connection %hu <-> %hu (%s)",
+ DEBUG ("tcpconns plugin: Connection %"PRIu16" <-> %"PRIu16" (%s)",
port_local, port_remote, tcp_state[state]);
pe = conn_get_port_entry (port_local, 0 /* no create */);