diff options
| author | Paul Buetow (europa) <paul@buetow.org> | 2015-05-25 10:39:47 +0100 |
|---|---|---|
| committer | Paul Buetow (europa) <paul@buetow.org> | 2015-05-25 10:39:47 +0100 |
| commit | b5117be9fc9dd7be25735fb8da93a2d1fb0349c9 (patch) | |
| tree | 678e734c51794b8b5a75a34fa2578adeaaf7c288 /gstat | |
| parent | b804f4905f48d3a05218a323b258963c514399f7 (diff) | |
initial diskstats
Diffstat (limited to 'gstat')
| -rw-r--r-- | gstat/main.go | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/gstat/main.go b/gstat/main.go index 6cef683..254edeb 100644 --- a/gstat/main.go +++ b/gstat/main.go @@ -2,11 +2,12 @@ package main import ( "fmt" + "github.com/buetow/gstat/diskstats" "github.com/buetow/gstat/process" "time" ) -func gather(timer <-chan bool, processes chan<- process.Process) { +func gather(timer <-chan bool, d chan<- diskstats.Diskstats, p chan<- process.Process) { for { switch <-timer { case false: @@ -15,14 +16,22 @@ func gather(timer <-chan bool, processes chan<- process.Process) { } case true: { - process.Gather(processes) + diskstats.Gather(d) + process.Gather(p) } } } - close(processes) + close(d) + close(p) } -func receive(processes <-chan process.Process) { +func receive1(diskstats <-chan diskstats.Diskstats) { + for diskstats := range diskstats { + diskstats.Print() + } +} + +func receive2(processes <-chan process.Process) { for process := range processes { process.Print() } @@ -30,14 +39,17 @@ func receive(processes <-chan process.Process) { func main() { timer := make(chan bool) - res := make(chan process.Process) + diskstats := make(chan diskstats.Diskstats) + processes := make(chan process.Process) - go gather(timer, res) - go receive(res) + go gather(timer, diskstats, processes) + go receive1(diskstats) + go receive2(processes) for counter := 0; counter < 3; counter++ { timer <- true time.Sleep(time.Second) + fmt.Printf("Next... %d\n", counter) } timer <- false |
