Fix Memory tam (Tomasz Przybył) FadeMind

This commit is contained in:
michal 2016-06-28 20:33:37 +02:00
parent 99fe9fe2d2
commit 82a7e46566
2 changed files with 74 additions and 114 deletions

View File

@ -39,6 +39,7 @@ Public INDEX0 As String
Public INDEX1 As String
Public INDEX2 As String
Public INDEX3 As String
Public MEMINFO_FILE As File
Public Sub Form_Open()
Dim default_display_manager As Boolean = Exist("/etc/X11/default-display-manager")
Dim i As Integer
@ -675,55 +676,71 @@ End
Public Sub dospam_uptime()
Dim Users As String
Dim USAGE_BUFFER As String
Shell "users | tr ' ' '\n' | wc -l" Wait To Users
Exec [ChkPrm.ChkExecDir("i-nex-usage")] Wait To USAGE_BUFFER
USAGE = JSON.Decode(USAGE_BUFFER)
Dim sIcon As String
Dim sLine As String
Dim iPos As Integer
Dim sKey As String
Dim sVal As String
Dim MemTotal As Float
Dim MemFree As Float
Dim MemAvailable As Float
Dim Buffers As Float
Dim Cached As Float
Dim SwapCached As Float
Dim SwapTotal As Float
Dim SwapFree As Float
Dim Active As Float
Dim MEMINFO_FILE As File
Label85.Text = "Total: " &
Int(USAGE["MEMORY_TOTAL"]) &
" MB"
Label86.Text = "Used: " &
Int(USAGE["MEMORY_USED"]) &
" MB"
Label87.Text = "Free: " &
Int(USAGE["MEMORY_FREE"]) &
" MB"
Label88.Text = "Shared: " &
Int(USAGE["MEMORY_SHARED"]) &
" MB"
Label89.Text = "Buffers: " &
Int(USAGE["MEMORY_BUFFERS"]) &
" MB"
Label90.Text = "Cached: " &
Int(USAGE["MEMORY_CACHED"]) &
" MB"
Label223.Text = "Ram used: " &
Int(USAGE["USED_PLUS_CACHED"]) &
" MB"
Label91.Text = "SWAP Total: " &
Int(USAGE["SWAP_TOTAL"]) &
" MB "
TextLabel24.Text = "SWAP memory used: " &
Int(USAGE["SWAP_USED"]) &
" MB"
If IsNull(MEMINFO_FILE) = True Then
MEMINFO_FILE = Open "/proc/meminfo"
Else
MEMINFO_FILE = Open MStart.MEMINFO_FILE
Endif
For Each sLine In MEMINFO_FILE.Lines
sLine = Trim(sLine)
If Not sLine Then Continue
iPos = InStr(sLine, ":")
If iPos = 0 Then Continue
sKey = Trim(Left$(sLine, iPos - 1))
sVal = Trim(Mid$(sLine, iPos + 1))
sVal = Replace(sVal, "kB", Null)
Select Case sKey
Case "MemTotal"
MemTotal = Val(sVal) / 1000
Case "MemFree"
MemFree = Val(sVal) / 1000
Case "MemAvailable"
MemAvailable = Val(sVal) / 1000
Case "Buffers"
Buffers = Val(sVal) / 1000
Case "Cached"
Cached = Val(sVal) / 1000
Case "SwapCached"
SwapCached = Val(sVal) / 1000
Case "SwapTotal"
SwapTotal = Val(sVal) / 1000
Case "SwapFree"
SwapFree = Val(sVal) / 1000
Case "Active"
Active = Val(sVal) / 1000
End Select
TextBox58.Text = "Days: " & USAGE["UPTIME_DAYS"] &
" " &
"Hours: " & USAGE["UPTIME_HOURS"] &
" " &
"Minutes: " & USAGE["UPTIME_MINUTES"] &
" " &
"Seconds: " & USAGE["UPTIME_SECONDS"] &
" " &
"Users: " & Subst$(Users) &
"load average: " & Int(USAGE["LOAD_AVG_1MIN"]) & " " &
", " & Int(USAGE["LOAD_AVG_5MIN"]) & " " &
", " & Int(USAGE["LOAD_AVG_15MIN"])
Label74.Text = USAGE["NUMBER_OF_PROCESSES"]
Next
Close #MEMINFO_FILE
'Solution
'https://access.redhat.com/solutions/406773
Label223.Text = "Mem used: " & CString(MemTotal - (MemFree + Buffers + Cached)) & " MB"
TextLabel24.Text = "Swap used: " & (SwapTotal - SwapFree) & " MB"
Try ProgressBar1.Value = (MemTotal - (MemFree + Buffers + Cached)) / MemTotal
Try ProgressBar4.Value = (SwapTotal - SwapFree) / SwapTotal
Try ProgressBar1.Value = Int(USAGE["USED_PLUS_CACHED"]) / Int(USAGE["MEMORY_TOTAL"])
Try ProgressBar4.Value = Int(USAGE["SWAP_USED"]) / Int(USAGE["SWAP_TOTAL"])
End
Public Sub battery_info()
@ -1151,7 +1168,6 @@ Public Sub Form_Close()
Settings["Window/Y"] = Me.Y
Settings["Tab/Pos"] = TabStrip1.Orientation
Logs("Good bye!", Logger.Info)
USAGE.Clear
DATAT.Clear
MCPUSAGE.CPUusage.Kill
Me.Close

