Skip to content

Instantly share code, notes, and snippets.

# define BPF program
bpf_text = """
#include <uapi/linux/ptrace.h>
#include <net/sock.h>
#include <bcc/proto.h>
BPF_HASH(ipv4_send_bytes, u32);
int kprobe__tcp_sendmsg(struct pt_regs *ctx, struct sock *sk,
{
"sources": [
"AWS::eu-central-1a",
"AWS::sa-east-1a",
"GCP::us-west1-a",
"GCP::asia-northeast1-a",
"AWS::us-west-2a",
"GCP::asia-east1-a",
"AWS::ap-northeast-1a",
"GCP::us-east4-a",
# Tested with curl 7.47.0 (x86_64-pc-linux-gnu)
curl -H "CC-LATENCY-API-KEY: 985668cf-cfa0-49e9-b087-83f1743fe5c7" \
https://api.cclatency.com/sources
# Assumes that you have requests installed
# Tested on python 2.7.12
import requests
req = requests.request(
'GET',
'https://api.cclatency.com/sources',
headers = {
'CC-LATENCY-API-KEY': '985668cf-cfa0-49e9-b087-83f1743fe5c7'
})
print(req.json())
// Assumes that you have both request and request-promised installed.
// Tested on node.js v7.5.0
const rp = require('request-promise');
const opts = {
uri: 'https://api.cclatency.com/sources',
headers: {
'CC-LATENCY-API-KEY': '985668cf-cfa0-49e9-b087-83f1743fe5c7'
}
};
<html>
<body>
<script>
var ws = new WebSocket('wss://api.cclatency.com');
ws.onopen = function(event) {
ws.send(JSON.stringify({
"action": "register",
"key": "f2afa502b8c08ac87748527f022303a5",
"apiKey": "985668cf-cfa0-49e9-b087-83f1743fe5c7"
}));
# Assumes that you have websocket-client installed
# Tested on python 2.7.12
import websocket
import json
def on_message(ws, message):
print message
def on_open(ws):
print 'opened'
// Assumes that you have websockets installed.
// Tested on node.js v7.5.0
const ws = new WebSocketClient();
ws.on('connect', (connection) => {
connection.send(JSON.stringify({
"action": "register",
"key": "f2afa502b8c08ac87748527f022303a5",
"apiKey": "985668cf-cfa0-49e9-b087-83f1743fe5c7"
}));
# Tested with curl 7.47.0 (x86_64-pc-linux-gnu)
curl -H "CC-LATENCY-API-KEY: <Your Private API Key>" \
-H "Content-Type: application/json" \
-X POST \
-d '{"source": "GCP::us-east4-a", "target": "8.8.8.8", "interval": 1000, "packetType": "ping" }' \
https://api.cclatency.com/stream
# Assumes that you have requests installed
# Tested on python 2.7.12
import requests
req = requests.post(
'https://api.cclatency.com/stream',
json = {
'source': 'GCP::us-east4-a',
'target': 'kernel.org',
'interval': 1000,