From d8f9c096f38020fe0fa861deea3a243085fca41c Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 12 Jun 2014 20:52:49 +0200 Subject: [PATCH] Report on system memory size --- CONTRIBUTING.md | 13 +++++++++++++ CONTRIBUTORS | 0 LICENSE | 19 +++++++++++++++++++ main.go | 6 ++++++ static/app.js | 1 + 5 files changed, 39 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTORS create mode 100644 LICENSE diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..92ccf315 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,13 @@ +## Licensing + +All contributions are made under the same MIT License as the rest of the +project, except documentation which is licensed under the Creative +Commons Attribution 4.0 International License. You retain the copyright +to code you have written. + +When accepting your first contribution, the maintainer of the project +will ensure that you are added to the CONTRIBUTORS file. + +## Style + +`go fmt` for Go code. diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 00000000..e69de29b diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..ac87dc7c --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2014 Jakob Borg and other contributors (see the CONTRIBUTORS file). + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +- The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/main.go b/main.go index 62774d05..738bb2de 100644 --- a/main.go +++ b/main.go @@ -89,6 +89,7 @@ type report struct { RepoMaxMiB int MemoryUsageMiB int SHA256Perf float64 + MemorySize int } var cache map[string]interface{} @@ -123,6 +124,7 @@ func reportHandler(w http.ResponseWriter, r *http.Request) { var maxMiB []int var memoryUsage []int var sha256Perf []float64 + var memorySize []int for _, fn := range files { f, err := os.Open(fn) @@ -148,6 +150,9 @@ func reportHandler(w http.ResponseWriter, r *http.Request) { maxMiB = append(maxMiB, rep.RepoMaxMiB) memoryUsage = append(memoryUsage, rep.MemoryUsageMiB) sha256Perf = append(sha256Perf, rep.SHA256Perf) + if rep.MemorySize > 0 { + memorySize = append(memorySize, rep.MemorySize) + } } cache = make(map[string]interface{}) @@ -162,6 +167,7 @@ func reportHandler(w http.ResponseWriter, r *http.Request) { cache["maxMiB"] = statsForInts(maxMiB) cache["memoryUsage"] = statsForInts(memoryUsage) cache["sha256Perf"] = statsForFloats(sha256Perf) + cache["memorySize"] = statsForInts(memorySize) } w.Header().Set("Content-Type", "application/json") diff --git a/static/app.js b/static/app.js index 79384161..bbbfadb8 100644 --- a/static/app.js +++ b/static/app.js @@ -20,6 +20,7 @@ reports.controller('ReportsCtrl', function ($scope, $http) { {key: 'numNodes', descr: 'Number of Nodes in Cluster', unit: ''}, {key: 'numRepos', descr: 'Number of Repositories Configured', unit: ''}, {key: 'memoryUsage', descr: 'Memory Usage', unit: 'MiB'}, + {key: 'memorySize', descr: 'System Memory', unit: 'MiB'}, {key: 'sha256Perf', descr: 'SHA-256 Hashing Performance', unit: 'MiB/s'}, ];