Trying to use the libgtop examples
Hello,
I'm working in a monitoring system for a database application. I need to measure usage of CPU, network, disk, partitions, memory, etc. I cannot handle the overhead of parsing this information from proc, so I found the libgtop. I am currently using the libgtop-2.28.1 version. After ./configure, make and make install it, I tried a small program in Eclipse to start learning the basics. I copied the procarg.c example and build it, having problems.
Code:
Code:
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <glib-2.0/glib.h>
#include <libgtop-2.0/glibtop.h>
#include <libgtop-2.0/glibtop/procargs.h>
#include <stdlib.h>
#include <unistd.h>
static void show_args(pid_t pid, unsigned max_len)
{
glibtop_proc_args buf;
char ** const pargv = glibtop_get_proc_argv(&buf, pid, max_len);
char **parg = pargv;
printf("<%ld>\t", (long)pid);
while(*parg)
{
printf("\"%s\" ", *parg);
parg++;
}
putchar('\n');
g_strfreev(pargv);
}
int main(int argc, char **argv)
{
glibtop_init();
show_args(getpid(), 0);
show_args(getpid(), 15);
while(*++argv)
{
pid_t pid = strtol(*argv, NULL, 10);
show_args(pid, 0);
show_args(pid, 15);
}
glibtop_close();
return 0;
}
Errors:
Code:
**** Build of configuration Debug for project GTopTest ****
make all
Building file: ../src/GTopTest.cpp
Invoking: GCC C++ Compiler
g++ -Igtop -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/GTopTest.d" -MT"src/GTopTest.d" -o"src/GTopTest.o" "../src/GTopTest.cpp"
In file included from ../src/GTopTest.cpp:13:
/usr/local/include/libgtop-2.0/glibtop.h:29: error: expected constructor, destructor, or type conversion before ‘typedef’
/usr/local/include/libgtop-2.0/glibtop.h:117: error: ‘glibtop_sysdeps’ does not name a type
/usr/local/include/libgtop-2.0/glibtop.h:118: error: ‘glibtop_sysdeps’ does not name a type
/usr/local/include/libgtop-2.0/glibtop.h:119: error: ‘pid_t’ does not name a type
/usr/local/include/libgtop-2.0/glibtop.h:124: error: expected initializer before ‘*’ token
/usr/local/include/libgtop-2.0/glibtop.h:128: error: expected constructor, destructor, or type conversion before ‘*’ token
/usr/local/include/libgtop-2.0/glibtop.h:131: error: expected constructor, destructor, or type conversion before ‘*’ token
/usr/local/include/libgtop-2.0/glibtop.h:136: error: expected constructor, destructor, or type conversion before ‘*’ token
/usr/local/include/libgtop-2.0/glibtop.h:141: error: ‘G_END_DECLS’ does not name a type
In file included from ../src/GTopTest.cpp:14:
/usr/local/include/libgtop-2.0/glibtop/procargs.h:38: error: ‘guint64’ does not name a type
/usr/local/include/libgtop-2.0/glibtop/procargs.h:39: error: ‘guint64’ does not name a type
/usr/local/include/libgtop-2.0/glibtop/procargs.h:44: error: ‘glibtop’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:44: error: ‘server’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:44: error: ‘glibtop_proc_args’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:44: error: ‘buf’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:45: error: ‘pid_t’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:45: error: expected primary-expression before ‘unsigned’
/usr/local/include/libgtop-2.0/glibtop/procargs.h:45: error: initializer expression list treated as compound expression
/usr/local/include/libgtop-2.0/glibtop/procargs.h:48: error: ‘glibtop_proc_args’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:48: error: ‘buf’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:48: error: ‘pid_t’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:48: error: expected primary-expression before ‘unsigned’
/usr/local/include/libgtop-2.0/glibtop/procargs.h:48: error: initializer expression list treated as compound expression
/usr/local/include/libgtop-2.0/glibtop/procargs.h:65: error: variable or field ‘_glibtop_init_proc_args_s’ declared void
/usr/local/include/libgtop-2.0/glibtop/procargs.h:65: error: ‘glibtop’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:65: error: ‘server’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:68: error: ‘glibtop’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:68: error: ‘server’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:68: error: ‘glibtop_proc_args’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:68: error: ‘buf’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:69: error: ‘pid_t’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:69: error: expected primary-expression before ‘unsigned’
/usr/local/include/libgtop-2.0/glibtop/procargs.h:69: error: initializer expression list treated as compound expression
/usr/local/include/libgtop-2.0/glibtop/procargs.h:79: error: ‘glibtop’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:79: error: ‘server’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:79: error: ‘glibtop_proc_args’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:79: error: ‘buf’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:80: error: ‘pid_t’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:80: error: expected primary-expression before ‘unsigned’
/usr/local/include/libgtop-2.0/glibtop/procargs.h:80: error: initializer expression list treated as compound expression
/usr/local/include/libgtop-2.0/glibtop/procargs.h:83: error: ‘glibtop_proc_args’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:83: error: ‘buf’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:83: error: ‘pid_t’ was not declared in this scope
/usr/local/include/libgtop-2.0/glibtop/procargs.h:83: error: expected primary-expression before ‘unsigned’
/usr/local/include/libgtop-2.0/glibtop/procargs.h:83: error: initializer expression list treated as compound expression
In file included from ../src/GTopTest.cpp:16:
/usr/include/unistd.h:28: error: expected constructor, destructor, or type conversion before ‘extern’
make: *** src/GTopTest.o Error 1
This is my first post here in this forum. I tried to be very specific to helo you to help me If I disagree with any rule just tell me, I really need to solve this and didn't finish reading the FAQ yet.
Thanks in advance,
Pedro Dusso