[gnome-talos] sysinfo: Add total system memory
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-talos] sysinfo: Add total system memory
- Date: Fri, 23 Sep 2011 15:13:38 +0000 (UTC)
commit 1b4c14d80c76d420d75c3f804e240f72656fa34f
Author: Colin Walters <walters verbum org>
Date: Fri Sep 23 11:12:26 2011 -0400
sysinfo: Add total system memory
src/gnome-talos-session.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-talos-session.c b/src/gnome-talos-session.c
index 4b5c042..3a1b5cb 100644
--- a/src/gnome-talos-session.c
+++ b/src/gnome-talos-session.c
@@ -247,6 +247,8 @@ get_system_info (void)
GDBusConnection *system_bus;
GError *error = NULL;
char *checksum;
+ char *procdata;
+ gsize len;
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (!system_bus)
@@ -269,6 +271,24 @@ get_system_info (void)
"myuid",
g_variant_new_int32 ((gint32)getuid ()));
+ if (g_file_get_contents ("/proc/meminfo", &procdata, &len, NULL))
+ {
+ const char *memtotal_str = strstr (procdata, "MemTotal:");
+
+ if (memtotal_str)
+ {
+ guint64 memtotal;
+
+ memtotal = g_ascii_strtoll (memtotal_str + strlen ("MemTotal:"), NULL, 10);
+
+ memtotal *= 1024;
+
+ g_variant_builder_add (&builder, "{sv}",
+ "memtotal",
+ g_variant_new_uint64 (memtotal));
+ }
+ }
+
return g_variant_builder_end (&builder);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]