工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆
浏览模式: 标准 | 列表全部文章

squid日志格式更改

squid日志里面默认记录的时间都是根据标准时间计算后加上毫秒记录的,不便于查看。
网上搜了搜,仿佛有许多方法都可以进行转换,但是想想还是麻烦,其实squid可以直接改日志的记录格式的。
打开squid的配置文件/etc/squid/squid.conf
找到下面这句,并取消注释

#logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%S

再找到:

access_log /var/log/squid/access.log squid

修改成

access_log /var/log/squid/access.log combined

重启squid
得到的日志格式就跟apache日志格式相似了

日志详解

在squid中access访问日志最为重要,位于/var/log/squid/access.log,常用的记录格式如下

例如:

下面来看看意思

1206507660.803  84367 192.168.1.114 TCP_MISS/502 1486 GET 
http://123.138.238.114/QQ2008SpringKB1.exe - DIRECT/123.138.238.114 text/html

 

logformat squid  %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt

解释如下:

%ts    Seconds since epoch;
%03tu  subsecond time (milliseconds); 
%6tr    Response time (milliseconds);
%>a    Client source IP address; 
%Ss    Squid request status (TCP_MISS etc);
%03Hs  HTTP status code;
%<st    Reply size including HTTP headers; 
%rm    Request method (GET/POST etc) ;
%ru     Request URL;
%un     User name;
%Sh    Squid hierarchy status (DEFAULT_PARENT etc); 
%<A    Client FQDN; 
%mt    MIME content type

 

我喜欢下面这样,可以输出 squid 日志的请求头

logformat squid_test_log %{%y%m%d%H%M%S}tl.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru  %un %Sh/%<A %mt "%>h"

 

>h      Request header. Optional header name argument on the format header[:[separator]element]
<h      Reply header. Optional header name argument as for >h


squid的日志很重要。常常要了解的,其中最重要的就是命中率啦,不然反向代理做的用就不大。

#cat access.log|gawk ‘{print $4}’|sort|uniq -c|sort -nr

9568 TCP_IMS_HIT/304
6313 TCP_HIT/200
2133 TCP_MISS/200
1568 TCP_MISS/206
587 TCP_MEM_HIT/200
531 TCP_MISS/304
207 TCP_REFRESH_HIT/200
152 TCP_REFRESH_HIT/304
86 TCP_NEGATIVE_HIT/404
69 TCP_MISS/404
9 TCP_MISS/000
4 TCP_MISS/503
1 TCP_REFRESH_MISS/000
1 TCP_DENIED/400

可以使用上面的方法,大约的分析一下命令中比。什么意思就看下面的详解.

#cat /var/log/squid/access.log |grep TCP_MEM_HIT

如果看到很多的TCP_MEM_HIT ,这表明该文件是从内存缓存读取的,squid已经起作用了!你再用浏览器打开该文件,应该是快如闪电了。。呵呵,大功告成了!还有其他类型的HIT,如TCP_HIT等等,这些是从磁盘读取的,我觉得加速的意义不大,只不过缓解了apache的压力而已。

相应于HTTP请求,下列标签可能出现在access.log文件的第四个域。

TCP_HIT

Squid发现请求资源的貌似新鲜的拷贝,并将其立即发送到客户端。

TCP_MISS

Squid没有请求资源的cache拷贝。

TCP_REFERSH_HIT

Squid发现请求资源的貌似陈旧的拷贝,并发送确认请求到原始服务器。原始服务器返回304(未修改)响应,指示squid的拷贝仍旧是新鲜的。

TCP_REF_FAIL_HIT

Squid发现请求资源的貌似陈旧的拷贝,并发送确认请求到原始服务器。然而,原始服务器响应失败,或者返回的响应Squid不能理解。在此情形下,squid发送现有cache拷贝(很可能是陈旧的)到客户端。

TCP_REFRESH_MISS

Squid发现请求资源的貌似陈旧的拷贝,并发送确认请求到原始服务器。原始服务器响应新的内容,指示这个cache拷贝确实是陈旧的。

TCP_CLIENT_REFRESH_MISS

Squid发现了请求资源的拷贝,但客户端的请求包含了Cache-Control: no-cache指令。Squid转发客户端的请求到原始服务器,强迫cache确认。

TCP_IMS_HIT

客户端发送确认请求,Squid发现更近来的、貌似新鲜的请求资源的拷贝。Squid发送更新的内容到客户端,而不联系原始服务器。

TCP_SWAPFAIL_MISS

Squid发现请求资源的有效拷贝,但从磁盘装载它失败。这时squid发送请求到原始服务器,就如同这是个cache丢失一样。

TCP_NEGATIVE_HIT

在对原始服务器的请求导致HTTP错误时,Squid也会cache这个响应。在短时间内对这些资源的重复请求,导致了否命中。 negative_ttl指令控制这些错误被cache的时间数量。请注意这些错误只在内存cache,不会写往磁盘。下列HTTP状态码可能导致否定 cache(也遵循于其他约束): 204, 305, 400, 403, 404, 405, 414, 500, 501, 502, 503, 504。

TCP_MEM_HIT

Squid在内存cache里发现请求资源的有效拷贝,并将其立即发送到客户端。注意这点并非精确的呈现了所有从内存服务的响应。例如,某些cache在内存里,但要求确认的响应,会以TCP_REFRESH_HIT, TCP_REFRESH_MISS等形式记录。

TCP_DENIED

因为http_access或http_reply_access规则,客户端的请求被拒绝了。注意被http_access拒绝的请求在第9域的值是NONE/-,然而被http_reply_access拒绝的请求,在相应地方有一个有效值。

TCP_OFFLINE_HIT

当offline_mode激活时,Squid对任何cache响应返回cache命中,而不用考虑它的新鲜程度。

TCP_REDIRECT

重定向程序告诉Squid产生一个HTTP重定向到新的URI(见11.1节)。正常的,Squid不会记录这些重定向。假如要这样做,必须在编译squid前,手工定义LOG_TCP_REDIRECTS预处理指令。

NONE

无分类的结果用于特定错误,例如无效主机名。

相应于ICP查询,下列标签可能出现在access.log文件的第四域。

UDP_HIT

Squid在cache里发现请求资源的貌似新鲜的拷贝。

UDP_MISS

Squid没有在cache里发现请求资源的貌似新鲜的拷贝。假如同一目标通过HTTP请求,就可能是个cache丢失。请对比UDP_MISS_NOFETCH。

UDP_MISS_NOFETCH

跟UDP_MISS类似,不同的是这里也指示了Squid不愿去处理相应的HTTP请求。假如使用了-Y命令行选项,Squid在启动并编译其内存索引时,会返回这个标签而不是UDP_MISS。

UDP_DENIED

因为icp_access规则,ICP查询被拒绝。假如超过95%的到某客户端的ICP响应是UDP_DENIED,并且客户端数据库激活了(见附录A),Squid在1小时内,停止发送任何ICP响应到该客户端。若这点发生,你也可在cache.log里见到一个警告。

