Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
88ecae1d00 | ||
|
89a73e2746 | ||
|
35bf89632a | ||
|
4285abe72b | ||
|
1a103bf142 | ||
|
3ff313dd03 | ||
|
01a56e2e30 | ||
|
7afc81f99d | ||
|
b0ab056e99 |
64
.gitignore
vendored
64
.gitignore
vendored
@@ -1,45 +1,38 @@
|
|||||||
*~
|
*.a
|
||||||
*.bak
|
*.bak
|
||||||
|
*.core
|
||||||
|
*.diff
|
||||||
|
*.gmo
|
||||||
|
*.header
|
||||||
|
*.in
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
*.o
|
*.o
|
||||||
*.out
|
*.out
|
||||||
*.a
|
*.patch
|
||||||
*.gmo
|
*.pot
|
||||||
*.lo
|
|
||||||
*.la
|
|
||||||
*.core
|
|
||||||
*.s
|
*.s
|
||||||
|
*.sed
|
||||||
|
*.sin
|
||||||
*.stamp
|
*.stamp
|
||||||
.libs
|
*.swp
|
||||||
|
*~
|
||||||
.deps
|
.deps
|
||||||
Makefile
|
.libs
|
||||||
Makefile.in
|
ABOUT-NLS
|
||||||
src/daemon/libgtop_daemon2
|
|
||||||
src/daemon/libgtop_server2
|
|
||||||
stamp-h1
|
|
||||||
po/stamp-it
|
|
||||||
po/POTFILES
|
|
||||||
po/Makefile.in.in
|
|
||||||
missing
|
|
||||||
m4/
|
|
||||||
ltmain.sh
|
|
||||||
libtool
|
|
||||||
libgtopconfig.h
|
|
||||||
libgtop.spec
|
|
||||||
libgtop-2.0.pc
|
|
||||||
lib/lib.c
|
|
||||||
lib/GTop-2.0.gir
|
|
||||||
lib/GTop-2.0.typelib
|
|
||||||
INSTALL
|
INSTALL
|
||||||
|
Makefile
|
||||||
|
Makevars.template
|
||||||
|
Rules-quot
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
autom4te.cache/
|
autom4te.cache/
|
||||||
|
compile
|
||||||
config.guess
|
config.guess
|
||||||
config.h
|
config.h
|
||||||
config.h.in
|
|
||||||
config.log
|
config.log
|
||||||
config.status
|
config.status
|
||||||
config.sub
|
config.sub
|
||||||
configure
|
configure
|
||||||
compile
|
|
||||||
depcomp
|
depcomp
|
||||||
doc/libgtop2.info
|
doc/libgtop2.info
|
||||||
doc/mdate-sh
|
doc/mdate-sh
|
||||||
@@ -79,3 +72,20 @@ examples/timings
|
|||||||
examples/wd
|
examples/wd
|
||||||
gtk-doc.make
|
gtk-doc.make
|
||||||
install-sh
|
install-sh
|
||||||
|
lib/GTop-2.0.gir
|
||||||
|
lib/GTop-2.0.typelib
|
||||||
|
lib/lib.c
|
||||||
|
libgtop-2.0.pc
|
||||||
|
libgtop.spec
|
||||||
|
libgtopconfig.h
|
||||||
|
libtool
|
||||||
|
ltmain.sh
|
||||||
|
m4/
|
||||||
|
missing
|
||||||
|
po/POTFILES
|
||||||
|
po/stamp-it
|
||||||
|
src/daemon/libgtop_daemon2
|
||||||
|
src/daemon/libgtop_server2
|
||||||
|
stamp-h1
|
||||||
|
stamp-po
|
||||||
|
tmp-*
|
||||||
|
22
NEWS
22
NEWS
@@ -1,3 +1,25 @@
|
|||||||
|
20 March 2017: Overview of changes in 2.36.0
|
||||||
|
================================================
|
||||||
|
|
||||||
|
* Version bumped
|
||||||
|
|
||||||
|
13 March 2017: Overview of changes in 2.35.92
|
||||||
|
================================================
|
||||||
|
|
||||||
|
* Better output format for arrays
|
||||||
|
|
||||||
|
13 February 2017: Overview of changes in 2.35.90
|
||||||
|
================================================
|
||||||
|
|
||||||
|
* Linux:
|
||||||
|
- Use dynamically allocated cpu buffer
|
||||||
|
- Do not cache getpagesize()
|
||||||
|
- Use faster g_ascii_isspace in tokenization
|
||||||
|
- Ignore paragraphs not describing a CPU/core
|
||||||
|
|
||||||
|
* Updated translations
|
||||||
|
* Added more gettext options
|
||||||
|
|
||||||
16 January 2017: Overview of changes in 2.34.2
|
16 January 2017: Overview of changes in 2.34.2
|
||||||
================================================
|
================================================
|
||||||
|
|
||||||
|
@@ -3,8 +3,8 @@ dnl Configure script for the Gnome library
|
|||||||
dnl
|
dnl
|
||||||
|
|
||||||
m4_define([libgtop_major_version], [2])
|
m4_define([libgtop_major_version], [2])
|
||||||
m4_define([libgtop_minor_version], [34])
|
m4_define([libgtop_minor_version], [36])
|
||||||
m4_define([libgtop_micro_version], [2])
|
m4_define([libgtop_micro_version], [0])
|
||||||
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
|
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
|
||||||
|
|
||||||
dnl increment if the interface has additions, changes, removals.
|
dnl increment if the interface has additions, changes, removals.
|
||||||
|
@@ -28,10 +28,11 @@
|
|||||||
(unsigned long) buf_offsetof(ARRAY), \
|
(unsigned long) buf_offsetof(ARRAY), \
|
||||||
(unsigned long) G_N_ELEMENTS(buf.ARRAY)); \
|
(unsigned long) G_N_ELEMENTS(buf.ARRAY)); \
|
||||||
for (i = 0; i < (SIZE); ++i) { \
|
for (i = 0; i < (SIZE); ++i) { \
|
||||||
printf(".%u = " FORMAT ", ", i, buf.ARRAY[i]); \
|
|
||||||
if (!buf.ARRAY[i] && i < (SIZE - 1) && !buf.ARRAY[i + 1]) { \
|
if (!buf.ARRAY[i] && i < (SIZE - 1) && !buf.ARRAY[i + 1]) { \
|
||||||
do { i++; } while (i < SIZE && !buf.ARRAY[i]); \
|
do { i++; } while (i < SIZE && !buf.ARRAY[i]); \
|
||||||
printf("..., "); \
|
printf("..., "); \
|
||||||
|
} else { \
|
||||||
|
printf(".%u = " FORMAT ", ", i, buf.ARRAY[i]); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
printf("}\n"); \
|
printf("}\n"); \
|
||||||
@@ -39,12 +40,12 @@
|
|||||||
|
|
||||||
#define PPRINT_ENTRY_ARRAY(ARRAY, SIZE) do { \
|
#define PPRINT_ENTRY_ARRAY(ARRAY, SIZE) do { \
|
||||||
size_t i; \
|
size_t i; \
|
||||||
printf("\t%4lu B %3lu " #ARRAY "[%lu] = { ", \
|
printf("\t%4lu B " #ARRAY "[%lu/%lu] = { \n", \
|
||||||
(unsigned long) sizeof buf->ARRAY, 0,\
|
(unsigned long) sizeof buf->ARRAY, (unsigned long)(SIZE), \
|
||||||
(unsigned long) G_N_ELEMENTS(buf->ARRAY)); \
|
(unsigned long) G_N_ELEMENTS(buf->ARRAY)); \
|
||||||
for(i = 0; i < SIZE; ++i) { \
|
for(i = 0; i < SIZE; ++i) { \
|
||||||
if (buf->ARRAY[i].values) { \
|
if (buf->ARRAY[i].values) { \
|
||||||
printf ("[ "); \
|
printf ("\t[ "); \
|
||||||
PPRINT_HASHTABLE(buf->ARRAY[i].values); \
|
PPRINT_HASHTABLE(buf->ARRAY[i].values); \
|
||||||
printf ("]\n"); \
|
printf ("]\n"); \
|
||||||
} \
|
} \
|
||||||
@@ -70,8 +71,8 @@ static void pprint_get_sysinfo(void)
|
|||||||
|
|
||||||
HEADER_PPRINT(glibtop_get_sysinfo);
|
HEADER_PPRINT(glibtop_get_sysinfo);
|
||||||
//PPRINT(flags, "%#llx");
|
//PPRINT(flags, "%#llx");
|
||||||
//PPRINT(ncpu, "%llu");
|
// PPRINT(ncpu, "%llu");
|
||||||
PPRINT_ENTRY_ARRAY(cpuinfo, 4);
|
PPRINT_ENTRY_ARRAY(cpuinfo, buf->ncpu);
|
||||||
FOOTER_PPRINT();
|
FOOTER_PPRINT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ char *
|
|||||||
skip_token (const char *p)
|
skip_token (const char *p)
|
||||||
{
|
{
|
||||||
p = next_token(p);
|
p = next_token(p);
|
||||||
while (*p && !isspace(*p)) p++;
|
while (*p && !g_ascii_isspace(*p)) p++;
|
||||||
p = next_token(p);
|
p = next_token(p);
|
||||||
return (char *)p;
|
return (char *)p;
|
||||||
}
|
}
|
||||||
@@ -178,20 +178,6 @@ get_boot_time(glibtop *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
|
||||||
get_page_size(void)
|
|
||||||
{
|
|
||||||
static size_t pagesize = 0;
|
|
||||||
|
|
||||||
if(G_UNLIKELY(!pagesize))
|
|
||||||
{
|
|
||||||
pagesize = getpagesize();
|
|
||||||
}
|
|
||||||
|
|
||||||
return pagesize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
check_cpu_line(glibtop *server, const char *line, unsigned i)
|
check_cpu_line(glibtop *server, const char *line, unsigned i)
|
||||||
|
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
|
|||||||
static inline char*
|
static inline char*
|
||||||
next_token(const char *p)
|
next_token(const char *p)
|
||||||
{
|
{
|
||||||
while (isspace(*p)) p++;
|
while (g_ascii_isspace(*p)) p++;
|
||||||
return (char*) p;
|
return (char*) p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,10 +122,6 @@ unsigned long
|
|||||||
get_boot_time(glibtop *server);
|
get_boot_time(glibtop *server);
|
||||||
|
|
||||||
|
|
||||||
size_t
|
|
||||||
get_page_size(void);
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
check_cpu_line(glibtop *server, const char *line, unsigned n);
|
check_cpu_line(glibtop *server, const char *line, unsigned n);
|
||||||
|
|
||||||
|
@@ -82,7 +82,7 @@ void
|
|||||||
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
|
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
|
||||||
{
|
{
|
||||||
char buffer [BUFSIZ], *p;
|
char buffer [BUFSIZ], *p;
|
||||||
const size_t pagesize = get_page_size();
|
const size_t pagesize = getpagesize();
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_mem));
|
memset (buf, 0, sizeof (glibtop_proc_mem));
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
|
|||||||
pid_t pid)
|
pid_t pid)
|
||||||
{
|
{
|
||||||
char buffer [BUFSIZ], *p;
|
char buffer [BUFSIZ], *p;
|
||||||
const size_t pagesize = get_page_size();
|
const size_t pagesize = getpagesize();
|
||||||
|
|
||||||
memset (buf, 0, sizeof (glibtop_proc_segment));
|
memset (buf, 0, sizeof (glibtop_proc_segment));
|
||||||
|
|
||||||
|
@@ -36,23 +36,34 @@ static glibtop_sysinfo sysinfo = { .flags = 0 };
|
|||||||
static void
|
static void
|
||||||
init_sysinfo (glibtop *server)
|
init_sysinfo (glibtop *server)
|
||||||
{
|
{
|
||||||
char buffer [65536];
|
char* buffer;
|
||||||
gchar ** processors;
|
gchar ** processors;
|
||||||
|
|
||||||
if(G_LIKELY(sysinfo.flags)) return;
|
if(G_LIKELY(sysinfo.flags)) return;
|
||||||
|
|
||||||
file_to_buffer(server, buffer, sizeof buffer, FILENAME);
|
if (!g_file_get_contents(FILENAME, &buffer, NULL, NULL)) {
|
||||||
|
glibtop_error_io_r(server, "g_file_get_contents(%s)", FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/* cpuinfo records are seperated by a blank line */
|
/* cpuinfo records are seperated by a blank line */
|
||||||
processors = g_strsplit(buffer, "\n\n", 0);
|
processors = g_strsplit(buffer, "\n\n", 0);
|
||||||
|
|
||||||
for(sysinfo.ncpu = 0;
|
g_free(buffer);
|
||||||
sysinfo.ncpu < GLIBTOP_NCPU && processors[sysinfo.ncpu] && *processors[sysinfo.ncpu];
|
|
||||||
sysinfo.ncpu++) {
|
sysinfo.ncpu = 0;
|
||||||
|
for (char** this_proc = &processors[0]; *this_proc && **this_proc; this_proc++) {
|
||||||
|
|
||||||
|
if (sysinfo.ncpu >= GLIBTOP_NCPU) {
|
||||||
|
glibtop_warn_r(server, "Cannot deal with more than %d CPUs", GLIBTOP_NCPU);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
gchar **parts, **p;
|
gchar **parts, **p;
|
||||||
if (g_strrstr (processors[sysinfo.ncpu], "processor" ) == NULL)
|
if (g_strrstr (*this_proc, "processor" ) == NULL) {
|
||||||
|
/* skip unknown paragraph */
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
glibtop_entry * const cpuinfo = &sysinfo.cpuinfo[sysinfo.ncpu];
|
glibtop_entry * const cpuinfo = &sysinfo.cpuinfo[sysinfo.ncpu];
|
||||||
|
|
||||||
cpuinfo->labels = g_ptr_array_new ();
|
cpuinfo->labels = g_ptr_array_new ();
|
||||||
@@ -64,7 +75,7 @@ init_sysinfo (glibtop *server)
|
|||||||
g_free, g_free);
|
g_free, g_free);
|
||||||
|
|
||||||
/* "<key> : <value>" */
|
/* "<key> : <value>" */
|
||||||
parts = g_strsplit_set(processors[sysinfo.ncpu], ":\n", 0);
|
parts = g_strsplit_set(*this_proc, ":\n", 0);
|
||||||
|
|
||||||
for(p = parts; *p && *(p+1); p += 2) {
|
for(p = parts; *p && *(p+1); p += 2) {
|
||||||
|
|
||||||
@@ -85,6 +96,7 @@ init_sysinfo (glibtop *server)
|
|||||||
|
|
||||||
g_free(parts);
|
g_free(parts);
|
||||||
|
|
||||||
|
sysinfo.ncpu++;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_strfreev(processors);
|
g_strfreev(processors);
|
||||||
|
Reference in New Issue
Block a user