Create show_replication.sh
This commit is contained in:
parent
0f0ced0f17
commit
0c875894d3
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Function to process the output and create a formatted table
|
||||
process_replication_info() {
|
||||
# Print header
|
||||
printf "%-20s | %-30s | %-10s | %-50s\n" "Server" "Last Sync" "Errors" "Domain"
|
||||
printf "%s\n" "$(printf '=%.0s' {1..115})"
|
||||
|
||||
# Read input line by line
|
||||
while IFS= read -r line; do
|
||||
# Get domain name
|
||||
if [[ $line =~ ^[A-Z][A-Za-z=]+ ]]; then
|
||||
current_domain=${line}
|
||||
continue
|
||||
fi
|
||||
|
||||
# Get server name
|
||||
if [[ $line =~ ^[[:space:]]+Default-First-Site-Name\\([^[:space:]]+) ]]; then
|
||||
server_name=${BASH_REMATCH[1]}
|
||||
continue
|
||||
fi
|
||||
|
||||
# Get last sync time
|
||||
if [[ $line =~ Last[[:space:]]success[[:space:]]@[[:space:]](.+)$ ]]; then
|
||||
last_sync=${BASH_REMATCH[1]}
|
||||
if [[ $last_sync == "NTTIME(0)" ]]; then
|
||||
last_sync="Never"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get error count
|
||||
if [[ $line =~ ([0-9]+)[[:space:]]consecutive[[:space:]]failure ]]; then
|
||||
errors=${BASH_REMATCH[1]}
|
||||
# Print the complete row
|
||||
printf "%-20s | %-30s | %-10s | %-50s\n" "$server_name" "$last_sync" "$errors" "$current_domain"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Main execution
|
||||
echo "Samba Replication Status Report"
|
||||
Loading…
Reference in New Issue