更改Android网络路由

使用的i909手机的免费流量是2G,不过如果要用手机看美剧,这个流量就有点不足。但是,当前我所被覆盖的无线网,上网需要手动设置上网路由。Android里面我还没有找到现成的能够设置路由的软件,不过经摸索,却找出了通过终端使用超级用户模式手工设置路由的办法。

首先确保机器已经root了,还安装了busybox和Emulator。

启动Emulator,然后输入命令:

# ip route show
172.18.0.0/16 dev eth0 src 172.18.3.80
default via 172.18.1.170 dev eth0

有井号的行是命令,没有的是输出结果。上述命令用于显示手机当前的路由。下面的命令删除手机的默认路由。如果出错,说明可能没有安装好busybox。

查看路由只需要普通权限,删除、添加、修改路由都需要超级用户权限。

# su ip route del default

然后,添加默认路由和一条通往内网另一个网段的路由

# su route add default gw 172.18.1.252
# su route add -net 192.30.1.0 netmask 255.255.255.0 gw 172.18.1.170

最后查看新的路由设置,下面的结果表示设置成功了。

#ip route show
192.30.1.0/24 via 172.18.1.170 dev eth0
172.18.0.0/16 dev eth0 src 172.18.3.80
default via 172.18.1.252 dev eth0

当前我使用的busybox有个问题就是命令返回出错结果,它也不会提示任何信息。此外,使用手机键盘输入实在麻烦,解决的一个办法是使用SSH,通过电脑来控制手机。

注意:不同版本的emulator, busybox, 命令稍微有差异,例如最近升级后,su命令需要而且只要首次单独执行一次,此后都不用su, 其次,route add 命令的格式也与电脑版本Linux更接近,需要用route add -net 此类的语法了。

近期升级后,我手机上修改路由的语句变成了:
su
ip route del default
route add -net 0.0.0.0 netmask 0.0.0.0 gw 172.18.1.252
route add -net 192.30.1.0 netmask 255.255.255.0 gw 172.18.1.170

发一份反编译的东东。感觉还不错

反编译(绝好!)
注意点:
1、需要软件
AXMLPrinter2.jar
baksmali.jar
smali.jar
2、用 AXMLPrinter2.jar查看apk中的布局xml文件
过程:
(1)将AXMLprinter2.jar放入某一文件夹中,建议放入SDK中的Tools中,(能不能放入到其它地方倒没试过!)
(2)然后在CMD中启动此文件,格式为:
D:\\android-sdk_r05-windows\\android-sdk-windows\\tools>
java -jar AXMLprinter2.jar   main.xml >main.txt
解释:将当前路径下的main.xml输出至当前下main.txt中。(输出之前,main.xml是乱码,输出后是个文件文件,所有东东全在里面,太TMD强了!)
3、用baksmali.jar反编译classes.dex:
(1)将baksmali.jar放入某一文件夹中,建议放入SDK中的Tools中,(能不能放入到其它地方倒没试过!)
(2)然后在CMD中启动此文件,格式为:
D:\\android-sdk_r05-windows\\android-sdk-windows\\tools>java -jar baksmali-1.2.5.jar -o classout/ classes.dex
(3)此时会在当前目录下生成一个classout文件夹,好东东全在里面了。

4、用smali.jar编译classout成classes.dex:
上一步已经将classes.dex反编译成了.smali文件,好了,我们看看smali文件看够了,在偿试把它编译成classes.dex吧,
输入如下命令:java -jar smali.jar classout/ -o classes.dex.
可以将新生成的classes.dex塞入ApkInstaller.apk里覆盖原来的classes.dex文件,这样我们的apk还是一样能用的哦~
5、特别注意:
反编译可将APK中的各种资源直接利用,例如图标等,特别好用。

关于android中的ramdisk.img及uImage无法包含驱动模块(*.ko)的问题

关于android中的ramdisk.img及uImage无法包含驱动模块(*.ko)的问题

这几天一起在整理freescale的imx53的android源码,今天在编译android kernel的时候发现make menuconfig中配置成<M>模式的驱动模块没有加入编译

之前一直是按照原厂的资料运行下面命令编译内核的:

make uImage

通过查看kernel的makefile发些了一些蛛丝马迹,现在将工作笔记记录如下:

在imx_kernel下运行终端,输入如下命令查看kernel编译相关的一些信息

make help

将会看到如下和编译相关的命令和信息

Cleaning targets:
  clean		  - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper	  - Remove all generated files + config + various backup files
  distclean	  - mrproper + remove editor backup and patch files

Configuration targets:
  config	  - Update current config utilising a line-oriented program
  nconfig         - Update current config utilising a ncurses menu based program
  menuconfig	  - Update current config utilising a menu based program
  xconfig	  - Update current config utilising a QT based front-end
  gconfig	  - Update current config utilising a GTK based front-end
  oldconfig	  - Update current config utilising a provided .config as base
  localmodconfig  - Update current config disabling modules not loaded
  localyesconfig  - Update current config converting local mods to core
  silentoldconfig - Same as oldconfig, but quietly, additionally update deps
  randconfig	  - New config with random answer to all options
  defconfig	  - New config with default answer to all options
  allmodconfig	  - New config selecting modules when possible
  allyesconfig	  - New config where all options are accepted with yes
  allnoconfig	  - New config where all options are answered with no

Other generic targets:
  all		  - Build all targets marked with [*]
* vmlinux	  - Build the bare kernel
* modules	  - Build all modules
  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
  firmware_install- Install all firmware to INSTALL_FW_PATH
                    (default: $(INSTALL_MOD_PATH)/lib/firmware)
  dir/            - Build all files in dir and below
  dir/file.[oisS] - Build specified target only
  dir/file.lst    - Build specified mixed source/assembly target only
                    (requires a recent binutils and recent build (System.map))
  dir/file.ko     - Build module including final link
  modules_prepare - Set up for building external modules
  tags/TAGS	  - Generate tags file for editors
  cscope	  - Generate cscope index
  kernelrelease	  - Output the release version string
  kernelversion	  - Output the version stored in Makefile
  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
                    (default: /data/EN3/freescale/i.MX536/i.MX53-QSB-Android-Release3.3/src/kernel_imx/usr)

Static analysers
  checkstack      - Generate a list of stack hogs
  namespacecheck  - Name space analysis on compiled kernel
  versioncheck    - Sanity check on version.h usage
  includecheck    - Check for duplicate included header files
  export_report   - List the usages of all exported symbols
  headers_check   - Sanity check on exported headers
  headerdep       - Detect inclusion cycles in headers

Kernel packaging:
  rpm-pkg         - Build both source and binary RPM kernel packages
  binrpm-pkg      - Build only the binary kernel package
  deb-pkg         - Build the kernel as an deb package
  tar-pkg         - Build the kernel as an uncompressed tarball
  targz-pkg       - Build the kernel as a gzip compressed tarball
  tarbz2-pkg      - Build the kernel as a bzip2 compressed tarball

