diff options
author | Dr. James Dominic P. Guana <jdpguana@histark.com> | 2021-08-20 19:08:15 +0800 |
---|---|---|
committer | Robert Roth <robert.roth.off@gmail.com> | 2022-03-28 12:32:26 +0000 |
commit | 629097436a2c654402e2a5210a2a0b4ca217b42c (patch) | |
tree | 86af25d46026ac741821f123fc75ee215f42ff54 | |
parent | 04bf09341203173bc2ee6ff1cd990cc78c2c38c0 (diff) | |
download | libgtop-629097436a2c654402e2a5210a2a0b4ca217b42c.tar.gz |
Exposes the processor model
Accessing processor model becomes easier
Signed off: Dr. James Dominic P. Guana <jdpguana@histark.com>
-rw-r--r-- | examples/Makefile.am | 2 | ||||
-rw-r--r-- | examples/sysinfo.c | 8 | ||||
-rw-r--r-- | include/glibtop/sysinfo.h | 2 | ||||
-rw-r--r-- | sysdeps/linux/sysinfo.c | 5 |
4 files changed, 12 insertions, 5 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index fb95f825..e2b72115 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -72,4 +72,4 @@ diskio_SOURCES = diskio.c diskio_LDADD = $(top_builddir)/lib/libgtop-2.0.la sysinfo_SOURCES = sysinfo.c -sysinfo_LDADD = $(top_builddir)/lib/libgtop-2.0.la -lm +sysinfo_LDADD = $(top_builddir)/lib/libgtop-2.0.la diff --git a/examples/sysinfo.c b/examples/sysinfo.c index ed6fb162..40eed37a 100644 --- a/examples/sysinfo.c +++ b/examples/sysinfo.c @@ -32,10 +32,16 @@ int main (int argc, char *argv []) { - const glibtop_sysinfo * sysinfo = glibtop_get_sysinfo (); + const glibtop_sysinfo * sysinfo; + + glibtop_init(); + + sysinfo = glibtop_get_sysinfo (); printf ("\nProcessor Model: %s\n", sysinfo->model); printf ("Number of Cores: %d\n\n", sysinfo->ncpu); + glibtop_close (); + exit (0); } diff --git a/include/glibtop/sysinfo.h b/include/glibtop/sysinfo.h index 52e204ff..30598f16 100644 --- a/include/glibtop/sysinfo.h +++ b/include/glibtop/sysinfo.h @@ -50,7 +50,7 @@ struct _glibtop_sysinfo { guint64 flags; guint64 ncpu; - gchar *model; + gchar *model; glibtop_entry cpuinfo [GLIBTOP_NCPU]; }; diff --git a/sysdeps/linux/sysinfo.c b/sysdeps/linux/sysinfo.c index c9a66653..2ebe0ec5 100644 --- a/sysdeps/linux/sysinfo.c +++ b/sysdeps/linux/sysinfo.c @@ -59,8 +59,9 @@ init_sysinfo (glibtop *server) if (buf != NULL) { - buf+=2; // we want to look at what's _after_ the ':' - sysinfo.model = buf; + /* we want to look at what's _after_ the ':' */ + buf+=2; + sysinfo.model = g_strdup (buf); } break; } |