initial commit
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
commit
6e3d50ad2d
|
@ -0,0 +1,12 @@
|
|||
YOLO LICENSE
|
||||
Version 1, July 10 2015
|
||||
|
||||
THIS SOFTWARE LICENSE IS PROVIDED "ALL CAPS" SO THAT YOU KNOW IT IS SUPER
|
||||
SERIOUS AND YOU DON'T MESS AROUND WITH COPYRIGHT LAW BECAUSE YOU WILL GET IN
|
||||
TROUBLE HERE ARE SOME OTHER BUZZWORDS COMMONLY IN THESE THINGS WARRANTIES
|
||||
LIABILITY CONTRACT TORT LIABLE CLAIMS RESTRICTION MERCHANTABILITY SUBJECT TO
|
||||
THE FOLLOWING CONDITIONS:
|
||||
|
||||
1. #yolo
|
||||
2. #swag
|
||||
3. #blazeit
|
|
@ -0,0 +1,4 @@
|
|||
# Aegis
|
||||
|
||||
Relays information from services running over Unix sockets to Prometheus. Aegis
|
||||
contacts services (blades) over their Unix sockets when Prometheus asks for them.
|
|
@ -0,0 +1,26 @@
|
|||
=:::::::::~~=
|
||||
:,:::::::,,:=
|
||||
= +++++ + +=
|
||||
:~+~~~~~~~===
|
||||
:=+=~~~~~~=~=
|
||||
=~:===~~~~~=~~=
|
||||
=::~====~~~~=::::=
|
||||
=: ++====~~~~==::=
|
||||
=: -=+====~~~~~=~=
|
||||
=~= ~++===~~~~=,~=
|
||||
=~ +++==~~=:=~+=
|
||||
,= +++==~~=~++
|
||||
:= +++=+=~=~++
|
||||
,= ++++==~==++
|
||||
,~ ++++==~=+++
|
||||
,~ +++===~~==+
|
||||
,= ++====~~=++
|
||||
,= +==~===~==+
|
||||
,=+======~~==+
|
||||
:=+=~~~~~~~=++
|
||||
:===~~~~~~~+==
|
||||
:~===~~~~~~=+=
|
||||
,~=~~~~~~~~===
|
||||
,~=~~~~~~~~+=~
|
||||
::+========+~=
|
||||
+=~~~~~~~~~~~=
|
|
@ -0,0 +1,62 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
hostport = flag.String("hostport", "[::]:31337", "TCP host:port to listen on")
|
||||
sockdir = flag.String("sockdir", "./run", "directory full of unix sockets to monitor")
|
||||
)
|
||||
|
||||
//go:embed "aegis.txt"
|
||||
var core string
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
fmt.Print(core)
|
||||
log.SetFlags(0)
|
||||
log.Printf("%s -> %s", *hostport, *sockdir)
|
||||
|
||||
http.DefaultServeMux.HandleFunc("/", proxyToUnixSocket)
|
||||
|
||||
log.Fatal(http.ListenAndServe(*hostport, nil))
|
||||
}
|
||||
|
||||
func proxyToUnixSocket(w http.ResponseWriter, r *http.Request) {
|
||||
name := path.Base(r.URL.Path)
|
||||
|
||||
fname := filepath.Join(*sockdir, name+".sock")
|
||||
_, err := os.Stat(fname)
|
||||
if os.IsNotExist(err) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
ts := &http.Transport{
|
||||
Dial: func(_, _ string) (net.Conn, error) {
|
||||
return net.Dial("unix", fname)
|
||||
},
|
||||
}
|
||||
|
||||
rp := httputil.ReverseProxy{
|
||||
Director: func(req *http.Request) {
|
||||
req.URL.Scheme = "http"
|
||||
req.URL.Host = "aegis"
|
||||
req.URL.Path = "/metrics"
|
||||
req.URL.RawPath = "/metrics"
|
||||
},
|
||||
Transport: ts,
|
||||
}
|
||||
rp.ServeHTTP(w, r)
|
||||
}
|
Loading…
Reference in New Issue