Documentation targets:
 Linux kernel internal documentation in different formats:
  htmldocs        - HTML
  pdfdocs         - PDF
  psdocs          - Postscript
  xmldocs         - XML DocBook
  mandocs         - man pages
  installmandocs  - install man pages generated by mandocs
  cleandocs       - clean all generated DocBook files

Architecture specific targets (arm):
* zImage        - Compressed kernel image (arch/arm/boot/zImage)
  Image         - Uncompressed kernel image (arch/arm/boot/Image)
* xipImage      - XIP kernel image, if configured (arch/arm/boot/xipImage)
  uImage        - U-Boot wrapped zImage
  bootpImage    - Combined zImage and initial RAM disk
                  (supply initrd image via make variable INITRD=<path>)
  install       - Install uncompressed kernel
  zinstall      - Install compressed kernel
                  Install using (your) ~/bin/installkernel or
                  (distribution) /sbin/installkernel or
                  install to $(INSTALL_PATH) and run lilo

ellip;… ………………

 

可以看到很多编译相关的命令,如:make, make all, make clean, make uImage等等

经过测试发现运行make命令之后,在make menuconfig中配置成<M>的驱动模块都可以加入编译,但是再make uImage生成uImage文件烧到板子上的时候,在目标板上的文件系统里怎么也找不到那些*.ko文件,看了一上午android filesystem相关的资料,总算是找到了解决办法,就是通过修改android生成的ramdisk.img,用脚本把这些*.ko文件导入到android的filesystem中,下面代码就是实现整个过程的脚本:

#!/bin/sh
MAKE_KERNEL=$1

#root dir
KERNEL_DIR=$(pwd)

#out dir
OUT_DIR=${KERNEL_DIR}/../../out

#modules install path
RAMDISK_DIR=ramdisk
INSTALL_MOD_PATH=${OUT_DIR}/tmp/${RAMDISK_DIR}

#echo "make kernel?(y,n)";read MAKE_KERNEL

echo    "******************************"
echo    "*        Make Kernel         *"
echo    "******************************"
if [ "$MAKE_KERNEL"x = "n"x ]; then
	echo "*** skip ***"
else
	make -j4
	make uImage -j4
	cp arch/arm/boot/uImage ${OUT_DIR}
fi


echo    "******************************"
echo    "*    Install modules         *"
echo    "******************************"
	cd ${OUT_DIR}
	[ -e "tmp" ] || { echo "mkdir tmp"; mkdir tmp; }
	cp ./ramdisk.img ./tmp
	
#上一次退出状态: 判断ramdisk.img是否存在
case "$?" in
	"0")
		cd tmp
		mv ramdisk.img ramdisk.img.gz
		cd ./${RAMDISK_DIR}
		gunzip ramdisk.img.gz
		[ -e "${RAMDISK_DIR}" ] || { echo "mkdir ${RAMDISK_DIR}"; mkdir ${RAMDISK_DIR}; }
		cd ${RAMDISK_DIR}
		cpio -i -F ../ramdisk.img
		cd ${KERNEL_DIR}
		make modules_install             #重点在这里,在kernel目录下运行此命令时,会把相关的*.ko文件install到由INSTALL_MOD_PATH指定的目录下!!
		cd ${INSTALL_MOD_PATH}
		find . | cpio -o -H newc | gzip > ../ramdisk.img
		cd ..

		echo    "******************************"
		echo    "*    Make uramdisk.img       *"
		echo    "******************************"
		mkimage -A arm -O linux -T ramdisk -C none -a 0x70308000 -n "Android Root Filesystem" -d ./ramdisk.img ./uramdisk.img	
		mv uramdisk.img ./..
		cd ..
		rm -rf ./tmp
		cd ${KERNEL_DIR}
		echo "***OKAY***"
		;;

	"1")
		echo "ramdisk.img文件不存在!!!!!!"
		rm -rf ./tmp
		cd ${KERNEL_DIR}
		;;
esac

经过这样的处理就可以向android源码生成的ramdisk.img中install任何我们自己的东西了,把uImage和uramdisk.img一起烧到板子上,通过串口查看,得到了我想要的东西,如下:

lrwxrwxrwx radio    radio             2011-07-06 08:58 build -> /data/EN3/freescale/i.MX536/i.MX53-QSB-Android-Release3.3/src/kernel_imx
-rw-r--r-- radio    radio          81 2011-07-06 08:58 modules.isapnpmap
-rw-r--r-- radio    radio          74 2011-07-06 08:58 modules.ofmap
-rw-r--r-- radio    radio          43 2011-07-06 08:58 modules.seriomap
-rw-r--r-- radio    radio        2908 2011-07-06 08:58 modules.dep.bin
-rw-r--r-- radio    radio        1671 2011-07-06 08:58 modules.symbols.bin
lrwxrwxrwx radio    radio             2011-07-06 08:58 source -> /data/EN3/freescale/i.MX536/i.MX53-QSB-Android-Release3.3/src/kernel_imx
-rw-r--r-- radio    radio         141 2011-07-06 08:58 modules.inputmap
-rw-r--r-- radio    radio       11595 2011-07-06 08:58 modules.builtin
-rw-r--r-- radio    radio          99 2011-07-06 08:58 modules.pcimap
-rw-r--r-- radio    radio        1072 2011-07-06 08:58 modules.symbols
drwxr-xr-x radio    radio             2011-07-06 08:58 kernel
-rw-r--r-- radio    radio       13189 2011-07-06 08:58 modules.builtin.bin
-rw-r--r-- radio    radio        3795 2011-07-06 08:58 modules.alias.bin
-rw-r--r-- radio    radio         189 2011-07-06 08:58 modules.usbmap
-rw-r--r-- radio    radio        1189 2011-07-06 08:58 modules.dep
-rw-r--r-- radio    radio        4404 2011-07-06 08:58 modules.alias
-rw-r--r-- radio    radio        1042 2011-07-06 08:58 modules.order
-rw-r--r-- radio    radio          69 2011-07-06 08:58 modules.ccwmap
-rw-r--r-- radio    radio          73 2011-07-06 08:58 modules.ieee1394map

相关的*.ko驱动模块就在kernel目录下!

nginx 虚拟目录的配置

nginx貌似没有虚拟目录的说法,因为它本来就是完完全全根据目录来设计并工作的。

如果非要给nginx安上一个虚拟目录的说法,那就只有alias标签比较“像”,干脆来说说alias标签和root标签的区别吧。

最基本的区别:alias指定的目录是准确的,root是指定目录的上级目录,并且该上级目录要含有location指定名称的同名目录。另外,根据前文所述,使用alias标签的目录块中不能使用rewrite的break。

说不明白,看下配置:

location /abc/ {
alias /home/html/abc/;
}

在这段配置下,http://test/abc/a.html就指定的是/home/html/abc/a.html。这段配置亦可改成

location /abc/ {
root /home/html/;
}

这样,nginx就会去找/home/html/目录下的abc目录了,得到的结果是相同的。

