Files
commander/roles/graylog_collector/files/collect_info.sh
2025-06-09 19:34:56 +09:00

26 lines
587 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
OUTPUT_DIR="${OUTPUT_DIR:-/var/log}"
filename="$OUTPUT_DIR/command_results_$(date +%F_%H-%M-%S).log"
commands=(
"hostnamectl"
"ip a"
"ip route"
"cat /etc/resolv.conf"
"uptime"
"who"
"df -h"
"free -m"
"netstat -tuln"
"systemctl list-units --type=service --state=running"
)
{
echo "== Сбор информации начат: $(date) =="
for cmd in "${commands[@]}"; do
echo "Команда: $cmd"
eval "$cmd" 2>&1
echo "--------------------------------------------------"
done
echo "== Завершено: $(date) =="
} > "$filename"