chore: initial import from KNEL/PFVCluster@041d311 [#769]

Split per O&M lane work order. Full history: KNEL/PFVCluster.
https://projects.knownelement.com/issues/769#note-4152
This commit is contained in:
2026-09-03 21:39:35 -05:00
commit 7a899b8ac6
67 changed files with 7166 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# identify-hosts.sh — identify all live hosts on a network via DNS/SNMP/SSH
# Usage: bash identify-hosts.sh <hosts-file-or-subnet>
# bash identify-hosts.sh 192.168.0.0/22
# bash identify-hosts.sh /tmp/live-hosts.txt
set -u
COMMUNITY="${SNMP_COMMUNITY:-kn3lmgmt}"
if [ -f "${1:-}" ]; then
HOSTS=$(cat "$1")
elif [ -n "${1:-}" ]; then
HOSTS=$(nmap -sn -n "$1" 2>/dev/null | grep 'Nmap scan report' | awk '{print $5}')
else
echo "Usage: $0 <hosts-file-or-subnet>"
exit 1
fi
printf "%-16s %-30s %-25s %-20s\n" "IP" "DNS_NAME" "SNMP_SYSDESCR" "SSH_BANNER"
printf "%-16s %-30s %-25s %-20s\n" "--" "-------" "-------------" "----------"
for ip in $HOSTS; do
# DNS reverse
rdns=$(dig +short -x "$ip" 2>/dev/null | head -1 | sed 's/\.$//')
[ -z "$rdns" ] && rdns="(no-ptr)"
# SNMP sysDescr (first 25 chars)
snmp=$(timeout 3 snmpget -Oqv -v2c -c "$COMMUNITY" "$ip" 1.3.6.1.2.1.1.1.0 2>/dev/null | head -1 | tr -d '"' | cut -c1-25)
[ -z "$snmp" ] && snmp="-"
# SSH banner (quick)
ssh_banner=$(timeout 3 bash -c "echo > /dev/tcp/$ip/22" 2>/dev/null && echo "ssh:open" || echo "-")
printf "%-16s %-30s %-25s %-20s\n" "$ip" "$rdns" "$snmp" "$ssh_banner"
done