-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes MUptime module. Now use Library "libc:6" sysinfo
- Loading branch information
Showing
2 changed files
with
34 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
' Gambas module file | ||
|
||
Public Sub _inits() | ||
Dim sLine As String | ||
Dim iPos As Integer | ||
Dim SUptime As String | ||
Dim SIdle As String | ||
Dim UPTIME_FILE As File | ||
|
||
If IsNull(UPTIME_FILE) = True Then | ||
UPTIME_FILE = Open "/proc/uptime" | ||
Endif | ||
|
||
For Each sLine In UPTIME_FILE.Lines | ||
sLine = Trim(sLine) | ||
If Not sLine Then Continue | ||
Print Left$(sLine, (InStr(sLine, ".") - 1)) / 60 | ||
Print Left$(sLine, (InStr(sLine, ".") - 1)) / 60 / 60 | ||
Print (4319 / 60) / 60 | ||
Next | ||
'Print Time(00, 00, 3600) | ||
Close #UPTIME_FILE | ||
'awk '{printf("%d:%02d:%02d:%02d",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime | ||
Library "libc:6" | ||
|
||
Public Struct sysinfo | ||
uptime As Long | ||
loads[3] As Long | ||
totalram As Long | ||
freeram As Long | ||
sharedram As Long | ||
bufferram As Long | ||
totalswap As Long | ||
freeswap As Long | ||
procs As Short | ||
pad As Short | ||
totalhigh As Long | ||
freehigh As Long | ||
mem_unit As Integer | ||
End Struct | ||
|
||
' int sysinfo (struct sysinfo *__info) | ||
' Returns information on overall system statistics. | ||
Private Extern sysinfo(info As Sysinfo) As Integer | ||
Public Logs As New Logger | ||
|
||
Public Sub Main() | ||
|
||
Dim si As New Sysinfo | ||
Dim err As Integer | ||
|
||
err = sysinfo(si) | ||
If err < 0 Then | ||
Logs("Libc6 Sysinfo Error", Logger.Error) | ||
Else | ||
Finfosys.TextBox58.Text = "Uptime: " & Date(0, 0, 0, 0, 0, 0, CInt(si.uptime * 1000)) | ||
Endif | ||
End |