Richtige Version hochgeladen?
Ich sehe da nur ein dig auf die NS, mehr nicht.
ich dachte an die Abfrage der PTR …
Wegen der Sache mit den dppelten hostst, meinst Du das:
95 vhost_domain=$(grep -oP 'ServerName \K.*' "$vhost" | awk '{print $1}') # Extract domain from ServerName directive
Da könnte ein "uniq" hinters grep gepiped reichen.
Code: Select all
26,118c26,31
< # System Information
< print_section_header "System Information"
< get_os_info
< echo "Hostname: $(hostname)"
< echo "Kernel Version: $(uname -r)"
< echo "Architecture: $(uname -m)"
<
< # CPU Information
< print_section_header "CPU Information"
< echo "Model Name: $(lscpu | awk -F': ' '/Model name/ {print $2}')"
< echo "Number of Cores: $(lscpu | awk -F': ' '/^CPU\(s\)/ {print $2}')"
< # Hypervisor (extracted from CPU information)
< hypervisor_vendor=$(lscpu | awk -F': ' '/Hypervisor vendor/ {print $2}')
< if [ -z "$hypervisor_vendor" ]; then
< hypervisor_vendor="Not Detected"
< fi
< echo "Hypervisor: $hypervisor_vendor"
<
< # Current CPU Usage
< print_section_header "Current CPU Usage"
< top -n 1 -b | grep '%Cpu'
<
< # Memory (RAM)
< print_section_header "Memory (RAM)"
< free -h
<
< # Disk Space
< print_section_header "Disk Space"
< df -h
<
< # Additional Disk Information
< print_section_header "Additional Disk Information"
< du -h --max-depth=1 --exclude=/proc / | sort -rn
<
< # Running Processes
< print_section_header "Running Processes"
< ps aux
<
< # Network Adapters
< print_section_header "Network Adapters"
< ip a
<
< # Network Connections
< print_section_header "Network Connections"
< netstat -tulpen
<
< # View Firewall Rules (iptables)
< print_section_header "Firewall Rules (iptables)"
< iptables -L
<
< # Apache Configuration
< print_section_header "Apache Configuration"
< apache_config_path="/etc/apache2/apache2.conf"
< cat "$apache_config_path"
<
< # Included Configuration Files
< print_section_header "Included Configuration Files"
< apache_includes_path="/etc/apache2/conf-enabled"
< for include in "$apache_includes_path"/*; do
< echo -e "\nInclude: $include\n"
< cat "$include"
< done
<
< # Enabled Virtual Hosts
< print_section_header "Enabled Virtual Hosts"
< apache_vhosts_path="/etc/apache2/keyhelp/vhosts"
< for vhost in "$apache_vhosts_path"/*; do
< vhost_name=$(basename "$vhost")
< echo -e "\nVirtual Host: $vhost_name\n"
< cat "$vhost"
< done
< #!/bin/bash
<
< # Redirect output to a file
< exec > info.txt
<
< # Set locale
< export LC_ALL=C
<
< # Function to print section header
< print_section_header() {
< echo -e "\n------------------------------------------------------------"
< echo -e "$1"
< echo -e "------------------------------------------------------------"
< }
<
< # Function to get operating system information
< get_os_info() {
< if [ -f /etc/os-release ]; then
< source /etc/os-release
< echo "Operating System: $PRETTY_NAME"
< else
< echo "Operating System: Unknown"
---
> # Check if dig is installed, if not, install dnsutils package
> check_and_install_dig() {
> if ! command -v dig &> /dev/null; then
> echo "dig is not installed. Installing dnsutils package..."
> sudo apt-get update
> sudo apt-get install -y dnsutils
133d45
< # Hypervisor (extracted from CPU information)
172,183c84,89
< # Apache Configuration
< print_section_header "Apache Configuration"
< apache_config_path="/etc/apache2/apache2.conf"
< cat "$apache_config_path"
<
< # Included Configuration Files
< print_section_header "Included Configuration Files"
< apache_includes_path="/etc/apache2/conf-enabled"
< for include in "$apache_includes_path"/*; do
< echo -e "\nInclude: $include\n"
< cat "$include"
< done
---
> # Display Used Nameservers
> print_section_header "Used Nameservers"
> cat /etc/resolv.conf
>
> # Check and install dig if needed
> check_and_install_dig
189,190c95,96
< vhost_name=$(basename "$vhost")
< echo -e "\nVirtual Host: $vhost_name\n"
---
> vhost_domain=$(grep -oP 'ServerName \K.*' "$vhost" | awk '{print $1}') # Extract domain from ServerName directive
> echo -e "\nVirtual Host: $vhost_domain\n"
191a98,102
>
> # Get DNS resource records for the domain
> echo -e "\nDNS Resource Records for $vhost_domain:"
> dns_records=$(dig $vhost_domain)
> echo "$dns_records"