a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 115|回复: 1

[红旗认证] 如何取远程linux主机的流量和tcp连接数

[复制链接]
发表于 2012-8-4 12:16:06 | 显示全部楼层 |阅读模式
  取远程linux主机的流量和tcp连接数$ P% N( p% x+ q1 N) c7 Q
  首先配置远程的linux主机的snmp.conf文件(可以理解为客户端)7 P" c' w7 U9 c% R; M4 j  c
  vi /etc/snmp/snmp.conf% ^% _8 b; R/ A9 @9 W( Y! d6 E
  只要修改几处地方即可( N' q$ A* m4 m1 e8 o
  ####
: v% I6 P$ f, \  r, X; g, Z  # First, map the community name "public" into a "security name"1 [$ t9 n& F& @
  # sec.name source community
: C/ `8 N$ @" U" j3 V! E; g  com2sec notConfigUser *.*.*.* username #*.*.*.* 是你远程监控机器的IP username是可信任的团体名' }  ]& L) m! I4 ^+ ]8 L7 D9 m& P
  ####6 v, p% M# `7 [5 a! ^
  # Second, map the security name into a group name:
7 m$ h7 H* r0 a* y% O  # groupName securityModel securityName8 y& ?- P' ~# ]# A( \- d
  group notConfigGroup v1 notConfigUser; W) n2 Q& X0 h& Q  s5 D
  group notConfigGroup v2c notConfigUser5 S! I2 g. X6 g* T: Z: \% V
  ####- Z0 [2 y$ Z, `1 l, f$ c+ b
  # Third, create a view for us to let the group have rights to:: K" D+ T. }" O2 B% r# @
  # Make at least snmpwalk -v 1 localhost -c public system fast again.
5 V: U, Q6 X  d8 ^8 M# w  # name incl/excl subtree mask(optional)
) z6 E4 Y1 A3 _, v$ W8 q  view systemview included .1.3.6.1.2.1.1- }- U$ B, `- O& W- h! j3 o) p
  view systemview included .1.3.6.1.2.1.2
' Z# _8 @( d' A. A8 _; D7 C  view systemview included .1.3.6.1.2.1.25.1.1
  d- Q. @; X$ K) V7 l" R% E* u  view all included .1
. v! r0 c6 n5 f% [) @+ d  ####) P* G3 G7 B6 J+ Y
  # Finally, grant the group read-only access to the systemview view.5 t, J2 z3 ]' i. N+ H" S! Q! L
  # group context sec.model sec.level prefix read write notif
  C5 k3 X1 i0 a$ _  #access notConfigGroup "" any noauth exact mib2 none none
) W. h- D0 X2 |. }) W. ?  access notConfigGroup "" any noauth exact all none none* Z  q0 R, A8 w) Z3 e6 ?
  # Here is a commented out example configuration that allows less
' n8 l( [3 p6 V9 p% Z* D, K* |  # restrictive access.2 ]2 f' T* q( j. d! c# U9 B
  # YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY' ], b# G7 h' o' v8 G1 D
  # KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO$ m7 T- ?: }! `. t
  # SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.
回复

使用道具 举报

 楼主| 发表于 2012-8-4 12:16:07 | 显示全部楼层

如何取远程linux主机的流量和tcp连接数

  ## sec.name source community' `7 P1 X4 I  J* H/ k
  com2sec notConfigUser default username #username是可信任的团体名1 u0 u8 d) e9 k
  com2sec *.*.*.0 *.*.*.*/24 username #username是可信任的团体名 *.*.*.* 是你远程监控机器的IP% }. I; b9 ~" z8 [; X
  ## group.name sec.model sec.name# z* v2 j; e3 D) i
  group MyRWGroup any local
0 g/ _( m* v4 Q9 u! U  group MyROGroup any mynetwork8 C" Z9 d7 b9 a# e, C! t! [' z: d
  group notConfigUser any zcom
8 I0 y- _9 A6 P7 v( v( I; q9 H0 r  #1 q' p$ i% R/ q
  #group MyRWGroup any otherv3user! I2 V# h# r% _" N2 A: n+ J) `
  #...
$ ]" m( t2 L+ ~, N: a7 C1 K# T  ## incl/excl subtree mask5 j  v" A# K' s) y
  view all included .1 80, V# l5 s1 y$ k1 C
  ## -or just the mib2 tree-
( p! V7 ?4 u3 A- C) A- u5 }  view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc. U% p  D0 {' M% t) a8 W
  ## context sec.model sec.level prefix read write notif! b0 `! T: x' q7 N
  access MyROGroup "" any noauth 0 all none none
, l+ S$ |& s3 l1 O% P  access MyRWGroup "" any noauth 0 all all all
; d5 U" a" N: P2 V  修改完毕后保存退出" }- f+ v  x9 j! B: y
  /etc/init.d/snmpd restart/ H' |$ T$ h2 T+ x6 C
  监控端(可以理解为server端)
) j& e, T1 n, g* @, ]  # snmpwalk -v 2c -c username *.*.*.* system
* K$ y0 D6 O1 x) K/ X" f% J  检查是否能取道远程的系统数据3 b# h  D* L4 q3 f1 l8 P
  # snmpwalk -v 2c -c username *.*.*.*|grep IF-MIB::ifInOctets.1 查看你的网卡流量$ s% x' ~6 [1 Y- Q) F
  在你的mrtg的文件里写入IF-MIB::ifInOctets.1 mrtg是不会取道流量的1 _- k3 H/ t9 ^4 y+ r) V
  # mib2c IF-MIB::ifInOctets.1 转化为mib值,结果类似于( Y9 N8 M. Y/ {9 b
  1.3.6.1.2.1.2.2.1.10
, r2 D* B, w& r( H( ]3 m  在你的mrtg文件中写进类似于这样的一句话8 J( J6 U6 F# b% n. U
  Target[*.*.*.*_BW_LAN]: 1:username@*.*.*.* #username是可信任的团体名 *.*.*.* 是你远程监控机器的IP
. j2 G) m" z8 Z  h8 `. m  Title[*.*.*.*_BW_LAN]: 202.102.251.133
' k- l. d. w0 r6 T2 n; u/ T  PageTop[*.*.*.*_BW_LAN]: *.*.*.*。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-3 11:07 , Processed in 0.168171 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表