Fix some error messages.

This commit is contained in:
Siavash Safi 2015-07-14 01:59:55 +04:30
parent 93708f3dda
commit dddb273dfc
6 changed files with 10 additions and 10 deletions

View File

@ -53,7 +53,7 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) (err error) {
var errbuf *C.char var errbuf *C.char
kd := C.kvm_open(nil, nil, nil, C.O_RDONLY, errbuf) kd := C.kvm_open(nil, nil, nil, C.O_RDONLY, errbuf)
if errbuf != nil { if errbuf != nil {
return errors.New("failed to call kvm_open().") return errors.New("failed to call kvm_open()")
} }
defer C.kvm_close(kd) defer C.kvm_close(kd)

View File

@ -191,10 +191,10 @@ func NewDevstatCollector() (Collector, error) {
func (c *devstatCollector) Update(ch chan<- prometheus.Metric) (err error) { func (c *devstatCollector) Update(ch chan<- prometheus.Metric) (err error) {
count := C._get_ndevs() count := C._get_ndevs()
if count == -1 { if count == -1 {
return errors.New("devstat_getdevs() failed!") return errors.New("devstat_getdevs() failed")
} }
if count == -2 { if count == -2 {
return errors.New("calloc() failed!") return errors.New("calloc() failed")
} }
for i := C.int(0); i < count; i++ { for i := C.int(0); i < count; i++ {

View File

@ -98,7 +98,7 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) (err error) {
var mntbuf *C.struct_statfs var mntbuf *C.struct_statfs
count := C.getmntinfo(&mntbuf, C.MNT_NOWAIT) count := C.getmntinfo(&mntbuf, C.MNT_NOWAIT)
if count == 0 { if count == 0 {
return errors.New("getmntinfo() failed!") return errors.New("getmntinfo() failed")
} }
mnt := (*[1 << 30]C.struct_statfs)(unsafe.Pointer(mntbuf)) mnt := (*[1 << 30]C.struct_statfs)(unsafe.Pointer(mntbuf))

View File

@ -51,7 +51,7 @@ func getLoad1() (float64, error) {
if samples > 0 { if samples > 0 {
return float64(loadavg[0]), nil return float64(loadavg[0]), nil
} else { } else {
return 0, errors.New("Failed to get load average!") return 0, errors.New("failed to get load average")
} }
} }

View File

@ -54,10 +54,10 @@ func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) (err error) {
size := C._sysctl(C.CString("vm.stats.vm.v_page_size")) size := C._sysctl(C.CString("vm.stats.vm.v_page_size"))
if size == -1 { if size == -1 {
return errors.New("sysctl(vm.stats.vm.v_page_size) failed!") return errors.New("sysctl(vm.stats.vm.v_page_size) failed")
} }
if size == -2 { if size == -2 {
return errors.New("sysctl(vm.stats.vm.v_page_size) failed, wrong buffer size!") return errors.New("sysctl(vm.stats.vm.v_page_size) failed, wrong buffer size")
} }
pages["active"] = C._sysctl(C.CString("vm.stats.vm.v_active_count")) pages["active"] = C._sysctl(C.CString("vm.stats.vm.v_active_count"))
@ -74,7 +74,7 @@ func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) (err error) {
return errors.New("sysctl() failed for " + key) return errors.New("sysctl() failed for " + key)
} }
if pages[key] == -2 { if pages[key] == -2 {
return errors.New("sysctl() failed for " + key + ", wrong buffer size!") return errors.New("sysctl() failed for " + key + ", wrong buffer size")
} }
} }
@ -88,7 +88,7 @@ func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) (err error) {
Help: k + " from sysctl()", Help: k + " from sysctl()",
}) })
} }
// Convert metrics to kB ( same as Linux meminfo). // Convert metrics to kB (same as Linux meminfo).
c.metrics[k].Set(float64(v) * float64(size)) c.metrics[k].Set(float64(v) * float64(size))
c.metrics[k].Collect(ch) c.metrics[k].Collect(ch)
} }

View File

@ -81,7 +81,7 @@ func getNetDevStats() (map[string]map[string]map[string]string, error) {
var ifap, ifa *C.struct_ifaddrs var ifap, ifa *C.struct_ifaddrs
if C.getifaddrs(&ifap) == -1 { if C.getifaddrs(&ifap) == -1 {
return nil, errors.New("getifaddrs() failed!") return nil, errors.New("getifaddrs() failed")
} }
defer C.freeifaddrs(ifap) defer C.freeifaddrs(ifap)