diff --git a/MagicEyes/src/backend/hypervisor/kvm_watcher/src/kvm_watcher.c b/MagicEyes/src/backend/hypervisor/kvm_watcher/src/kvm_watcher.c index 8f9a559dd..2fea062b7 100644 --- a/MagicEyes/src/backend/hypervisor/kvm_watcher/src/kvm_watcher.c +++ b/MagicEyes/src/backend/hypervisor/kvm_watcher/src/kvm_watcher.c @@ -31,7 +31,6 @@ #include "trace_helpers.h" #include "uprobe_helpers.h" #include "hypervisor/kvm_watcher/kvm_watcher.skel.h" - //可视化调整输出格式 int is_first = 1; // 创建并打开临时文件 @@ -563,10 +562,15 @@ static int handle_event(void *ctx, void *data, size_t data_sz) { break; } case CONTAINER_SYSCALL: { - printf("%-8u %-22s %-10lld %-10lld %-16s\n", e->syscall_data.pid, + if(env.show){ + printf("%-10lld %-10lld\n",e->syscall_data.delay,e->syscall_data.syscall_id); + break; + }else{ + printf("%-8u %-22s %-10lld %-10lld %-16s\n", e->syscall_data.pid, e->syscall_data.container_id, e->syscall_data.delay, e->syscall_data.syscall_id, e->syscall_data.comm); - break; + break; + } } case HALT_POLL: { // 使用 e->halt_poll_data 访问 HALT_POLL 特有成员 @@ -779,8 +783,12 @@ static int print_event_head(struct env *env) { "VAILD?"); break; case CONTAINER_SYSCALL: - printf("%-8s %-22s %-9s %10s %-16s\n", "PID", "CONTAINER_ID", - "DELAY(us)", "SYSCALLID", "COMM"); + if(env->show){ + printf("%-9s %10s\n", "DELAY(us)","SYSCALLID"); + }else{ + printf("%-8s %-22s %-9s %10s %-16s\n", "PID", "CONTAINER_ID", + "DELAY(us)", "SYSCALLID", "COMM"); + } break; case EXIT: //可视化调整输出格式 @@ -1242,7 +1250,7 @@ void print_map_and_check_error(int (*print_func)(struct kvm_watcher_bpf *), void print_logo() { char *logo = LOGO_STRING; char command[512]; - sprintf(command, "echo \"%s\" | /usr/games/lolcat", logo); + sprintf(command, "bash -c 'echo \"%s\" | /usr/games/lolcat'", logo); system(command); } @@ -1316,9 +1324,8 @@ int main(int argc, char **argv) { fprintf(stderr, "Please specify an option using %s.\n", OPTIONS_LIST); goto cleanup; } - err = ring_buffer__poll(rb, RING_BUFFER_TIMEOUT_MS /* timeout, ms */); while (!exiting) { - //err = ring_buffer__poll(rb, RING_BUFFER_TIMEOUT_MS /* timeout, ms */); + err = ring_buffer__poll(rb, RING_BUFFER_TIMEOUT_MS /* timeout, ms */); if (env.execute_hypercall) { print_map_and_check_error(print_hc_map, skel, "hypercall", err); } diff --git a/MagicEyes/src/visualization/vscode_ext/panels/kvm_watcher.json b/MagicEyes/src/visualization/vscode_ext/panels/kvm_watcher.json index 94128257e..7e67a29fa 100644 --- a/MagicEyes/src/visualization/vscode_ext/panels/kvm_watcher.json +++ b/MagicEyes/src/visualization/vscode_ext/panels/kvm_watcher.json @@ -78,10 +78,94 @@ }, "gridPos": { "h": 8, - "w": 10, + "w": 12, "x": 0, "y": 0 }, + "id": 24, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "CzHV6L_Ik" + }, + "exemplar": true, + "expr": "bpf_metrics{bpf_out_data=\"DELAY(us)\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "container_syscall_delay", + "type": "timeseries" + }, + { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 10, + "x": 0, + "y": 8 + }, "id": 10, "options": { "legend": { @@ -164,7 +248,7 @@ "h": 8, "w": 11, "x": 10, - "y": 0 + "y": 8 }, "id": 8, "options": { @@ -233,7 +317,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -248,7 +333,7 @@ "h": 7, "w": 10, "x": 0, - "y": 8 + "y": 16 }, "id": 6, "libraryPanel": { @@ -354,7 +439,7 @@ "h": 7, "w": 11, "x": 10, - "y": 8 + "y": 16 }, "id": 4, "options": { @@ -446,7 +531,7 @@ "h": 7, "w": 10, "x": 0, - "y": 15 + "y": 23 }, "id": 12, "options": { @@ -530,7 +615,7 @@ "h": 7, "w": 11, "x": 10, - "y": 15 + "y": 23 }, "id": 14, "options": { @@ -614,7 +699,7 @@ "h": 7, "w": 10, "x": 0, - "y": 22 + "y": 30 }, "id": 16, "options": { @@ -698,7 +783,7 @@ "h": 7, "w": 11, "x": 10, - "y": 22 + "y": 30 }, "id": 18, "options": { @@ -782,7 +867,7 @@ "h": 7, "w": 10, "x": 0, - "y": 29 + "y": 37 }, "id": 20, "options": { @@ -867,7 +952,7 @@ "h": 7, "w": 11, "x": 10, - "y": 29 + "y": 37 }, "id": 22, "options": { diff --git a/eBPF_Supermarket/kvm_watcher/src/kvm_watcher.c b/eBPF_Supermarket/kvm_watcher/src/kvm_watcher.c index 928a422da..b349e7ee7 100644 --- a/eBPF_Supermarket/kvm_watcher/src/kvm_watcher.c +++ b/eBPF_Supermarket/kvm_watcher/src/kvm_watcher.c @@ -563,10 +563,15 @@ static int handle_event(void *ctx, void *data, size_t data_sz) { break; } case CONTAINER_SYSCALL: { - printf("%-8u %-22s %-10lld %-10lld %-16s\n", e->syscall_data.pid, + if(env.show){ + printf("%-10lld %-10lld\n",e->syscall_data.delay,e->syscall_data.syscall_id); + break; + }else{ + printf("%-8u %-22s %-10lld %-10lld %-16s\n", e->syscall_data.pid, e->syscall_data.container_id, e->syscall_data.delay, e->syscall_data.syscall_id, e->syscall_data.comm); - break; + break; + } } case HALT_POLL: { // 使用 e->halt_poll_data 访问 HALT_POLL 特有成员 @@ -779,8 +784,12 @@ static int print_event_head(struct env *env) { "VAILD?"); break; case CONTAINER_SYSCALL: - printf("%-8s %-22s %-9s %10s %-16s\n", "PID", "CONTAINER_ID", - "DELAY(us)", "SYSCALLID", "COMM"); + if(env->show){ + printf("%-9s %10s\n", "DELAY(us)","SYSCALLID"); + }else{ + printf("%-8s %-22s %-9s %10s %-16s\n", "PID", "CONTAINER_ID", + "DELAY(us)", "SYSCALLID", "COMM"); + } break; case EXIT: //可视化调整输出格式 @@ -1242,7 +1251,7 @@ void print_map_and_check_error(int (*print_func)(struct kvm_watcher_bpf *), void print_logo() { char *logo = LOGO_STRING; char command[512]; - sprintf(command, "echo \"%s\" | /usr/games/lolcat", logo); + sprintf(command, "bash -c 'echo \"%s\" | /usr/games/lolcat'", logo); system(command); }