马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
1.首先在服务器端安装snmp工具 [root@bogon yinzhengjie]# yum -y installnet-snmp-utils snmp-libs snmp-devel snmp 2.检测与路由器的连通性 [root@bogon yinzhengjie]# snmpwalk -v 2c -c private192.168.1.1 在执行此命令之前~你首先要确认你的路由器是否开启了snmp功能哟~ 0 e2 O5 {, s# a/ @
出现如下信息说明情况是正确的~这是zabbix server在服务器上可以在你的路由器获取到信息 3.添加路由器的监控主机 4.用snmp协议进行监控
% R( P' X4 d$ b( Q5.选择zabbix自带的模板
8 a0 x: U7 s: X 等2分钟左右~会生成图像
1 g) a R' X" o" F% _$ z, E' b 我们来查看一下我的路由器的wan1口的出口流量 8 p" u7 V3 o, X& N1 T' a
! M( d6 \8 y# E* F o9 [* ]5 j
我们的设备是双WAN口的路由器,让我们一起看看wan2口的流量吧 % E0 R$ \1 F5 P/ e
5 \# j: g e3 _0 G9 ~
. W# `8 x! t% o3 h 至此~我们对路由器的监控就搞定了~那么~你成功了吗? 4 D8 ]$ U( q, [* M5 }! y
; x7 n4 X( D5 m* |7 u1 d# ~
Step 1: Configure SNMP on the CiscoSwitch or Router Configure SNMPv2c on Cisco routers andswitches with one command as shown below: switch> enable switch# configure terminal switch(config)# snmp-server communityMyCommunity RO switch(config)# exit switch# copy running-config startup-config That will cover most Cisco devices, but ifyou need to use SNMPv3 or configure Nexus or ASA firewall then read this short tutorial. My favorite tool for testing SNMP isNet-SNMP. On Ubuntu/Debian you can install Net-SNMP tools with one simplecommand: “apt-get install snmp“, or if you have CentOS/RHEL you canuse “yum install net-snmp net-snmp-utils“. Run the following Net-SNMP command fromLinux machine to verify that SNMP is working as configured onthe device: snmpwalk -v2c -c MyCommunity 192.168.1.11.3.6.1.2.1.1.1 iso.3.6.1.2.1.1.1.0 = STRING: "CiscoIOS Software, Catalyst 4500 L3 Switch Software (cat4500-ENTSERVICESK9-M),Version 12.2(54)SG1, RELEASE SOFTWARE (fc1) Copyright (c) 1986-2011 by Cisco Systems,Inc. Compiled Thu 27-Jan-11 11:39 " If your snmpwalk fails, then make sure thatthe network or local firewall on the device is not blocking UDP port 161. Step 2: Install Zabbix monitoring system Step 3: Change global SNMP communitystring for all devices Zabbix needs SNMP community string toretrieve data from SNMP enabled devices. A community string is like a password.Global SNMP community string in Zabbix is “public” and if you are usingsomething else than you need to change it. You can change community string for alldevices by changing value for macro “{$SNMP_COMMUNITY}” under Administration→General→Macrosjust as shown in the picture below. Picture showing how to changeglobal macro {$SNMP_COMMUNITY} on Zabbix WELL DONE!' @! }8 ?/ N8 s- [8 a5 Q
SNMP is enabled on the device and Zabbix is ready for monitoring. Now it’s timeto add that device to Zabbix. Step 4: Add host to Zabbix withappropriate SNMP template Go to the “Hosts” menu under the “Configuration”tab and click the “Create host” option to create a host in Zabbix.Define the name of your switch/router in the “Host name” field andchoose the appropriate template for your Cisco device under the section “Templates”by typing “Cisco”. Select the “Cisco IOS SNMP” template if you are notsure what to choose. Picture showing how to addCisco Switch or Router to Zabbix monitoring system Next, set “Groups” using existinghost groups or create a new one. Then add SNMP interface under the “Interfaces”section and set the IP address of the device. CONGRATULATIONS!
6 j( v4 H/ ]1 z* ~" lYou have successfully configured network monitoring (Cisco router and switch)on Zabbix!
* p4 D2 \' A" fNo need to change anything else as other steps are optional.
( H/ F8 L2 x" ]: ~# S5 _4 B$ ?/ N; n8 b3 L7 ~0 m! _
CONTINUE TO LEARN MORE:7 @2 {2 U4 |2 a
How to use Clone option?$ t4 W! {& L5 p$ `! c# d
Create discovery rules and action to automatically add devices to Zabbix
+ n9 U+ Z, \( }) _; Z9 V% SChange community string per host
1 g) @4 j; @3 X$ W+ aHow to force instant data collection Step 5: Tips and tricks (optional) This step is optional, but I stronglyrecommend the tips and tricks from this section, as they will ease your hostadministration in Zabbix. a) Use Clone option After you have added your first device youcan add other similar devices very fast by using “Clone” option.Clicking on “Clone” will retain all host parameters andtemplate linkage (don’t use “Full clone” option because itwill retain directly attached entities: applications, items, triggers, graphs,low-level discovery rules, and web scenarios). Pictureshowing how to clone a host in Zabbix Stepsfor clonning are very simple. Find the host that you want to clone with the “Search”option. Click on the “Clone” option, then change the “Host name”and “IP address” and add a new host by pressing “Add”button b) Create discovery rules andaction to automatically add devices to Zabbix Adding hosts to Zabbix manually is tediousjob, and even with the “Clone” option, it’s still slow and error-proneprocess. Wouldn’t it be great if Zabbix could automatically discover devices onthe network, add them to the appropriate host group and link them to theappropriate template depending on whether it was a Cisco, Juniper, HP,Mikrotik, Huawei device? Well, good news! Zabbix can do just that!Let me show you. I will configure Zabbix discovery rule thatwill scan the network and search for SNMP enabled devices. Discovery will querydevices with SNMP OID 1.3.6.1.2.1.1.1 (sysDescr) which contains a lot ofinformation about the vendor, hardware, and software versions of the device.This information will allow us to add devices to the appropriate host group andlink them to the appropriate template. Go to the “Discovery” under the “Configuration”section and click the “Create discovery rule” option. Define the name ofyour discovery and your network. You can set one network like 192.168.1.1-255or use multiple networks divided with a comma just like I did in the picturebelow. Pictureshowing how to create discovery rule in Zabbix Under the section “Checks” add adiscovery check that will use: SNMPv2 agent on port 161; default Zabbix SNMPcommunity (you can change that to a another community ); and SNMP OID1.3.6.1.2.1.1.1.0. Click the “Add” button when you aredone with the configuration. Nice job! Zabbix will now scan the networkand on the “Discovery” section under the “Monitoring” tab, youcan view all the devices that Zabbix has found. What now? Now we need to create a discoveryaction that will do something with discovered devices! In my case, I willconfigure a discovery action that will link Cisco devices to the Cisco templateand add them to the host group for network devices. Navigate to “Configuration“→ “Actions”→ “Discovery actions” and click the “Create action” button in theupper right corner. Enter the name of your action and add 2 conditions justlike in the image below. Condition A will make sure that this discovery checkis only active on our newly create discovery rule, in my case that would be thediscovery rule “Discover my network“, and condition B will take intoaccount only devices that cointain the word “Cisco” in systemdescription (1.3.6.1.2.1.1.1.0). Pictureshowing how to create discovery actions in Zabbix Next, under the “Operations” tabcreate two operation, one that will link the device to the “Cisco IOS SNMP”template, and the other that will add the device to the host group “Devices/Network”(of course you can link any template and add any group as you wish). Click the “Add” button when you’redone with the configuration! And that’s all there is to Zabbix rules anddiscovery actions! c) Use “Execute now” option to forceinstant discovery and data collection It will take some time before Zabbixdiscovers components (interfaces, power supply, serial number, etc.) on thenewly added device. Usually, it takes around 1 hour, but if you are impatientyou can speed things up by using the “Execute now” option. Picture showing how toinstantly check all the LLD discoverys on a Zabbix host Find the host that you want to force aninstant check with “Search” option and click on “Discovery“.Select all discoveries (LLD) and click “Execute now” option. Most items have faster polling intervals(around 1 minute) so there is no need to use “Execute now” on them.However, you can force instant check even for them. Move to “Items”sections and do the same: select all items (ignore “SNMP trap” and “ZabbixTrapper” item types if present) and click “Execute now“. d) Change SNMP community string per host(multiple SNMP community) What if one device has a different SNMPcommunity string and (for some reason) you can’t change it on the device? Noproblem, you can set different SNMP community on any host in Zabbix. How to change the SNMPcommunity string only for one host Find the host that that is using differentSNMP community with the “Search” option. Under host configurationselect “Macros” and change tab to “Inherited and host macros“.Click “Change” on macro “{$SNMP_COMMUNITY}” and enter your newcommunity string. Hit the “Update” button after changing the SNMPcommunity. Under host configuration select “Macros”and change tab to “Inherited and host macros“. Click “Change” onmacro “{$SNMP_COMMUNITY}” and enter your new community string. Hit the“Update” button after changing the SNMP community. : {9 T# S2 b+ l) l8 b
Thank you for reading.
8 c p& t! F- Z: @8 Y# J# F: ]2 p- `5 j
8 ]; y% N3 q" n* S$ r
% n z) M3 r, L5 X |