X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=contrib%2Fcussh.pl;h=ee4c89396b98d0ecaa9ae2e1769b26876a4cc787;hb=98062438c25226e2e4a28ab629de5dfa27a79913;hp=f95d54d2010eac76bd1e0a134d17b23fdd9fe383;hpb=6acb19befc321c501e4d8b79f403ebda0c021acc;p=collectd.git diff --git a/contrib/cussh.pl b/contrib/cussh.pl index f95d54d2..ee4c8939 100755 --- a/contrib/cussh.pl +++ b/contrib/cussh.pl @@ -62,6 +62,7 @@ use Collectd::Unixsock(); GETVAL => \&getval, FLUSH => \&flush, LISTVAL => \&listval, + PUTNOTIF => \&putnotif, }; if (! $sock) { @@ -163,6 +164,7 @@ Available commands: GETVAL FLUSH LISTVAL + PUTNOTIF See the embedded Perldoc documentation for details. To do that, run: perldoc $0 @@ -243,6 +245,15 @@ sub flush { elsif ($option eq "timeout") { $args{"timeout"} = $value; } + elsif ($option eq "identifier") { + my $id = getid (\$value); + if (!$id) + { + print STDERR "Not a valid identifier: \"$value\"\n"; + next; + } + push @{$args{"identifier"}}, $id; + } else { print STDERR "Invalid option \"$option\".\n"; return; @@ -281,6 +292,29 @@ sub listval { return 1; } +=item B [[B=I<$severity>] [B=I<$message>] [ ...]] + +=cut + +sub putnotif { + my $sock = shift || return; + my $line = shift || return; + + my (%values) = (); + foreach my $i (split m/ /, $line) { + my($key,$val) = split m/=/, $i, 2; + if ($key && $val) { + $values{$key} = $val; + } + else { + $values{'message'} .= ' '.$key; + } + } + $values{'time'} ||= time(); + my(@tmp) = %values; + return $sock->putnotif(%values); +} + =back These commands follow the exact same syntax as described in