I am working on a script to filter community entries from snmpd.conf
Script is:
SERVER=$(hostname)
touch /tmp/snmp_audit_$SERVER
echo $SERVER >> /tmp/snmp_audit_$SERVER
SNMP=$(cat /etc/snmp/snmpd.conf |grep -i rocommunity | awk '{print $1,$2,$3}'
echo $SNMP >> /tmp/snmp_audit_$SERVER
Which gives me output in below format:
rocommunity XXXX 1nn.nn.nnn.40
rocommunity XXXX 1nn.nn.nnn.0/24
rocommunity XXXX 1nn.nn.nnn.30
However, I want to filter those servers only, which doesn't have any of the below entries in snmpd.conf:
rocommunity XXXX 127.10.30.40
rocommunity XXXX 192.10.30.0/24
rocommunity XXXX 192.20.100.30
And for all those which doesn't have these entries, later I would need to add these ranges. Also, I need to run it on multiple server over ssh, from a jump server where I have list of server names in a file. Please advice.