Skip to content

Instantly share code, notes, and snippets.

@kmassada
Last active May 11, 2018 17:40
Show Gist options
  • Save kmassada/2b00fb7b4a121bb86c4db673f5d71201 to your computer and use it in GitHub Desktop.
Save kmassada/2b00fb7b4a121bb86c4db673f5d71201 to your computer and use it in GitHub Desktop.
scrape CoS nodes running GKE for node logs
#!/bin/bash
# GENERIC
# uptime
# dmesg
# df -a --inodes
# cat /proc/sys/fs/file-nr
# systemctl status -l docker
# sudo journalctl -u docker
# sudo journalctl -u kube-docker-monitor.service
# systemctl status -l kubelet
# sudo journalctl -u kubelet
# sudo journalctl -u kubelet-monitor.service
# mount
# NETWORKING
# ip addr
# sudo iptables -L
# ip route list table all
CMDS=`cat <<END
uptime;uptime
dmesg;dmesg
df;df -a --inodes
file-nr;cat /proc/sys/fs/file-nr
systemctl_status_docker;systemctl status -l docker
journalctl_docker;sudo journalctl -u docker
journalctl_kube-docker-monitor;sudo journalctl -u kube-docker-monitor.service
systemctl_status_kubelet;systemctl status -l kubelet
journalctl_kubelet;sudo journalctl -u kubelet
journalctl_kubelet-monitor;sudo journalctl -u kubelet-monitor.service
ip;ip addr
iptables;sudo iptables -L
mount;mount
route;ip route list table all
END
`
DIR=$(mktemp -d)
echo "Using temporary directory: $DIR"
while read line
do
name=$(echo $line | awk -F ';' '{print $1}')
cmd=$(echo $line | awk -F ';' '{print $2}')
echo "Executing $cmd > $DIR/$name"
$cmd > $DIR/$name
done <<< "$CMDS"
echo "List of files to send:"
ls -1 $DIR
echo "Archiving to /tmp/$(hostname).tar ..."
tar -C $DIR -cpvf /tmp/$(hostname).tar .
echo "Cleaning up ..."
rm -rf $DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment