예제 #1
0
파일: main.go 프로젝트: dell-esg/idracula
func getCPU(client *wsman.Client) string {
	msg := client.Enumerate("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_CPUView")
	msg.Selectors("InstanceID", "System.Embedded.1")
	res, err := msg.Send()
	if err != nil {
		log.Printf("Error getting cpus: %v\n", err)
		return "-1"
	}
	activeCores := 0
	procs := search.All(search.Tag("DCIM_CPUView", "*"), res.AllBodyElements())
	for _, proc := range procs {
		cores := search.First(search.Tag("NumberOfEnabledCores", "*"), proc.Children())
		if cores == nil {
			log.Println("Could not find number of enabled cores!")
			os.Exit(1)
		}
		count, err := strconv.Atoi(string(cores.Content))
		if err != nil {
			log.Println("Error parsing %s into an integer\n", string(cores.Content))
			os.Exit(1)
		}
		activeCores += count
	}
	return strconv.Itoa(activeCores)
}
예제 #2
0
파일: main.go 프로젝트: cdearborn/idracula
func getDisk(client *wsman.Client) string {
	msg := client.Enumerate("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_VirtualDiskView")
	msg.Selectors("InstanceID", "System.Embedded.1")
	res, err := msg.Send()
	if err != nil {
		log.Printf("Error getting disks: %v\n", err)
		return "-1"
	}
	vds := search.All(search.Tag("DCIM_VirtualDiskView", "*"), res.AllBodyElements())
	return strconv.Itoa(len(vds))
}
예제 #3
0
파일: main.go 프로젝트: dell-esg/idracula
func getMemory(client *wsman.Client) string {
	msg := client.Enumerate("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_SystemView")
	msg.Selectors("InstanceID", "System.Embedded.1")
	res, err := msg.Send()
	if err != nil {
		log.Printf("Error getting memory: %v\n", err)
		return "-1"
	}
	n := search.First(search.Tag("SysMemTotalSize", "*"), res.AllBodyElements())
	if n == nil {
		log.Println("Could not find total system memory")
		return "-1"
	}
	return string(n.Content)
}
예제 #4
0
파일: main.go 프로젝트: dell-esg/idracula
func getMAC(client *wsman.Client) string {
	msg := client.Enumerate("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_NICView")
	msg.Selectors("InstanceID", "System.Embedded.1")
	res, err := msg.Send()
	if err != nil {
		log.Printf("Error getting nics: %v\n", err)
		return ""
	}
	bootnic := getBootNic(client,
		search.All(search.Tag("DCIM_NICView", "*"), res.AllBodyElements()))
	if bootnic == nil {
		return ""
	}
	return strings.ToLower(
		string(search.First(
			search.Tag("CurrentMACAddress", "*"),
			bootnic.Children()).Content))
}
예제 #5
0
파일: main.go 프로젝트: dell-esg/idracula
func getDisk(client *wsman.Client) string {
	msg := client.Enumerate("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_VirtualDiskView")
	msg.Selectors("InstanceID", "System.Embedded.1")
	res, err := msg.Send()
	if err != nil {
		log.Printf("Error getting disks: %v\n", err)
		return "-1"
	}
	vd := search.First(search.Tag("DCIM_VirtualDiskView", "*"), res.AllBodyElements())
	if vd == nil {
		log.Printf("Error getting first disk information\n")
		return "-1"
	}
	sizeBytes := search.First(search.Tag("SizeInBytes", "*"), vd.Children())
	if sizeBytes == nil {
		log.Printf("Error getting first disk size\n")
		return "-1"
	}
	count, err := strconv.Atoi(string(sizeBytes.Content))
	sizeGBytes := count / (1024 * 1024 * 1024)
	return strconv.Itoa(sizeGBytes)
}