| [Date Prev] [Date Next] | [Thread Prev] [Thread Next] | [Date Index] [Thread Index] |
[snips-users] Garbage characters in snips log files
|
Hello,
Todd and I have discovered the cause of the random garbage characters
in the units field of the logs and various other output. E.g.
Sun Dec 7 18:43:04 2003 [hostmon]: DEVICE a_host_name a_host_name
VAR Load5 2 2 load-5mi^C^C^Bÿ(×Ó?(×Ó? LEVEL Warning LOGLEVEL Warning
STATE down
The problem is that the varunits field in the EVENT structure
(include/snips.h) is "char units[8];".
Obviously, "load-5min" is 9 characters. Other units which display
this problem are also longer than 8 characters.
The quick fix is to substr the units to 7 characters long. This
can be done in the perl code without recompiling, which is very
attractive. (I think the C code needs an end of string character.
We had tried the fix substringing to 8 character and still had
the problem. 7 characters appears to be enough.)
As a context diff:
==============Cut here==============================================
*** hostmon 2001-09-24 09:32:22.000000000 -0600
--- hostmon.new 2003-12-11 12:54:42.000000000 -0700
***************
*** 269,275 ****
}
## for snmpmon/hostmon-collector datafiles
elsif ( /^\s*(\S+)\s+(\d+)\s+(\S+)(\s+(\S.*)?)?\s*$/ ) {
! ($curvar, $curvalue, $curunit, $comment) = ($1, $2, $3, $5);
$comment = "" if (!defined ($comment));
}
else {
--- 269,275 ----
}
## for snmpmon/hostmon-collector datafiles
elsif ( /^\s*(\S+)\s+(\d+)\s+(\S+)(\s+(\S.*)?)?\s*$/ ) {
! ($curvar, $curvalue, $curunit, $comment) = ($1, $2, substr($3,0,7), $5);
$comment = "" if (!defined ($comment));
}
else {
==============Cut here==============================================
--
Anthony Vealé
National Snow and Ice Data Center
E-Mail: veale at nsidc org
Phone: (303)735-5069
|