Skip to content

Instantly share code, notes, and snippets.

@kawaz
Last active Mar 7, 2016
Embed
What would you like to do?
shutdown -r nowをする前後に実行してipやmount状況やlisten状況の差分が無いかざっと確認する。
#!/usr/bin/env bash
d=${1:-"/tmp/$(date +%Y%m%d)"}
if [[ ! -d $d ]]; then
echo dump
mkdir "$d"
ip a > "$d/ip-a"
df -ha > "$d/df-ha"
netstat -lnp|perl -pe's| \d+\/| |;s/(STREAM\s+LISTENING\s+)\d+\s*/$1/'|sort > "$d/netstat-lnp"
else
echo diff
diff "$d/ip-a" <(ip a)
diff "$d/df-ha" <(df -ha)
diff -bB "$d/netstat-lnp" <(netstat -lnp|perl -pe's| \d+\/| |;s/(STREAM\s+LISTENING\s+)\d+\s*/$1/'|sort)
fi

再起動の前後に以下を実行する感じで使う。

curl -sL https://gist.githubusercontent.com/kawaz/eed1c5582ccf975753c6/raw/dump_and_diff.sh | bash

ダンプを保存する場所を変えたければ以下のようにすれば良い

curl -sL https://gist.githubusercontent.com/kawaz/eed1c5582ccf975753c6/raw/dump_and_diff.sh | bash /dev/stdin /tmp/hogehoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment