Data Collector für Community Support -- Diskussionsthread

For topics beyond KeyHelp. / Für Themen jenseits von KeyHelp.
User avatar
24unix
Posts: 1645
Joined: Sun 21. Jun 2020, 17:16
Location: Kollmar
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by 24unix »

Sheldon Cooper wrote: Sun 13. Aug 2023, 15:05 Ich verstehe euer Problem nicht, IP-Adressen und Domains sind doch öffentliche Informationen, was will man da geheim halten?
Du bist noch relativ neu im Forum, sonst wüsstest Du es schon :-)

Die Daten muss man geheim halten, um die Suche nach Fehlern so schwer wie möglich zu machen :)
mfg Micha
--
If Bill Gates had a nickel for every time Windows crashed …
… oh wait, he does.
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

24unix wrote: Sun 13. Aug 2023, 15:11 Du bist noch relativ neu im Forum, sonst wüsstest Du es schon :-)

Die Daten muss man geheim halten, um die Suche nach Fehlern so schwer wie möglich zu machen :)
YMMD :mrgreen: :mrgreen: :mrgreen:
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

24unix wrote: Sun 13. Aug 2023, 15:09 Damit könntest Du in zweierlei Weise die Akzeptanz steigern :-)

1) Beim Anwender, der seine Daten verstümmelnanonymisieren will, dass er trotzdem Dein Script nutzt.

2) Bei Leuten wie bei mir, die helfen wollen. Wenn die Leute echte Daten nutzen, weiß ich, dass sie auch echte Hilfe wollen :)
Wer dann lieber Geheimniskrämer spielt muss damit leben, dass nicht jeder für ihn seine Zeit opfern wird …
Genau das war mein Hintergedanke :D 8-)
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

Hier nun das Script mit rein englischer Kommentierung und Ausgabe:

Code: Select all

#!/bin/bash

# Check if lsb-release is installed
if ! command -v lsb_release &> /dev/null; then
    echo "lsb-release is not installed. Installing..."
    sudo apt-get update
    sudo apt-get install -y lsb-release
fi

# 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 "------------------------------------------------------------"
}

# System Information
print_section_header "System Information"
echo "Operating System: $(lsb_release -d -s)"
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
    echo -e "\nVirtual Host: $vhost\n"
    cat "$vhost"
done
Ich mußte das Script noch geringfügig modifizieren...Auf einem meiner Testsysteme war lsb-release noch nicht installiert, das Paket ist aber notwendig, um das OS korrekt auszulesen. Also wird es vom Script direkt mit installiert, wenn nötig.
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
FaWa
Posts: 12
Joined: Tue 9. May 2023, 08:16

Re: Data Collector für Community Support -- Diskussionsthread

Post by FaWa »

Alternative damit man nicht unbedingt lsb-release installieren muss:

Code: Select all

ls /etc/ | grep -e '[_-]release$' -e '[_-]version$' | xargs -I % -n 1 cat /etc/%
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

FaWa wrote: Sun 13. Aug 2023, 16:27 Alternative damit man nicht unbedingt lsb-release installieren muss:

Code: Select all

ls /etc/ | grep -e '[_-]release$' -e '[_-]version$' | xargs -I % -n 1 cat /etc/%
Danke für dein Feedback. :mrgreen:
Ich habe deinen Ansatz aufgegriffen und lese direkt das File /etc/os-release aus. So bin ich tatsächlich nicht mehr auf das Paket lsb-release angewiesen. :geek:

Hier die aktuelle Scripversion:

Code: Select all

#!/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"
    fi
}

# 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
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
User avatar
24unix
Posts: 1645
Joined: Sun 21. Jun 2020, 17:16
Location: Kollmar
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by 24unix »

Jolinar wrote: Sun 13. Aug 2023, 15:02 denn manche Sachen (zB. DNS-RR) kann man ja nur anhand echter Infos von extern prüfen.
Ach ja, das könnte man direkt ins Script einbauen, je nachdem, wie viel Zeit Du investieren willst :)
mfg Micha
--
If Bill Gates had a nickel for every time Windows crashed …
… oh wait, he does.
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

24unix wrote: Sun 13. Aug 2023, 17:04 Ach ja, das könnte man direkt ins Script einbauen, je nachdem, wie viel Zeit Du investieren willst :)
Hatte ich auch schon überlegt...Aber wenn die Namensauflösung lokal aufgrund von Fehlkonfigurationen nicht funktioniert, läuft das ins Leere.
Davon abgesehen gibt es im DNS so viele mögliche Variablen, daß eine automatisierte Auswertung ziemlich aufwändig wäre... :?
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

24unix wrote: Sun 13. Aug 2023, 17:04 Ach ja, das könnte man direkt ins Script einbauen, je nachdem, wie viel Zeit Du investieren willst :)
Ich hab es mal eingebaut.
Allerdings werden die Domainnamen doppelt ausgelesen und auch doppelt abgefragt (wegen ServerName bei vhost:80 und vhost:443). Falls jemand einen Denkanstoß hat, wie man das besser lösen kann...immer her damit :mrgreen:

Hier die aktuelle Version des Scripts:

Code: Select all

#!/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"
    fi
}

# 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
    fi
}

# 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_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

# Display Used Nameservers
print_section_header "Used Nameservers"
cat /etc/resolv.conf

# Check and install dig if needed
check_and_install_dig

