aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorChristine Dodrill <xena@yolo-swag.com>2015-09-02 19:40:12 -0700
committerChristine Dodrill <xena@yolo-swag.com>2015-09-02 19:41:22 -0700
commit71dec7d34779633c2e6354f3a41842ed1f1167f3 (patch)
tree42948318ac9e06fbc5b2b0ec927d43167754bcd1 /docker
parent359b838e78c6f85f54ca105feada0da99019f2e9 (diff)
downloadx-71dec7d34779633c2e6354f3a41842ed1f1167f3.tar.xz
x-71dec7d34779633c2e6354f3a41842ed1f1167f3.zip
add Camp Triggerfish
Diffstat (limited to 'docker')
-rw-r--r--docker/status/main.go44
-rw-r--r--docker/status/stats.go137
2 files changed, 181 insertions, 0 deletions
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"`
+}