diff options
| -rw-r--r-- | BLESSING | 6 | ||||
| -rw-r--r-- | docker/status/main.go | 44 | ||||
| -rw-r--r-- | docker/status/stats.go | 137 | ||||
| -rw-r--r-- | irc/splatbot/maps.go | 1 | ||||
| -rw-r--r-- | splattus/lib/maps.go | 1 |
5 files changed, 189 insertions, 0 deletions
diff --git a/BLESSING b/BLESSING new file mode 100644 index 0000000..4504e70 --- /dev/null +++ b/BLESSING @@ -0,0 +1,6 @@ +The author disclaims copyright to this source code. In place of +a legal notice, here is a blessing: + + May you do good and not evil. + May you find forgiveness for yourself and forgive others. + May you share freely, never taking more than you give.
\ No newline at end of file diff --git a/docker/status/main.go b/docker/status/main.go new file mode 100644 index 0000000..68fa28e --- /dev/null +++ b/docker/status/main.go @@ -0,0 +1,44 @@ +package main + +import ( + "encoding/json" + "io/ioutil" + "log" + "net/http" + "time" + + "github.com/tv42/httpunix" +) + +func main() { + u := &httpunix.Transport{ + DialTimeout: 100 * time.Millisecond, + RequestTimeout: 2 * time.Second, + ResponseHeaderTimeout: 2 * time.Second, + } + u.RegisterLocation("docker", "/var/run/docker.sock") + + var client = http.Client{ + Transport: u, + } + + resp, err := client.Get("http+unix://docker/v1.12/containers/e1778874f60b5a4ff18a122606bfe2ba45ba41e2ba71b27ce8de1e2dd403aabd/stats?stream=0") + if err != nil { + log.Fatal(err) + } + defer resp.Body.Close() + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + log.Fatal(err) + } + + reply := &Stats{} + + err = json.Unmarshal(data, reply) + if err != nil { + log.Fatal(err) + } + + log.Printf("%#v", reply) +} diff --git a/docker/status/stats.go b/docker/status/stats.go new file mode 100644 index 0000000..de38d49 --- /dev/null +++ b/docker/status/stats.go @@ -0,0 +1,137 @@ +package main + +type Stats struct { + Read string `json:"read"` + Network struct { + RxBytes int `json:"rx_bytes"` + RxPackets int `json:"rx_packets"` + RxErrors int `json:"rx_errors"` + RxDropped int `json:"rx_dropped"` + TxBytes int `json:"tx_bytes"` + TxPackets int `json:"tx_packets"` + TxErrors int `json:"tx_errors"` + TxDropped int `json:"tx_dropped"` + } `json:"network"` + PrecpuStats struct { + CPUUsage struct { + TotalUsage int64 `json:"total_usage"` + PercpuUsage []int64 `json:"percpu_usage"` + UsageInKernelmode int64 `json:"usage_in_kernelmode"` + UsageInUsermode int64 `json:"usage_in_usermode"` + } `json:"cpu_usage"` + SystemCPUUsage int64 `json:"system_cpu_usage"` + ThrottlingData struct { + Periods int `json:"periods"` + ThrottledPeriods int `json:"throttled_periods"` + ThrottledTime int `json:"throttled_time"` + } `json:"throttling_data"` + } `json:"precpu_stats"` + CPUStats struct { + CPUUsage struct { + TotalUsage int64 `json:"total_usage"` + PercpuUsage []int64 `json:"percpu_usage"` + UsageInKernelmode int64 `json:"usage_in_kernelmode"` + UsageInUsermode int64 `json:"usage_in_usermode"` + } `json:"cpu_usage"` + SystemCPUUsage int64 `json:"system_cpu_usage"` + ThrottlingData struct { + Periods int `json:"periods"` + ThrottledPeriods int `json:"throttled_periods"` + ThrottledTime int `json:"throttled_time"` + } `json:"throttling_data"` + } `json:"cpu_stats"` + MemoryStats struct { + Usage int `json:"usage"` + MaxUsage int `json:"max_usage"` + Stats struct { + ActiveAnon int `json:"active_anon"` + ActiveFile int `json:"active_file"` + Cache int `json:"cache"` + HierarchicalMemoryLimit int64 `json:"hierarchical_memory_limit"` + HierarchicalMemswLimit int64 `json:"hierarchical_memsw_limit"` + InactiveAnon int `json:"inactive_anon"` + InactiveFile int `json:"inactive_file"` + MappedFile int `json:"mapped_file"` + Pgfault int `json:"pgfault"` + Pgmajfault int `json:"pgmajfault"` + Pgpgin int `json:"pgpgin"` + Pgpgout int `json:"pgpgout"` + RecentRotatedAnon int `json:"recent_rotated_anon"` + RecentRotatedFile int `json:"recent_rotated_file"` + RecentScannedAnon int `json:"recent_scanned_anon"` + RecentScannedFile int `json:"recent_scanned_file"` + Rss int `json:"rss"` + RssHuge int `json:"rss_huge"` + Swap int `json:"swap"` + TotalActiveAnon int `json:"total_active_anon"` + TotalActiveFile int `json:"total_active_file"` + TotalCache int `json:"total_cache"` + TotalInactiveAnon int `json:"total_inactive_anon"` + TotalInactiveFile int `json:"total_inactive_file"` + TotalMappedFile int `json:"total_mapped_file"` + TotalPgfault int `json:"total_pgfault"` + TotalPgmajfault int `json:"total_pgmajfault"` + TotalPgpgin int `json:"total_pgpgin"` + TotalPgpgout int `json:"total_pgpgout"` + TotalRss int `json:"total_rss"` + TotalRssHuge int `json:"total_rss_huge"` + TotalSwap int `json:"total_swap"` + TotalUnevictable int `json:"total_unevictable"` + TotalWriteback int `json:"total_writeback"` + Unevictable int `json:"unevictable"` + Writeback int `json:"writeback"` + } `json:"stats"` + Failcnt int `json:"failcnt"` + Limit int64 `json:"limit"` + } `json:"memory_stats"` + BlkioStats struct { + IoServiceBytesRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"io_service_bytes_recursive"` + IoServicedRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"io_serviced_recursive"` + IoQueueRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"io_queue_recursive"` + IoServiceTimeRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"io_service_time_recursive"` + IoWaitTimeRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"io_wait_time_recursive"` + IoMergedRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"io_merged_recursive"` + IoTimeRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"io_time_recursive"` + SectorsRecursive []struct { + Major int `json:"major"` + Minor int `json:"minor"` + Op string `json:"op"` + Value int `json:"value"` + } `json:"sectors_recursive"` + } `json:"blkio_stats"` +} diff --git a/irc/splatbot/maps.go b/irc/splatbot/maps.go index 4845bb9..e3f9ff8 100644 --- a/irc/splatbot/maps.go +++ b/irc/splatbot/maps.go @@ -18,6 +18,7 @@ func init() { "c52a7ab7202a576ee18d94be687d97190e90fdcc25fc4b1591c1a8e0c1c299a5": "Kelp Dome", "6a6c3a958712adedcceb34f719e220ab0d840d8753e5f51b089d363bd1763c91": "Moray Towers", "a54716422edf71ac0b3d20fbb4ba5970a7a78ba304fcf935aaf69254d61ca709": "Flounder Heights", + "fafe7416d363c7adc8c5c7b0f76586216ba86dcfe3fd89708d672e99bc822adc": "Camp Triggerfish", } } diff --git a/splattus/lib/maps.go b/splattus/lib/maps.go index 29aa883..56d402d 100644 --- a/splattus/lib/maps.go +++ b/splattus/lib/maps.go @@ -18,6 +18,7 @@ func init() { "c52a7ab7202a576ee18d94be687d97190e90fdcc25fc4b1591c1a8e0c1c299a5": "Kelp Dome", "6a6c3a958712adedcceb34f719e220ab0d840d8753e5f51b089d363bd1763c91": "Moray Towers", "a54716422edf71ac0b3d20fbb4ba5970a7a78ba304fcf935aaf69254d61ca709": "Flounder Heights", + "fafe7416d363c7adc8c5c7b0f76586216ba86dcfe3fd89708d672e99bc822adc": "Camp Triggerfish", } } |