# Enabled Virtual Hosts
print_section_header "Enabled Virtual Hosts"
apache_vhosts_path="/etc/apache2/keyhelp/vhosts"
for vhost in "$apache_vhosts_path"/*; do
    vhost_domain=$(grep -oP 'ServerName \K.*' "$vhost" | awk '{print $1}')  # Extract domain from ServerName directive
    echo -e "\nVirtual Host: $vhost_domain\n"
    cat "$vhost"

    # Get DNS resource records for the domain
    echo -e "\nDNS Resource Records for $vhost_domain:"
    dns_records=$(dig $vhost_domain)
    echo "$dns_records"
done
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
User avatar
24unix
Posts: 1645
Joined: Sun 21. Jun 2020, 17:16
Location: Kollmar
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by 24unix »

Jolinar wrote: Sun 13. Aug 2023, 19:16
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"
mfg Micha
--
If Bill Gates had a nickel for every time Windows crashed …
… oh wait, he does.
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

24unix wrote: Sun 13. Aug 2023, 19:37 ich dachte an die Abfrage der PTR …
PTR Abfrage eingebaut.

24unix wrote: Sun 13. Aug 2023, 19:37 Da könnte ein "uniq" hinters grep gepiped reichen.
Perfekt, danke für den Ansatz :mrgreen:

Hier das aktuelle Script:

Code: Select all

#!/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"
    fi
}

# 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
    fi
}

# 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_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

# Display Used Nameservers
print_section_header "Used Nameservers"
cat /etc/resolv.conf | awk '/^nameserver/ {print "Nameserver:", $2}'

# Reverse DNS Lookup (PTR) for IP Addresses
print_section_header "Reverse DNS Lookup (PTR) for IP Addresses"
for ip in $(ip -o -4 addr show scope global | awk '{print $4}' | cut -d'/' -f1); do
    ptr_record=$(dig -x "$ip" +short)
    echo "IP Address: $ip"
    echo "PTR Record: $ptr_record"
    echo
done

# Check and install dig if needed
check_and_install_dig

# Enabled Virtual Hosts
print_section_header "Enabled Virtual Hosts"
apache_vhosts_path="/etc/apache2/keyhelp/vhosts"
for vhost in "$apache_vhosts_path"/*; do
    vhost_domain=$(grep -oP 'ServerName \K.*' "$vhost" | awk '{print $1}' | uniq)  # Extract domain from ServerName directive
    echo -e "\nVirtual Host: $vhost_domain\n"
    cat "$vhost"

    # Get DNS resource records for the domain
    echo -e "\nDNS Resource Records for $vhost_domain:"
    dns_records=$(dig $vhost_domain)
    echo "$dns_records"
done
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
User avatar
Sheldon Cooper
Posts: 29
Joined: Fri 11. Aug 2023, 08:42
Location: Pasadena

Re: Data Collector für Community Support -- Diskussionsthread

Post by Sheldon Cooper »

Wenn ihr das DNS abfragt, wird das aber nichts mehr mit der Anonymisierung. :o
:mrgreen: Ich bin nicht verrückt. Meine Mutter hat mich testen lassen. :mrgreen:
User avatar
24unix
Posts: 1645
Joined: Sun 21. Jun 2020, 17:16
Location: Kollmar
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by 24unix »

Sheldon Cooper wrote: Sun 13. Aug 2023, 20:01 Wenn ihr das DNS abfragt, wird das aber nichts mehr mit der Anonymisierung. :o
Tja, wer die Option "anonym" auswählt muss darauf dann verzichten.

Und sicher auch auf die freiwillige Hilfe vieler im Forum :-)
mfg Micha
--
If Bill Gates had a nickel for every time Windows crashed …
… oh wait, he does.
User avatar
Jolinar
Community Moderator
Posts: 3612
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Data Collector für Community Support -- Diskussionsthread

Post by Jolinar »

Kann mir jemand einen Denkanstoß geben?

Hier erstmal das aktuelle Script:

Code: Select all

#!/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"
    fi
}

# 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
    fi
}

# 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_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

# Display Used Nameservers
print_section_header "Used Nameservers"
cat /etc/resolv.conf | awk '/^nameserver/ {print "Nameserver:", $2}'

# Reverse DNS Lookup (PTR) for IP Addresses
print_section_header "Reverse DNS Lookup (PTR) for IP Addresses"
for ip in $(ip -o -4 addr show scope global | awk '{print $4}' | cut -d'/' -f1); do
    ptr_record=$(dig -x "$ip" +short)
    echo "IP Address: $ip"
    echo "PTR Record: $ptr_record"
    echo
done

# Check and install dig if needed
check_and_install_dig

# Enabled Virtual Hosts
print_section_header "Enabled Virtual Hosts"
apache_vhosts_path="/etc/apache2/keyhelp/vhosts"
for vhost in "$apache_vhosts_path"/*; do
    vhost_domain=$(grep -oP 'ServerName \K.*' "$vhost" | awk '{print $1}' | uniq)  # Extract domain from ServerName directive
    echo -e "\nVirtual Host: $vhost_domain\n"
    cat "$vhost"

    # Get DNS resource records for the domain
    echo -e "\nDNS Resource Records for $vhost_domain:"
    dns_records=$(dig $vhost_domain any)
    echo "$dns_records"
done
Bei der Ermittlung der DNS-RR gebe ich dem dig Kommando den Parameter any mit. Trotzdem bekomme ich nur A-RR gelistet, obwohl weitere DNS-RR (AAAA, MX, TXT) existieren. Wo liegt mein Denkfehler?
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
CaseF
Posts: 12
Joined: Fri 12. Jan 2018, 02:04

Re: Data Collector für Community Support -- Diskussionsthread

Post by CaseF »

Kein Denkfehler. "any" funktioniert nicht mit jedem DNS Server bzw. ist die Ausgabe nicht überall komplett.
Post Reply