Esempio n. 1
0
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)
}
Esempio n. 2
0
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))
}
Esempio n. 3
0
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))
}