但是,如果我把alias的配置改成:

location /abc/ {
alias /home/html/def/;
}

那么nginx将会从/home/html/def/取数据,这段配置还不能直接使用root配置,如果非要配置,只有在/home/html/下建立一个 def->abc的软link(快捷方式)了。

一般情况下,在location /中配置root,在location /other中配置alias是一个好习惯。

至于alias和root的区别,我估计还没有说完全,如果在配置时发现奇异问题,不妨把这两者换换试试。

MRTG 配置完整手册

主要功能:
用一个网页来监视系统的CPU,NIC,MEM,SWAP,DISK usage, DISK I/O.情况.
里面的script有部分是自已写的,也有部分是下载的.像磁盘空间那个script是下载的,但是觉得功能不是很好用,由于有现成的也就没有再写,如果哪位有更好的script望请共享.

1. 安装.
(1)需要的RPM
RHEL 3.0/4.0的安装CD带有MRTG的RPM安装包. 为了使用MRTG的一些脚本,需要安装其他的一些安装包.
Sysstat.rpm 系统状况监视安装包.(cpu.sh)
Procps.rpm 内存,Swap 使用情况工具等(cpu.sh,mem.sh,swap.sh)
Coreutils.rpm (df.pl,disk.sh)
gd-1.8.4-4
gd-devel-1.8.4-4
perl-5.6.0-17
perl-CGI
mod_perl-1.24_01-3
libpng-1.0.12-2
libpng-devel-1.0.12-2
gcc-2.96-98
gcc-g77-2.96-98
gcc-c++-2.96-98
zlib-1.1.3-24
zlib-devel-1.1.3-24
httpd(apache)
net-snmp
mrtg
检查装有没有上面rpm包.
(2)安装MRTG
  Rpm –ivh mrtg -2.9.29-4.ent.i386.rpm

 

2. 配置SNMP 让他可以配合MRTG工作
编辑/etc/snmp/snmpd.conf
把下面的#号去掉 
#view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc #在89行 
把下面的语句#在62行 
access notConfigGroup "" any noauth exact systemview none none  
改为: 
access notConfigGroup "" any noauth exact mib2 none none
改完重启一下snmp
Service snmpd restat

 

3. 配置MRTG
(1) mkdir /var/www/html/mrtg
(2) mkdir /opt/mrtg
(3) 从下面的贴子复制以下几个script 到/opt/mrtg
Cpu.sh , mem.sh , swap.sh, diskperf.sh, disk.pl
    (4) cp /var/www/mrtg/* /var/www/html/mrtg
(5) /usr/bin/cfgmaker –output=/var/www/html/mrtg/mrtg.cfg public@10.102.17.100 用来配置一个mrtg配置文件.
(6) 编辑MRTG的配置文件 vi /var/www/html/mrtg/mrtg.cfg
   (1)把WorkDir: /var/www/html/mrtg 加入到配置文件的前面.
(2)把Options[_]: growright, bits 前面的#删掉.
(3)把要监测的几个ITEM加入到配置文件里面去.
  1) CPU 
   ################CPU######################
Target[cpu]: `/opt/mrtg/cpu.sh`
MaxBytes[cpu]: 12500000
Title[cpu]: CPU -- XMNLINUXTEST02
Options[cpu]: gauge,nopercent,growright
YLegend[cpu]: CPU loading (%)
ShortLegend[cpu]:%
LegendO[cpu]: & CPU USER;
LegendI[cpu]: & CPU SYSTEM;
PageTop[cpu]: <H1>;CPU  -- XMNLINUXTEST02</H1>;
2)NIC 用配置文件自动配好的.
3)MEM  这个图最大设为2G,如果服务器有更大的内存,可以修改Maxbytes.
###############    MEM  2G  #################
Target[managemem]:`/opt/mrtg/mem.sh`
Unscaled[managemem]: dwym
MaxBytes[managemem]: 2048000
Title[managemem]:Memory
ShortLegend[managemem]: &
kmg[managemem]:kB,MB
kilo[managemem]:1024
YLegend[managemem]: Memory Usage
Legend1[managemem]: Total Memory
Legend2[managemem]: Used Memory
LegendI[managemem]: Total Memory
LegendO[managemem]: Used Memory
Options[managemem]: growright,gauge,nopercent
PageTop[managemem]:<H1>;Memory -------XMNLINUXTEST2</H1>;
4)Swap   也是设为2G,根据实际情况改MaxBytes.
################### Swap  2G#######################
Target[swap]:`/opt/mrtg/swap.sh`
Unscaled[swap]: dwym
MaxBytes[swap]: 2048000
Title[swap]:Memory State of Server
ShortLegend[swap]: &
kmg[swap]:kB,MB
kilo[swap]:1024
YLegend[swap]: Swap Usage
Legend1[swap]: Total Swap
Legend2[swap]: Used Swap
LegendI[swap]: Total Swap
LegendO[swap]: Used Swap
Options[swap]: growright,gauge,nopercent
PageTop[swap]:<H1>;Swap-------XMNLINUXTEST02</H1>;

5)设置磁盘使用量  最大为480G,可以根据实际情况修改MaxBytes
################## Disk Space  480G  #########################
Target[disk]: `/opt/mrtg/df.pl`
Title[disk]: Disk Space ----XMNLINUXTEST02
Unscaled[disk]: dwym
MaxBytes[disk]: 465247550
kmg[disk]: KB,MB,GB
LegendI[disk]: Total Disk Space
LegendO[disk]: Used Disk Space
Legend1[disk]: Total Disk Space
Legend2[disk]: Used Disk Space
YLegend[disk]:  Megabytes
ShortLegend[disk]: &
Options[disk]: growright,gauge,nopercent
PageTop[disk]: <H1>;Disk Space --------XMNLINUXTEST02</H1>;

 

6)磁盘I/O的检测,如果需要的检,更多的分区,修改并复制这个部分,并修改diskperf.sh
################## Disk I/O 100K/sec  /DEV/SDA  ##########
# If you want monitor more disk, please copy below create
# now monitor job, and copy & modify the diskperf.sh to setting disk.
Target[diskIO]: `/opt/mrtg/diskperf.sh`
Title[diskIO]: Disk HDA I/O Utilization Report
Unscaled[diskIO]: dwym
MaxBytes[diskIO]: 100
PageTop[diskIO]: <H1>;Disk I/O Utilization Report</H1>;
kmg[diskIO]: KB,MB,GB
LegendI[diskIO]: Disk I/O KBread/sec
LegendO[diskIO]: Disk I/O KBwrite/sec
Legend1[diskIO]: Disk I/O KBread/sec
Legend2[diskIO]: Disk I/O KBwrite/sec
YLegend[diskIO]:  Megabytes
ShortLegend[diskIO]: &
Options[diskIO]: growright,gauge,nopercent

 

4. 编译配置文件
先在/etc/profile 加入两个参数
LC_ALL=C
LANGUAGE=on

# env LANG=C /usr/bin/mrtg /var/www/html/mrtg/mrtg.cfg  
前面两次会出错,多运行几次就没有问题.


5. 生成html文件.
/usr/bin/indexmaker –output=/var/www/html/mrtg/index.html –title=主机名 /var/www/html/mrtg/mrtg.cfg


6. 配置apache 的设置. 
#vi /etc/httpd/conf.d/mrtg.cfg
 把Alias /mrtg /var/www/mrtg 改为Alias /mrtg /var/www/html/mrtg
 把Allow from localhost  改为Allow from all
#service httpd restart ,重启apache.


7. 配置,自运行脚本,每五分钟自动运行一次.
在root 下启动 crontab –e 添加计划
     */5 * * * *  env LANG=C /usr/bin/mrtg /var/www/html/mrtg/mrtg.cfg


