Update project

This commit is contained in:
2024-07-10 21:20:16 +02:00
parent dcd82624e2
commit 63c1d4cc5d
17 changed files with 475 additions and 258 deletions
Executable
BIN
View File
Binary file not shown.
+44
View File
@@ -0,0 +1,44 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "ic.h"
int main(int argc, char *argv[], char *argp[]){
char buf[300];
char host[64];
char orgID[64];
char token[128];
int stats = 0;
if (argc < 3){
printf("Usage: ./main <host> <orgID> <token>");
return 0;
}
printf("%s %s %s\n", argv[1], argv[2], argv[3]);
memcpy(host, argv[1], 64);
memcpy(orgID, argv[2], 64);
memcpy(token, argv[3], 128);
printf("Host: %s\n", host);
printf("orgID: %s\n", orgID);
printf("Token: %s\n", token);
ic_influx_database(host, 8086, "tcp_metrics");
ic_influx_orgID(orgID);
ic_influx_token(token);
ic_debug(2);
while(1){
snprintf(buf, 300, "host=%s", host);
ic_tags(buf);
ic_measure("tcp_reset");
stats += 1;
ic_measureend();
ic_push();
sleep(30);
}
return 0;
}
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env python3
from bcc import BPF
with open("tp_tcp.c", 'r') as f:
data = f.read()
b = BPF(text=data)
#b = BPF(src_file="tp_tcp_py.c")
Executable
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/bash
curl -i -X POST "http://192.168.1.68:8086/api/v2/query?bucket=tcp_metrics&orgID=f32d493484526abc" \
--header "Authorization: Token $1" \
--header "Accept: application/csv" \
--header "Content-Type: application/vnd.flux" \
--data 'from(bucket: "tcp_metrics")|> range(start: -1m)|> filter(fn: (r) => r["_measurement"] == "tcp_reset")|> filter(fn: (r) => r["host"] == "127.0.0.1")|> filter(fn: (r) => r["_field"] == "127.0.0.1")|> last()'
# --data 'from(bucket: "tcp_metrics")
# |> range(start: -5m)
# |> filter(fn: (r) => r["_measurement"] == "tcp_reset")
# |> filter(fn: (r) => r["host"] == "127.0.0.1")
# |> filter(fn: (r) => r["_field"] == "127.0.0.1")
# |> yield(name: "mean")'
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/bash
#curl -i -X POST 'http://localhost:8086/api/v2/write?bucket=tcp_metrics&orgID=392fcb79fc296d8e&rp&precision=ns' \
curl -i -X POST "http://localhost:8086/api/v2/write?bucket=tcp_metrics&orgID=392fcb79fc296d8e" \
--header "Authorization: Token $1" \
--data "cpu_load_short,host=server01,region=us-west value=1"
# --data-raw 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'