Skip to content

Instantly share code, notes, and snippets.

View tembleking's full-sized avatar
🏠
Working from home

Fede Barcelona tembleking

🏠
Working from home
View GitHub Profile
@tembleking
tembleking / metallb-workload.yaml
Created November 14, 2019 11:13
MetalLB Workload (DaemonSet + Deployment)
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: metallb
component: speaker
name: speaker
namespace: metallb-system
spec:
selector:
@tembleking
tembleking / config.yaml
Created October 5, 2018 22:54
JMX Sysdig Configuration Example
jmx:
per_process_beans:
systemStatus:
pattern: "Main"
beans:
- query: "com.sysdig.app:name=SystemStatusExample"
attributes:
- name: NumberOfSecondsRunning
alias: java.app.numberOfSecondsRunning
- name: NumberOfUnixSecondsRunning
@tembleking
tembleking / Main.java
Created October 5, 2018 22:53
JMX MBean Main Example
import javax.management.*;
import java.lang.management.ManagementFactory;
public class Main {
public static void main(String[] args) {
try {
String programName = (args.length == 0) ? "Java" : args[0];
// Initialize the object
SystemStatus systemStatus = new SystemStatus(programName);
@tembleking
tembleking / SystemStatus.java
Created October 5, 2018 22:48
JMX MBean Interface Implementation Example
public class SystemStatus implements SystemStatusMBean {
private Integer numberOfSecondsRunning;
private String programName;
private Long numberOfUnixSecondsRunning;
private Boolean switchStatus;
private Thread backgroundThread;
public SystemStatus(String programName) {
// First we initialize all the metrics
this.backgroundThread = new Thread();
@tembleking
tembleking / SystemStatusMBean.java
Created October 5, 2018 22:47
JMX MBean Interface Example
public interface SystemStatusMBean {
Integer getNumberOfSecondsRunning();
String getProgramName();
Long getNumberOfUnixSecondsRunning();
Boolean getSwitchStatus();
}
@tembleking
tembleking / config.yaml
Created October 5, 2018 22:44
Golang Expvar Config YAML
- name: go-expvar
check_module: go_expvar
pattern:
comm: go-expvar
conf:
expvar_url: "http://localhost:8080/debug/vars" # automatically match url using the listening port
# Add custom metrics if you want
metrics:
- path: system.numberOfSeconds
type: gauge # gauge or rate
@tembleking
tembleking / gist:71c6d33a3058f5ade89fc31710d7d46c
Created October 5, 2018 22:43
Golang Expvar Response Example
$ curl localhost:8080/debug/vars
{
"cmdline": [
"/go-expvar"
],
"memstats": {
"Alloc": 878208,
"TotalAlloc": 878208,
"Sys": 3084288,
"Lookups": 277,
@tembleking
tembleking / main.go
Created October 5, 2018 22:42
Golang Expvar Example
package main
import (
"expvar"
"net/http"
"time"
"os"
"io/ioutil"
"strings"
"strconv"
@tembleking
tembleking / main.py
Created October 4, 2018 21:07
Prometheus Python Example
import prometheus_client as prom
import random
import time
from threading import Thread
from flask import Flask, request
from flask_prometheus import monitor
req_summary = prom.Summary('python_my_req_example', 'Time spent processing a request')
@tembleking
tembleking / main.java
Created October 4, 2018 21:06
Prometheus Java Example
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import io.prometheus.client.*;
import io.prometheus.client.exporter.HTTPServer;
import io.prometheus.client.hotspot.DefaultExports;
import java.io.IOException;
import java.net.InetSocketAddress;