Example #1
0
func getCurrentInfo(site string) *jbossinfo.JbossStatus {
	fmt.Printf("Trying to get xml from: %s\n", JbossStatusUrls[site])

	resp, respErr := http.Get(JbossStatusUrls[site])
	if respErr != nil {
		fmt.Printf("Can't get jboss xml: %s\n", respErr)
		return nil
	}

	info, infoErr := jbossinfo.ParseJbossInfoXML(resp.Body)
	if infoErr != nil {
		fmt.Printf("Parsing jboss xml failed: %s\n", infoErr)
		return nil
	}

	return info
}
Example #2
0
func getFieldValueFromXml(xml io.Reader, field string) string {
	var value string

	info, infoErr := jbossinfo.ParseJbossInfoXML(xml)
	if infoErr != nil {
		fmt.Printf("Parsing jboss xml failed: %s\n", infoErr)
		return ""
	}

	switch field {
	case "free":
		value = strconv.FormatUint(uint64(info.JvmStatus.Free), 10)
	case "total":
		value = strconv.FormatUint(uint64(info.JvmStatus.Total), 10)
	case "max":
		value = strconv.FormatUint(uint64(info.JvmStatus.Max), 10)
	case "used":
		value = strconv.FormatUint(uint64(info.JvmStatus.Total-info.JvmStatus.Free), 10)
	case "threads":
		threadCount := 0
		for _, connector := range info.Connectors {
			threadCount += connector.ThreadInfo.CurrentThreadsBusy
		}
		value = strconv.Itoa(threadCount)
	case "maxRequestTime":
		maxRequestTime := 0
		for _, connector := range info.Connectors {
			for _, worker := range connector.Workers {
				if worker.RequestProcessingTime > maxRequestTime {
					maxRequestTime = worker.RequestProcessingTime
				}
			}
		}
		value = strconv.Itoa(maxRequestTime)
	default:
		return ""
	}

	return value
}