8.  确认service http&crontab的运进级别.
可以用下面两个命令查看这个服务的进行状况, 
#chkconfig –list |grep httpd
#chkconfig –list |grep crontab
    或用设定运行级别
chkconfig --level 35 httpd on
chkconfig --level 35 crontab on

 

5. 常见问题
(1)问:实际内存或硬盘跟的图里面的值相差太多,要吗线超出图表,要吗,在图表的下面. 如何更改图表的比例? 如内存实际上只有512M,但表里面内存显示最大为2G.
答:修改/var/www/html/mrtg/mrtg.cfg 找到相关的部分, 修改MaxBytes[managemem]: 2048000 中的2048000为512000
(2)问:我有几个硬盘,如果要监测其他的硬盘IO?
  答:首先复制一份diskperf.sh 成diskperf2.sh ,再修改diskperf2.sh里面把hd=xxx改为你要监测的硬盘,再修改/var/www/html/mrtg/mrtg.cfg 复制sda的那一部门,并修改相关的部分.
如Target[diskIO]:`/opt/mrtg/diskperf.sh` 改成Target[diskIO]: `/opt/mrtg/diskperf2.sh`
   这一部份的[diskIO]改为disk2IO
(3)问:修改了配置文件/var/www/html/mrtg/mrtg.cfg 后,网页没有生效
  答:修改完配置文件应该要重新用下面命令生成新的网页.
/usr/bin/indexmaker –output=/var/www/html/mrtg/index.html –title=主机名 /var/www/html/mrtg/mrtg.cfg
        (4)问:如何看我的MRTG图.
          答:用http://你的IP/mrtg/ 就可以看到了.
     
附:1: mrtg.cfg 里面几个参数的意思.
Target:是要执行的脚本 
Xsize:生成图表的横向宽度(最大600) 
Ysize:生成图表的纵向高度(最大200) 
Title:标题 
kMG: Change the default multiplier prefixes
Ytics:纵向划分为几个块(格子) 
MaxBytes:图表纵向数值的最大上限 
PageTop:页面上面的提示 
kilo:一般是写1024,如果需要的话,是1000在计算机里的单位 
LegendI:从SHELL返回的数据中的第一个 
LegendO:从SHELL返回的数据中的第二个 
Options: growright,表示图表向右延展
附2:各个script
(1)
cat /opt/mrtg/cpu.sh
#!/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
hostname
(2)
Disk usage
cat /opt/mrtg/df.pl
#!/usr/bin/perl
# output(df -kl) looks like this:
# Filesystem           1k-blocks      Used Available Use% Mounted on
# /dev/md0              95645100  30401312  64272080  33% /
# /dev/hde1                14119      1159     12231   9% /boot
#
# In which case, this script returns :
# 95659219
# 30402503
# when run.
foreach $filesystem (`df -kl | grep -v "Filesystem"`)
{
  @df = split(/\s+/,$filesystem);
  $total += $df[1];
  $usage += $df[2];
}
print "$total\n";
print "$usage\n";
hostname
(3) DISK IO   # cat /opt/mrtg/diskperf.sh

#!/bin/bash
# This script will monitor the KBread/sec &KBwriten/sec of Disk.
# Creater: CCC IT loren  ext:2288   2005/8/3
# As sda ,sdb,sdc,sdd,hda.


# disk=sda
hd=sda
disk=/dev/$hd
KBread_sec=`iostat -x $disk|grep $hd |awk '{print $8}'`
KBwrite_sec=`iostat -x $disk|grep $hd |awk '{print $9}'`
echo "$KBread_sec"
echo "$KBwrite_sec"
hostname
(4)MEMORY
cat /opt/mrtg/mem.sh
#!/bin/bash
# This script to monitor the mem usage.
totalmem=`/usr/bin/free |grep Mem |awk '{print $2}'`
usedmem=`/usr/bin/free |grep Mem |awk '{print $3}'`
echo "$totalmem"
echo "$usedmem"
(5)SWAP
cat /opt/mrtg/swap.sh
#!/bin/bash
# This script to monitor the swap usage.
totalswap=`/usr/bin/free |grep Swap |awk '{print $2}'`
usedswap=`/usr/bin/free |grep Swap |awk '{print $3}'`
echo "$totalswap"
echo "$usedswap"

Mrtg系统状态监控

Mrtg系统状态监控[CPU 内存 网卡流量 系统进程 硬盘空间 TCP连接数]

----------------------------
1) 安装所需rpm包
----------------------------
net-snmp-perl-5.1.2-11.EL4.6.x86_64.rpm
net-snmp-libs-5.1.2-11.EL4.6.x86_64.rpm
net-snmp-utils-5.1.2-11.EL4.6.x86_64.rpm
net-snmp-devel-5.1.2-11.EL4.6.x86_64.rpm
   !!需要预先安装以下rpm包
   beecrypt-devel-3.1.0-6.x86_64.rpm
   elfutils-devel-0.97-5.x86_64.rpm(在第5张安装光盘上)
net-snmp-5.1.2-11.EL4.6.x86_64.rpm
net-snmp-utils-5.1.2-11.EL4.6.x86_64.rpm
安装mrtg-2.10.15-1.x86_64.rpm

----------------------------
2) 修改/etc/snmp/snmpd.conf
----------------------------
找到这行:
# Make at least  snmpwalk -v 1 59.57.251.56 -c public system fast again
#       name           incl/excl     subtree         mask(optional)
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
在view几行的下面,加上这段文字:
# For Mrtg Add start ####################################
view    all           included   .1.3.6
# For Mrtg Add end   ####################################
找到这行:
####
# Finally, grant the group read-only access to the systemview view.
#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  mib2   none   none
把 access  notConfigGroup 里的mib2(也可能是systemview) 更改为all
如果需要监控硬盘容量使用状况,还需要进行以下操作:
用 df -a 看到你要监控的硬盘分卷方式以及容量大小(-am:以M为单位; -ak:以K为单位 -ag:以G为单位)
比如:
#df -am
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda2                63993     10284     50459  17% /
/dev/sda1                  981        24       908   3% /boot

