func GetCPUCapacity() (Capacity, error) {
	count, err := cpu.Counts(true)
	if err != nil {
		return CapacityLow, err
	}
	cap, err := returnCapacityForValue(int64(count), "cpu")
	if err != nil {
		return cap, err
	}
	log.Infof("CPU Capacity : %s", cap)
	return cap, nil
}
GetCPUCapacity returns the corresponding CPU Capacity
package requirements
import (
	"encoding/json"
	"github.com/shirou/gopsutil/cpu"
	"github.com/shirou/gopsutil/mem"
	log "github.com/sirupsen/logrus"
)
type Capacity int
type NetworkType int
type Requirements struct {
	NetworkType       NetworkType `json:"network_type"`        
	NetworkCapacity   Capacity    `json:"network_capacity"`    
	ComputingCapacity Capacity    `json:"computing_capacity"`  
	MemoryCapacity    Capacity    `json:"memory_capacity"`     
}
func (r Requirements) MarshalJSON() ([]byte, error) {
	m := make(map[string]string)
	m["network_type"] = r.NetworkType.String()
	m["network_capacity"] = r.NetworkCapacity.String()
	m["computing_capacity"] = r.ComputingCapacity.String()
	m["memory_capacity"] = r.MemoryCapacity.String()
	return json.Marshal(m)
}
const (
	CapacityLow Capacity = iota
	CapacityMedium
	CapacityHigh
)
func (c Capacity) String() string {
	switch c {
	case CapacityLow:
		return "Capacity low"
	case CapacityMedium:
		return "Capacity medium"
	case CapacityHigh:
		return "Capacity high"
	default:
		return "Unknown capacity"
	}
}
const (
	NetworkExternal NetworkType = iota
	NetworkInternal
)
func (t NetworkType) String() string {
	switch t {
	case NetworkExternal:
		return "External Network"
	case NetworkInternal:
		return "Internal Network"
	default:
		return "Unknown type of network"
	}
}
const (
	KiloByte = (1 << 10)
	MegaByte = (KiloByte << 10)
	GigaByte = (MegaByte << 10)
	TeraByte = (GigaByte << 10)
)
var (
	MemUsage map[Capacity]int64
	CPUUsage map[Capacity]int64
	NetUsage map[Capacity]int64
	Usage = map[string]map[Capacity]int64{
		"memory":  MemUsage,
		"cpu":     CPUUsage,
		"network": NetUsage,
	}
)
func init() {
	MemUsage = map[Capacity]int64{
		CapacityLow:    1 * GigaByte,
		CapacityMedium: 2 * GigaByte,
		CapacityHigh:   4 * GigaByte,
	}
	CPUUsage = map[Capacity]int64{
		CapacityLow:    1,
		CapacityMedium: 2,
		CapacityHigh:   4,
	}
}
func GetMemoryCapacity() (Capacity, error) {
	cap := CapacityLow
	m, err := mem.VirtualMemory()
	if err != nil {
		return cap, err
	}
	cap, err = returnCapacityForValue(int64(m.Available), "memory")
	if err != nil {
		return cap, err
	}
	log.Infof("Memory capacity : %s", cap)
	return cap, nil
}