Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I'm trying to find a way to make some kind of monitor in C. I found this but i get : error: config.h: No such file or directory error: ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    5

    Cpu And Memory Monitoring

    Hi,
    I'm trying to find a way to make some kind of monitor in C.
    I found this but i get :
    error: config.h: No such file or directory
    error: glibtop.h: No such file or directory
    error: glibtop/error.h: No such file or directory
    error: glibtop/cpu.h: No such file or directory
    error: glibtop_suid.h: No such file or directory

    Can anyone help me with this?
    Or to give me another idea like how to get info from /proc/cpuinfo with C ?



    #include <stdio.h>
    #include <glibtop.h>
    #include <glibtop/cpu.h>
    #include <glibtop/mem.h>
    #include <glibtop/proclist.h>



    int main(){

    glibtop_init();

    glibtop_cpu cpu;
    glibtop_mem memory;
    glibtop_proclist proclist;

    glibtop_get_cpu (&cpu);
    glibtop_get_mem(&memory);


    printf("CPU TYPE INFORMATIONS \n\n"
    "Cpu Total : %ld \n"
    "Cpu User : %ld \n"
    "Cpu Nice : %ld \n"
    "Cpu Sys : %ld \n"
    "Cpu Idle : %ld \n"
    "Cpu Frequences : %ld \n",
    (unsigned long)cpu.total,
    (unsigned long)cpu.user,
    (unsigned long)cpu.nice,
    (unsigned long)cpu.sys,
    (unsigned long)cpu.idle,
    (unsigned long)cpu.frequency);

    printf("\nMEMORY USING\n\n"
    "Memory Total : %ld MB\n"
    "Memory Used : %ld MB\n"
    "Memory Free : %ld MB\n"
    "Memory Buffered : %ld MB\n"
    "Memory Cached : %ld MB\n"
    "Memory user : %ld MB\n"
    "Memory Locked : %ld MB\n",
    (unsigned long)memory.total/(1024*1024),
    (unsigned long)memory.used/(1024*1024),
    (unsigned long)memory.free/(1024*1024),
    (unsigned long)memory.shared/(1024*1024),
    (unsigned long)memory.buffer/(1024*1024),
    (unsigned long)memory.cached/(1024*1024),
    (unsigned long)memory.user/(1024*1024),
    (unsigned long)memory.locked/(1024*1024));

    int which,arg;
    glibtop_get_proclist(&proclist,which,arg);
    printf("%ld\n%ld\n%ld\n",
    (unsigned long)proclist.number,
    (unsigned long)proclist.total,
    (unsigned long)proclist.size);
    return 0;
    }

  2. #2
    Just Joined!
    Join Date
    Nov 2007
    Posts
    2
    The header files are not available in your default include path, just locate the files and provide the path,
    locate <filename>
    OR
    find /usr/include/ -name "filename"

    and provide this path in compilation
    like
    gcc test.c -o test -I/usr/include/libgtop-2.0/

    Hope this solves ur problem.

    Regards,
    Amit Sahrawat

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...