From e8ea485a0db8e550f05d6ed08515974ace41adf2 Mon Sep 17 00:00:00 2001 From: Abin Shahab Date: Sun, 19 Oct 2014 23:39:04 +0000 Subject: [PATCH] Gofmt all files --- container/raw/handler.go | 4 ++-- fs/fs.go | 32 +++++++++++++++---------------- fs/fs_test.go | 41 ++++++++++++++++++++-------------------- fs/types.go | 28 +++++++++++++-------------- info/container.go | 24 +++++++++++------------ 5 files changed, 65 insertions(+), 64 deletions(-) diff --git a/container/raw/handler.go b/container/raw/handler.go index 3b274ebb..955e804b 100644 --- a/container/raw/handler.go +++ b/container/raw/handler.go @@ -238,9 +238,9 @@ func (self *rawContainerHandler) GetStats() (*info.ContainerStats, error) { if self.networkInterface != nil { state = dockerlibcontainer.State{ NetworkState: network.NetworkState{ - VethHost: self.networkInterface.VethHost, + VethHost: self.networkInterface.VethHost, VethChild: self.networkInterface.VethChild, - NsPath: "unknown", + NsPath: "unknown", }, } } diff --git a/fs/fs.go b/fs/fs.go index a37ae482..3de66d21 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -12,8 +12,8 @@ import "C" import ( "bufio" "fmt" - "os/exec" "os" + "os/exec" "regexp" "strconv" "strings" @@ -63,7 +63,7 @@ func (self *RealFsInfo) GetFsInfoForPath(mountSet map[string]struct{}) ([]Fs, er for device, partition := range self.partitions { _, hasMount := mountSet[partition.mountpoint] _, hasDevice := deviceSet[device] - if mountSet == nil || hasMount && !hasDevice { + if mountSet == nil || hasMount && !hasDevice { total, free, err := getVfsStats(partition.mountpoint) if err != nil { glog.Errorf("Statvfs failed. Error: %v", err) @@ -94,7 +94,7 @@ func getDiskStatsMap(diskStatsFile string) (map[string]DiskStats, error) { diskStatsMap := make(map[string]DiskStats) partitionRegex, _ := regexp.Compile("sd[a-z]\\d") for scanner.Scan() { - line :=scanner.Text() + line := scanner.Text() words := strings.Fields(line) if !partitionRegex.MatchString(words[2]) { continue @@ -102,7 +102,7 @@ func getDiskStatsMap(diskStatsFile string) (map[string]DiskStats, error) { // 8 50 sdd2 40 0 280 223 7 0 22 108 0 330 330 deviceName := "/dev/" + words[2] wordLength := len(words) - var stats = make([]uint64,wordLength) + var stats = make([]uint64, wordLength) var error error for i := 3; i < wordLength; i++ { stats[i], error = strconv.ParseUint(words[i], 10, 64) @@ -110,18 +110,18 @@ func getDiskStatsMap(diskStatsFile string) (map[string]DiskStats, error) { return nil, error } } - diskStats := DiskStats { - ReadsCompleted: stats[3], - ReadsMerged: stats[4], - SectorsRead: stats[5], - ReadTime: stats[6], - WritesCompleted:stats[7], - WritesMerged: stats[8], - SectorsWritten: stats[9], - WriteTime: stats[10], - IOInProgress: stats[11], - IOTime: stats[12], - WeightedIOTime: stats[13], + diskStats := DiskStats{ + ReadsCompleted: stats[3], + ReadsMerged: stats[4], + SectorsRead: stats[5], + ReadTime: stats[6], + WritesCompleted: stats[7], + WritesMerged: stats[8], + SectorsWritten: stats[9], + WriteTime: stats[10], + IOInProgress: stats[11], + IOTime: stats[12], + WeightedIOTime: stats[13], } diskStatsMap[deviceName] = diskStats } diff --git a/fs/fs_test.go b/fs/fs_test.go index 715c15ed..27664b2c 100644 --- a/fs/fs_test.go +++ b/fs/fs_test.go @@ -1,4 +1,5 @@ package fs + import ( "testing" ) @@ -12,26 +13,26 @@ func TestGetDiskStatsMap(t *testing.T) { t.Errorf("diskStatsMap %s not valid", diskStatsMap) } keySet := map[string]string{ - "/dev/sdb1": "/dev/sdb1", - "/dev/sdb2": "/dev/sdb2", - "/dev/sda1": "/dev/sda1", - "/dev/sda2": "/dev/sda2", - "/dev/sdc1": "/dev/sdc1", - "/dev/sdc2": "/dev/sdc2", - "/dev/sdc3": "/dev/sdc3", - "/dev/sdc4": "/dev/sdc4", - "/dev/sdd1": "/dev/sdd1", - "/dev/sdd2": "/dev/sdd2", - "/dev/sdd3": "/dev/sdd3", - "/dev/sdd4": "/dev/sdd4", - "/dev/sde1": "/dev/sde1", - "/dev/sde2": "/dev/sde2", - "/dev/sdf1": "/dev/sdf1", - "/dev/sdf2": "/dev/sdf2", - "/dev/sdg1": "/dev/sdg1", - "/dev/sdg2": "/dev/sdg2", - "/dev/sdh1": "/dev/sdh1", - "/dev/sdh2": "/dev/sdh2", + "/dev/sdb1": "/dev/sdb1", + "/dev/sdb2": "/dev/sdb2", + "/dev/sda1": "/dev/sda1", + "/dev/sda2": "/dev/sda2", + "/dev/sdc1": "/dev/sdc1", + "/dev/sdc2": "/dev/sdc2", + "/dev/sdc3": "/dev/sdc3", + "/dev/sdc4": "/dev/sdc4", + "/dev/sdd1": "/dev/sdd1", + "/dev/sdd2": "/dev/sdd2", + "/dev/sdd3": "/dev/sdd3", + "/dev/sdd4": "/dev/sdd4", + "/dev/sde1": "/dev/sde1", + "/dev/sde2": "/dev/sde2", + "/dev/sdf1": "/dev/sdf1", + "/dev/sdf2": "/dev/sdf2", + "/dev/sdg1": "/dev/sdg1", + "/dev/sdg2": "/dev/sdg2", + "/dev/sdh1": "/dev/sdh1", + "/dev/sdh2": "/dev/sdh2", } for device := range diskStatsMap { diff --git a/fs/types.go b/fs/types.go index 1ff9e4d5..3b454407 100644 --- a/fs/types.go +++ b/fs/types.go @@ -8,23 +8,23 @@ type DeviceInfo struct { type Fs struct { DeviceInfo - Capacity uint64 - Free uint64 - DiskStats DiskStats + Capacity uint64 + Free uint64 + DiskStats DiskStats } type DiskStats struct { - ReadsCompleted uint64 - ReadsMerged uint64 - SectorsRead uint64 - ReadTime uint64 - WritesCompleted uint64 - WritesMerged uint64 - SectorsWritten uint64 - WriteTime uint64 - IOInProgress uint64 - IOTime uint64 - WeightedIOTime uint64 + ReadsCompleted uint64 + ReadsMerged uint64 + SectorsRead uint64 + ReadTime uint64 + WritesCompleted uint64 + WritesMerged uint64 + SectorsWritten uint64 + WriteTime uint64 + IOInProgress uint64 + IOTime uint64 + WeightedIOTime uint64 } type FsInfo interface { diff --git a/info/container.go b/info/container.go index 43322bb0..bbf3d2a7 100644 --- a/info/container.go +++ b/info/container.go @@ -218,7 +218,7 @@ type NetworkStats struct { // Cumulative count of packets received. RxPackets uint64 `json:"rx_packets"` // Cumulative count of receive errors encountered. - RxErrors uint64 `json:"rx_errors"` + RxErrors uint64 `json:"rx_errors"` // Cumulative count of packets dropped while receiving. RxDropped uint64 `json:"rx_dropped"` // Cumulative count of bytes transmitted. @@ -243,49 +243,49 @@ type FsStats struct { // # of reads completed // This is the total number of reads completed successfully. - ReadsCompleted uint64 `json:"reads_completed"` + ReadsCompleted uint64 `json:"reads_completed"` // # of reads merged // Reads and writes which are adjacent to each other may be merged for // efficiency. Thus two 4K reads may become one 8K read before it is // ultimately handed to the disk, and so it will be counted (and queued) // as only one I/O. This field lets you know how often this was done. - ReadsMerged uint64 `json:"reads_merged"` + ReadsMerged uint64 `json:"reads_merged"` // # of sectors read // This is the total number of sectors read successfully. - SectorsRead uint64 `json:"sectors_read"` + SectorsRead uint64 `json:"sectors_read"` // # of milliseconds spent reading // This is the total number of milliseconds spent by all reads (as // measured from __make_request() to end_that_request_last()). - ReadTime uint64 `json:"read_time"` + ReadTime uint64 `json:"read_time"` // # of writes completed // This is the total number of writes completed successfully. - WritesCompleted uint64 `json:"writes_completed"` + WritesCompleted uint64 `json:"writes_completed"` // # of writes merged // See the description of reads merged. - WritesMerged uint64 `json:"writes_merged"` + WritesMerged uint64 `json:"writes_merged"` // # of sectors written // This is the total number of sectors written successfully. - SectorsWritten uint64 `json:"sectors_written"` + SectorsWritten uint64 `json:"sectors_written"` // # of milliseconds spent writing // This is the total number of milliseconds spent by all writes (as // measured from __make_request() to end_that_request_last()). - WriteTime uint64 `json:"write_time"` + WriteTime uint64 `json:"write_time"` // # of I/Os currently in progress // The only field that should go to zero. Incremented as requests are // given to appropriate struct request_queue and decremented as they finish. - IOInProgress uint64 `json:"io_in_progress"` + IOInProgress uint64 `json:"io_in_progress"` // # of milliseconds spent doing I/Os // This field increases so long as field 9 is nonzero. - IOTime uint64 `json:"io_time"` + IOTime uint64 `json:"io_time"` // weighted # of milliseconds spent doing I/Os // This field is incremented at each I/O start, I/O completion, I/O @@ -293,7 +293,7 @@ type FsStats struct { // (field 9) times the number of milliseconds spent doing I/O since the // last update of this field. This can provide an easy measure of both // I/O completion time and the backlog that may be accumulating. - WeightedIOTime uint64 `json:"weighted_io_time"` + WeightedIOTime uint64 `json:"weighted_io_time"` } type ContainerStats struct {