Skip to content

Instantly share code, notes, and snippets.

View ktsaou's full-sized avatar

Costa Tsaousis ktsaou

View GitHub Profile
@ktsaou
ktsaou / netdata-ioc-check-24401.sh
Created October 23, 2026 12:12
Netdata #24401 indicator-of-compromise check (read-only): access log, go.d ${cmd:} secret executions, injected dyncfg jobs, netdata-user persistence
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Read-only indicator-of-compromise check for netdata/netdata#24401
# (Function payload injection -> go.d dyncfg `test` -> ${cmd:...} secret -> command execution).
#
# The script changes nothing. Run it as root for full coverage (journal namespace, crontabs, other users' files).
#
# Usage: netdata-ioc-check-24401.sh [--since "YYYY-MM-DD"] [--user netdata] [--prefix /opt/netdata]
# [--access-log 'GLOB'] [--max-rows N] [--quiet]
@ktsaou
ktsaou / collect-jetson-evidence.sh
Last active October 11, 2026 13:58
Jetson evidence capture for Netdata monitoring (v1.1.1; no Netdata required)
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Read-only provider evidence; no installation, workload or service management.
set +e +u
set -o pipefail
VERSION=1.1.1
exec 3>&2
usage() {
@ktsaou
ktsaou / arithmetic_probe.py
Created September 15, 2026 09:12
Standalone arithmetic API probe: compare reasoning, temperature, concurrency and streaming across Chat, Responses and Messages APIs
#!/usr/bin/env python3
"""Repeat one arithmetic question against OpenAI/Anthropic-compatible APIs.
Python 3.10+; standard library only. No pip install needed.
Example (600 requests: 100 per API/streaming combination):
python3 arithmetic_probe.py --base-url http://localhost:8000/v1 \
--model YOUR_MODEL --temperature 1.0 --reasoning none \
--concurrency 32 --tries 100 --api all --stream both --output results.json
--tries is PER API/streaming mode; all + both means six times that number.
@ktsaou
ktsaou / proc-net-tcp-test.c
Created October 17, 2024 17:46
Test the speed of reading /proc/net/tcp vs libmnl
/*
Save as: proc-net-tcp-test.c
Compile with:
gcc -O2 -o proc-net-tcp-test proc-net-tcp-test.c -lmnl
Run with:
@ktsaou
ktsaou / systemd-journal-self-signed-certs.sh
Last active May 11, 2025 21:36
systemd-journal-remote/upload self-signed certificates management script
#!/usr/bin/env bash
# The directory to save the generated certificates (and everything about this certificate authority).
# This is only used on the node generating the certificates (usually on the journals server).
DIR="/etc/ssl/systemd-journal-remote"
# The journals centralization server name (the CN of the server certificate).
SERVER="server-hostname"
# All the DNS names or IPs this server is reachable at (the certificate will include them).
@ktsaou
ktsaou / JulyL.c
Last active January 9, 2023 21:51
An implementation of JudyL with fewer memory allocations, when items are mainly appended to the array
// SPDX-License-Identifier: GPL-3.0-or-later
#include "july.h"
#define JULYL_MIN_ENTRIES 10
struct JulyL_item {
Word_t index;
void *value;
};
@ktsaou
ktsaou / spinlock.c
Last active December 2, 2022 23:41
spinlock vs mutex benchmark
//
// compile with:
// gcc -O2 -o spinlock spinlock.c -lpthread && ./spinlock
//
// verification and spinlock stats can be enabled with this:
// gcc -O2 -DSPINLOCK_VERIFY_AND_STATS=1 -o spinlock spinlock.c && ./spinlock
#define _GNU_SOURCE
#define __USE_GNU
(gdb) taas bt
Thread 463 (Thread 0x7fd5d4952700 (LWP 272185) "DBENGINE"):
#0 futex_abstimed_wait (private=0, abstime=0x0, clockid=0, expected=3, futex_word=<optimized out>) at ../sysdeps/nptl/futex-internal.h:287
#1 __pthread_rwlock_rdlock_full (abstime=0x0, clockid=0, rwlock=0x5615817057c8) at pthread_rwlock_common.c:460
#2 __GI___pthread_rwlock_rdlock (rwlock=0x5615817057c8) at pthread_rwlock_rdlock.c:27
#3 0x00007fd6d2e746e9 in uv_rwlock_rdlock () from target:/lib/x86_64-linux-gnu/libuv.so.1
#4 0x000056157bd0b1a6 in get_descriptor (page_index=0x5615817057a0, start_time_s=1668212224) at database/engine/rrdengine.c:763
#5 0x000056157bd0b24d in try_to_remove_v2_descriptor (ctx=0x56157c34fcc0 <multidb_ctx_storage_tier0>, page_index=0x5615817057a0, start_time_s=1668212224, expired=false) at database/engine/rrdengine.c:772
#6 0x000056157bd0b4b8 in check_journal_file (journalfile=0x5615829dda10) at database/engine/rrdengine.c:830
@ktsaou
ktsaou / stress-with-curl.sh
Last active August 1, 2024 09:23
Command line web server stress testing tool, implemented with curl and real-time statistics to netdata
#!/usr/bin/env bash
# Stress With Curl
# Run multiple curl worker to stress a web server
# Real-time statistics at a Netdata server
#
# To use, you need:
# - curl
# - The nc command from the openbsd-netcat package
# - Netdata
@ktsaou
ktsaou / gist:36b7ae1680a909a88642c5d75e9248fb
Created October 27, 2021 11:12
gvpe static compilation log
$ ./compile-gvpe/build-gvpe-linux-static.sh
ME : build-gvpe-linux-static.sh
DIR : /home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe
/home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe > sudo docker run -a stdin -a stdout -a stderr -i -t -v /home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe:/tmp/mapped:rw alpine:edge /bin/sh /tmp/mapped/build-gvpe-linux-static.sh inside-container
/ > apk update
fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v3.15.0_alpha20210804-4905-ga7f55994b5 [https://dl-cdn.alpinelinux.org/alpine/edge/main]