美文网首页
libnethogs c调用

libnethogs c调用

作者: 霡霂976447044 | 来源:发表于2019-09-29 08:39 被阅读0次
#include <stdio.h>
#include "libnethogs.h"
#include "memory.h"
#include <stdlib.h>
#include <unistd.h>


void callback(int action,
               NethogsMonitorRecord const *data) {
    if (action == NETHOGS_APP_ACTION_REMOVE || data->sent_bytes || data->recv_bytes) {

        printf("name: %s\n, ", data->name);
        printf("devname: %s\n", data->device_name),
        printf("send: %f, %ld\n", data->sent_kbs, data->sent_bytes);
        printf("recv: %f, %ld\n", data->recv_kbs, data->recv_bytes);
        printf("recoid: %d\n", data->record_id);
        printf("----------------------------------\n");
    }
}

int main() {
    struct NethogsMonitorRecord record;
    NethogsMonitorCallback cb  = callback;
//    int a = nethogsmonitor_loop(cb, NULL);
    nethogsmonitor_loop_devices(cb, NULL, 0, NULL, false);
//    printf("%d\n", a);

    return 0;
}
cmake_minimum_required(VERSION 3.14)
project(test_call_so C)

set(CMAKE_C_STANDARD 99)
link_directories(/home/baloneo/CLionProjects/test_call_so)


link_libraries(nethogs)
add_executable(test_call_so main.c libnethogs.h)

相关文章

网友评论

      本文标题:libnethogs c调用

      本文链接:https://www.haomeiwen.com/subject/ogpdectx.html