#!/usr/bin/python3

# Importing the library
import psutil
 
## RAM:
# Getting % usage of virtual_memory ( 3rd field)
#print('RAM memory % used:', psutil.virtual_memory()[2])
# Getting usage of virtual_memory in GB ( 4th field)
# Obtenemos la RAM y redondeamos a dos decimales: psutil devuelve un float, el cual se puede redondear
ramgb = round(psutil.virtual_memory()[3]/1000000000,2)
ramtotal = round(psutil.virtual_memory().total/1000000000,2)
# El símbolo + concatena cadenas, hay que pasar los float a string:
print ('RAM:', str(ramgb) + "GB/" + str(ramtotal) + "GB", str(psutil.virtual_memory()[2]) + "%")

## SWAP:
swapgb = round(psutil.swap_memory().used/1000000000,2)
swaptotal = round(psutil.swap_memory().total/1000000000,2)
print ('SWAP:', str(swapgb) + "GB/" + str(swaptotal) + "GB", str(psutil.swap_memory().percent) + "%")
