Skip to content
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

[fix] Fix errors in package and improve debugging #42

Merged
merged 10 commits into from
Jul 24, 2021

Conversation

devkapilbansal
Copy link
Member

@devkapilbansal devkapilbansal commented Jul 13, 2021

Fixes #41

  • Fix error related to monitoring interfaces when * is passed
  • Add verbose mode for easy debugging

@devkapilbansal devkapilbansal changed the base branch from master to gsoc21 July 13, 2021 21:00
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_set_param stderr 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this to log all errors in the instance so that it can be accessed using logread

@@ -52,8 +52,9 @@ start_service() {
monitored_interfaces="--monitored_interfaces $monitored_interfaces"

procd_open_instance "openwisp_monitoring_monitoring"
procd_set_param command $PROG "$base_url" "$uuid" "$key" "$verify_ssl" "$interval" "$monitored_interfaces"
procd_set_param command $PROG $base_url $uuid $key $verify_ssl $interval $monitored_interfaces
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverting quotes as this was causing monitoring.agent to read --url http://www..... as one word

@devkapilbansal devkapilbansal marked this pull request as ready for review July 15, 2021 18:49
@devkapilbansal devkapilbansal moved this from In progress to Needs Review in [GSoC 2021] OpenWRT OpenWISP Monitoring Package Jul 15, 2021
@devkapilbansal devkapilbansal linked an issue Jul 16, 2021 that may be closed by this pull request
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this patch, the daemon sends data to OpenWISP Monitoring 👍 .

Here's the issues I found during testing.

Non verbose mode

I see these two lines in non-verbose mode:

Fri Jul 16 10:32:36 2021 daemon.info monitoring: Collecting NetJSON Monitoring data
Fri Jul 16 10:32:38 2021 daemon.info monitoring: Data sent successfully.

But this output should not be shown in non-verbose mode, otherwise logs will be filled with irrelevant lines.

Traffic stats seem missing

I don't see traffic stats being collected on the device I am using for testing, once I installed this branch and remove the old monitoring scripts, the traffic charts are flat zero.

Did you test this?

Verbose mode testing

Here's a few problems I see with verbose mode.

Identifeir different

The logread output uses different identifiers: monitoring, openwisp_monitoring, openwisp_monitoring[]. This is bad because log collectors will interpret these as different programs, can you make sure this is always the same? monitoring seems to generic, I think it should be openwisp_monitoring.

Logged response can be improved

Here's an example output: Data not sent successfully. Response code is {"detail":"Authentication credentials were not provided."}403.. The message is readable but it's weird. The response body is {"detail":"Authentication credentials were not provided."} while the response status code is 403. Can you turn this into something like:
The response received was: 403 {"detail":"Authentication credentials were not provided."}?

Run with verbose mode redundant

This is showing up with verbose mode:

Fri Jul 16 10:53:31 2021 daemon.err monitoring: Run with verbose mode to find more.
Fri Jul 16 10:53:31 2021 daemon.err openwisp_monitoring[4023]: monitoring: Run with verbose mode to find more.
  1. we're already in verbose mode so we don't need to send this output.
  2. if we're not in verbose mode, ensure the output is not repeated twice
  3. do you see how one log line is identified by daemon.err monitoring and the otehr one by daemon.err openwisp_monitoring[4023]? This was mentioned in one of the previous review sections but please make sure to avoid it.

@@ -1,3 +1,4 @@
config monitoring 'monitoring'
option monitored_interfaces '*'
option monitored_interfaces '"*"'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requiring the user to remember to wrap the value around double quotes is really bad and weird. I think we can do better than this.

@@ -50,10 +51,12 @@ start_service() {
fi
interval="--interval $interval"
monitored_interfaces="--monitored_interfaces $monitored_interfaces"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does

monitored_interfaces="--monitored_interfaces \"$monitored_interfaces\""

allow us to not having to wrap the value in quotes in the UCI config file?

Added default value of version to silent sh: out of range error and replaced == with 0 to follow POSIX notations as it can break on some systems.
@devkapilbansal
Copy link
Member Author

Thanks for testing this. I made some changes as follows:

Non Verbose Mode
Unnecessary lines have been removed. Those two lines will be logged in verbose mode only.

Traffic stats
I just ensured that traffic stats are sent in netjson response from the scripts. Will test it to be more sure.

Identifier
All messages tagged with monitoring are changed to openwisp_monitoring. But in verbose_mode, messages are coming as openwisp_monitoring[number] and I am unsure of that number. I think that this is the id of procd instance. 🤔

Redundant Log Messages
Messages were logged twice in verbose mode. This was because messages were logged once by the logger tagged with the identifier we were passing.These messages were catched by the procd instance and logged again with procd instance name as the identifier.
For this, I removed the identifier from the messages I was logging in verbose mode so that we get relevant lines only when grepping log messages.
If we use logread then the messages are redundant in verbose_mode but passing logread | grep openwisp_monitoring will show the message once.

[GSoC 2021] OpenWRT OpenWISP Monitoring Package automation moved this from Needs Review to Reviewer approved Jul 24, 2021
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a couple of minor improvements 021307c 0083e00.

Tested and it's working better, I think there's room for improvements but let's merge and I will open new issues for improvements.

@nemesifier nemesifier merged commit cded593 into gsoc21 Jul 24, 2021
[GSoC 2021] OpenWRT OpenWISP Monitoring Package automation moved this from Reviewer approved to Done Jul 24, 2021
@devkapilbansal devkapilbansal deleted the issues/41-improve-debugging branch July 25, 2021 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

[bug] Data not sent successfully. Exit code is 127
2 participants