然后修改/etc/snmp/snmpd.conf,在刚才修改的view行最下面加入:
disk / 63993
disk /boot 981
然后重启snmp服务
# service snmpd restart

----------------------------
3) 修改mrtg配置文件 mrtg.cfg
----------------------------
使用Redhat AS4u5 自带的mrtg
安装以后的配置文件是/usr/local/apache/htdocs/mrtg

我们预设要监控的服务器以下参数:
连接公网网卡的流量;
主机连续运行时间;
系统负载;
CPU负载;
内存使用量;
系统进程数;
硬盘空间;
打开的TCP连接数。

mrtg.cfg配置如下:

  1. ###################### Configuration Being #########################  
  2. #---------------------------------  
  3. # filename : mrtg.cfg  
  4. # 注意如果文件夹不存在,需要先创建  
  5. #---------------------------------  
  6. ### Global Config Options  
  7. #  to get bits instead of bytes and graphs growing to the right  
  8. #Options[_]: growright, bits  
  9. EnableIPv6: no  
  10. WorkDir: /usr/local/apache/htdocs/mrtg  
  11. Language: Chinese  
  12. HtmlDir: /usr/local/apache/htdocs/mrtg  
  13. ImageDir: /usr/local/apache/htdocs/mrtg  
  14. LogDir: /var/log/mrtg  
  15. ThreshDir: /var/lib/mrtg  
  16. LoadMIBs:/usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt  
  17. #================================================================================  
  18. #监控eth0网卡(连接公网的)  
  19. #================================================================================  
  20. Target[eth0_lan]: /59.57.251.56:public@59.57.251.56:  
  21. Options[eth0_lan]: growright  
  22. Directory[eth0_lan]: eth0  
  23. MaxBytes[eth0_lan]: 100000000  
  24. Kmg[eth0_lan]: ,k,M,G,T,P  
  25. YLegend[eth0_lan]: Bytes per Second  
  26. ShortLegend[eth0_lan]: B/s  
  27. Legend1[eth0_lan]: 每秒流入量 (单位 Bytes)  
  28. Legend2[eth0_lan]: 每秒流出量 (单位 Bytes)  
  29. LegendI[eth0_lan]: 流入:  
  30. LegendO[eth0_lan]: 流出:  
  31. Title[eth0_lan]: eth0网络流量[流入+流出]  
  32. PageTop[eth0_lan]: <H1>eth0网络流量[流入+流出]</H1> 
  33. <TABLE> 
  34.   <TR><TD>描述 :</TD><TD>LAN网络接口eth0的网络流量(Bytes/s)</TD></TR> 
  35. </TABLE> 
  36. #================================================================================  
  37. #监控主机连续运行时间[运行天数] 实际操作过程中此节未配置,没有多大用途  
  38. #================================================================================  
  39. Target[upday]: `/usr/local/mrtg/bin/mrtg-updays.pl`  
  40. Options[upday]: gauge,nopercent,growright  
  41. Directory[upday]: upday  
  42. MaxBytes[upday]: 1000  
  43. YLegend[upday]: Up Days  
  44. ShortLegend[upday]: 天  
  45. Legend1[upday]: 主机连续运行时间(天)  
  46. Legend2[upday]:  
  47. LegendI[upday]: 运行时间:  
  48. LegendO[upday]:  
  49. Title[upday]: 主机连续运行时间[运行天数]  
  50. PageTop[upday]: <h1>主机连续运行时间[运行天数]</h1> 
  51. <TABLE> 
  52.   <TR><TD>描述:</TD><TD>主机连续运行的时间(天)</TD></TR> 
  53. </TABLE> 
  54. #================================================================================  
  55. #监控系统负载[1分钟+15分钟]  
  56. #================================================================================  
  57. Target[systemload]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.3:public@59.57.251.56:  
  58. Options[systemload]: gauge,nopercent,growright  
  59. Directory[systemload]: load  
  60. MaxBytes[systemload]: 3000  
  61. YLegend[systemload]: System Load  
  62. ShortLegend[systemload]:  
  63. Legend1[systemload]: 最近1分钟系统负载(x100)  
  64. Legend2[systemload]: 最近15分钟系统负载(x100)  
  65. LegendI[systemload]: 1分钟负载:  
  66. LegendO[systemload]: 15分钟负载:  
  67. Title[systemload]: 系统负载(x100)[1分钟+15分钟]  
  68. PageTop[systemload]: <h1>系统负载(x100)[1分钟+15分钟]</h1> 
  69. <TABLE> 
  70.   <TR><TD>描述:</TD><TD>系统负载(x100)[1分钟+15分钟]</TD></TR> 
  71. </TABLE> 
  72. #================================================================================  
  73. #监控CPU负载[用户+闲置]  
  74. #================================================================================  
  75. Target[cpuload]: .1.3.6.1.4.1.2021.11.50.0&1.3.6.1.4.1.2021.11.53.0:public@59.57.251.56:  
  76. Options[cpuload]: nopercent,growright  
  77. Directory[cpuload]: cpu  
  78. MaxBytes[cpuload]: 100  
  79. Unscaled[cpuload]: dwym  
  80. YLegend[cpuload]: CPU Utilization  
  81. ShortLegend[cpuload]: %;  
  82. Legend1[cpuload]: CPU用户负载(%)  
  83. Legend2[cpuload]: CPU闲置(%)  
  84. LegendI[cpuload]: 用户:  
  85. LegendO[cpuload]: 闲置:  
  86. Title[cpuload]: CPU负载[用户+闲置]  
  87. PageTop[cpuload]: <h1>CPU负载[用户+闲置]</h1> 
  88. <TABLE> 
  89.   <TR><TD>描述:</TD><TD>CPU负载[用户+闲置]</TD></TR> 
  90. </TABLE> 
  91. #================================================================================  
  92. #监控内存使用量[Mem+Swap]  
  93. #================================================================================  
  94. Target[memory]: .1.3.6.1.2.1.25.2.3.1.6.2&.1.3.6.1.2.1.25.2.3.1.6.3:public@59.57.251.56:  
  95. Options[memory]: gauge,growright  
  96. Directory[memory]: mem  
  97. MaxBytes1[memory]: 4045336  
  98. MaxBytes2[memory]: 2097152  
  99. Kmg[memory]: k,M,G,T,P  
  100. Kilo[memory]: 1024  
  101. Unscaled[memory]: dwym  
  102. YLegend[memory]: Bytes  
  103. ShortLegend[memory]: B  
  104. Legend1[memory]: 已用Mem (Bytes)  
  105. Legend2[memory]: 已用Swap(Bytes)  
  106. LegendI[memory]: 已用Mem :  
  107. LegendO[memory]: 已用Swap:  
  108. Title[memory]: 内存使用量[Mem+Swap]  
  109. PageTop[memory]: <h1>内存使用量[Mem+Swap]</h1> 
  110. <TABLE> 
  111.   <TR><TD>描述:</TD><TD>Memory和Swap的使用量(Bytes)</TD></TR> 
  112. </TABLE> 
  113. #================================================================================  
  114. #监控系统进程数[进程数]  
  115. #================================================================================  
  116. Target[process]: .1.3.6.1.2.1.25.1.6.0&.1.3.6.1.2.1.25.1.6.0:public@59.57.251.56:  
  117. Options[process]: gauge,nopercent,growright  
  118. Directory[process]: process  
  119. MaxBytes[process]: 1000  
  120. YLegend[process]: Processes  
  121. ShortLegend[process]: 个  
  122. Legend1[process]: 系统进程数(个)  
  123. Legend2[process]:  
  124. LegendI[process]: 进程数:  
  125. LegendO[process]:  
  126. Title[process]: 系统进程数[进程数]  
  127. PageTop[process]: <h1>系统进程数[进程数]</h1> 
  128. <TABLE> 
  129.   <TR><TD>描述:</TD><TD>系统进程数(个)</TD></TR> 
  130. </TABLE> 
  131. #==================================================================================  
  132. # 监控硬盘空间[系统盘+数据盘]  !!参照前面的2) 这里需要与修改后snmpd.conf 的硬盘参数一致  
  133. #==================================================================================  
  134. Target[disk]: .1.3.6.1.4.1.2021.9.1.8.1&.1.3.6.1.4.1.2021.9.1.8.2:public@59.57.251.56:  
  135. Options[disk]: gauge,growright  
  136. Directory[disk]: disk  
  137. MaxBytes1[disk]: 10080520  
  138. MaxBytes2[disk]: 46251780  
  139. Kmg[disk]: k,M,G,T,P  
  140. Kilo[disk]: 1024  
  141. Unscaled[disk]: dwym  
  142. YLegend[disk]: Bytes  
  143. ShortLegend[disk]: B  
  144. Legend1[disk]: 系统盘已用空间  
  145. Legend2[disk]: 数据盘已用空间  
  146. LegendI[disk]: 系统已用:  
  147. LegendO[disk]: 数据已用:  
  148. Title[disk]: 硬盘空间[系统盘+数据盘]  
  149. PageTop[disk]: <h1>硬盘空间[系统盘+数据盘]</h1> 
  150. <TABLE> 
  151.   <TR><TD>描述:</TD><TD>监控硬盘空间</TD></TR> 
  152. </TABLE> 
  153. #================================================================================  
  154. #监控打开的TCP连接数[TCP连接数]  
  155. #================================================================================  
  156. Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@59.57.251.56:  
  157. Options[tcpopen]: gauge,nopercent,growright  
  158. Directory[tcpopen]: tcpopen  
  159. MaxBytes[tcpopen]: 1000  
  160. YLegend[tcpopen]: Tcp Connections  
  161. ShortLegend[tcpopen]: 个  
  162. Legend1[tcpopen]: 打开的TCP连接数(个)  
  163. Legend2[tcpopen]:  
  164. LegendI[tcpopen]: TCP连接数:  
  165. LegendO[tcpopen]:  
  166. Title[tcpopen]: TCP连接数[TCP连接数]  
  167. PageTop[tcpopen]: <h1>TCP连接数[TCP连接数]</h1> 
  168. <TABLE> 
  169.   <TR><TD>描述:</TD><TD>打开的TCP连接数(个)</TD></TR> 
  170. </TABLE> 
  171. ###################### Configuration End ######################### 


