Allow diagnostics to be downloaded on port 62374

A client like `pinata diagnose` can do the equivalent of:

  nc 192.168.64.2 62374 > foo.tar

and find `foo.tar` contains

- the output of `/usr/bin/diagnostics`
- `iptables -L`
- `netstat -an`
- `ps uax`
- `docker ps`
- `dig docker.com`
- `wget http://docker.com`

This will allow us to diagnose various in-VM faults, without having
to ask the user to access the console and run commands.

Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
David Scott 2016-03-29 21:20:53 +01:00
parent 38aef85f6a
commit af9b3ad7a2
4 changed files with 30 additions and 0 deletions

View File

@ -34,6 +34,8 @@ COPY packages/docker/docker /usr/bin/
COPY packages/docker/etc /etc/
COPY packages/docker-x/docker-x /usr/bin/
COPY packages/diagnostics/diagnostics /usr/bin/
COPY packages/diagnostics/diagnostics-server /usr/bin/
COPY packages/diagnostics/diagnostics-download /usr/bin/
COPY packages/diagnostics/etc /etc/
COPY packages/automount/etc /etc/
COPY packages/9pinit/etc /etc/

View File

@ -0,0 +1,20 @@
#!/bin/sh
# Gather diagnostic data and write a .tar file to stdout
TEMP=$(mktemp -d diagnoseXXXXXXX)
trap 'rm -rf "$TEMP"' EXIT
cd $TEMP
# gather diagnostic data
ps uax > "ps -aux"
netstat -an > "netstat -an"
iptables -L > "iptables -L"
dmesg > dmesg
timeout -t 2 docker ps > "docker ps"
/usr/bin/diagnostics > "diagnostics"
dig docker.com > "dig docker.com"
wget -O - http://www.docker.com/ &> "wget docker.com"
# send everything to the client
tar -c .

View File

@ -0,0 +1,7 @@
#!/bin/sh
# Allow clients (e.g. pinata diagnose) to download diagnostic data
while /bin/true; do
nc -l -p 62374 -e /usr/bin/diagnostics-download 2>> /var/log/diagnostics-server.log
done

View File

@ -10,4 +10,5 @@ start()
ebegin "Checking system state"
/usr/bin/diagnostics
/usr/bin/diagnostics-server &
}