Fix occurreneces of initial uppercase in error strings.
This commit is contained in:
parent
e70cbd2045
commit
a25751e0b3
|
@ -60,7 +60,7 @@ func (c *gmondCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
conn, err := net.Dial(gangliaProto, gangliaAddress)
|
conn, err := net.Dial(gangliaProto, gangliaAddress)
|
||||||
log.Debugf("gmondCollector Update")
|
log.Debugf("gmondCollector Update")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Can't connect to gmond: %s", err)
|
return fmt.Errorf("can't connect to gmond: %s", err)
|
||||||
}
|
}
|
||||||
conn.SetDeadline(time.Now().Add(gangliaTimeout))
|
conn.SetDeadline(time.Now().Add(gangliaTimeout))
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func (c *gmondCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
|
|
||||||
err = decoder.Decode(&ganglia)
|
err = decoder.Decode(&ganglia)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't parse xml: %s", err)
|
return fmt.Errorf("couldn't parse xml: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cluster := range ganglia.Clusters {
|
for _, cluster := range ganglia.Clusters {
|
||||||
|
|
|
@ -23,7 +23,7 @@ func splitToInts(str string, sep string) (ints []int, err error) {
|
||||||
for _, part := range strings.Split(str, sep) {
|
for _, part := range strings.Split(str, sep) {
|
||||||
i, err := strconv.Atoi(part)
|
i, err := strconv.Atoi(part)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Could not split '%s' because %s is no int: %s", str, part, err)
|
return nil, fmt.Errorf("could not split '%s' because %s is no int: %s", str, part, err)
|
||||||
}
|
}
|
||||||
ints = append(ints, i)
|
ints = append(ints, i)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,13 +53,13 @@ func NewInterruptsCollector() (Collector, error) {
|
||||||
func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
interrupts, err := getInterrupts()
|
interrupts, err := getInterrupts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't get interrupts: %s", err)
|
return fmt.Errorf("couldn't get interrupts: %s", err)
|
||||||
}
|
}
|
||||||
for name, interrupt := range interrupts {
|
for name, interrupt := range interrupts {
|
||||||
for cpuNo, value := range interrupt.values {
|
for cpuNo, value := range interrupt.values {
|
||||||
fv, err := strconv.ParseFloat(value, 64)
|
fv, err := strconv.ParseFloat(value, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Invalid value %s in interrupts: %s", value, err)
|
return fmt.Errorf("invalid value %s in interrupts: %s", value, err)
|
||||||
}
|
}
|
||||||
labels := prometheus.Labels{
|
labels := prometheus.Labels{
|
||||||
"CPU": strconv.Itoa(cpuNo),
|
"CPU": strconv.Itoa(cpuNo),
|
||||||
|
|
|
@ -53,7 +53,7 @@ func NewLastLoginCollector() (Collector, error) {
|
||||||
func (c *lastLoginCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
func (c *lastLoginCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
last, err := getLastLoginTime()
|
last, err := getLastLoginTime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't get last seen: %s", err)
|
return fmt.Errorf("couldn't get last seen: %s", err)
|
||||||
}
|
}
|
||||||
log.Debugf("Set node_last_login_time: %f", last)
|
log.Debugf("Set node_last_login_time: %f", last)
|
||||||
c.metric.Set(last)
|
c.metric.Set(last)
|
||||||
|
@ -92,12 +92,12 @@ func getLastLoginTime() (float64, error) {
|
||||||
|
|
||||||
dateParts, err := splitToInts(lastDate, "-") // 2013-04-16
|
dateParts, err := splitToInts(lastDate, "-") // 2013-04-16
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("Couldn't parse date in line '%s': %s", fields, err)
|
return 0, fmt.Errorf("couldn't parse date in line '%s': %s", fields, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
timeParts, err := splitToInts(lastTime, ":") // 11:33
|
timeParts, err := splitToInts(lastTime, ":") // 11:33
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("Couldn't parse time in line '%s': %s", fields, err)
|
return 0, fmt.Errorf("couldn't parse time in line '%s': %s", fields, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
last_t := time.Date(dateParts[0], time.Month(dateParts[1]), dateParts[2], timeParts[0], timeParts[1], 0, 0, time.UTC)
|
last_t := time.Date(dateParts[0], time.Month(dateParts[1]), dateParts[2], timeParts[0], timeParts[1], 0, 0, time.UTC)
|
||||||
|
|
|
@ -50,7 +50,7 @@ func NewLoadavgCollector() (Collector, error) {
|
||||||
func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
load, err := getLoad1()
|
load, err := getLoad1()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't get load: %s", err)
|
return fmt.Errorf("couldn't get load: %s", err)
|
||||||
}
|
}
|
||||||
log.Debugf("Set node_load: %f", load)
|
log.Debugf("Set node_load: %f", load)
|
||||||
c.metric.Set(load)
|
c.metric.Set(load)
|
||||||
|
|
|
@ -48,7 +48,7 @@ func NewLoadavgCollector() (Collector, error) {
|
||||||
func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
load, err := getLoad1()
|
load, err := getLoad1()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't get load: %s", err)
|
return fmt.Errorf("couldn't get load: %s", err)
|
||||||
}
|
}
|
||||||
log.Debugf("Set node_load: %f", load)
|
log.Debugf("Set node_load: %f", load)
|
||||||
c.metric.Set(load)
|
c.metric.Set(load)
|
||||||
|
@ -68,7 +68,7 @@ func parseLoad(data string) (float64, error) {
|
||||||
parts := strings.Fields(data)
|
parts := strings.Fields(data)
|
||||||
load, err := strconv.ParseFloat(parts[0], 64)
|
load, err := strconv.ParseFloat(parts[0], 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("Could not parse load '%s': %s", parts[0], err)
|
return 0, fmt.Errorf("could not parse load '%s': %s", parts[0], err)
|
||||||
}
|
}
|
||||||
return load, nil
|
return load, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func NewMeminfoCollector() (Collector, error) {
|
||||||
func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
memInfo, err := getMemInfo()
|
memInfo, err := getMemInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't get meminfo: %s", err)
|
return fmt.Errorf("couldn't get meminfo: %s", err)
|
||||||
}
|
}
|
||||||
log.Debugf("Set node_mem: %#v", memInfo)
|
log.Debugf("Set node_mem: %#v", memInfo)
|
||||||
for k, v := range memInfo {
|
for k, v := range memInfo {
|
||||||
|
@ -91,14 +91,14 @@ func parseMemInfo(r io.Reader) (map[string]float64, error) {
|
||||||
parts := strings.Fields(string(line))
|
parts := strings.Fields(string(line))
|
||||||
fv, err := strconv.ParseFloat(parts[1], 64)
|
fv, err := strconv.ParseFloat(parts[1], 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Invalid value in meminfo: %s", err)
|
return nil, fmt.Errorf("invalid value in meminfo: %s", err)
|
||||||
}
|
}
|
||||||
switch len(parts) {
|
switch len(parts) {
|
||||||
case 2: // no unit
|
case 2: // no unit
|
||||||
case 3: // has unit, we presume kB
|
case 3: // has unit, we presume kB
|
||||||
fv *= 1024
|
fv *= 1024
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Invalid line in meminfo: %s", line)
|
return nil, fmt.Errorf("invalid line in meminfo: %s", line)
|
||||||
}
|
}
|
||||||
key := parts[0][:len(parts[0])-1] // remove trailing : from key
|
key := parts[0][:len(parts[0])-1] // remove trailing : from key
|
||||||
// Active(anon) -> Active_anon
|
// Active(anon) -> Active_anon
|
||||||
|
|
|
@ -41,7 +41,7 @@ func init() {
|
||||||
// the offset between ntp and the current system time.
|
// the offset between ntp and the current system time.
|
||||||
func NewNtpCollector() (Collector, error) {
|
func NewNtpCollector() (Collector, error) {
|
||||||
if *ntpServer == "" {
|
if *ntpServer == "" {
|
||||||
return nil, fmt.Errorf("No NTP server specifies, see --ntpServer")
|
return nil, fmt.Errorf("no NTP server specifies, see --ntpServer")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ntpCollector{
|
return &ntpCollector{
|
||||||
|
@ -56,7 +56,7 @@ func NewNtpCollector() (Collector, error) {
|
||||||
func (c *ntpCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
func (c *ntpCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
t, err := ntp.Time(*ntpServer)
|
t, err := ntp.Time(*ntpServer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't get ntp drift: %s", err)
|
return fmt.Errorf("couldn't get ntp drift: %s", err)
|
||||||
}
|
}
|
||||||
drift := t.Sub(time.Now())
|
drift := t.Sub(time.Now())
|
||||||
log.Debugf("Set ntp_drift_seconds: %f", drift.Seconds())
|
log.Debugf("Set ntp_drift_seconds: %f", drift.Seconds())
|
||||||
|
|
Loading…
Reference in New Issue