-
-
Notifications
You must be signed in to change notification settings - Fork 990
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
OPNSense widget #730
OPNSense widget #730
Conversation
Cool. Why are cpu and memory unreliable? Regex matching in general isn’t the most reliable thing but sometimes unavoidable |
Well, CPU usage sometime displays "NaN" and I can't understand why. The memory usage displayed by the widget is not the same as in the dashboard. Values returned by the API call are not the same. I've asked why on the OPNsense forum. If I don't get any answer, I think I'll have to write a special proxy for OPNsense and call the widget API, which is not callable in API mode (you have to be logged on the firewall interface to call it). EDIT : beside, I'm only using regex for isolate the uptime. To isolate the CPU and memory values, I'm using the split function. I can send you the JSON result of the API call if you want. |
Gotcha. In general we prefer widgets to not use their own proxy if possible, hugely reduces code maintenance, errors, etc Once I figure out how to get one of these setup I can test and review |
That's what I thought and honestly, I would really prefer it without a proxy.js file. I've found the reason why the CPU value is unreliable, my split code is wrong : sometime, values are separated by two spaces, and sometime, not. So I think I'll use substr instead. EDIT : it seems the substr function is deprecated so I'm using substring 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.
Overall nice, works great.
I think the calculations are overkill, I would just change to using the statistics reported from the api.
I also think that 5 blocks gets pretty cramped (see below) so I would advocate for reducing this by at least 1. In fact I would say to remove the WAN data and then you can remove the second API call to keep things speedier. But up to you on that last point, I didnt include it in the suggestions.
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.
couple other random things
That is the data requested in the enhancement request. But I'm wondering if the uptime is really that important a data to see : if the firewall were to reboot, the WAN datas will be reset to zero at the reboot moment so you'll see a huge decrease on the widget. |
Yea but as the widget author it’s really up to you :) |
Mate, you asked for feedback and are ignoring it even though you mentioned not being very comfortable with JS. We appreciate your contribution but please understand that part of the job here is to try and maintain consistent code quality. The memory calc isnt working in my testing. Again, my suggestions are meant to simplify your code and make it less error-prone. Please adjust. |
* OPNSense widget : initial version, memory usage is inaccurate. * OPNSense widget : code cleanup in widget.js. Firewall is no longer displayed, so it did not need to be queried.
* OPNSense widget : initial version, memory usage is inaccurate. * OPNSense widget : code cleanup in widget.js. Firewall is no longer displayed, so it did not need to be queried. * OPNSense widget : fixing the CPU code to make it more reliable. * OPNSense widget : fixing the CPU code to make it more reliable. Removing uptime info
It was a code suggestion above, you can just apply suggestions using the GH site |
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
Let me know if youre still working on this (obviously if youre offline no worries) |
I have to work (holidays are over) but I think I'll work on it in the evening. As the memory code is really unreliable (as per your testings, I'm not the only one in this case) I think I'm going to drop it, because I think it's better to report no value than a unreliable value. |
I agree. That change is also a suggestion here, if you dont mind we can apply and get this merged and done. |
If I understand correctly, your proposition is to report the active memory, and I don't think that's a meaningful value. I'm more into purely stopping to report memory usage until I have a reliable way to retrieve it. |
I mean, if you feel strongly OK, but I would think most people would find the active memory value more useful than nothing, no? |
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
That's a valid point, I've validated your commits. |
Cheers, thanks for all the effort |
I've added more details so only the least required amount of privileges are given to use this widget and also removed the `uptime` field which is non-functional and [I can't see a reference to it in the code](https://github.com/benphelps/homepage/blob/main/src/widgets/opnsense/component.jsx#L23-L26), so I think it was a leftover from a conversation [here.](gethomepage/homepage#730 (comment))
I've added more details so only the least required amount of privileges are given to use this widget and also removed the `uptime` field which is non-functional and [I can't see a reference to it in the code](https://github.com/benphelps/homepage/blob/main/src/widgets/opnsense/component.jsx#L23-L26), so I think it was a leftover from a conversation [here.](gethomepage/homepage#730 (comment))
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns. |
First working version of OPNsense widget. CPU and memory usage are not quite reliable yet.