Exposes the processor model

Accessing processor model becomes easier

Signed off: Dr. James Dominic P. Guana <jdpguana@histark.com>
This commit is contained in:
Dr. James Dominic P. Guana
2021-08-20 19:08:15 +08:00
committed by Robert Roth
parent 04bf093412
commit 629097436a
4 changed files with 12 additions and 5 deletions

View File

@@ -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

View File

@@ -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);
}

View File

@@ -50,7 +50,7 @@ struct _glibtop_sysinfo
{
guint64 flags;
guint64 ncpu;
gchar *model;
gchar *model;
glibtop_entry cpuinfo [GLIBTOP_NCPU];
};

View File

@@ -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;
}