注意<一>
在上面监控主机连续运行时间的配置中,有提到要使用/usr/local/mrtg/bin/mrtg-updays.pl这个文件。需要手动创建,内容如下:

  1. #!/usr/bin/perl  
  2. $machine = `/bin/hostname`;  
  3. $uptime1 = `/usr/bin/uptime`;  
  4. $uptime2 = $uptime1;  
  5. $uptime1 =~ /up (.*?) day/;  
  6. $upday = int($1);  
  7. $uptime2 =~ /up (.*?) load/;  
  8. $uptime = $1;  
  9. print "$upday\n";  
  10. print "$upday\n";  
  11. print "$uptime\n";  
  12. print $machine."\n"


保存以后修改权限为可执行:

  1. #chmod +x /usr/local/mrtg/bin/mrtg-updays.pl 

注意<二>
关于硬盘参数,一定要注意
snmp.conf与mrtg.cfg中的格式、参数一定要一致,并且完全跟df -a*的命令结果相符。否则会得到输入错误的提示信息。
 
----------------------------
4) 生成工作目录及相关文件
----------------------------
env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg/mrtg.cfg
 
----------------------------
5) 生成监控的页面文件
----------------------------
env LANG=C /usr/local/mrtg/bin/indexmaker --output /usr/local/apache/htdocs/mrtg/index.html --title="System state Monitor" /usr/local/apache/htdocs/mrtg/mrtg.cfg

6) 多服务器环境下的集中管理
mrtg主目录:/usr/local/apache/htdocs/mrtg
如果存在多服务器,建议用创建ip文件夹,方便识别:
实例:
创建一IP文件夹(117.25.130.49),
(1) 生成CFG配置文件
/usr/local/mrtg/bin/cfgmaker public@117.25.130.49 --global 'workdir: /usr/local/apache/htdocs/mrtg/117.25.130.49' --output /usr/local/apache/htdocs/mrtg/117.25.130.49/mrtg.cfg
这样生成的配置文件只是MRTG默认的配置,可以不用操作这一步,直接COPY上面的配置模板,将其中IP更改为要监控的服务器IP

(2) 生成监控页面文件
/usr/local/mrtg/bin/indexmaker --output=/usr/local/apache/htdocs/mrtg/117.25.130.49/index.html --title="System Monitor" /usr/local/apache/htdocs/mrtg/117.25.130.49/mrtg.cfg

(3) 生成工作目录及相关文件
env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg/117.25.130.49/mrtg.cfg

(4) 更改模板文件的字符集,
上面生成的html文件中,默认字符集为iso-8859-1,浏览时可能会出现乱码,可以将其更改为utf-8
# sed -i "s/charset=iso-8859-15/charset=utf-8/" filename
# sed -i "s/charset=iso-8859-1/charset=utf-8/" filename

(5) 定时执行
*/5 * * * * env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/apache/htdocs/mrtg/117.25.130.49/mrtg.cfg

(6) 浏览
http://59.57.251.56/mrtg/117.25.130.49/


(7) 防火墙
iptables -A INPUT -s 59.57.251.56 -p udp --destination-port 161 -j ACCEPT
iptables -A INPUT -s 59.57.251.56 -p udp --destination-port 162 -j ACCEPT

