collect logs
This commit is contained in:
parent
761105d337
commit
9271aeb39a
2 changed files with 48 additions and 0 deletions
11
flash.sh
11
flash.sh
|
|
@ -20,4 +20,15 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "collecting logs"
|
||||
|
||||
dir="./logs/$(date +"%Y%m%d_%H%M%S")-zeroize"
|
||||
|
||||
mkdir -p "$dir"
|
||||
|
||||
touch "$dir/zeroize"
|
||||
|
||||
cp "./serve/config.txt" "$dir/"
|
||||
cp ./flash.sh "$dir"
|
||||
|
||||
echo "finished"
|
||||
|
|
|
|||
37
script.py
37
script.py
|
|
@ -50,3 +50,40 @@ print("Icmp correspondance")
|
|||
print(pprint(icmpid))
|
||||
print("Seen vlans")
|
||||
print(pprint(seen))
|
||||
|
||||
print("Collecting :")
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + "-test"
|
||||
log_dir = Path("./logs") / timestamp
|
||||
log_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(log_dir / "seen_vlans.txt", "w") as f:
|
||||
f.write(pprint(seen))
|
||||
|
||||
with open(log_dir / "seen_icmp_ids.txt", "w") as f:
|
||||
f.write(pprint(icmpid))
|
||||
|
||||
shutil.copy(Path("./script.py"), log_dir / "script.py")
|
||||
|
||||
print(" - [x] script.py")
|
||||
|
||||
with open(log_dir / "egress.pcap", "wb") as file:
|
||||
wrpcap(file, plist)
|
||||
|
||||
print(" - [x] pcap")
|
||||
|
||||
cmd_config = ["ssh", "-o", "StrictHostKeyChecking=no", "root@192.168.42.6", "cli show config"]
|
||||
cmd_rsi = ["ssh", "-o", "StrictHostKeyChecking=no", "root@192.168.42.6", "cli request support information"]
|
||||
|
||||
result = subprocess.run(cmd_config, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
||||
|
||||
with open(log_dir / "config.txt", "w") as f:
|
||||
f.write(result.stdout)
|
||||
|
||||
print(" - [x] config")
|
||||
|
||||
print("Finished, saved to", log_dir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue