-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Speed up MBUF Usage command in system information widget #4703
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
base: master
Are you sure you want to change the base?
Conversation
GChuf
commented
Oct 12, 2024
•
edited
Loading
edited
- Redmine Issue: https://redmine.pfsense.org/issues/15780
- Ready for review
$mbuf = "{$mbufs_total}/{$mbufs_max}"; | ||
$mbufpercent = ($mbufs_max > 0) ? round(($mbufs_total / $mbufs_max) * 100, 0) : "NA"; | ||
function get_mbuf() { | ||
$mbufs_output=trim(`/usr/bin/vmstat -z | /usr/bin/grep mbuf_cluster | /usr/bin/grep -v debugnet | /usr/bin/awk '{print $3,$4,$5}'`); |
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 does not work properly in several cases. The output is not guaranteed to have spaces between columns.
For example:
: /usr/bin/vmstat -z | /usr/bin/grep mbuf_cluster | /usr/bin/grep -v debugnet
mbuf_cluster: 2048,1000000, 12028, 1434, 144434, 0, 0, 0
: /usr/bin/vmstat -z | /usr/bin/grep mbuf_cluster | /usr/bin/grep -v debugnet | /usr/bin/awk '{print $3,$4,$5}'
12027, 1435, 144434,
If you want to try going that route, call vmstat -z --libxo=json
and process that output to find the exact values you want accurately. Or to narrow that a bit:
: /usr/bin/vmstat -z --libxo=json | /usr/local/bin/jq '."memory-zone-statistics".zone.[] | select(.name=="mbuf_cluster")'
{
"name": "mbuf_cluster",
"size": 2048,
"limit": 1000000,
"used": 12028,
"free": 1434,
"requests": 144620,
"fail": 0,
"sleep": 0,
"xdomain": 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.
My bad, you're right - I noticed this one when testing but the fix slipped away somewhere in between the testing and commiting.
One idea was to use comma delimiter with awk, but then whitespaces become potentially problematic (output needs to be trimmed). I'll take a look at json output and try to find the cleanest/fastest solution.
3517da1
to
a070c8d
Compare
Updated the code. The other option was: |
The libxo method is necessary to ensure accuracy, and is the only method that will be accepted. Anything else is just guessing and making assumptions about the format which could be wrong. It would require a lot more testing on a lot more hardware/networks when all such concerns are eliminated by using libxo which is designed for this purpose. |
a070c8d
to
9838dd5
Compare
Understood - changed the code. |