//PrintForInfluxDB prints the data in influxdb lineformat
func (p PerformanceData) PrintForInfluxDB(version string) string {
	if helper.VersionOrdinal(version) >= helper.VersionOrdinal("0.9") {
		tableName := fmt.Sprintf(`metrics,host=%s`, helper.SanitizeInfluxInput(p.hostname))
		if p.service == "" {
			tableName += fmt.Sprintf(`,service=%s`, helper.SanitizeInfluxInput(config.GetConfig().Influx.HostcheckAlias))
		} else {
			tableName += fmt.Sprintf(`,service=%s`, helper.SanitizeInfluxInput(p.service))
		}
		tableName += fmt.Sprintf(`,command=%s,performanceLabel=%s`,
			helper.SanitizeInfluxInput(p.command),
			helper.SanitizeInfluxInput(p.performanceLabel),
		)
		if len(p.tags) > 0 {
			tableName += fmt.Sprintf(`,%s`, helper.PrintMapAsString(helper.SanitizeMap(p.tags), ",", "="))
		}
		if p.unit != "" {
			tableName += fmt.Sprintf(`,unit=%s`, p.unit)
		}

		tableName += fmt.Sprintf(` %s`, helper.PrintMapAsString(helper.SanitizeMap(p.fields), ",", "="))
		tableName += fmt.Sprintf(" %s\n", p.time)
		return tableName
	}
	return ""
}
//PrintForInfluxDB prints the data in influxdb lineformat
func (p Printable) PrintForInfluxDB(version string) string {
	if helper.VersionOrdinal(version) >= helper.VersionOrdinal("0.9") {
		line := p.Table
		if len(p.tags) > 0 {
			line += fmt.Sprintf(`,%s`, helper.PrintMapAsString(p.tags, ",", "="))
		}
		line += " "
		if len(p.fields) > 0 {
			line += fmt.Sprintf(`%s`, helper.PrintMapAsString(p.fields, ",", "="))
		}
		return fmt.Sprintf("%s %s", line, p.Timestamp)
	}
	return ""
}
Exemple #3
0
func (p *PerformanceData) String() string {
	if p.awsinstanceid == "" {
		p.awsinstanceid = "empty"
	}
	tableName := fmt.Sprintf(`%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s`, p.service, p.fieldseperator, `command=`, p.command, p.fieldseperator, `awsinstanceid=`, p.awsinstanceid, p.fieldseperator, `awsservice=`, p.awsservice, p.fieldseperator, `awsserviceid=`, p.awsserviceid, p.fieldseperator, `awsstage=`, p.awsstage, p.fieldseperator, `host=`, p.hostname)
	if p.unit != "" {
		p.tags["unit"] = p.unit
	}

	p.tags["metric"] = p.performanceLabel

	if len(p.tags) > 0 {
		tableName += fmt.Sprintf(`,%s`, helper.PrintMapAsString(p.tags, ",", "="))
	}

	if len(p.mvals) > 0 {
		tableName += fmt.Sprintf(` %s`, helper.PrintMapAsString(p.mvals, ",", "="))
	}

	tableName += fmt.Sprintf(` %s`, p.time)
	return tableName
}
Exemple #4
0
func (p *PerformanceData) String() string {
	tableName := fmt.Sprintf(`%s%s%s%s%s%s%s%s%s`,
		p.hostname, p.fieldseperator,
		p.service, p.fieldseperator,
		p.command, p.fieldseperator,
		p.performanceLabel, p.fieldseperator,
		p.performanceType)
	if p.unit != "" {
		tableName += fmt.Sprintf(`,unit=%s`, p.unit)
	}

	if len(p.tags) > 0 {
		tableName += fmt.Sprintf(`,%s`, helper.PrintMapAsString(p.tags, ",", "="))
	}

	tableName += fmt.Sprintf(` value=%s %s`, p.value, p.time)
	return tableName
}