This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
сервис_snmp [2021/07/22 12:30] admin [Настройка 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.3 /usr/bin/traptoemail -s localhost student@corpX.un | + | #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 106: | Line 117: | ||
/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 * | ||
Line 122: | 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 153: | Line 167: | ||
=== Вывод количества байт, прошедших через порт устройства с момента его включения === | === Вывод количества байт, прошедших через порт устройства с момента его включения === | ||
<code> | <code> | ||
- | server# snmpget -c public -v2c -On router ifInOctets.3 | + | FastEthernet0/0 |
- | server# snmpget -c public -v2c -On router ifHCInOctets.3 | + | |
+ | 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.2 | + | server# snmpget -c public -v2c -On router ifOutOctets.5 |
- | server# snmpget -c public -v2c -On router ifHCOutOctets.2 | + | server# snmpget -c public -v2c -On router ifHCOutOctets.5 |
</code> | </code> | ||