orangeCatDeveloper opened a new pull request, #4308:
URL: https://github.com/apache/hertzbeat/pull/4308

   ## What's changed?
   
   Fixes #1560: an SSH/script `oneRow` command whose trailing check produces no 
output (e.g. `df -hT | grep -o "some-mount"` when the mount is gone) fails the 
whole collection, so the metric disappears exactly when the user needs to see 
and alert on the gap.
   
   Two paths caused it:
   
   - **Partial output**: `parseResponseDataByOne` dropped the entire row when 
output lines < alias fields — even the values that were collected. This is the 
reporter's `ssh response data not enough` log. The loop below that check 
already pads missing columns with `NULL_VALUE`; the check is simply removed.
   - **Empty output**: any blank stdout was `FAIL: response data is null`. Now 
a blank one-row result with no stderr and exit status <= 1 (the grep-no-match 
signature) becomes a row of `NULL_VALUE` — visible and alertable 
(`!exists(field)`), while real failures still fail, with the message upgraded 
to carry the captured stderr or exit code.
   
   To make that distinction possible, both collectors now capture stderr and 
the exit status (ssh previously dumped remote stderr to `System.err`; script 
never read it — its stderr is drained on a daemon thread to avoid pipe 
deadlock). The duplicated one-row parsing in the two collectors is merged into 
`OneRowResponseSupport`. Known tradeoff, pinned by a test: a command that exits 
1 silently with no output is indistinguishable from a grep no-match and is 
accepted as empty data.
   
   Also adds an optional `charset` to `SshProtocol` (default UTF-8) so 
non-UTF-8 remote output decodes correctly, matching what `ScriptProtocol` 
already had.
   
   The script collector is fixed alongside ssh because it shared the identical 
copy-pasted logic; no other collector has the one-row command semantics.
   
   Before/after with the reporter's script shape (`echo 52; echo 35.8033; echo 
5%; grep -o 'missing-mount' ...`, 5 alias fields) against a real sshd:
   
   ```
   before: no metric row; each cycle logs "ssh response data not enough: 52 ..."
   after:  row = 52 / 35.8033 / 5% / null / <responseTime>, no errors
   ```
   
   ## Checklist
   
   - [x]  I have read the [Contributing 
Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide)
   - [x]  I have written the necessary doc or comment.
   - [x]  I have added the necessary unit tests and all cases have passed.
   
   ## Add or update API
   
   - [ ] I have added the necessary [e2e 
tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have 
passed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to