X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=contrib%2Fcussh.pl;h=ae758d17b14e1600188f57386572a339c6e338f0;hp=320bf73b047323e71e56189bb58e67363469aedb;hb=de407dd4e036f73e9bd4658af9d71f504fc11109;hpb=9d15d1058b93acb7be041934acfe76548539041a diff --git a/contrib/cussh.pl b/contrib/cussh.pl index 320bf73b..ae758d17 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, @@ -198,6 +199,7 @@ Available commands: HELP PUTVAL GETVAL + GETTHRESHOLD FLUSH LISTVAL PUTNOTIF @@ -327,6 +329,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