{"action":"created","issue":{"url":"https://api.github.com/repos/NagiosEnterprises/nagioscore/issues/442","repository_url":"https://api.github.com/repos/NagiosEnterprises/nagioscore","labels_url":"https://api.github.com/repos/NagiosEnterprises/nagioscore/issues/442/labels{/name}","comments_url":"https://api.github.com/repos/NagiosEnterprises/nagioscore/issues/442/comments","events_url":"https://api.github.com/repos/NagiosEnterprises/nagioscore/issues/442/events","html_url":"https://github.com/NagiosEnterprises/nagioscore/issues/442","id":267693329,"node_id":"MDU6SXNzdWUyNjc2OTMzMjk=","number":442,"title":"Nagios Core call NEB method after nebmodule_deinit() was executed","user":{"login":"nook24","id":9019992,"node_id":"MDQ6VXNlcjkwMTk5OTI=","avatar_url":"https://avatars1.githubusercontent.com/u/9019992?v=4","gravatar_id":"","url":"https://api.github.com/users/nook24","html_url":"https://github.com/nook24","followers_url":"https://api.github.com/users/nook24/followers","following_url":"https://api.github.com/users/nook24/following{/other_user}","gists_url":"https://api.github.com/users/nook24/gists{/gist_id}","starred_url":"https://api.github.com/users/nook24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nook24/subscriptions","organizations_url":"https://api.github.com/users/nook24/orgs","repos_url":"https://api.github.com/users/nook24/repos","events_url":"https://api.github.com/users/nook24/events{/privacy}","received_events_url":"https://api.github.com/users/nook24/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"hedenface","id":16650353,"node_id":"MDQ6VXNlcjE2NjUwMzUz","avatar_url":"https://avatars2.githubusercontent.com/u/16650353?v=4","gravatar_id":"","url":"https://api.github.com/users/hedenface","html_url":"https://github.com/hedenface","followers_url":"https://api.github.com/users/hedenface/followers","following_url":"https://api.github.com/users/hedenface/following{/other_user}","gists_url":"https://api.github.com/users/hedenface/gists{/gist_id}","starred_url":"https://api.github.com/users/hedenface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hedenface/subscriptions","organizations_url":"https://api.github.com/users/hedenface/orgs","repos_url":"https://api.github.com/users/hedenface/repos","events_url":"https://api.github.com/users/hedenface/events{/privacy}","received_events_url":"https://api.github.com/users/hedenface/received_events","type":"User","site_admin":false},"assignees":[{"login":"hedenface","id":16650353,"node_id":"MDQ6VXNlcjE2NjUwMzUz","avatar_url":"https://avatars2.githubusercontent.com/u/16650353?v=4","gravatar_id":"","url":"https://api.github.com/users/hedenface","html_url":"https://github.com/hedenface","followers_url":"https://api.github.com/users/hedenface/followers","following_url":"https://api.github.com/users/hedenface/following{/other_user}","gists_url":"https://api.github.com/users/hedenface/gists{/gist_id}","starred_url":"https://api.github.com/users/hedenface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hedenface/subscriptions","organizations_url":"https://api.github.com/users/hedenface/orgs","repos_url":"https://api.github.com/users/hedenface/repos","events_url":"https://api.github.com/users/hedenface/events{/privacy}","received_events_url":"https://api.github.com/users/hedenface/received_events","type":"User","site_admin":false}],"milestone":null,"comments":20,"created_at":"2017-10-23T14:37:23Z","updated_at":"2018-06-04T17:50:11Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\nI noticed an issue with my Nagios Event Broker Module, but I'm not able to trace this back to find the root cause of my issue. So may be it is not a Nagios issue and I just misunderstood something.\r\n\r\nMy Broker Module fetch every Nagios event, and export it to a Gearman Queue as json objects. I noticed that if I try to restart Nagios Core, i get the following message to the nagios.log:\r\n````\r\n[1508766761] Caught SIGTERM, shutting down...\r\n[1508766761] Caught SIGTERM, shutting down...\r\n[1508766761] wproc: Socket to worker Core Worker 31996 broken, removing\r\n[1508766761] wproc: Socket to worker Core Worker 31993 broken, removing\r\n[1508766761] wproc: Socket to worker Core Worker 31995 broken, removing\r\n[1508766761] wproc: Socket to worker Core Worker 31994 broken, removing\r\n[1508766761] Successfully shutdown... (PID=31990)\r\n[1508766761] Event broker module 'NERD' deinitialized successfully.\r\n[1508766761] [Statusengine] Deregister callbacks\r\n[1508766761] [Statusengine] We are done here\r\n[1508766761] [Statusengine] Bye\r\n[1508766761] Event broker module '/opt/nagios_420/statusengine-4-1-0.o' deinitialized successfully.\r\n[1508766761] Caught SIGTERM, shutting down...\r\n[1508766761] flush(Broken pipe) lost connection to server during send -> libgearman/connection.cc:830\r\n````\r\n\r\nIf the [nebmodule_deinit](https://github.com/statusengine/module/blob/master/src/statusengine.c#L339) method of the broker gets called, it will write `[Statusengine] Deregister callbacks` to the nagios.log.\r\n\r\nIt looks like, that after deinit was called, Nagios still call the modules callback to export other log entries. Which should be the reason for the broken pipe message.\r\n\r\nIf I `strace` the Nagios process, I can see, that the Callback of the broker try to export nagios log messages:\r\n````\r\nsetsockopt(10, SOL_SOCKET, SO_RCVBUF, [32768], 4) = 0\r\nconnect(10, {sa_family=AF_INET, sin_port=htons(4730), sin_addr=inet_addr(\"127.0.0.1\")}, 16) = -1 EINPROGRESS (Operation now in progress)\r\npoll([{fd=10, events=POLLOUT}], 1, -1)  = 1 ([{fd=10, revents=POLLOUT}])\r\nsendto(10, \"\\0REQ\\0\\0\\0\\22\\0\\0\\1\\36statusngin_logentrie\"..., 298, MSG_NOSIGNAL, NULL, 0) = 298\r\npoll([{fd=10, events=POLLIN}], 1, -1)   = 1 ([{fd=10, revents=POLLIN}])\r\nrecvfrom(10, \"\\0RES\\0\\0\\0\\10\\0\\0\\0\\35H:dziegler-master-xe\"..., 8192, MSG_NOSIGNAL, NULL, NULL) = 41\r\nrecvfrom(10, 0x16ae8a1, 8192, MSG_NOSIGNAL, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)\r\n````\r\nAnd run into a broken pipe, because nebmodule_deinit was already executed.\r\n\r\nSo my broker don't use threads, but I guess this issue is related to internal Nagios threads and is just a timing issue.\r\nThread 1 call deinit of the broker\r\nThread 2 call the broker callbacks to process log entries\r\n\r\nThis happens on Nagios 4.0.8 and 4.3.4. \r\n\r\nMay be you have an idea, of how I could prevent this issue.\r\nI also tried something like this, but this was not helping at all:\r\n````C\r\nint init = 0;\r\n\r\nint nebmodule_init(int flags, char *args, nebmodule *handle){\r\n    init = 1;\r\n    //Rest of the code\r\n}\r\n\r\nint nebmodule_deinit(int flags, int reason){\r\n    init = 0;\r\n    //Rest of the code\r\n}\r\n\r\nint statusengine_handle_data(int event_type, void *data){\r\n    if(init == 0){\r\n        return 0;\r\n    }\r\n    //Rest of the code\r\n}\r\n````\r\n\r\nThe Broker Code is available here: https://github.com/statusengine/module/blob/master/src/statusengine.c"},"comment":{"url":"https://api.github.com/repos/NagiosEnterprises/nagioscore/issues/comments/394441310","html_url":"https://github.com/NagiosEnterprises/nagioscore/issues/442#issuecomment-394441310","issue_url":"https://api.github.com/repos/NagiosEnterprises/nagioscore/issues/442","id":394441310,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDQ0MTMxMA==","user":{"login":"nook24","id":9019992,"node_id":"MDQ6VXNlcjkwMTk5OTI=","avatar_url":"https://avatars1.githubusercontent.com/u/9019992?v=4","gravatar_id":"","url":"https://api.github.com/users/nook24","html_url":"https://github.com/nook24","followers_url":"https://api.github.com/users/nook24/followers","following_url":"https://api.github.com/users/nook24/following{/other_user}","gists_url":"https://api.github.com/users/nook24/gists{/gist_id}","starred_url":"https://api.github.com/users/nook24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nook24/subscriptions","organizations_url":"https://api.github.com/users/nook24/orgs","repos_url":"https://api.github.com/users/nook24/repos","events_url":"https://api.github.com/users/nook24/events{/privacy}","received_events_url":"https://api.github.com/users/nook24/received_events","type":"User","site_admin":false},"created_at":"2018-06-04T17:50:11Z","updated_at":"2018-06-04T17:50:11Z","author_association":"NONE","body":"I crated a bash script, which install Nagios 4.3.4 and the stripped Statusengine broker. I tested this script on a blank Ubuntu 16.04 digitalocean Droplet, but it should work on every blank Ubuntu 16.04 box: https://gist.github.com/nook24/a5b6ae30f56d4f6187837d85382e50ef\r\n\r\nI also noticed, that I can **not** reproduce the issue, if I run Nagios in foreground and kill it in a second terminal. Also if I run `bin/nagios -d etc/nagios.cfg` kill it with a second terminal, everything works.\r\n\r\nBut: If if try to restart or stop nagios via systemd, things get smashed up. I also recorded my terminal for you, so you can see what I've done so far: https://asciinema.org/a/poIzLG9oLL1mDD7ovrVNXyKJD\r\n\r\nThe new broker version with `signal()`: https://gist.github.com/nook24/1474fed0add839e95651094de4090bcc\r\n\r\nAs already mentioned, this only happens, if the broker export nagios logentires. If I disable logentries in the broker model, everything works fine - I have no idea..."}}
{"actor":{"display_login":"nook24"}}