View File

@ -1607,89 +1607,27 @@
Text = "Memory"
Picture = Picture["AppIcons/Finfosys/utilities-system-monitor.png"]
{ ProgressBar1 ProgressBar
Move(119,21,350,21)
Move(7,35,455,21)
}
{ ProgressBar4 ProgressBar
Move(119,63,350,21)
Move(7,84,455,21)
}
{ TextLabel24 TextLabel
Move(119,42,350,21)
Move(7,56,455,28)
Font = Font["Bold,8"]
Text = ("N/A")
Alignment = Align.Center
Border = Border.Raised
}
{ Label176 Label
Move(154,133,315,21)
Font = Font["Bold,8"]
Text = ("Label176")
Border = Border.Raised
}
{ Label85 Label
Move(0,91,154,21)
Font = Font["Bold,8"]
Expand = True
Border = Border.Raised
}
{ Label86 Label
Move(308,91,161,21)
Font = Font["Bold,8"]
Expand = True
Border = Border.Raised
}
{ Label87 Label
Move(154,112,154,21)
Font = Font["Bold,8"]
Expand = True
Border = Border.Raised
}
{ Label88 Label
Move(308,112,161,21)
Font = Font["Bold,8"]
Expand = True
Border = Border.Raised
}
{ Label89 Label
Move(154,91,154,21)
Font = Font["Bold,8"]
Expand = True
Border = Border.Raised
}
{ Label90 Label
Move(0,112,154,21)
Font = Font["Bold,8"]
Expand = True
Alignment = Align.Left
Border = Border.Raised
}
{ Label91 Label
Move(0,133,154,21)
Font = Font["Bold,8"]
Expand = True
Border = Border.Raised
}
{ Label223 Label
Move(119,0,350,21)
Move(7,7,455,28)
Font = Font["Bold,8"]
Text = ("Label223")
Alignment = Align.Center
Border = Border.Raised
}
{ Label74 Label
Move(7,21,105,70)
Font = Font["Bold,20"]
Foreground = &HFF7F00&
Alignment = Align.Center
}
{ Label77 Label
Move(0,0,119,21)
Font = Font["Bold,8"]
Text = ("Processes ↓")
Alignment = Align.Center
Border = Border.Raised
}
{ Frame2 Frame
Move(0,154,469,322)
Move(0,280,469,196)
Font = Font["8"]
Text = ("---===Serial Presence Detect===---")
{ Label227 Label
@ -1747,6 +1685,12 @@
Border = Border.Raised
}
}
{ Label176 Label
Move(7,112,315,28)
Font = Font["Bold,8"]
Text = ("Label176")
Border = Border.Raised
}
Index = 8
Text = "Network"
Picture = Picture["AppIcons/Finfosys/network-wired.png"]