This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
сервис_snmp [2021/02/09 16:21] val [Настройка snmptrapd сервиса] |
сервис_snmp [2024/06/19 14:12] (current) val [Настройка snmptrapd сервиса] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Сервис SNMP ====== | ====== Сервис SNMP ====== | ||
+ | * https://ru.wikipedia.org/wiki/Management_Information_Base | ||
===== Пакет net-snmp ===== | ===== Пакет net-snmp ===== | ||
Line 31: | Line 32: | ||
gate# apt install snmpd | gate# apt install snmpd | ||
+ | gate# systemctl status snmpd.service | ||
+ | или | ||
gate# cat /etc/default/snmpd | gate# cat /etc/default/snmpd | ||
</code><code> | </code><code> | ||
Line 70: | Line 73: | ||
server# systemctl enable snmptrapd | server# systemctl enable snmptrapd | ||
+ | ubuntu24# systemctl status snmptrapd.socket | ||
</code> | </code> | ||
+ | === Debian/Ubuntu === | ||
+ | * Срабатывает более точный traphandle | ||
+ | * !!! В Ubuntu24 snmptrapd работает с правами Debian-snmp, надо использовать [[Пакет sudo]] | ||
- | === Debian/Ubuntu === | ||
<code> | <code> | ||
server# cat /etc/snmp/snmptrapd.conf | server# cat /etc/snmp/snmptrapd.conf | ||
</code><code> | </code><code> | ||
- | #traphandle .1.3.6.1.6.3.1.1.5.3 mail -s snmptrap userX@isp.un | ||
- | traphandle .1.3.6.1.6.3.1.1.5.3 /usr/bin/traptoemail -s mail.isp.un userX@isp.un | + | #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 | ||
- | traphandle .1.3.6.1.4.1.9.9.43* /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 | traphandle default cat >> /tmp/traps | ||
Line 102: | Line 114: | ||
while read l;do :; done | while read l;do :; done | ||
- | echo $cisco_name | + | #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 ${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/ | cd /srv/tftp/ | ||
/usr/bin/git add * | /usr/bin/git add * | ||
- | /usr/bin/git status | grep 'modified\|deleted\|new file' | /usr/bin/git commit -a -F - | + | /usr/bin/git --no-optional-locks status | grep 'modified\|deleted\|new file' | /usr/bin/git commit -a -F - |
</code> | </code> | ||
!!! На стенде при первой итерации большие задержки | !!! На стенде при первой итерации большие задержки | ||
Line 121: | Line 134: | ||
<code> | <code> | ||
server# snmpget -c public -v2c router .1.3.6.1.2.1.1.5.0 | 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 SNMPv2-MIB::sysName.0 | ||
Line 147: | Line 162: | ||
=== Вывод списка интерфейсов устройства === | === Вывод списка интерфейсов устройства === | ||
<code> | <code> | ||
- | server# snmpwalk -c public -v2c router ifDescr | + | server# snmpwalk -c public -v2c -On router ifDescr |
</code> | </code> | ||
=== Вывод количества байт, прошедших через порт устройства с момента его включения === | === Вывод количества байт, прошедших через порт устройства с момента его включения === | ||
<code> | <code> | ||
- | server# snmpget -c public -v2c router ifInOctets.2 | + | FastEthernet0/0 |
- | server# snmpget -c public -v2c router ifHCInOctets.2 | + | |
+ | 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 router ifOutOctets.2 | + | server# snmpget -c public -v2c -On router ifOutOctets.5 |
- | server# snmpget -c public -v2c router ifHCOutOctets.2 | + | server# snmpget -c public -v2c -On router ifHCOutOctets.5 |
</code> | </code> | ||