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 System information dashboard to check all swap on system. Bug #8587 #3950

Merged
merged 3 commits into from Jun 21, 2018

Conversation

Projects
None yet
5 participants
@marcelloc
Copy link
Contributor

commented Jun 20, 2018

marcelloc added some commits Jun 20, 2018

check total swap size on dashboard
Refer to bug #8587
@jim-p
Copy link
Contributor

left a comment

This may fix systems with multiple swap partitions but it breaks systems with only one. See my inline comment.

@@ -177,7 +177,7 @@ function disk_usage($slice = '/') {
}
function swap_usage() {
exec("/usr/sbin/swapinfo", $swap_info);
exec("/usr/sbin/swapinfo | /usr/bin/grep Total", $swap_info);

This comment has been minimized.

Copy link
@jim-p

jim-p Jun 20, 2018

Contributor

swapinfo does not output a line with Total for me, which makes this always empty/blank.

: /usr/sbin/swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/label/swap0    524284        0   524284     0%
@marcelloc

This comment has been minimized.

Copy link
Contributor Author

commented Jun 20, 2018

Forgot to test on systems without more then on swap file.

The code needs more checks.

I'll review the fix.

@marcelloc

This comment has been minimized.

Copy link
Contributor Author

commented Jun 20, 2018

A tail -1 works on both situations.
Pushed to fix for the fix.

@@ -177,7 +177,7 @@ function disk_usage($slice = '/') {
}
function swap_usage() {
exec("/usr/sbin/swapinfo", $swap_info);
exec("/usr/sbin/swapinfo | /usr/bin/tail -1", $swap_info);

This comment has been minimized.

Copy link
@rbgarga

rbgarga Jun 20, 2018

Member

This will not work for multiple swap devices. Instead use swapinfo | tain -n -1 which will just remove header line

This comment has been minimized.

Copy link
@marcelloc

marcelloc Jun 20, 2018

Author Contributor

@rbgarga, the fix is to show only one swap info . Or the only one present on system (default) or the total of swap used while using more then one.

I think there is no need to show individual usage od each swap.

https://redmine.pfsense.org/attachments/download/2478/two_swaps.PNG

This comment has been minimized.

Copy link
@rbgarga

rbgarga Jun 21, 2018

Member

Oh, that makes senes. Thanks!

@@ -435,7 +435,7 @@
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="<?=$swapusage?>" aria-valuemin="0" aria-valuemax="100" style="width: <?=$swapusage?>%">
</div>
</div>
<span><?=$swapusage?>% of <?= sprintf("%.0f", `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MiB</span>
<span><?=$swapusage?>% of <?= sprintf("%.0f", `/usr/sbin/swapinfo -m | /usr/bin/tail -1 | /usr/bin/awk '{ print $2;}'`) ?> MiB</span>

This comment has been minimized.

Copy link
@rbgarga

rbgarga Jun 20, 2018

Member

Same here

@jim-p

jim-p approved these changes Jun 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.