From 086400e695e9348d4fba797f1af75505ec8f42e4 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 6 Sep 2009 11:00:27 +0200 Subject: [PATCH] =?utf8?q?contrib/cussh.pl:=20Add=20support=20for=20the=20?= =?utf8?q?=E2=80=9CGETTHRESHOLD=E2=80=9D=20command.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- contrib/cussh.pl | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/contrib/cussh.pl b/contrib/cussh.pl index 3f1f7c80..b2a44eeb 100755 --- a/contrib/cussh.pl +++ b/contrib/cussh.pl @@ -60,6 +60,7 @@ use Collectd::Unixsock(); HELP => \&cmd_help, PUTVAL => \&putval, GETVAL => \&getval, + GETTHRESHOLD => \&getthreshold, FLUSH => \&flush, LISTVAL => \&listval, PUTNOTIF => \&putnotif, @@ -191,6 +192,7 @@ Available commands: HELP PUTVAL GETVAL + GETTHRESHOLD FLUSH LISTVAL PUTNOTIF @@ -281,6 +283,48 @@ sub getval { return 1; } +=item B I + +=cut + +sub getthreshold { + my $sock = shift || return; + my $line = shift || return; + + my @line = tokenize($line); + + my $id; + my $vals; + + if (! @line) { + return; + } + + if (scalar(@line) < 1) { + print STDERR "Synopsis: GETTHRESHOLD " . $/; + return; + } + + $id = getid($line[0]); + + if (! $id) { + print STDERR "Invalid id \"$line[0]\"." . $/; + return; + } + + $vals = $sock->getthreshold(%$id); + + if (! $vals) { + print STDERR "socket error: " . $sock->{'error'} . $/; + return; + } + + foreach my $key (keys %$vals) { + print "\t$key: $vals->{$key}\n"; + } + return 1; +} + =item B [B=I<$timeout>] [B=I<$plugin>[ ...]] =cut -- 2.30.2