附:NET-SNMP Tutorial -- MRTG

  1. ### Global Config Options  
  2. EnableIPv6: no  
  3. Options[_]: growright, bits  
  4. WorkDir: /usr/local/apache/htdocs/mrtg  
  5. Language: Chinese  
  6. HtmlDir: /usr/local/apache/htdocs/mrtg  
  7. ImageDir: /usr/local/apache/htdocs/mrtg  
  8. LogDir: /var/log/mrtg  
  9. ThreshDir: /var/lib/mrtg  
  10. LoadMIBs:/usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt  
  11.  
  12. # User vs Idle CPU usage  
  13. Target[kontor.cpu]:ssCpuRawUser.0&ssCpuRawIdle.0:public@59.57.251.56  
  14. RouterUptime[kontor.cpu]: public@59.57.251.56  
  15. MaxBytes[kontor.cpu]: 100  
  16. Title[kontor.cpu]: CPU LOAD  
  17. PageTop[kontor.cpu]: <H1>User CPU Load %</H1> 
  18. Unscaled[kontor.cpu]: ymwd  
  19. ShortLegend[kontor.cpu]: %  
  20. YLegend[kontor.cpu]: CPU Utilization  
  21. Legend1[kontor.cpu]: User CPU in % (Load)  
  22. Legend2[kontor.cpu]: Idle CPU in % (Load)  
  23. Legend3[kontor.cpu]:  
  24. Legend4[kontor.cpu]:  
  25. LegendI[kontor.cpu]:  User  
  26. LegendO[kontor.cpu]:  Idle  
  27. Options[kontor.cpu]: growright,nopercent  
  28.  
  29. # User vs System CPU usage  
  30. Target[kontor.usrsys]:ssCpuRawUser.0&ssCpuRawSystem.0:public@59.57.251.56  
  31. RouterUptime[kontor.usrsys]: public@59.57.251.56  
  32. MaxBytes[kontor.usrsys]: 100  
  33. Title[kontor.usrsys]: CPU LOAD  
  34. PageTop[kontor.usrsys]: <H1>CPU (user and system) Load %</H1> 
  35. Unscaled[kontor.usrsys]: ymwd  
  36. ShortLegend[kontor.usrsys]: %  
  37. YLegend[kontor.usrsys]: CPU Utilization  
  38. Legend1[kontor.usrsys]: User CPU in % (Load)  
  39. Legend2[kontor.usrsys]: System CPU in % (Load)  
  40. Legend3[kontor.usrsys]:  
  41. Legend4[kontor.usrsys]:  
  42. LegendI[kontor.usrsys]:  User  
  43. LegendO[kontor.usrsys]:  System  
  44. Options[kontor.usrsys]: growright,nopercent  
  45.  
  46. ### Active CPU usage  
  47. Target[kontor.cpusum]:ssCpuRawUser.0&ssCpuRawUser.0:public@59.57.251.56 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@59.57.251.56 + ssCpuRawNice.0&ssCpuRawNice.0:public@59.57.251.56  
  48. RouterUptime[kontor.cpusum]: public@59.57.251.56  
  49. MaxBytes[kontor.cpusum]: 100  
  50. Title[kontor.cpusum]: CPU LOAD  
  51. PageTop[kontor.cpusum]: <H1>Active CPU Load %</H1> 
  52. Unscaled[kontor.cpusum]: ymwd  
  53. ShortLegend[kontor.cpusum]: %  
  54. YLegend[kontor.cpusum]: CPU Utilization  
  55. Legend1[kontor.cpusum]: Active CPU in % (Load)  
  56. Legend2[kontor.cpusum]:  
  57. Legend3[kontor.cpusum]:  
  58. Legend4[kontor.cpusum]:  
  59. LegendI[kontor.cpusum]:  Active  
  60. LegendO[kontor.cpusum]:  
  61. Options[kontor.cpusum]: growright,nopercent  
  62.  
  63. ###Monitoring DISK space  
  64. ###Monitoring from dskTable  
  65.  
  66. Target[kontor.root]:dskPercent.1&dskPercent.2:public@59.57.251.56  
  67. RouterUptime[kontor.root]: public@59.57.251.56  
  68. MaxBytes[kontor.root]: 100  
  69. Title[kontor.root]: DISK USAGE  
  70. PageTop[kontor.root]: <H1>DISK / and /usr Usage %</H1> 
  71. Unscaled[kontor.root]: ymwd  
  72. ShortLegend[kontor.root]: %  
  73. YLegend[kontor.root]: DISK Utilization  
  74. Legend1[kontor.root]: Root disk  
  75. Legend2[kontor.root]: /usr disk  
  76. Legend3[kontor.root]:  
  77. Legend4[kontor.root]:  
  78. LegendI[kontor.root]:  Root disk  
  79. LegendO[kontor.root]:  /usr disk  
  80. Options[kontor.root]: growright,gauge,nopercent  
  81.  
  82. ###Monitoring from hrStorageTable  
  83.  
  84. Target[kontor.hrroot]:hrStorageSize.1&hrStorageUsed.1:public@59.57.251.56  
  85. RouterUptime[kontor.hrroot]: public@59.57.251.56  
  86. MaxBytes[kontor.hrroot]: 300000  
  87. Title[kontor.hrroot]: DISK / USAGE  
  88. PageTop[kontor.hrroot]: <H1>DISK / Usage</H1> 
  89. ShortLegend[kontor.hrroot]: B  
  90. kMG[kontor.hrroot]: k,M,G,T,P  
  91. kilo[kontor.hrroot]: 1024  
  92. YLegend[kontor.hrroot]: DISK / Utilization  
  93. Legend1[kontor.hrroot]: Root disk size  
  94. Legend2[kontor.hrroot]: Root disk usage  
  95. Legend3[kontor.hrroot]:  
  96. Legend4[kontor.hrroot]:  
  97. LegendI[kontor.hrroot]:  Root disk size  
  98. LegendO[kontor.hrroot]:  Root disk usage  
  99. Options[kontor.hrroot]: growright,gauge,nopercent  
  100. Two further examples that have been offered:   
  101.  
  102. ### Monitoring TCP connections  
  103.  
  104. Target[tcpopen]:   
  105. .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@localhost   
  106. Options[tcpopen]: nopercent,growright,gauge,noinfo   
  107. Title[tcpopen]: Open TCP connections   
  108. PageTop[tcpopen]: Open TCP connections  
  109. MaxBytes[tcpopen]: 1000000   
  110. YLegend[tcpopen]: # conns   
  111. ShortLegend[tcpopen]: connections   
  112. LegendI[tcpopen]:  Connections:   
  113. LegendO[tcpopen]:   
  114. Legend1[tcpopen]: Open TCP connections   
  115.  
  116.  
  117. ### Monitoring Free Memory  
  118. Target[freemem]: .1.3.6.1.4.1.2021.4.11.0&.1.3.6.1.4.1.2021.4.11.0:public@localhost   
  119. Options[freemem]: nopercent,growright,gauge,noinfo   
  120. Title[freemem]: Free Memory   
  121. PageTop[freemem]: Free Memory  
  122. MaxBytes[freemem]: 1000000   
  123. kMG[freemem]: k,M,G,T,P,X   
  124. YLegend[freemem]: bytes   
  125. ShortLegend[freemem]: bytes   
  126. LegendI[freemem]:  Free Memory:   
  127. LegendO[freemem]:   
  128. Legend1[freemem]: Free memory, not including swap, in bytes