projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
761b500
)
contrib/cussh.pl: Improved error reporting.
author
Sebastian Harl
<sh@tokkee.org>
Thu, 19 Feb 2009 10:04:49 +0000
(11:04 +0100)
committer
Sebastian Harl
<sh@tokkee.org>
Thu, 19 Feb 2009 12:51:59 +0000
(13:51 +0100)
contrib/cussh.pl
patch
|
blob
|
history
diff --git
a/contrib/cussh.pl
b/contrib/cussh.pl
index
ee4c893
..
47c72c3
100755
(executable)
--- a/
contrib/cussh.pl
+++ b/
contrib/cussh.pl
@@
-182,13
+182,20
@@
sub putval {
my $id = getid(\$line);
my $id = getid(\$line);
+ my $ret;
+
if (! $id) {
if (! $id) {
- print STDERR
$sock->{'error'}
. $/;
+ print STDERR
"Invalid id \"$line\"."
. $/;
return;
}
my ($time, @values) = split m/:/, $line;
return;
}
my ($time, @values) = split m/:/, $line;
- return $sock->putval(%$id, time => $time, values => \@values);
+ $ret = $sock->putval(%$id, time => $time, values => \@values);
+
+ if (! $ret) {
+ print STDERR "socket error: " . $sock->{'error'} . $/;
+ }
+ return $ret;
}
=item B<PUTVAL> I<Identifier> I<Valuelist>
}
=item B<PUTVAL> I<Identifier> I<Valuelist>
@@
-202,14
+209,14
@@
sub getval {
my $id = getid(\$line);
if (! $id) {
my $id = getid(\$line);
if (! $id) {
- print STDERR
$sock->{'error'}
. $/;
+ print STDERR
"Invalid id \"$line\"."
. $/;
return;
}
my $vals = $sock->getval(%$id);
if (! $vals) {
return;
}
my $vals = $sock->getval(%$id);
if (! $vals) {
- print STDERR $sock->{'error'} . $/;
+ print STDERR
"socket error: " .
$sock->{'error'} . $/;
return;
}
return;
}
@@
-264,10
+271,9
@@
sub flush {
}
if (! $res) {
}
if (! $res) {
- print STDERR $sock->{'error'} . $/;
- return;
+ print STDERR "socket error: " . $sock->{'error'} . $/;
}
}
- return
1
;
+ return
$res
;
}
=item B<LISTVAL>
}
=item B<LISTVAL>
@@
-282,7
+288,7
@@
sub listval {
@res = $sock->listval();
if (! @res) {
@res = $sock->listval();
if (! @res) {
- print STDERR $sock->{'error'} . $/;
+ print STDERR
"socket error: " .
$sock->{'error'} . $/;
return;
}
return;
}
@@
-300,6
+306,8
@@
sub putnotif {
my $sock = shift || return;
my $line = shift || return;
my $sock = shift || return;
my $line = shift || return;
+ my $ret;
+
my (%values) = ();
foreach my $i (split m/ /, $line) {
my($key,$val) = split m/=/, $i, 2;
my (%values) = ();
foreach my $i (split m/ /, $line) {
my($key,$val) = split m/=/, $i, 2;
@@
-311,8
+319,12
@@
sub putnotif {
}
}
$values{'time'} ||= time();
}
}
$values{'time'} ||= time();
- my(@tmp) = %values;
- return $sock->putnotif(%values);
+
+ $ret = $sock->putnotif(%values);
+ if (! $ret) {
+ print STDERR "socket error: " . $sock->{'error'} . $/;
+ }
+ return $ret;
}
=back
}
=back