-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mention plugin exit codes outside [0..3] in the plugin output and warning log #10021
Conversation
52c6842
to
98ecb61
Compare
@Al2Klimov looks fine. If there is no output from the check plugin, any information helps. So you don't have to start the debug log on an agent. Especially if you have'nt any (direct) access to the server and always need different colleagues for it. So big thumb up and thank you! Should we test it? If yes, were we can get the Windows-Setup-Files for this patch? But I'm sure, if you patched it, it will work fine ;-) |
Which Icinga version shall I cherry pick this patch on top? |
We use 2.14.2 |
You can download the artifacts here: https://git.icinga.com/packaging/windows-icinga2/-/jobs/490746 |
There seems to be an overflow though. The logs you shared in the ticket show a positive value instead:
And indeed, this value is exactly I think it would also make sense to (maybe additionally) show the hexadecimal value on Windows, as that's how those are typically presented, for example 3221225477 is listed as 0xC0000005 STATUS_ACCESS_VIOLATION there. Side note: you don't have to resort to the logs, the exit code is also part of the check result. I still think it makes sense to have this in the output just like it's also done with signals on Linux. The |
@julianbrost you're right, Any optimized output is appreciated. But now it's better than any empty output like before. ;-) At the end every - let's say - "normal" user (not Admin like us) - should see what's going on in the UI in the plugin output. |
98ecb61
to
778b230
Compare
@julianbrost @stevie-sy https://git.icinga.com/packaging/windows-icinga2/-/jobs/495257 |
My colleague reinstalled the agent with the new package on an affected server. And the benefit now: Thank you. Great work! |
@@ -25,7 +26,7 @@ struct ProcessResult | |||
pid_t PID; | |||
double ExecutionStart; | |||
double ExecutionEnd; | |||
long ExitStatus; | |||
int_fast64_t ExitStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't understand why you are changing this, why not keep using long
? What benefits does this fancy type have over the original type in this specific context and its intended usage? I would simply change the type of the CheckResult#exit_status
attribute from int
to long
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm addressing a 32-bit overflow here, so I need 64+ bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm addressing a 32-bit overflow here, so I need 64+ bits.
First of all, it is not ProcessResult#ExitStatus
that's overflowing int32
, but CheckResult#exit_status
, which has been of type int
so far. Secondly, int_fast64_t
is just an alias of some other 64
bit types, e.g. on my Mac it is just an alias of int64_t
and the compiler might do some optimisations based on this type when doing some sophisticated arithmetic, but it is not intended to overcome 64+
overflows.
I just don't think it's needed here and long
should be way more than enough for signals/exit codes IMHO, given that there are no 64+ systems at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- CheckResult#exit_status gets set from ProcessResult#ExitStatus, so both need a large type
- Just grep for int_fast in the code - if we need X bits, we declare it explicitly
- long has 32 bits, even on x64 Windows https://learn.microsoft.com/en-us/cpp/build/common-visual-cpp-64-bit-migration-issues?view=msvc-170&redirectedfrom=MSDN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3. long has 32 bits, even on x64 Windows https://learn.microsoft.com/en-us/cpp/build/common-visual-cpp-64-bit-migration-issues?view=msvc-170&redirectedfrom=MSDN
An int and a long are 32-bit values on 64-bit Windows operating systems.
🤦♂️! I wasn't aware of this sh*tty operating system.
std::stringstream crOutput; | ||
|
||
crOutput << "<Terminated with exit code " << pr.ExitStatus | ||
<< " (0x" << std::noshowbase << std::hex << std::uppercase << pr.ExitStatus << ").>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice, but obvious code is even nicer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested only on my MacBook! LFTM!
Before:*
...
"execution_end": 1712328047.745857,
"execution_start": 1712328047.74055,
"exit_status": -2147483648,
"output": "Overflowing exit code (2^31)\\n",
After:
...
"execution_end": 1712328344.578195,
"execution_start": 1712328344.571937,
"exit_status": 2147483648,
"output": "Overflowing exit code (2^31)\\n<Terminated with exit code 2147483648 (0x80000000).>",
so that they can hold Windows exit codes like 3221225477 (>2147483647).
…ide 0..3 in the plugin output as well, in addition to the warning log.
778b230
to
bb13e98
Compare
to simplify debugging. Now customers seeing a misbehaving plugin don't have to turn on debug logs.
ref/IP/52294
Test
👍