diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-05 02:59:47 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-05 02:59:47 +0000 |
commit | 5c78971c19a9f941c896b2c818d45319b64651b3 (patch) | |
tree | e5d69148d5d38427f3152ae486f4ce5685adea65 /hardinfo2/arch/linux/common/devmemory.h | |
parent | a1054182ecd202db45cde1883991d70dbb954763 (diff) |
LoadGraph optimizations, enhancements and cleanups.
Diffstat (limited to 'hardinfo2/arch/linux/common/devmemory.h')
-rw-r--r-- | hardinfo2/arch/linux/common/devmemory.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/hardinfo2/arch/linux/common/devmemory.h b/hardinfo2/arch/linux/common/devmemory.h index 0adea960..cc4b1582 100644 --- a/hardinfo2/arch/linux/common/devmemory.h +++ b/hardinfo2/arch/linux/common/devmemory.h @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +static GHashTable *memlabels; + static void __scan_memory() { gchar **keys, *tmp; @@ -41,13 +43,18 @@ static void __scan_memory() g_strstrip(newkeys[1]); + if ((tmp = g_hash_table_lookup(memlabels, newkeys[0]))) { + g_free(newkeys[0]); + newkeys[0] = g_strdup(tmp); + } + g_hash_table_replace(moreinfo, g_strdup(newkeys[0]), g_strdup(newkeys[1])); + tmp = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL); g_free(meminfo); meminfo = tmp; tmp = g_strconcat(lginterval, - "LoadGraphInterval$", newkeys[0], "=500\n", "UpdateInterval$", newkeys[0], "=1000\n", NULL); g_free(lginterval); lginterval = tmp; @@ -56,3 +63,29 @@ static void __scan_memory() } g_strfreev(keys); } + +static void __init_memory_labels(void) +{ + static struct { + char *proc_label; + char *real_label; + } proc2real[] = { + { "MemTotal", "Total Memory" }, + { "MemFree", "Free Memory" }, + { "SwapCached", "Cached Swap" }, + { "HighTotal", "High Memory" }, + { "HighFree", "Free High Memory" }, + { "LowTotal", "Low Memory" }, + { "LowFree", "Free Low Memory" }, + { "SwapTotal", "Virtual Memory" }, + { "SwapFree", "Free Virtual Memory" }, + { NULL }, + }; + gint i; + + memlabels = g_hash_table_new(g_str_hash, g_str_equal); + + for (i = 0; proc2real[i].proc_label; i++) { + g_hash_table_insert(memlabels, proc2real[i].proc_label, proc2real[i].real_label); + } +} |