Example #1
0
// GetHostInfo returns host identifying information; see sg_get_host_info(3).
func GetHostInfo() (*HostInfo, error) {
	c := C.sg_get_host_info()
	if c == nil {
		return nil, getError()
	}
	return &HostInfo{
		C.GoString(c.os_name),
		C.GoString(c.os_release),
		C.GoString(c.os_version),
		C.GoString(c.platform),
		C.GoString(c.hostname),
		time.Duration(c.uptime) * time.Second}, nil
}
Example #2
0
// HostInfo get the host informations
// Go equivalent to sg_host_info
func (s *Stat) HostInfos() *HostInfos {
	s.Lock()
	stats := C.sg_get_host_info(nil)
	s.Unlock()

	hi := &HostInfos{
		OSName:    C.GoString(stats.os_name),
		OSRelease: C.GoString(stats.os_release),
		OSVersion: C.GoString(stats.os_version),
		Platform:  C.GoString(stats.platform),
		HostName:  C.GoString(stats.hostname),
		NCPUs:     int(stats.ncpus),
		MaxCPUs:   int(stats.maxcpus),
		BitWidth:  int(stats.bitwidth),
		//TODO: uptime
	}

	C.sg_free_stats_buf(unsafe.Pointer(stats))

	return hi
}