aten_pdu: Get PDU location from LDAP

This commit is contained in:
Timo Makinen 2025-04-20 14:22:39 +00:00
parent 190a377076
commit c820614f44

View file

@ -36,11 +36,22 @@ for state in /run/keepalived/*.state ; do
break
done
ldapsearch -Q -LLL "(&(objectClass=device)(description=Aten PE*))" cn | \
awk '{ if ($1 == "cn:") print $2 }' | while read -r name
ldapsearch -Q -LLL "(&(objectClass=device)(description=Aten PE*))" cn l | awk '
{
if ($1 == "cn:") {
cn = $2
}
if ($1 == "l:") {
l = substr($0, 3)
}
if ($0 == "" && cn != "" && l != "") {
print cn l
cn = ""
l = ""
}
}
' | while read -r name location
do
location="$(snmp_get "$name" RFC1213-MIB::sysLocation.0 | \
tr '[:upper:]' '[:lower:]' | tr ' ' '_')"
snmpwalk -v 1 -c "$community" "$name" -Oq \
-m ATEN-PE-CFG ATEN-PE-CFG::outletName | while read -r port device
do