author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 14 Mar 2009 17:52:38 +0000 (18:52 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 14 Mar 2009 17:52:38 +0000 (18:52 +0100) |
13 files changed:
contrib/collection3/bin/graph.cgi | patch | blob | history | |
contrib/collection3/bin/index.cgi | patch | blob | history | |
contrib/collection3/bin/json.cgi | patch | blob | history | |
contrib/collection3/etc/collection.conf | patch | blob | history | |
contrib/collection3/lib/Collectd/Graph/Common.pm | patch | blob | history | |
contrib/collection3/lib/Collectd/Graph/Type/PsCputime.pm | [new file with mode: 0644] | patch | blob |
contrib/collection3/lib/Collectd/Graph/Type/TableSize.pm | [new file with mode: 0644] | patch | blob |
contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm | [new file with mode: 0644] | patch | blob |
src/bind.c | patch | blob | history | |
src/common.c | patch | blob | history | |
src/liboping/test_liboping.c | [deleted file] | patch | blob | history |
src/memory.c | patch | blob | history | |
src/types.db | patch | blob | history |
index 7fe20871a20ccd7eee60bbf11837e9ec0a6968ed..c096dc9444215f1707d18540b0f59b8b725bdc91 100755 (executable)
our $Begin = param ('begin');
our $End = param ('end');
our $GraphWidth = param ('width');
+our $GraphHeight = param ('height');
+our $Index = param ('index') || 0;
our $OutputFormat = 'PNG';
our $ContentType = 'image/png';
$GraphWidth = gc_get_scalar ('GraphWidth', 400);
}
+if ($GraphHeight)
+{
+ $GraphHeight =~ s/\D//g;
+}
+
+if (!$GraphHeight)
+{
+ $GraphHeight = gc_get_scalar ('GraphHeight', 100);
+}
+
{ # Sanitize begin and end times
$End ||= 0;
$Begin ||= 0;
print "\$expires = $expires;\n";
}
-my $args = $obj->getRRDArgs (0);
+my $args = $obj->getRRDArgs (0 + $Index);
if ($Debug)
{
}
$| = 1;
- RRDs::graph ('-', '-a', $OutputFormat, '--width', $GraphWidth, @timesel, @$args);
+ RRDs::graph ('-', '-a', $OutputFormat, '--width', $GraphWidth, '--height', $GraphHeight, @timesel, @$args);
if (my $err = RRDs::error ())
{
print STDERR "RRDs::graph failed: $err\n";
index be20928c029972fadff8285804865d9ae0b13b82..ba5b48a0937b8c42bd2557142fbe33565ab156c8 100755 (executable)
use lib ('../lib');
use utf8;
+use Carp (qw(cluck confess));
use FindBin ('$RealBin');
use CGI (':cgi');
use CGI::Carp ('fatalsToBrowser');
<title>collection.cgi, Version 3</title>
<link rel="icon" href="../share/shortcut-icon.png" type="image/png" />
<link rel="stylesheet" href="../share/style.css" type="text/css" />
- <script type="text/javascript" src="../share/navigate.js" />
+ <script type="text/javascript" src="../share/navigate.js"></script>
</head>
<body onload="nav_init ($begin, $end);">
HTML
index c2af61cbf1165210c234ae3c88a16e1ac2aaa9aa..99e27034193c3fc1aeda2830324e7f275967c4a5 100755 (executable)
use CGI (':cgi');
use CGI::Carp ('fatalsToBrowser');
use URI::Escape ('uri_escape');
+use JSON ('objToJson');
use Data::Dumper;
use Collectd::Graph::Type ();
our $Debug = param ('debug') ? 1 : 0;
+our $ServerName = 'collect.noris.net';
gc_read_config ("$RealBin/../etc/collection.conf");
print "Content-Type: application/json; charset=utf-8\n\n";
}
-print "{\n";
-
+my $obj = {};
my @hosts = get_all_hosts ();
for (my $i = 0; $i < @hosts; $i++)
{
+ my $host_obj = {};
my $host = $hosts[$i];
my $files = get_files_for_host ($host);
my %graphs = ();
$graphs{$type}->addFiles ($file);
} # for (@$files)
- print qq( "$host":\n {\n);
+ #print qq( ") . objToJson ({ foo => 123 }) . qq(":\n {\n);
@graphs = keys %graphs;
for (my $j = 0; $j < @graphs; $j++)
{
my $type = $graphs[$j];
my $graphs_num = $graphs{$type}->getGraphsNum ();
- my @args = ();
- for (my $k = 0; $k < $graphs_num; $k++)
+ if (!defined ($host_obj->{$type}))
{
- my $args = $graphs{$type}->getGraphArgs ($k);
- my $url = 'http://' . $ENV{'SERVER_NAME'} . "/cgi-bin/graph.cgi?" . $args;
- push (@args, $url);
+ $host_obj->{$type} = [];
}
- print qq( "$type": [ )
- . join (', ', map { qq("$_") } (@args));
-
- if ($j == (@graphs - 1))
- {
- print qq( ]\n);
- }
- else
+ for (my $k = 0; $k < $graphs_num; $k++)
{
- print qq( ],\n);
+ my $args = $graphs{$type}->getGraphArgs ($k);
+ my $url = "http://$ServerName/cgi-bin/collection3/bin/graph.cgi?" . $args;
+ push (@{$host_obj->{$type}}, $url);
}
} # for (keys %graphs)
- if ($i == (@hosts - 1))
- {
- print qq( }\n);
- }
- else
- {
- print qq( },\n\n);
- }
+ $obj->{$host} = $host_obj;
} # for (my $i = 0; $i < @hosts; $i++)
-print "}\n";
+print STDOUT objToJson ($obj, { pretty => 1, indent => 2 });
exit (0);
index b7e76b2b7eef3cd1f2b3900a9352424156253963..9497d8e383e0dd2d5f50d90fcd041a0fe90052f3 100644 (file)
RRDFormat "%5.1lf%ss"
Scale 0.001
</Type>
+<Type dns_opcode>
+ DataSources value
+ DSName "value Queries/s"
+ RRDTitle "DNS Opcode {type_instance}"
+ RRDVerticalLabel "Queries/s"
+ RRDFormat "%6.1lf"
+</Type>
<Type entropy>
DataSources entropy
DSName entropy Entropy bits
DataSources rx tx
DSName rx RX
DSName tx TX
- RRDTitle "Interface Traffic ({type_instance})"
+ RRDTitle "Interface Traffic ({instance})"
RRDVerticalLabel "Bits per second"
# RRDOptions ...
RRDFormat "%5.1lf%s"
# RRDOptions ...
RRDFormat "%5.1lf%s"
</Type>
+<Type io_octets>
+ Module GenericIO
+ DataSources rx tx
+ DSName "rx Read "
+ DSName "tx Written"
+ RRDTitle "IO Traffic ({instance})"
+ RRDVerticalLabel "Bytes per second"
+# RRDOptions ...
+ RRDFormat "%5.1lf%s"
+</Type>
<Type ipt_bytes>
DataSources value
DSName value Bytes/s
DSName "free Free "
DSName "cached Cached "
DSName "buffered Buffered"
+ DSName "locked Locked "
DSName "used Used "
#Order used buffered cached free
Order free cached buffered used
Color free 00e000
Color cached 0000ff
Color buffered ffb000
+ Color locked ff00ff
Color used ff0000
</Type>
<Type mysql_commands>
RRDVerticalLabel "Invocations"
RRDFormat "%6.2lf"
+
DSName admin_commands admin_commands
DSName alter_table alter_table
DSName begin begin
RRDFormat "%6.2lf%sW"
Color value 008080
</Type>
+<Type ps_cputime>
+ Module PsCputime
+</Type>
<Type ps_rss>
DataSources value
DSName value RSS
Color cached 0000ff
Color used ff0000
</Type>
+<Type table_size>
+ Module TableSize
+ DataSources value
+ DSName value Bytes
+ RRDTitle "Table size ({instance})"
+ RRDVerticalLabel "Size [Bytes]"
+# RRDOptions ...
+ RRDFormat "%5.1lf%s"
+</Type>
<Type tcp_connections>
Module GenericStacked
DataSources value
RRDFormat "%4.1lfV"
Color value f00000
</Type>
+<Type wirkleistung>
+ Module Wirkleistung
+ DataSources kWh
+ DSName value Wh
+ RRDTitle "Watt"
+ RRDVerticalLabel "W"
+ RRDFormat "%4.1lfW"
+</Type>
# vim: set sw=2 sts=2 et syntax=apache fileencoding=latin-1 :
diff --git a/contrib/collection3/lib/Collectd/Graph/Common.pm b/contrib/collection3/lib/Collectd/Graph/Common.pm
index 0deefd6368f638412f496db4deca5a87bed25344..b445c8e45e9736feb2082eb34f147c79d9e297a6 100644 (file)
get_timespan_selection
get_host_selection
get_plugin_selection
+ get_random_color
get_faded_color
sort_idents_by_type_instance
type_to_module_name
return (sprintf ('%02hx%02hx%02hx', map { int (255.0 * $_) } @{$_[0]}));
} # _color_to_string
+sub get_random_color
+{
+ my ($r, $g, $b) = (rand (), rand ());
+ my $min = 0.0;
+ my $max = 1.0;
+
+ if (($r + $g) < 1.0)
+ {
+ $min = 1.0 - ($r + $g);
+ }
+ else
+ {
+ $max = 2.0 - ($r + $g);
+ }
+
+ $b = $min + (rand () * ($max - $min));
+
+ return (_color_to_string ([$r, $g, $b]));
+} # get_random_color
+
sub get_faded_color
{
my $fg = shift;
diff --git a/contrib/collection3/lib/Collectd/Graph/Type/PsCputime.pm b/contrib/collection3/lib/Collectd/Graph/Type/PsCputime.pm
--- /dev/null
@@ -0,0 +1,97 @@
+package Collectd::Graph::Type::PsCputime;
+
+# Copyright (C) 2008,2009 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 base ('Collectd::Graph::Type');
+
+use Collectd::Graph::Common (qw(ident_to_filename get_faded_color));
+
+return (1);
+
+sub getDataSources
+{
+ return ([qw(syst user)]);
+} # getDataSources
+
+sub new
+{
+ my $pkg = shift;
+ my $obj = Collectd::Graph::Type->new (@_);
+ $obj->{'data_sources'} = [qw(syst user)];
+ $obj->{'rrd_opts'} = ['-v', 'CPU time [s]', '-l', '0'];
+ $obj->{'rrd_title'} = 'CPU time used by {plugin_instance}';
+ $obj->{'rrd_format'} = '%5.1lf';
+ $obj->{'colors'} = [qw(00b000 ff0000)];
+
+ return (bless ($obj, $pkg));
+} # new
+
+sub getRRDArgs
+{
+ my $obj = shift;
+ my $index = shift;
+
+ my $ident = $obj->{'files'}[$index];
+ if (!$ident)
+ {
+ cluck ("Invalid index: $index");
+ return;
+ }
+ my $filename = ident_to_filename ($ident);
+ $filename =~ s#:#\\:#g;
+
+ my $faded_blue = get_faded_color ('0000ff');
+ my $faded_red = get_faded_color ('ff0000');
+
+ return (['-t', $obj->getTitle (), @{$obj->{'rrd_opts'}},
+ "DEF:user_min_raw=${filename}:user:MIN",
+ "DEF:user_avg_raw=${filename}:user:AVERAGE",
+ "DEF:user_max_raw=${filename}:user:MAX",
+ "DEF:syst_min_raw=${filename}:syst:MIN",
+ "DEF:syst_avg_raw=${filename}:syst:AVERAGE",
+ "DEF:syst_max_raw=${filename}:syst:MAX",
+ "CDEF:user_min=0.000001,user_min_raw,*",
+ "CDEF:user_avg=0.000001,user_avg_raw,*",
+ "CDEF:user_max=0.000001,user_max_raw,*",
+ "CDEF:syst_min=0.000001,syst_min_raw,*",
+ "CDEF:syst_avg=0.000001,syst_avg_raw,*",
+ "CDEF:syst_max=0.000001,syst_max_raw,*",
+ "VDEF:v_user_min=user_min,MINIMUM",
+ "VDEF:v_user_avg=user_avg,AVERAGE",
+ "VDEF:v_user_max=user_max,MAXIMUM",
+ "VDEF:v_user_lst=syst_avg,LAST",
+ "VDEF:v_syst_min=syst_min,MINIMUM",
+ "VDEF:v_syst_avg=syst_avg,AVERAGE",
+ "VDEF:v_syst_max=syst_max,MAXIMUM",
+ "VDEF:v_syst_lst=syst_avg,LAST",
+ "CDEF:user_stack=syst_avg,user_avg,+",
+ "AREA:user_stack#${faded_blue}",
+ 'LINE1:user_stack#0000ff:User ',
+ 'GPRINT:v_user_min:%5.1lf%ss Min,',
+ 'GPRINT:v_user_avg:%5.1lf%ss Avg,',
+ 'GPRINT:v_user_max:%5.1lf%ss Max,',
+ 'GPRINT:v_user_lst:%5.1lf%ss Last\l',
+ "AREA:syst_avg#${faded_red}",
+ 'LINE1:syst_avg#ff0000:System',
+ 'GPRINT:v_syst_min:%5.1lf%ss Min,',
+ 'GPRINT:v_syst_avg:%5.1lf%ss Avg,',
+ 'GPRINT:v_syst_max:%5.1lf%ss Max,',
+ 'GPRINT:v_syst_lst:%5.1lf%ss Last\l']);
+} # getRRDArgs
+
+# vim: set shiftwidth=2 softtabstop=2 tabstop=8 :
diff --git a/contrib/collection3/lib/Collectd/Graph/Type/TableSize.pm b/contrib/collection3/lib/Collectd/Graph/Type/TableSize.pm
--- /dev/null
@@ -0,0 +1,236 @@
+package Collectd::Graph::Type::TableSize;
+
+# Copyright (C) 2008,2009 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 base ('Collectd::Graph::Type');
+
+use Collectd::Graph::Common (qw($ColorCanvas $ColorFullBlue $ColorHalfBlue
+ ident_to_filename sanitize_type_instance
+ get_random_color sort_idents_by_type_instance));
+
+use RRDs ();
+
+return (1);
+
+sub _get_last_value
+{
+ my $ident = shift;
+ my $value = undef;
+ my $filename = ident_to_filename ($ident);
+ my ($start ,$step ,$names ,$data) = RRDs::fetch ($filename, 'AVERAGE', '-s', '-3600');
+ if (my $errmsg = RRDs::error ())
+ {
+ print STDERR "RRDs::fetch ($filename) failed: $errmsg\n";
+ return;
+ }
+
+ for (@$data)
+ {
+ my $line = $_;
+
+ for (@$line)
+ {
+ my $ds = $_;
+
+ if (defined ($ds))
+ {
+ $value = $ds;
+ }
+ }
+ } # for (@$data)
+
+ return ($value);
+} # _get_last_value
+
+sub getLastValues
+{
+ my $obj = shift;
+ my $last_value = {};
+
+ if (exists ($obj->{'last_value'}))
+ {
+ return ($obj->{'last_value'});
+ }
+
+ for (@{$obj->{'files'}})
+ {
+ my $file = $_;
+
+ $last_value->{$file} = _get_last_value ($file);
+ }
+ $obj->{'last_value'} = $last_value;
+ return ($obj->{'last_value'});
+} # getLastValues
+
+sub _group_files
+{
+ my $obj = shift;
+ my $data = [];
+ my @files;
+ my $last_values;
+
+ $last_values = $obj->getLastValues ();
+
+ @files = sort
+ {
+ if (!defined ($last_values->{$a}) && !defined ($last_values->{$b}))
+ {
+ return (0);
+ }
+ elsif (!defined ($last_values->{$a}))
+ {
+ return (1);
+ }
+ elsif (!defined ($last_values->{$b}))
+ {
+ return (-1);
+ }
+ else
+ {
+ return ($last_values->{$a} <=> $last_values->{$b});
+ }
+ } (@{$obj->{'files'}});
+
+ for (my $i = 0; $i < @files; $i++)
+ {
+ my $file = $files[$i];
+ my $j = int ($i / 10);
+
+ $data->[$j] ||= [];
+ push (@{$data->[$j]}, $file);
+ }
+
+ return ($data);
+} # _group_files
+
+sub getGraphsNum
+{
+ my $obj = shift;
+ my $group = _group_files ($obj);
+
+ return (0 + @$group);
+}
+
+sub getRRDArgs
+{
+ my $obj = shift;
+ my $index = shift;
+
+ my $group = _group_files ($obj);
+
+ my $rrd_opts = $obj->{'rrd_opts'} || [];
+ my $format = $obj->{'rrd_format'} || '%5.1lf';
+
+ my $idents = $group->[$index];
+ my $ds_name_len = 0;
+
+ my $ds = $obj->getDataSources ();
+ if (!$ds)
+ {
+ confess ("obj->getDataSources failed.");
+ }
+ if (@$ds != 1)
+ {
+ confess ("I can only work with RRD files that have "
+ . "exactly one data source!");
+ }
+ my $data_source = $ds->[0];
+
+ my $rrd_title = $obj->getTitle ($idents->[0]);
+
+ my $colors = $obj->{'rrd_colors'} || {};
+ my @ret = ('-t', $rrd_title, @$rrd_opts);
+
+ if (defined $obj->{'rrd_vertical'})
+ {
+ push (@ret, '-v', $obj->{'rrd_vertical'});
+ }
+
+ if ($obj->{'custom_order'})
+ {
+ sort_idents_by_type_instance ($idents, $obj->{'custom_order'});
+ }
+
+ $obj->{'ds_names'} ||= {};
+ my @names = map { $obj->{'ds_names'}{$_->{'type_instance'}} || $_->{'type_instance'} } (@$idents);
+
+ for (my $i = 0; $i < @$idents; $i++)
+ {
+ my $ident = $idents->[$i];
+ my $filename = ident_to_filename ($ident);
+
+ if ($ds_name_len < length ($names[$i]))
+ {
+ $ds_name_len = length ($names[$i]);
+ }
+
+ # Escape colons _after_ the length has been checked.
+ $names[$i] =~ s/:/\\:/g;
+
+ push (@ret,
+ "DEF:min${i}=${filename}:${data_source}:MIN",
+ "DEF:avg${i}=${filename}:${data_source}:AVERAGE",
+ "DEF:max${i}=${filename}:${data_source}:MAX");
+ }
+
+ for (my $i = 0; $i < @$idents; $i++)
+ {
+ my $type_instance = $idents->[$i]{'type_instance'};
+ my $ds_name = sprintf ("%-*s", $ds_name_len, $names[$i]);
+ my $color = '000000';
+ if (exists $colors->{$type_instance})
+ {
+ $color = $colors->{$type_instance};
+ }
+ else
+ {
+ $color = get_random_color ();
+ }
+ push (@ret,
+ "LINE1:avg${i}#${color}:${ds_name}",
+ "GPRINT:min${i}:MIN:${format} Min,",
+ "GPRINT:avg${i}:AVERAGE:${format} Avg,",
+ "GPRINT:max${i}:MAX:${format} Max,",
+ "GPRINT:avg${i}:LAST:${format} Last\\l");
+ }
+
+ return (\@ret);
+}
+
+sub getGraphArgs
+{
+ my $obj = shift;
+ my $index = shift;
+
+ my $group = _group_files ($obj);
+ my $idents = $group->[$index];
+
+ my @args = ();
+ for (qw(hostname plugin plugin_instance type))
+ {
+ if (defined ($idents->[0]{$_}))
+ {
+ push (@args, $_ . '=' . $idents->[0]{$_});
+ }
+ }
+ push (@args, "index=$index");
+
+ return (join (';', @args));
+} # getGraphArgs
+
+# vim: set shiftwidth=2 softtabstop=2 tabstop=8 :
diff --git a/contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm b/contrib/collection3/lib/Collectd/Graph/Type/Wirkleistung.pm
--- /dev/null
@@ -0,0 +1,90 @@
+package Collectd::Graph::Type::Wirkleistung;
+
+# Copyright (C) 2009 Stefan Pfab <spfab at noris.net>
+#
+# 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 base ('Collectd::Graph::Type');
+
+use Collectd::Graph::Common (qw(ident_to_filename get_faded_color));
+
+return (1);
+
+sub getDataSources
+{
+ return ([qw(wirkleistung)]);
+} # getDataSources
+
+sub new
+{
+ my $pkg = shift;
+ my $obj = Collectd::Graph::Type->new (@_);
+ $obj->{'data_sources'} = [qw(wirkleistung)];
+ $obj->{'rrd_opts'} = ['-v', 'Watt'];
+ $obj->{'rrd_title'} = 'Wirkleistung ({type_instance})';
+ $obj->{'rrd_format'} = '%5.1lf%s W';
+ $obj->{'colors'} = [qw(000000 f00000)];
+
+ return (bless ($obj, $pkg));
+} # new
+
+sub getRRDArgs
+{
+ my $obj = shift;
+ my $index = shift;
+
+ my $ident = $obj->{'files'}[$index];
+ if (!$ident)
+ {
+ cluck ("Invalid index: $index");
+ return;
+ }
+ my $filename = ident_to_filename ($ident);
+ $filename =~ s#:#\\:#g;
+
+ my $faded_green = get_faded_color ('00ff00');
+ my $faded_red = get_faded_color ('ff0000');
+
+ return (['-t', 'Wirkleistung (' . $ident->{'type_instance'} . ')', '-v', 'Watt', '-l', '0',
+ "DEF:min0=${filename}:kWh:MIN",
+ "DEF:avg0=${filename}:kWh:AVERAGE",
+ "DEF:max0=${filename}:kWh:MAX",
+ 'AREA:max0#bfbfbf',
+ 'AREA:min0#FFFFFF',
+ 'CDEF:watt_avg0=avg0,36000,*,',
+ 'CDEF:watt_min0=min0,36000,*,',
+ 'CDEF:watt_max0=max0,36000,*,',
+ 'CDEF:watt_total=avg0,10,*,',
+ 'VDEF:total=watt_total,TOTAL',
+ 'VDEF:first=watt_total,FIRST',
+ 'VDEF:last=watt_total,LAST',
+ #'CDEF:first_value=first,POP',
+ #'CDEF:first_time=first,POP',
+ 'LINE1:watt_avg0#000000:W',
+ 'HRULE:190#ff0000',
+ 'GPRINT:watt_min0:MIN:%4.1lfW Min,',
+ 'GPRINT:watt_avg0:AVERAGE:%4.1lfW Avg,',
+ 'GPRINT:watt_max0:MAX:%4.1lfW Max,',
+ 'GPRINT:watt_avg0:LAST:%4.1lfW Last\l',
+ 'GPRINT:total:%4.1lf%sWh Gesamtverbrauch im angezeigten Zeitraum\l',
+ 'GPRINT:first:erster Wert %c:strftime',
+ 'GPRINT:last:letzter Wert %c:strftime']);
+
+ # HRULE:190\ ff0000
+
+} # getRRDArgs
+
+# vim: set shiftwidth=2 softtabstop=2 tabstop=8 :
diff --git a/src/bind.c b/src/bind.c
index 4b3662f9819f867abd8161aeb29f4817ce5641b6..783d2b057bfad46aed9ee7dbd0b82b362e4e4117 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
@@ -484,7 +484,7 @@ static int bind_parse_generic_name_value (const char *xpath_expression, /* {{{ *
list_callback_t list_callback,
void *user_data,
xmlDoc *doc, xmlXPathContext *xpathCtx,
- time_t current_time)
+ time_t current_time, int ds_type)
{
xmlXPathObject *xpathObj = NULL;
int num_entries;
@@ -532,7 +532,10 @@ static int bind_parse_generic_name_value (const char *xpath_expression, /* {{{ *
value_t value;
int status;
- status = bind_xml_read_counter (doc, counter, &value.counter);
+ if (ds_type == DS_TYPE_GAUGE)
+ status = bind_xml_read_gauge (doc, counter, &value.gauge);
+ else
+ status = bind_xml_read_counter (doc, counter, &value.counter);
if (status != 0)
continue;
list_info_ptr_t list_info =
{
plugin_instance,
- /* type = */ "dns_qtype"
+ /* type = */ "dns_qtype_gauge"
};
ssnprintf (plugin_instance, sizeof (plugin_instance), "%s-qtypes",
bind_parse_generic_name_value (/* xpath = */ "rdtype",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
- doc, path_ctx, current_time);
+ doc, path_ctx, current_time, DS_TYPE_COUNTER);
} /* }}} */
if (view->resolver_stats != 0) /* {{{ */
bind_parse_generic_name_value ("resstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
- doc, path_ctx, current_time);
+ doc, path_ctx, current_time, DS_TYPE_COUNTER);
} /* }}} */
if (view->cacherrsets != 0) /* {{{ */
list_info_ptr_t list_info =
{
plugin_instance,
- /* type = */ "dns_qtype"
+ /* type = */ "dns_qtype_gauge"
};
ssnprintf (plugin_instance, sizeof (plugin_instance), "%s-cache_rr_sets",
bind_parse_generic_name_value (/* xpath = */ "cache/rrset",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
- doc, path_ctx, current_time);
+ doc, path_ctx, current_time, DS_TYPE_GAUGE);
} /* }}} */
if (view->zones_num > 0)
bind_parse_generic_name_value (/* xpath = */ "server/requests/opcode",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
- doc, xpathCtx, current_time);
+ doc, xpathCtx, current_time, DS_TYPE_COUNTER);
}
/* XPath: server/queries-in/rdtype
bind_parse_generic_name_value (/* xpath = */ "server/queries-in/rdtype",
/* callback = */ bind_xml_list_callback,
/* user_data = */ &list_info,
- doc, xpathCtx, current_time);
+ doc, xpathCtx, current_time, DS_TYPE_COUNTER);
}
/* XPath: server/nsstats, server/nsstat
bind_parse_generic_name_value ("server/nsstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
- doc, xpathCtx, current_time);
+ doc, xpathCtx, current_time, DS_TYPE_COUNTER);
}
}
bind_parse_generic_name_value ("server/zonestat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
- doc, xpathCtx, current_time);
+ doc, xpathCtx, current_time, DS_TYPE_COUNTER);
}
}
bind_parse_generic_name_value ("server/resstat",
/* callback = */ bind_xml_table_callback,
/* user_data = */ &table_ptr,
- doc, xpathCtx, current_time);
+ doc, xpathCtx, current_time, DS_TYPE_COUNTER);
}
}
diff --git a/src/common.c b/src/common.c
index b37db889b36d5c704fb94bb13f29f5650720c6e2..d42453e444f1e5f484ef459a9c6d72b031e0a3a2 100644 (file)
--- a/src/common.c
+++ b/src/common.c
int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name)
{
char ident[128];
+
+ *ksp_ptr = NULL;
if (kc == NULL)
return (-1);
ssnprintf (ident, sizeof (ident), "%s,%i,%s", module, instance, name);
+ *ksp_ptr = kstat_lookup (kc, module, instance, name);
if (*ksp_ptr == NULL)
{
- if ((*ksp_ptr = kstat_lookup (kc, module, instance, name)) == NULL)
- {
- ERROR ("Cound not find kstat %s", ident);
- return (-1);
- }
+ ERROR ("get_kstat: Cound not find kstat %s", ident);
+ return (-1);
+ }
- if ((*ksp_ptr)->ks_type != KSTAT_TYPE_NAMED)
- {
- WARNING ("kstat %s has wrong type", ident);
- *ksp_ptr = NULL;
- return (-1);
- }
+ if ((*ksp_ptr)->ks_type != KSTAT_TYPE_NAMED)
+ {
+ ERROR ("get_kstat: kstat %s has wrong type", ident);
+ *ksp_ptr = NULL;
+ return (-1);
}
#ifdef assert
if (kstat_read (kc, *ksp_ptr, NULL) == -1)
{
- WARNING ("kstat %s could not be read", ident);
+ ERROR ("get_kstat: kstat %s could not be read", ident);
return (-1);
}
if ((*ksp_ptr)->ks_type != KSTAT_TYPE_NAMED)
{
- WARNING ("kstat %s has wrong type", ident);
+ ERROR ("get_kstat: kstat %s has wrong type", ident);
return (-1);
}
diff --git a/src/liboping/test_liboping.c b/src/liboping/test_liboping.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "liboping.h"
-
-int main (int argc, char **argv)
-{
- pingobj_t *ping;
- pingobj_iter_t *iter;
-
- int i;
-
- if (argc < 2)
- {
- printf ("Usage: %s <host> [host [host [...]]]\n", argv[0]);
- return (1);
- }
-
- if ((ping = ping_construct ()) == NULL)
- {
- fprintf (stderr, "ping_construct failed\n");
- return (-1);
- }
-
- for (i = 1; i < argc; i++)
- {
- printf ("Adding host `%s'..\n", argv[i]);
-
- if (ping_host_add (ping, argv[i]) > 0)
- {
- fprintf (stderr, "ping_host_add (verplant.org) failed\n");
- return (-1);
- }
- }
-
- while (1)
- {
- if (ping_send (ping) < 0)
- {
- fprintf (stderr, "ping_send failed\n");
- return (-1);
- }
-
- for (iter = ping_iterator_get (ping); iter != NULL; iter = ping_iterator_next (iter))
- {
- const char *host;
- double latency;
-
- host = ping_iterator_get_host (iter);
- latency = ping_iterator_get_latency (iter);
-
- printf ("host = %s, latency = %f\n", host, latency);
- }
-
- sleep (5);
- }
-
- return (0);
-}
diff --git a/src/memory.c b/src/memory.c
index ebaa8f29ce76f9e2bc9681c0a6a9d17376f5e9bb..7e4e7543adc7f6a575ae3ea72a327555770594fe 100644 (file)
--- a/src/memory.c
+++ b/src/memory.c
#elif defined(HAVE_LIBKSTAT)
/* getpagesize(3C) tells me this does not fail.. */
pagesize = getpagesize ();
- if (get_kstat (&ksp, "unix", 0, "system_pages"))
+ if (get_kstat (&ksp, "unix", 0, "system_pages") != 0)
+ {
ksp = NULL;
+ return (-1);
+ }
#endif /* HAVE_LIBKSTAT */
return (0);
diff --git a/src/types.db b/src/types.db
index db469843445c902fa3605afcb9b2ebc6c8e34030..f0525fe4064a79f8c7d191e3e7441b82b0cbaa62 100644 (file)
--- a/src/types.db
+++ b/src/types.db
disk_ops read:COUNTER:0:4294967295, write:COUNTER:0:4294967295
disk_time read:COUNTER:0:1000000, write:COUNTER:0:1000000
dns_answer value:COUNTER:0:65535
+dns_notify value:COUNTER:0:65535
dns_octets queries:COUNTER:0:125000000, responses:COUNTER:0:125000000
dns_opcode value:COUNTER:0:65535
dns_qtype value:COUNTER:0:65535
+dns_qtype_cached value:GAUGE:0:4294967295
+dns_query value:COUNTER:0:65535
dns_question value:COUNTER:0:65535
dns_rcode value:COUNTER:0:65535
+dns_reject value:COUNTER:0:65535
dns_request value:COUNTER:0:65535
dns_resolver value:COUNTER:0:65535
+dns_response value:COUNTER:0:65535
+dns_transfer value:COUNTER:0:65535
dns_update value:COUNTER:0:65535
dns_zops value:COUNTER:0:65535
-dns_notify value:COUNTER:0:65535
-dns_transfer value:COUNTER:0:65535
-dns_query value:COUNTER:0:65535
-dns_response value:COUNTER:0:65535
-dns_reject value:COUNTER:0:65535
email_check value:GAUGE:0:U
email_count value:GAUGE:0:U
email_size value:GAUGE:0:U