Differenze tra le versioni di "Ottenere informazioni sulle statistiche di sistema globali con la funzione esterna sysinfo()"
Da Gambas-it.org - Wikipedia.
Riga 36: | Riga 36: | ||
With si | With si | ||
− | Print "Tempo dall'avvio: " | + | Print "Tempo dall'avvio: "; Date(0, 0, 0, 0, 0, 0, CInt(.uptime * 1000)) |
− | Print "Numero dei processi: " | + | Print "Numero dei processi: "; .procs |
− | Print "RAM totale: " | + | Print "RAM totale: "; Format(.totalram / MB, "0.0") |
− | Print "RAM libera: " | + | Print "RAM libera: "; Format(.freeram / MB, "0.0") |
− | Print "Shared memory: " | + | Print "Shared memory: "; Format(.sharedram / MB, "0.0") |
− | Print "Buffers RAM: " | + | Print "Buffers RAM: "; Format(.bufferram / MB, "0.0") |
− | Print "Buffers RAM: " | + | Print "Buffers RAM: "; Format(.bufferram / MB, "0.0") |
− | Print "Swap totale: " | + | Print "Swap totale: "; Format(.totalswap / MB, "0.0") |
− | Print "Swap disponibile: " | + | Print "Swap disponibile: "; Format(.freeswap / MB, "0.0") |
− | Print "Totale memoria alta: " | + | Print "Totale memoria alta: "; Format(.totalhigh / MB, "0.0") |
− | Print "Memoria alta disponibile: " | + | Print "Memoria alta disponibile: "; Format(.freehigh / MB, "0.0") |
End With | End With | ||
Versione delle 08:53, 5 lug 2016
La funzione esterna sysinfo(), contenuta nella libreria /usr/include/x86_64-linux-gnu/sys/sysinfo.h, consente di conoscere alcune informazioni sulle statistiche di sistema come ricavabili dalla Struttura sysinfo, contenuta nella libreria /usr/include/linux/sysinfo.h .
Mostriamo un semplice esempio pratico:
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 Sub Main() Dim si As New Sysinfo Dim err As Integer Dim MB As Float = 1024 * 1024 err = sysinfo(si) If err < 0 Then Error.Raise("Il puntatore alla Struttura 'sysinfo' non è valido !") With si Print "Tempo dall'avvio: "; Date(0, 0, 0, 0, 0, 0, CInt(.uptime * 1000)) Print "Numero dei processi: "; .procs Print "RAM totale: "; Format(.totalram / MB, "0.0") Print "RAM libera: "; Format(.freeram / MB, "0.0") Print "Shared memory: "; Format(.sharedram / MB, "0.0") Print "Buffers RAM: "; Format(.bufferram / MB, "0.0") Print "Buffers RAM: "; Format(.bufferram / MB, "0.0") Print "Swap totale: "; Format(.totalswap / MB, "0.0") Print "Swap disponibile: "; Format(.freeswap / MB, "0.0") Print "Totale memoria alta: "; Format(.totalhigh / MB, "0.0") Print "Memoria alta disponibile: "; Format(.freehigh / MB, "0.0") End With End