Skip to content

Commit

Permalink
Calculate SWAP Usage in Drives
Browse files Browse the repository at this point in the history
  • Loading branch information
eloaders committed Aug 9, 2014
1 parent 613aeff commit cc71a32
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
62 changes: 61 additions & 1 deletion I-Nex/i-nex/.src/Disk_Drives.module
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ Public Sub get_informations()
If Used = SIZE_W Then
Try Finfosys.ProgressBar2.Value = 0 / 10
Endif

If check_swap Like "*" & Finfosys.ComboBox3.Text & "*" Then
Finfosys.Label248.Text = "Free: " & CString(SWAP_FREE())
Endif
End

Function Schedule(sched As String) As String
Expand Down Expand Up @@ -286,7 +290,7 @@ Function CalculateSIZE(BlockSize As Float, Optional ReturnIn As Boolean) As Stri
End

Public Sub disks()
Dim i, i2, i3 As Integer
Dim i, i2 As Integer
Dim MOUNTS_PROC As File
Dim SWAPS_PROC As File
Dim MountsLine As String
Expand Down Expand Up @@ -440,6 +444,10 @@ Public Sub disks()
Case Like ""
SATA_PIC = Null
End Select

Print SWAP_TOTAL()
Print SWAP_USED()
Print SWAP_FREE()
End

Function SETNULL()
Expand Down Expand Up @@ -492,3 +500,55 @@ physical_block_size = Null
rotational = Null
rq_affinity = Null
End

Function SWAP_TOTAL() As Float
Dim sTemp As String

Exec ["cat", "/proc/meminfo"] To sTemp
Try sTemp = Scan(sTemp, "*SwapTotal:*\n*")[1]
If Error Then
sTemp = ""
Else
While Not IsDigit(Right(sTemp))
sTemp = Left(sTemp, -1)
Wend
sTemp = Trim(sTemp)
Endif

If sTemp Then
Try sTemp = Format(CInt(sTemp) / 1024, "0")
If Not Error Then Return CFloat(sTemp)
Endif

End

Function SWAP_FREE() As Float
Dim sTemp As String

Exec ["cat", "/proc/meminfo"] To sTemp
Try sTemp = Scan(sTemp, "*SwapFree:*\n*")[1]
If Error Then
sTemp = ""
Else
While Not IsDigit(Right(sTemp))
sTemp = Left(sTemp, -1)
Wend
sTemp = Trim(sTemp)
Endif

If sTemp Then
Try sTemp = Format(CInt(sTemp) / 1024, "0")
If Not Error Then Return CFloat(sTemp)
Endif

End

Function SWAP_USED() As Float
Dim USED As Float
Dim Frees As Float
Dim Total As Float
Total = CFloat(SWAP_TOTAL())
Frees = CFloat(SWAP_FREE())
USED = (Total - Frees)
Return USED
End
1 change: 1 addition & 0 deletions I-Nex/i-nex/.src/Finfosys.class
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ Label134.Text = "Rq affinity: " & Disk_Drives.rq_affinity
If IsNull(ComboBox3.Text) = False Then
If Disk_Drives.check_swap Like "*" & ComboBox3.Text & "*" Then
Label48.Visible = True
Try ProgressBar2.Value = Disk_Drives.SWAP_USED / Disk_Drives.SWAP_TOTAL
Else
Label48.Visible = False
Endif
Expand Down

0 comments on commit cc71a32

Please sign in to comment.