summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0a905cb)
raw | patch | inline | side by side (parent: 0a905cb)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 25 Mar 2008 14:59:40 +0000 (15:59 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 26 Mar 2008 08:37:02 +0000 (09:37 +0100) |
Also fixed the following minor problems:
* the arguments passed to Collectd::Unixsock::putval() have been updated
to the current version of the Perl module
* remove newlines from the end of the input line - the unixsock plugin
currently seems to be buggy when receiving two newlines in a row
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
* the arguments passed to Collectd::Unixsock::putval() have been updated
to the current version of the Perl module
* remove newlines from the end of the input line - the unixsock plugin
currently seems to be buggy when receiving two newlines in a row
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
contrib/cussh.pl | patch | blob | history |
diff --git a/contrib/cussh.pl b/contrib/cussh.pl
index c19c3f3092c659a860e108b753fac6505dcba3c6..df3df344aed962777d7b2e6eea085da82f390a5c 100755 (executable)
--- a/contrib/cussh.pl
+++ b/contrib/cussh.pl
my $sock = Collectd::Unixsock->new($path);
my $cmds = {
- PUTVAL => \&putval,
- GETVAL => \&getval,
- FLUSH => \&flush,
+ PUTVAL => \&putval,
+ GETVAL => \&getval,
+ FLUSH => \&flush,
+ LISTVAL => \&listval,
};
if (! $sock) {
exit 1;
}
- print "cussh version 0.2, Copyright (C) 2007 Sebastian Harl\n"
+ print "cussh version 0.2, Copyright (C) 2007-2008 Sebastian Harl\n"
. "cussh comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
. "and you are welcome to redistribute it under certain conditions.\n"
. "See the GNU General Public License 2 for more details.\n\n";
print "cussh> ";
my $line = <STDIN>;
- last if ((! $line) || ($line =~ m/^quit$/i));
+ last if (! $line);
+
+ chomp $line;
+
+ last if ($line =~ m/^quit$/i);
my ($cmd) = $line =~ m/^(\w+)\s+/;
$line = $';
return \%id;
}
+sub putid {
+ my $ident = shift || return;
+
+ my $string;
+
+ $string = $ident->{'host'} . "/" . $ident->{'plugin'};
+
+ if (defined $ident->{'plugin_instance'}) {
+ $string .= "-" . $ident->{'plugin_instance'};
+ }
+
+ $string .= "/" . $ident->{'type'};
+
+ if (defined $ident->{'type_instance'}) {
+ $string .= "-" . $ident->{'type_instance'};
+ }
+ return $string;
+}
+
=head1 COMMANDS
=over 4
=item B<GETVAL> I<Identifier>
-=item B<PUTVAL> I<Identifier> I<Valuelist>
-
-These commands follow the exact same syntax as described in
-L<collectd-unixsock(5)>.
-
=cut
sub putval {
}
my ($time, @values) = split m/:/, $line;
- return $sock->putval(%$id, $time, \@values);
+ return $sock->putval(%$id, time => $time, values => \@values);
}
+=item B<PUTVAL> I<Identifier> I<Valuelist>
+
+=cut
+
sub getval {
my $sock = shift || return;
my $line = shift || return;
my $vals = $sock->getval(%$id);
- return if (! $vals);
+ if (! $vals) {
+ print STDERR $sock->{'error'} . $/;
+ return;
+ }
foreach my $key (keys %$vals) {
print "\t$key: $vals->{$key}\n";
return 1;
}
+=item B<FLUSH> [B<timeout>=I<$timeout>] [B<plugin>=I<$plugin>[ ...]]
+
+=cut
+
sub flush {
my $sock = shift || return;
my $line = shift;
return 1;
}
+=item B<LISTVAL>
+
+=cut
+
+sub listval {
+ my $sock = shift || return;
+
+ my @res;
+
+ @res = $sock->listval();
+
+ if (! @res) {
+ print STDERR $sock->{'error'} . $/;
+ return;
+ }
+
+ foreach my $ident (@res) {
+ print $ident->{'time'} . " " . putid($ident) . $/;
+ }
+ return 1;
+}
+
+=back
+
+These commands follow the exact same syntax as described in
+L<collectd-unixsock(5)>.
+
=head1 SEE ALSO
L<collectd(1)>, L<collectd-unisock(5)>