martes, 22 de noviembre de 2016

TIL: Oneliner http endpoint

Today I was looking for some 'Taco Bell' way to create an http endpoint in a server that would output very basic stats about the server.

In this stackoverflow thread I found a pretty neat way to do it.


 while true ; do nc -l -p 1500 -c 'echo -e "HTTP/1.1 200 OK\n\n $(lsof -a -p $(pgrep myprocname) | wc -l)"'; done

Nice, eh?

No hay comentarios: