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
WIP: syslog-ng-ctl: add start and stop internal log message command. #2840
base: master
Are you sure you want to change the base?
WIP: syslog-ng-ctl: add start and stop internal log message command. #2840
Conversation
This user does not have permission to start the build. Can one of the admins verify this patch and start the build? |
Build FAILURE |
dc23973
to
2e032e7
Compare
Build FAILURE |
ce14eec
to
499ca1e
Compare
Build FAILURE |
``
With this change, it will collect logs at higher levels. I think it was one of the requirements of this feature. |
ok. I will first stop the collection and then get the internal message logs |
499ca1e
to
0849bb3
Compare
Build FAILURE |
Yes, it is. But the question how much higher should it be is still open, well it gave an answer as highest. But imho that is not good enough. So it should be up to the user to decide, it could be configured like
Which is good enough for now, one could simply do:
|
0849bb3
to
db3e2f8
Compare
Build SUCCESS |
db3e2f8
to
2aeaa5f
Compare
Build SUCCESS |
Build SUCCESS |
Build SUCCESS |
Build FAILURE |
c9c13fb
to
1ee4e6a
Compare
Build SUCCESS |
1ee4e6a
to
0d5dcb9
Compare
Build SUCCESS |
0d5dcb9
to
d42e9d1
Compare
Build SUCCESS |
d42e9d1
to
e2c2a8e
Compare
Build SUCCESS |
e2c2a8e
to
243a0e6
Compare
Build SUCCESS |
243a0e6
to
acef9ee
Compare
Build SUCCESS |
acef9ee
to
4fada10
Compare
Build SUCCESS |
while (!g_queue_is_empty(internal_msg_queue)) | ||
{ | ||
msg = g_queue_pop_head(internal_msg_queue); | ||
msg_text = log_msg_get_value(msg, LM_V_MESSAGE, NULL); |
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 suggest doing something similar that is used in dqtool (dqtool.c). Dqtool allows specifying a template function as cli parameter. You can use that input to format the message. If template function is not provided, I think the same default can be fine that is used in dqtool: log_template_compile(template, "$DATE $HOST $MSGHDR$MSG\n", NULL);
.
log_writer_format_log
would be somewhat difficult to use, as you would need a (at least partially) initialized LogWriter instance.
control_internal_logs(ControlConnection *cc, GString *command, gpointer user_data) | ||
{ | ||
GString *result = g_string_new(""); | ||
gchar **arguments = g_strsplit(command->str, " ", 0); |
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 should be freed in the end with g_strfreev()
.
slng_internal(int argc, char *argv[], const gchar *mode, GOptionContext *ctx) | ||
{ | ||
GString *cmd = g_string_new(""); | ||
|
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.
If neither start or stop are provided, I think we should write an error. Now the cli exits silently. Well the error code is not zero, so not entirely silently. Still, we could write something out.
else if (config_options_stop) | ||
g_string_assign(cmd, "INTERLOGS STOP"); | ||
else | ||
return 1; |
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.
We should not allow that start and stop are provided at the same time.
else if (g_str_equal(arguments[1], "STOP")) | ||
{ | ||
afinter_stop_live_collection(); | ||
afinter_get_collected_messages(result); |
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 get assertion error with the following case:
@version: 3.25
log {
source { example-msg-generator(num(1)); };
destination { file(/dev/stdout); };
};
Start syslog-ng with ./syslog-ng -Fe -f ../etc/internal.conf
.
After calling start, and then stop, syslog-ng emits:
[2020-03-03T13:05:58.048621] g_queue_is_empty: assertion 'queue != NULL' failed
} | ||
|
||
if (!strlen(result->str)) | ||
g_string_assign(result, "No live messages collected"); |
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.
The log collection does not work for me some reason. I am generating messages continuously with:
@version: 3.25
log {
source { example-msg-generator(); };
destination { file(/dev/stdout); };
};
Starting syslog-ng with -Fevdt, I can see internal logs generating continuously. However when I start the cli, wait a few seconds, then stop it, I only see this error message: No live messages collected.
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.
My bad. If I start syslog-ng in foreground, then there will be no internal messages.
Could you please handle as error if someone wants to start the log collection while syslog-ng is running in foreground? Others can run into this as well.
|
||
g_static_mutex_lock(&internal_msg_lock); | ||
|
||
while (!g_queue_is_empty(internal_msg_queue)) |
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 steadily get deadlock in the following case:
@version: 3.25
log {
source { example-msg-generator(); };
destination { file(/dev/stdout); };
};
Start syslog-ng with ./syslog-ng -F -f ../etc/internal.conf
(! just -F, not -Fdt. With -Fdt, I did not see deadlock yet).
After start and stop, syslog-ng hangs. I crashed syslog-ng with segv (kill -segv ), then checked the core dump with gdb: I see syslog-ng hangs while trying to grab a lock during pushing internal message. Moving up in the stack, the message is triggered by g_queue_is_empty
(through a g_log
call). The hint is internal_msg_queue
is empty for some reason, and I think the code wants to emit the same assert that I mentioned in the other comment. So maybe the root cause and the fix is the same.
|
||
while (!g_queue_is_empty(internal_msg_queue)) | ||
{ | ||
msg = g_queue_pop_head(internal_msg_queue); |
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 message needs to be unreffed using log_msg_unref
.
@mehul-m-prajapati I think this PR is close to the finish line. Did you have time to look into the review comments? Is there anything to be clarified? Let me know if you need any help. |
Hi @furiel , Thanks for taking time to review my PR. I will make changes in this week. |
afinter: add functions to collect internal messages at higher level. Signed-off-by: Mehul Prajapati <mehul.encs@gmail.com>
4fada10
to
c9f6bf8
Compare
Build SUCCESS |
Hi,
This patch will add 2 new syslog-ng-ctl commands,
Later, I will use these commands in debun to save internal log messages in a file.
To set message levels,
resolves mehul-m-prajapati/gsoc-debun-tool#5
Thanks,
Mehul