Differenze tra le versioni di "Ottenere informazioni sulle statistiche di sistema globali con la funzione esterna sysinfo()"

Da Gambas-it.org - Wikipedia.
(Creata pagina con "La funzione esterna ''sysinfo()'', contenuta nella libreria ''/usr/include/x86_64-linux-gnu/sys/sysinfo.h'', consente di conoscere alcune informazioni sulle statistiche di sis...")
 
Riga 36: Riga 36:
 
    
 
    
 
   With si
 
   With si
     Print "Tempo dall'avvio:        ", Date(0, 0, 0, 0, 0, 0, CInt(si.uptime * 1000))
+
     Print "Tempo dall'avvio:        ", Date(0, 0, 0, 0, 0, 0, CInt(.uptime * 1000))
     Print "Numero dei processi:      ", si.procs
+
     Print "Numero dei processi:      ", .procs
     Print "RAM totale:              ", Format(si.totalram / MB, "0.0")
+
     Print "RAM totale:              ", Format(.totalram / MB, "0.0")
     Print "RAM libera:              ", Format(si.freeram / MB, "0.0")
+
     Print "RAM libera:              ", Format(.freeram / MB, "0.0")
     Print "Shared memory:            ", Format(si.sharedram / MB, "0.0")
+
     Print "Shared memory:            ", Format(.sharedram / MB, "0.0")
     Print "Buffers RAM:              ", Format(si.bufferram / MB, "0.0")
+
     Print "Buffers RAM:              ", Format(.bufferram / MB, "0.0")
     Print "Buffers RAM:              ", Format(si.bufferram / MB, "0.0")
+
     Print "Buffers RAM:              ", Format(.bufferram / MB, "0.0")
     Print "Swap totale:              ", Format(si.totalswap / MB, "0.0")
+
     Print "Swap totale:              ", Format(.totalswap / MB, "0.0")
     Print "Swap disponibile:        ", Format(si.freeswap / MB, "0.0")
+
     Print "Swap disponibile:        ", Format(.freeswap / MB, "0.0")
     Print "Totale memoria alta:      ", Format(si.totalhigh / MB, "0.0")
+
     Print "Totale memoria alta:      ", Format(.totalhigh / MB, "0.0")
     Print "Memoria alta disponibile: ", Format(si.freehigh / MB, "0.0")
+
     Print "Memoria alta disponibile: ", Format(.freehigh / MB, "0.0")
 
   End With
 
   End With
 
    
 
    

Versione delle 08:51, 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



Riferimenti