In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
The purpose of this article is to share with you about how RHEL4U5 builds the network inspection service SNMP. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The system used is RHEL4U5, and the native IP address is 192.168.1.100
1. Make sure that the following software packages are installed on your system
[root@zone src] # rpm-qa | grep snmp
Net-snmp-5.1.2-11.EL4.10
Net-snmp-utils-5.1.2-11.EL4.10
Net-snmp-devel-5.1.2-11.EL4.10
Net-snmp-libs-5.1.2-11.EL4.10
Note that the system may prompt you to install
Beecrypt-devel-3.1.0-6.i386.rpm
Elfutils-devel-0.97.1-4.i386.rpm
Elfutils-libelf-devel-0.97.1-4.i386.rpm
These documents are on the second and fourth disks, respectively.
two。 Modify / etc/snmp/snmpd.conf
Remove the comments from the following line
View mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
Add the following line at about 55 lines
View systemview included .1.3.6.1.2.1.2
Such as the following line
Access notConfigGroup "" any noauth exact systemview none none
Changed to:
Access notConfigGroup "" any noauth exact mib2 none none
3. Enable the snmpd service
# service snmpd start
# chkconfig-- levle 2345 snmpd on
4. Check the opening status of the port
# netstat-tunlp | grep snmp
Tcp 0 0 0.0.0. 0 199 0.0.0. 0. 0. 0. V * LISTEN 4973/snmpd
Udp 0 0 0.0.0. 0 161 0.0.0. 0. 0. 0. 0. 0.
Second, MRTG to generate images for browsing needs the support of httpd services, but also needs the support of gd, libpng and zlib software packages, and the normal operation of gd also needs several other software, which are installed below.
# rpm-qa | grep libpng
Libpng-1.2.7-1
Libpng10-1.0.16-1
Libpng10-devel-1.0.16-1
Libpng-devel-1.2.7-1
# rpm-qa | grep ^ libxml
Libxml2-python-2.6.16-6
Libxml2-devel-2.6.16-6
Libxml2-2.6.16-6
# rpm-qa | grep ^ gd-
Gd-2.0.28-4
Gd-devel-2.0.28-4
# rpm-qa | grep jpeg
Libjpeg-6b-33
Libjpeg-devel-6b-33
# rpm-qa | grep zlib
Zlib-1.2.1.2-1.2
Zlib-devel-1.2.1.2-1.2
# rpm-qa | grep freetype
Freetype-2.1.9-1
Freetype-devel-2.1.9-1
Mine has already been installed, if not, please check and fill the gap according to your own situation.
Please make sure that the version number of your package is equal to or higher than the version shown above.
3. Install and configure MRTG
1. Download mrtg. The latest version is mrtg-2.15.2.tar.gz.
# tar zxvf mrtg-2.15.2.tar.gz
# cd mrtg-2.15.2
# / configure-- prefix=/usr/local/mrtg-- sysconfdir=/etc/mrtg-- with-gd=/usr/local/gd2/include-- with-gd-lib=/usr/local/gd2/lib-- with-gd-inc=/usr/local/gd2/include-- with-png=/usr/local/include-- with-png-lib=/usr/local/lib-- with-png-inc=/usr/local/include-- with-zlib=/usr/local/zlib/include-- with-zlib- Lib=/usr/local/zlib/include-with-zlib-inc=/usr/local/zlib/include
# make
# make install
3. Basic configuration
Generate the master configuration file
# / usr/local/mrtg/cfgmaker public@localhost > / etc/mrtg/mrtg.cfg
Edit / etc/mrtg/mrtg.cfg
Set
# WorkDir:/home/http/mrtg
Remove the comments and change to
WorkDir: / usr/local/apache/htdocs/mrtg (here is the default home directory of your httpd)
Remove the comments such as the following line
# Options [_]: growright, bits
Add the following line to realize the display of Chinese characters in the web page
Language:gb2312
Generate the main page file of MRTG web page
# / usr/local/mrtg/bin/indexmaker / etc/mrtg/mrtg.cfg-output=/usr/local/apache/htdocs/mrtg/index.html-title= "My MRTG"
4. Start MRTG
# env LANG=C / usr/local/mrtg/bin/mrtg / etc/mrtg/mrtg.cfg
This command will output some error messages, which can be safely ignored and can be executed three times in a row.
The web page generated by 5.MRTG is static. In order to refresh it constantly, you need to add the above command to crontab.
# crontab-e
Add the following line
* / 3 * env LANG=C / usr/local/mrtg/bin/mrtg / etc/mrtg/mrtg.cfg
Note: this line means that it is refreshed every three minutes, and you can modify the refresh interval according to your needs.
6. After the installation, you can check the results and enter the following address in the browser
Http://192.168.1.100/mrtg (the IP address is your machine IP)
Fourth, an example: memory usage monitoring
1. Create a new folder where scripts are stored
# mkdir-pv / usr/local/apache/htdocs/mrtgsh
two。 Create a script file
# vi / usr/local/apache/htdocs/mrtgsh/mrtg.memory
Add the following script:
#! / bin/bash
# run this script to check the mem usage.
Totalmem= `/ usr/bin/free | grep Mem | awk'{print $2}'`
Usedmem= `/ usr/bin/free | grep Mem | awk'{print $3}'`
UPtime= `/ usr/bin/uptime | awk'{print $3 "" $4 "" $5}'`
Echo $totalmem
Echo $usedmem
Echo $UPtime
Let it have the permission to run
# chmod 755 / usr/local/apache/htdocs/mrtgsh/mrtg.memory
3. Edit / etc/mrtg/mrtg.cfg
Add the following
Target [memory]: `/ usr/local/apache/htdocs/mrtgsh/ mrtg.roomy`
MaxBytes [memory]: 4096000
Title [memory]: Memory Usages
ShortLegend [memory]: &
Kmg [memory]: kB,MB
Kilo [memory]: 1024
YLegend [memory]: Memory Usage:
Legend1 [memory]: Total Memory:
Legend2 [memory]: Used Memory:
LegendI [memory]: Total Memory:
LegendO [memory]: Used Memory:
Options [memory]: growright,gauge,nopercent
PageTop [memory]: Memory Usages
4. Regenerate the main page file
# / usr/local/mrtg/bin/indexmaker / etc/mrtg/mrtg.cfg-output=/usr/local/apache/htdocs/mrtg/index.html-title= "My MRTG"
5. Restart MRTG as appropriate, and then you can see the effect.
Detect CPU load
Create script mrtg.cpu
#! / bin/bash
Cpuusr= `/ usr/bin/sar-u 1 3 | grep Average | awk'{print $3}'`
Cpusys= `/ usr/bin/sar-u 1 3 | grep Average | awk'{print $5}'`
UPtime= `/ usr/bin/uptime | awk'{print $3 "" $4 "" $5}'`
Echo $cpuusr
Echo $cpusys
Echo $UPtime
Echo www.zhang.org, write your host name here.
# vi / etc/mrtg/mrtg.cfg
Add the following
Target [localhost]: `/ usr/local/apache/htdocs/mrtg/cpu/ mrtg.cpu`
MaxBytes [localhost]: 100
Options [localhost]: gauge, nopercent, growright
YLegend [localhost]: CPU loading (%)
ShortLegend [localhost]:%
LegendO [localhost]: CPU user license
LegendI [localhost]: CPU system administrator
Title [localhost]: CPU? t???v
PageTop [localhost]: VBird host CPU failure rate
System: RedHat 6.1 in Linux Kernel 2.2.19
At the same time, we can also detect the number of people online immediately.
Create script mrtg.person.sh
#! / bin/bash
# this program is mainly used to calculate how many people are connected to our mainframe in the way of WWW!
# 1. Calculate the number of connections
Echo `netstat-a | grep www | awk'{print$ 5}'| sort | wc-l | awk'{print$1-1}'`
# netstat-a | grep www | awk'{print $5}'| sort | uniq
# 2. Calculate the number of connections:
Echo `netstat-a | grep www | awk'{print $5}'| cut-d ":"-F1 | sort | uniq | wc-l | awk'{print $1-1}'`
# netstat-a | grep www | awk'{print $5}'| cut-d ":"-F1 | sort | uniq
# 3. Output time
UPtime= `/ usr/bin/uptime | awk'{print $3 "" $4 "" $5}'`
Echo $UPtime
Echo your.host.name
# vi / etc/mrtg/mrtg.cfg
Add the following
# CPU Loading detecting...
Target [tsai.adsldns.org _ person]: `/ usr/local/mrtg-2/bin/ mrtg.person.sh`
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.