@ -18,7 +18,6 @@
package collector
package collector
import (
import (
"bytes"
"strings"
"strings"
"golang.org/x/sys/unix"
"golang.org/x/sys/unix"
@ -33,10 +32,10 @@ func getUname() (uname, error) {
nodeName , domainName := parseHostNameAndDomainName ( utsname )
nodeName , domainName := parseHostNameAndDomainName ( utsname )
output := uname {
output := uname {
SysName : string ( utsname . Sysname [ : bytes . IndexByte ( utsname . Sysname [ : ] , 0 ) ] ) ,
SysName : unix . ByteSliceToString ( utsname . Sysname [ : ] ) ,
Release : string ( utsname . Release [ : bytes . IndexByte ( utsname . Release [ : ] , 0 ) ] ) ,
Release : unix . ByteSliceToString ( utsname . Release [ : ] ) ,
Version : string ( utsname . Version [ : bytes . IndexByte ( utsname . Version [ : ] , 0 ) ] ) ,
Version : unix . ByteSliceToString ( utsname . Version [ : ] ) ,
Machine : string ( utsname . Machine [ : bytes . IndexByte ( utsname . Machine [ : ] , 0 ) ] ) ,
Machine : unix . ByteSliceToString ( utsname . Machine [ : ] ) ,
NodeName : nodeName ,
NodeName : nodeName ,
DomainName : domainName ,
DomainName : domainName ,
}
}
@ -47,7 +46,7 @@ func getUname() (uname, error) {
// parseHostNameAndDomainName for FreeBSD,OpenBSD,Darwin.
// parseHostNameAndDomainName for FreeBSD,OpenBSD,Darwin.
// Attempts to emulate what happens in the Linux uname calls since these OS doesn't have a Domainname.
// Attempts to emulate what happens in the Linux uname calls since these OS doesn't have a Domainname.
func parseHostNameAndDomainName ( utsname unix . Utsname ) ( hostname string , domainname string ) {
func parseHostNameAndDomainName ( utsname unix . Utsname ) ( hostname string , domainname string ) {
nodename := string ( utsname . Nodename [ : bytes . IndexByte ( utsname . Nodename [ : ] , 0 ) ] )
nodename := unix . ByteSliceToString ( utsname . Nodename [ : ] )
split := strings . SplitN ( nodename , "." , 2 )
split := strings . SplitN ( nodename , "." , 2 )
// We'll always have at least a single element in the array. We assume this
// We'll always have at least a single element in the array. We assume this