server# apt install snmp snmp-mibs-downloader server# :> /etc/snmp/snmp.conf
MIBDIRS=C:\usr\share\snmp\mibs
server# snmptranslate -Tp | more
gate# apt install snmpd gate# systemctl status snmpd.service или gate# cat /etc/default/snmpd
... #export MIBS= ... SNMPDRUN=yes ...
gate# cd /etc/snmp/
gate# pkg install net-snmp gate# service snmpd rcvar gate# mkdir /usr/local/etc/snmp/ gate# cd /usr/local/etc/snmp/
gate# cat snmpd.conf
rocommunity public 0.0.0.0/0
server# apt install snmptrapd server# systemctl enable snmptrapd ubuntu24# systemctl status snmptrapd.socket
server# cat /etc/snmp/snmptrapd.conf
#IF-MIB::linkDown IF-MIB::linkUp #traphandle .1.3.6.1.6.3.1.1.5.* mail -s snmptrap userX@isp.un traphandle .1.3.6.1.6.3.1.1.5.* /usr/bin/traptoemail -s mail.isp.un userX@isp.un #traphandle .1.3.6.1.6.3.1.1.5.* /usr/bin/traptoemail -s localhost student@corpX.un traphandle SNMPv2-SMI::enterprises.9.9.43.* /root/cisco-backup-config.sh #traphandle SNMPv2-SMI::enterprises.9.9.43.* sudo /root/cisco-backup-config.sh #router RMON traphandle SNMPv2-SMI::mib-2.16.0.* /usr/bin/traptoemail -s localhost student@corpX.un traphandle default cat >> /tmp/traps authCommunity execute writetrap
# service snmptrapd start # snmptrap -v 1 -c writetrap 127.0.0.1 '.1.3.6.1.6.3.1.1.5.3' '0.0.0.0' 6 33 '55' .1.3.6.1.6.3.1.1.5.3 s "teststring000" # tail -f /tmp/traps # cat /root/cisco-backup-config.sh
#!/bin/sh read cisco_name while read l;do :; done #echo $cisco_name /usr/bin/sshpass -p cisco /usr/bin/scp ${cisco_name}:running-config /srv/tftp/${cisco_name}-running-config #/usr/bin/sshpass -p cisco /usr/bin/scp -O ${cisco_name}:running-config /srv/tftp/${cisco_name}-running-config cd /srv/tftp/ /usr/bin/git add * /usr/bin/git --no-optional-locks status | grep 'modified\|deleted\|new file' | /usr/bin/git commit -a -F -
!!! На стенде при первой итерации большие задержки
server# snmpwalk -On -c public -v2c router 1
server# snmpget -c public -v2c router .1.3.6.1.2.1.1.5.0 server# snmpget -c public -v2c router SNMPv2-SMI::mib-2.1.5.0 server# snmpget -c public -v2c router SNMPv2-MIB::sysName.0 server# snmpget -c public -v2c router sysName.0 server# snmpwalk -c public -v2c router sysName
server# snmpget -c public -v2c router sysUpTime.0
radio$ snmpwalk -On -v2c -c public@101 switch 1.3.6.1.2.1.17.4.3.1.2
server# snmpget -c public -v2c router .1.3.6.1.4.1.9.2.1.56.0
server# snmpwalk -c public -v2c -On router ifDescr
FastEthernet0/0 server# snmpget -c public -v2c -On router ifInOctets.1 server# snmpget -c public -v2c -On router ifHCInOctets.1 Port-channel1 server# snmpget -c public -v2c -On router ifOutOctets.5 server# snmpget -c public -v2c -On router ifHCOutOctets.5
server# snmpwalk -c public -v2c router .1.3.6.1.4.1.9.9.23.1.2.1.1
server# snmpwalk -c write -v2c switch ifDescr server# snmpwalk -c write -v2c switch ifOperStatus server# snmpwalk -c write -v2c switch ifAdminStatus server# snmpset -c write -v2c switch ifAdminStatus.3 integer 2 server# snmpset -c write -v2c switch ifAdminStatus.3 integer 1
server# cat /srv/tftp/firewall.acl server# snmpset -c write -v2c router .1.3.6.1.4.1.9.2.1.53.192.168.X.10 string "firewall.acl"
значение 192.168.X.10 в конце OID содержит адрес tftp сервера