From: Florian Forster Date: Sun, 6 Sep 2009 09:00:27 +0000 (+0200) Subject: contrib/cussh.pl: Add support for the “GETTHRESHOLD” command. X-Git-Tag: collectd-4.8.0~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=086400e695e9348d4fba797f1af75505ec8f42e4;p=collectd.git contrib/cussh.pl: Add support for the “GETTHRESHOLD” command. --- 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