Skip to content

Instantly share code, notes, and snippets.

@mateobur
mateobur / webhook_receiver.py
Created December 12, 2017 15:58
Prometheus alerts to Sysdig Monitor integration webhook
from flask import Flask, request
from sdcclient import SdcClient
import json, os
app = Flask(__name__)
sdclient = SdcClient(os.environ['SYSDIG_API_KEY'])
@app.route('/', methods=['POST'])
def handle_alert():
@mateobur
mateobur / generate-secure-rules.py
Last active March 28, 2019 12:21
Kube-system Kubernetes security with Sysdig Secure (Autogenerate Python script)
#!/usr/bin/python
import yaml
import sys
import collections
from collections import OrderedDict as OD
def dict_representer(dumper, data):
return dumper.represent_dict(data.iteritems())
@mateobur
mateobur / input_rules.yaml
Last active February 7, 2019 07:55
Kube-system Kubernetes security with Sysdig Secure
- podname: etcd
proc: [etcd]
write_dir: [/var/lib/etcd]
outbound_proc: [etcd]
listen_proc: [etcd]
- podname: kube_apiserver
proc: [kube-apiserver]
write_dir: false
outbound_proc: [kube-apiserver]
@mateobur
mateobur / pythonprometheus.py
Created October 20, 2017 20:14
Prometheus metric sample in python
from prometheus_client import start_http_server, Histogram
import random
import time
function_exec = Histogram('function_exec_time',
'Time spent processing a function',
['func_name'])
def func1():
var express = require('express'),
async = require('async'),
pg = require("pg"),
cookieParser = require('cookie-parser'),
bodyParser = require('body-parser'),
methodOverride = require('method-override'),
app = express(),
server = require('http').Server(app),
io = require('socket.io')(server);
@mateobur
mateobur / SysdigMonitorKubernetesScheduler.py
Last active January 21, 2022 13:12
Sysdig Monitor Kubernetes Scheduler
#!/usr/bin/env python
import time
import random
import json
from kubernetes import client, config, watch
from sdcclient import SdcClient
config.load_kube_config()
@mateobur
mateobur / sysdigsched.py
Created September 15, 2017 15:40
python sysdig scheduler
#!/usr/bin/env python
import time
import random
import json
from kubernetes import client, config, watch
from sdcclient import SdcClient
@mateobur
mateobur / Sysdig GDB ioncube
Created August 31, 2017 21:58
Sysdig GDB ioncube
(gdb) bt
#0 0x00007f842ea770ac in __brk (addr=0x55a5681df000) at ../sysdeps/unix/sysv/linux/x86_64/brk.c:31
#1 0x00007f842ea77146 in __GI___sbrk (increment=135168) at sbrk.c:53
#2 0x00007f842ea147a9 in __GI___default_morecore (increment=<optimized out>) at morecore.c:47
#3 0x00007f842ea10954 in sysmalloc (av=0x7f842ed3b620 <main_arena>, nb=4112) at malloc.c:2462
#4 _int_malloc (av=0x7f842ed3b620 <main_arena>, bytes=4096) at malloc.c:3800
#5 0x00007f842ea12020 in __GI___libc_malloc (bytes=4096) at malloc.c:2891
#6 0x00007f84300bf19b in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#7 0x00007f84300dc7ed in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
#8 0x00007f84300d4a39 in ?? () from /lib/x86_64-linux-gnu/libpcre.so.3
@mateobur
mateobur / Sysdig capture php fpm
Created August 31, 2017 21:40
Sysdig capture php fpm
1409831 20:49:54.464412513 0 s1_php_1 (3257e0a01572) php-fpm (3532:21) > brk addr=556341D6F000
1409832 20:49:54.464416248 0 s1_php_1 (3257e0a01572) php-fpm (3532:21) < brk res=556341D6F000 vm_size=767128 vm_rss=394508 vm_swap=22048
1409855 20:49:54.464470456 0 s1_php_1 (3257e0a01572) php-fpm (3532:21) > mmap addr=0 length=264 prot=1(PROT_READ) flags=1(MAP_SHARED) fd=9(<f>/var/www/html/wp-content/plugins/bj-lazy-load/inc/compat/opera-mini.php) offset=0
1409856 20:49:54.464473864 0 s1_php_1 (3257e0a01572) php-fpm (3532:21) < mmap res=7FF9E2A3D000 vm_size=767132 vm_rss=394508 vm_swap=22048
1409891 20:49:54.464538246 0 s1_php_1 (3257e0a01572) php-fpm (3532:21) > mmap addr=0 length=245 prot=1(PROT_READ) flags=1(MAP_SHARED) fd=9(<f>/var/www/html/wp-content/plugins/bj-lazy-load/inc/compat/wp-print.php) offset=0
1409892 20:49:54.464540660 0 s1_php_1 (3257e0a01572) php-fpm (3532:21) < mmap res=7FF9E2A3D000 vm_size=767132 vm_rss=394512 vm_swap=22048
1409925 20:49:54.464585580 0 s1_php_1 (3257e0a01572) php-fpm (3532:21)
@mateobur
mateobur / Sysdig capture
Created August 31, 2017 21:33
Sysdig capture 404 errors
----- Write 58B to pipe:[3992672] (php-fpm)
127.0.0.1 - 19/Aug/2017:22:23:12 +0000 "GET /status" 404
------ Write 168B to 127.0.0.1:35264->127.0.0.1:9000 (php-fpm)
Primary script unknown
kStatus: 404 Not Found
X-Powered-By: PHP
------ Read 8B from 127.0.0.1:35264->127.0.0.1:9000 (php-fpm)
------ Read 8B from 127.0.0.1:35264->127.0.0.1:9000 (php-fpm)
------ Read 8B from 127.0.0.1:35266->127.0.0.1:9000 (php-fpm)