Network Monitoring

SNMP

command

remote script(ssh)

SNMP(监控工具)

RRDTool(绘图)

cacti(php)

  展示

  时间序列数据

Nagios

  on->Off

 

Simple Network Management Protocol(SNMP)

  The core of SNMP is a simple set of operations (and the information these operations gather)that gives administrators the ability to get or change the state of some SNMP-based device

SNMPv1

  the initial version of the SNMP protocol

  SNMPv1's security is based on communities,which are nothing more than passwords:plain-text strings that allow any SNMP-based application that knows the strings to goin access to a device's management information

  There are typically three communities in SNMPv1:read-only(只读) read-write(读写,关机),and trap(捕获,通知,被监控端主动发送信息给监控端)

SNMPv2

  It is often referred to as community-string-based SNMPv2

  This version of SNMP is technically called SNMPv2c

SNMPv3

  It adds support for strong authentication and private communication between managed entities

 

Managers and Agents

A manager is a server running some kind of software system that can handle management tasks for a network

A poll,in the context of network management,is the act of querying an agent(router,switch,Unix server,etc.)for some piece of informaiton

A trap is a way for the agent to tell the NMS that some thing has happened

  Traps are sent asynchronously,not in response to queries from the NMS

MIBs(管理信息库)

The Structur of Management Information(SMI) defines how management information is grouped and named;allowed operations;permitted data types;and the syntax for specifying MIBs

The Management Information Base(MIB) can be thought of as a database of managed objects that the agent tracks

An agent may implement many MIBs,but all agents implement a particular MIB clled MIB-II

 

The Concept of Network Management

Fault Management(故障管理)

  To detect,log,and notify users of systems or networks of problems

Configuration Management(配置管理)

  To monitor network and system configuration information

  Such as the number of hard disks

Accounting Management(记账管理)

  To ensure that computing and network resources are used fairly by all groups or individuals who access them

Performance Mnagement(性能管理)

  To measure and report on various aspects of network or system performance

Security Management(安全管理)

 

TCP/IP communication model and SNMP

SNMP Communities

SNMPv1 and SNMPv2 use the notion of communities to establish trust between managers and agents

An agent is configured with three community names: read-only, read-write, and trap

  The community names are essentially passwords

  public and private

SMI object tree

MIB-II subtree

Brief description of the MIB-II group

SNMP Operations

Each of the following SNMP operations has a standard PDU format

  get (获取一个指定oid的信息)

  getnext(获取指定节点下的所有子节点的相关信息)

  getbulk(SNMPv2 and SNMPv3)(获取指定节点下的所有子节点及子子节点相关信息,递归)

  set(发去控制指令)

  getresponse(客户端发起的获取响应)

  trap(由trap端发起)

  notification(SNMPv2 and SNMPv3)

  inform(SNMPv2 and SNMPv3)

  report(SNMPv2 and SNMPv3)

get request sequence

The getnext Operation

The getnext operation lets you issue a sequence of commands to retrieve a group of values from a MIB

# snmpwalk -v 1 -c public 127.0.0.1 system

The getbulk Operation

SNMPv2 defines the getbulk operation,which allows a management application to retrieve a large section of a table at once

The standard get operation can attempt to retrieve more than one MIB object at ance,but message sizes are limited by the agent's capabilities

Host Management Revisited

Managing your hosts is an important part of network management

The Host Resources MIB deines the fllowing seven groups:

hrsystem: 系统

hrstorage: 存储

hrdevice: 设备

hrswrun: 获取操作系统版本

hrswrunperf: 系统性能

hrswinstalled: 操作系统安装那些软件;

Host Management Revisited

The host OID is 1.3.6.1.2.1.25

  The hrSystem(1.3.6.1.2.1.25.1) group deines objects that pertion to the system itself.These objects include uptime.system date,system users,and system processes

  The hrDevice(1.3.6.1.2.1.25.3) and Storate(1.3.6.1.2.1.25.2) groups define objects pertaining to filesystems and system storage,such as system memory,disk utilization,and CPU nonidle percentage

  The hrSWRun(1.3.6.1.2.1.25.4),hrSWRunPerf(1.3.6.1.2.1.25.5),and hrSWInstalled(1.3.6.1.2.1.25.6) groups deine objects that represent various aspects of software running or installed on the system

    From these groups,you can determine what operating system is running on the host,as well as what programs the host is currently running

    The hrSWInstalled group can be used to track which software packages are installed

net-snmp(Agent)被监控端

net-snmp-utils(NMS::command)监控端,监控端要使用trap功能还要安装net-snmp,并启用snmptrapd服务;

RRDTool:

RRA: Round Robin Archive 轮转归档信息

 

About RRDTool

Round Robin Database Tool

It aims to handle time-series data like network bandwidth,temperatures,CPU load,etc

The data are stored in a round-robin database(circular buffer),thus the system storage footprint remains constant over time

It also includes tools to extract RRD data in a graphical format,for which it was originally intended

300s, PDP: Primary Data Ponit 主数据节点

CDP: Consolidation Data Point 聚合数据节点

解析度:resolution

rrd文件:

  DS:(Data Source)数据源

rrdtool

rrdtool - [workdir]| function

  create(创建空的轮转数据库)

    Set up a new Round Robin Database(RRD)

  update(向空库填充数据)

    Store new data values into an RRD

  updatev

    Operationally equivalent to update except for output

  graph(做绘图)

    Create a graph from data stored in one or several RRDs

    Apart from generating graphs,data can also be extracted to stdout

  dump(将数据取出来)

    Dump the contents of an RRD in plain ASCII.In connection with restore you can use this to move an RRD from one computer architecture to another
  restore

    Restore an RRD in XML format to a binary RRD

  fetch(只取一个数据)

    Get data for a certain time period from a RRD.The graph function uses fetch to retrieve its data from an RRD
  tune

    Alter setup of an RRD

  last(只看上个数据)

    Find the last update time of an RRD

  info

    Get information about an RRD

  rrdresize

    Change the size of individual RRAs

  xport

    Export data retrieved from one or several RRDs

  flushcached

    Flush the values for a specific RRD file from memory

  rrdcgi

    This is a standalone tool for producing RRD graphs on the fly

 

rrdtool create(创建初始化的rrd数据库文件)

rrdtool create filname(文件名字路径) [--start|-b start time](指定起始时间) [--step|-s step](解析度,时间跨度)[--no-overwrite]

[DS:ds-name:DST:dst arguments](指定数据源)

[RRA(关键字):CF(聚合函数):cf arguments(聚合函数参数)](如何做聚合)

--start|-b start time(default: now - 10s)

--step|-s step(default:300 seconds)

DS(关键字):ds-name(数据源名字):DST(数据源类型):dst arguments(数据源类型参数)

A single RRD can accept input from several data sources(DS)

ds-name is the name you will use to reference this particular data source from anRRD

  A ds-name must be 1 to 19 characters long in the characters[a-zA-Z0-9](ds-name最长19个字符,只能包含字母和数字下划线)

  DST define the Data Source Type

For GAUGE,(没做任何修改的值)COUNTER,(保存相对值,相对上个值而言,必须处于一直递增的数据)DERIVE,(保存相对值,相对上个值而言,无所谓增减)and ABSOLUTE(初始值最最原始的值来取得一个相对值) the format for a data source entry is:(数据源类型GAUGE,COUNTER,DERIVE,and ABSOLUTE)

  DS:ds-name:GAUGE|COUNTER|DERIVE|ABSOLUTE:heartbeat(当我们数据来了以后在最长多长时间内认为是对应时间槽的数据,如果在规定时间内没有到来就标记为*UNKNOWN*):min(最小值):max(最大值)

    heartbeat defines the maximum number of seconds that may pass between two updates of this data source before the value of the data source is assumed to be *UNKNOWN*

    min and max define the expected range vlues for data supplied by a data source

For COMPUTE data sources,the format is:

  DS:ds-name:COMPUTE:rpn-expression

 

RRA:CF:cf arguments

The purpose of an RRD is to store data in the round robin archives(RRA)

RRA:AVERAGE(指定聚合函数)|MIN|MAX|LAST:xff(定义unknown比例是多大的时候把它定义为unknown):steps(用于定义聚合函数对几个pdp组合起来进行聚合的):rows(计算过去每59秒为一个平均,而且保存两天平均)

  xff The xfiles factor defines what part of a consolidation interval may be mode up from *UNKNOWN* data while the consolidated value is still regarded as known

  It is given as the ratio of allowed *UNKNOWN* PDPs to the number of PDPs in the interval.Thus,it ranges from 0 to 1(exclusive)

  steps defines how many of these primary data points are used to build a consolidated data point which then goes into the archive

  rows defines how many generations of data values are kept in an RRA

 

5s, 生成随机数-->

  5s

  50s

  100s

0

  2 3 6 9

  GAUGE: 2 3 6 9

  COMPUTE: 2 1 3 3(每个在前面基础上减去的结果,不能接受负值)

  DERIVE: 2 1 3 3(每个在前面基础上减去的结果,可以接受负值)

  ABSOLUTE: 2 3 6 9(相对于初始值减去的结果,初始值为0,所以还是2 3 6 9,如果初始值为1结果为1 2 5 8)

5s,PDP

10,RRA

 

[root@localhost ~]# yum -y install net-snmp net-snmp-utils(通过yum源安装net-snmp和net-snmp-utils软件)
[root@localhost ~]# rpm -ql net-snmp | less(查看net-snmp安装生成那些文件)
/etc/logrotate.d/snmpd
/etc/rc.d/init.d/snmpd
/etc/rc.d/init.d/snmptrapd(监控端使用trap功能服务)
/etc/snmp
/etc/snmp/snmpd.conf(配置文件)
/etc/sysconfig/snmpd.options(agent使用)
/etc/sysconfig/snmptrapd.options(trap服务端使用)
/usr/bin/ucd5820stat
/usr/sbin/snmpd(snmpd服务程序)
/usr/sbin/snmptrapd(trap服务程序)
/usr/share/doc/net-snmp-5.3.2.2
/usr/share/doc/net-snmp-5.3.2.2/AGENT.txt
/usr/share/doc/net-snmp-5.3.2.2/COPYING
/usr/share/doc/net-snmp-5.3.2.2/ChangeLog.trimmed
/usr/share/doc/net-snmp-5.3.2.2/EXAMPLE.conf
/usr/share/doc/net-snmp-5.3.2.2/FAQ
/usr/share/doc/net-snmp-5.3.2.2/NEWS
/usr/share/doc/net-snmp-5.3.2.2/PORTING
/usr/share/doc/net-snmp-5.3.2.2/README
/usr/share/doc/net-snmp-5.3.2.2/README.agent-mibs
/usr/share/doc/net-snmp-5.3.2.2/README.agentx
/usr/share/doc/net-snmp-5.3.2.2/README.irix
/usr/share/doc/net-snmp-5.3.2.2/README.krb5
/usr/share/doc/net-snmp-5.3.2.2/README.mib2c
/usr/share/doc/net-snmp-5.3.2.2/README.snmpv3
/usr/share/doc/net-snmp-5.3.2.2/README.thread
/usr/share/doc/net-snmp-5.3.2.2/README.tru64
/usr/share/doc/net-snmp-5.3.2.2/TODO
/usr/share/doc/net-snmp-5.3.2.2/ipf-mod.pl
/usr/share/doc/net-snmp-5.3.2.2/passtest
/usr/share/man/man5/mib2c.conf.5.gz
/usr/share/man/man5/snmp.conf.5.gz
/usr/share/man/man5/snmp_config.5.gz
/usr/share/man/man5/snmpd.conf.5.gz
/usr/share/man/man5/snmpd.examples.5.gz
/usr/share/man/man5/snmpd.internal.5.gz
/usr/share/man/man5/snmptrapd.conf.5.gz
/usr/share/man/man5/variables.5.gz
/usr/share/man/man8/snmpd.8.gz
/usr/share/man/man8/snmptrapd.8.gz
/usr/share/snmp
/usr/share/snmp/mib2c-data
/usr/share/snmp/mib2c-data/default-mfd-top.m2c
/usr/share/snmp/mib2c-data/details-enums.m2i
/usr/share/snmp/mib2c-data/details-node.m2i
/usr/share/snmp/mib2c-data/details-table.m2i
/usr/share/snmp/mib2c-data/generic-ctx-copy.m2i
/usr/share/snmp/mib2c-data/generic-ctx-get.m2i
/usr/share/snmp/mib2c-data/generic-ctx-set.m2i
/usr/share/snmp/mib2c-data/generic-data-allocate.m2i
/usr/share/snmp/mib2c-data/generic-data-context.m2i
/usr/share/snmp/mib2c-data/generic-get-char.m2i
/usr/share/snmp/mib2c-data/generic-get-decl-bot.m2i
/usr/share/snmp/mib2c-data/generic-get-decl.m2i
/usr/share/snmp/mib2c-data/generic-get-long.m2i
/usr/share/snmp/mib2c-data/generic-get-oid.m2i
/usr/share/snmp/mib2c-data/generic-header-bottom.m2i
/usr/share/snmp/mib2c-data/generic-header-top.m2i
/usr/share/snmp/mib2c-data/generic-source-includes.m2i
/usr/share/snmp/mib2c-data/generic-table-constants.m2c
/usr/share/snmp/mib2c-data/generic-table-enums.m2c
/usr/share/snmp/mib2c-data/generic-table-indexes-from-oid.m2i
/usr/share/snmp/mib2c-data/generic-table-indexes-set.m2i
/usr/share/snmp/mib2c-data/generic-table-indexes-to-oid.m2i
/usr/share/snmp/mib2c-data/generic-table-indexes-varbind-setup.m2i
/usr/share/snmp/mib2c-data/generic-table-indexes.m2i
/usr/share/snmp/mib2c-data/generic-table-oids.m2c
/usr/share/snmp/mib2c-data/generic-value-map-func.m2i
/usr/share/snmp/mib2c-data/generic-value-map-reverse.m2i
/usr/share/snmp/mib2c-data/generic-value-map.m2i
/usr/share/snmp/mib2c-data/m2c-internal-warning.m2i
/usr/share/snmp/mib2c-data/m2c_setup_enum.m2i
/usr/share/snmp/mib2c-data/m2c_setup_node.m2i
/usr/share/snmp/mib2c-data/m2c_setup_table.m2i
/usr/share/snmp/mib2c-data/m2c_table_save_defaults.m2i
/usr/share/snmp/mib2c-data/mfd-access-container-cached-defines.m2i
/usr/share/snmp/mib2c-data/mfd-access-unsorted-external-defines.m2i
/usr/share/snmp/mib2c-data/mfd-data-access.m2c
/usr/share/snmp/mib2c-data/mfd-data-get.m2c
/usr/share/snmp/mib2c-data/mfd-data-set.m2c
/usr/share/snmp/mib2c-data/mfd-doxygen.m2c
/usr/share/snmp/mib2c-data/mfd-interactive-setup.m2c
/usr/share/snmp/mib2c-data/mfd-interface.m2c
/usr/share/snmp/mib2c-data/mfd-makefile.m2m
/usr/share/snmp/mib2c-data/mfd-persistence.m2i
/usr/share/snmp/mib2c-data/mfd-readme.m2c
/usr/share/snmp/mib2c-data/mfd-top.m2c
/usr/share/snmp/mib2c-data/node-get.m2i
/usr/share/snmp/mib2c-data/node-set.m2i
/usr/share/snmp/mib2c-data/node-storage.m2i
/usr/share/snmp/mib2c-data/node-validate.m2i
/usr/share/snmp/mib2c-data/node-varbind-validate.m2i
/usr/share/snmp/mib2c-data/parent-dependencies.m2i
/usr/share/snmp/mib2c-data/parent-set.m2i
/usr/share/snmp/mib2c-data/subagent.m2c
/usr/share/snmp/mib2c-data/syntax-COUNTER64-get.m2i
/usr/share/snmp/mib2c-data/syntax-DateAndTime-get.m2d
/usr/share/snmp/mib2c-data/syntax-DateAndTime-get.m2i
/usr/share/snmp/mib2c-data/syntax-DateAndTime-readme.m2i
/usr/share/snmp/mib2c-data/syntax-InetAddress-get.m2i
/usr/share/snmp/mib2c-data/syntax-InetAddress-set.m2i
/usr/share/snmp/mib2c-data/syntax-InetAddressType-get.m2i
/usr/share/snmp/mib2c-data/syntax-InetAddressType-set.m2i
/usr/share/snmp/mib2c-data/syntax-RowStatus-dependencies.m2i
/usr/share/snmp/mib2c-data/syntax-RowStatus-get.m2i
/usr/share/snmp/mib2c-data/syntax-RowStatus-varbind-validate.m2i
/usr/share/snmp/mib2c-data/syntax-StorageType-dependencies.m2i
/usr/share/snmp/mib2c-data/syntax-TestAndIncr-get.m2i
/usr/share/snmp/mib2c.access_functions.conf
/usr/share/snmp/mib2c.array-user.conf
/usr/share/snmp/mib2c.check_values.conf
/usr/share/snmp/mib2c.check_values_local.conf
/usr/share/snmp/mib2c.column_defines.conf
/usr/share/snmp/mib2c.column_enums.conf
/usr/share/snmp/mib2c.column_storage.conf
/usr/share/snmp/mib2c.conf
/usr/share/snmp/mib2c.container.conf
/usr/share/snmp/mib2c.create-dataset.conf
/usr/share/snmp/mib2c.genhtml.conf
/usr/share/snmp/mib2c.int_watch.conf
/usr/share/snmp/mib2c.iterate.conf
/usr/share/snmp/mib2c.iterate_access.conf
/usr/share/snmp/mib2c.mfd.conf
/usr/share/snmp/mib2c.notify.conf
/usr/share/snmp/mib2c.old-api.conf
/usr/share/snmp/mib2c.scalar.conf
/usr/share/snmp/mib2c.table_data.conf
/usr/share/snmp/mibs(当前主机所能够使用mib库文件)
/usr/share/snmp/mibs/.index
/usr/share/snmp/mibs/AGENTX-MIB.txt
/usr/share/snmp/mibs/DISMAN-EVENT-MIB.txt
/usr/share/snmp/mibs/DISMAN-SCHEDULE-MIB.txt
/usr/share/snmp/mibs/DISMAN-SCRIPT-MIB.txt
/usr/share/snmp/mibs/EtherLike-MIB.txt
/usr/share/snmp/mibs/HCNUM-TC.txt
/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
/usr/share/snmp/mibs/HOST-RESOURCES-TYPES.txt
/usr/share/snmp/mibs/IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt
/usr/share/snmp/mibs/IANA-LANGUAGE-MIB.txt
/usr/share/snmp/mibs/IANA-RTPROTO-MIB.txt
/usr/share/snmp/mibs/IANAifType-MIB.txt
/usr/share/snmp/mibs/IF-INVERTED-STACK-MIB.txt
/usr/share/snmp/mibs/IF-MIB.txt
/usr/share/snmp/mibs/INET-ADDRESS-MIB.txt
/usr/share/snmp/mibs/IP-FORWARD-MIB.txt
/usr/share/snmp/mibs/IP-MIB.txt
/usr/share/snmp/mibs/IPV6-ICMP-MIB.txt
/usr/share/snmp/mibs/IPV6-MIB.txt
/usr/share/snmp/mibs/IPV6-TC.txt
/usr/share/snmp/mibs/IPV6-TCP-MIB.txt
/usr/share/snmp/mibs/IPV6-UDP-MIB.txt
/usr/share/snmp/mibs/LM-SENSORS-MIB.txt
/usr/share/snmp/mibs/MTA-MIB.txt
/usr/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
/usr/share/snmp/mibs/NET-SNMP-EXAMPLES-MIB.txt
/usr/share/snmp/mibs/NET-SNMP-EXTEND-MIB.txt
/usr/share/snmp/mibs/NET-SNMP-MIB.txt
/usr/share/snmp/mibs/NET-SNMP-TC.txt
/usr/share/snmp/mibs/NETWORK-SERVICES-MIB.txt
/usr/share/snmp/mibs/NOTIFICATION-LOG-MIB.txt
/usr/share/snmp/mibs/RFC-1215.txt
/usr/share/snmp/mibs/RFC1155-SMI.txt
/usr/share/snmp/mibs/RFC1213-MIB.txt
/usr/share/snmp/mibs/RMON-MIB.txt
/usr/share/snmp/mibs/SCTP-MIB.txt
/usr/share/snmp/mibs/SMUX-MIB.txt
/usr/share/snmp/mibs/SNMP-COMMUNITY-MIB.txt
/usr/share/snmp/mibs/SNMP-FRAMEWORK-MIB.txt
/usr/share/snmp/mibs/SNMP-MPD-MIB.txt
/usr/share/snmp/mibs/SNMP-NOTIFICATION-MIB.txt
/usr/share/snmp/mibs/SNMP-PROXY-MIB.txt
/usr/share/snmp/mibs/SNMP-TARGET-MIB.txt
/usr/share/snmp/mibs/SNMP-USER-BASED-SM-MIB.txt
/usr/share/snmp/mibs/SNMP-USM-AES-MIB.txt
/usr/share/snmp/mibs/SNMP-USM-DH-OBJECTS-MIB.txt
/usr/share/snmp/mibs/SNMP-VIEW-BASED-ACM-MIB.txt
/usr/share/snmp/mibs/SNMPv2-CONF.txt
/usr/share/snmp/mibs/SNMPv2-MIB.txt
/usr/share/snmp/mibs/SNMPv2-SMI.txt
/usr/share/snmp/mibs/SNMPv2-TC.txt
/usr/share/snmp/mibs/SNMPv2-TM.txt
/usr/share/snmp/mibs/TCP-MIB.txt
/usr/share/snmp/mibs/TRANSPORT-ADDRESS-MIB.txt
/usr/share/snmp/mibs/UCD-DEMO-MIB.txt
/usr/share/snmp/mibs/UCD-DISKIO-MIB.txt
/usr/share/snmp/mibs/UCD-DLMOD-MIB.txt
/usr/share/snmp/mibs/UCD-IPFWACC-MIB.txt
/usr/share/snmp/mibs/UCD-SNMP-MIB.txt
/usr/share/snmp/mibs/UDP-MIB.txt
/usr/share/snmp/snmp_perl.pl
/usr/share/snmp/snmp_perl_trapd.pl
/usr/share/snmp/snmpconf-data
/usr/share/snmp/snmpconf-data/snmp-data
/usr/share/snmp/snmpconf-data/snmp-data/authopts
/usr/share/snmp/snmpconf-data/snmp-data/debugging
/usr/share/snmp/snmpconf-data/snmp-data/mibs
/usr/share/snmp/snmpconf-data/snmp-data/output
/usr/share/snmp/snmpconf-data/snmp-data/snmpconf-config
/usr/share/snmp/snmpconf-data/snmpd-data
/usr/share/snmp/snmpconf-data/snmpd-data/acl
/usr/share/snmp/snmpconf-data/snmpd-data/basic_setup
/usr/share/snmp/snmpconf-data/snmpd-data/extending
/usr/share/snmp/snmpconf-data/snmpd-data/monitor
/usr/share/snmp/snmpconf-data/snmpd-data/operation
/usr/share/snmp/snmpconf-data/snmpd-data/snmpconf-config
/usr/share/snmp/snmpconf-data/snmpd-data/system
/usr/share/snmp/snmpconf-data/snmpd-data/trapsinks
/usr/share/snmp/snmpconf-data/snmptrapd-data
/usr/share/snmp/snmpconf-data/snmptrapd-data/authentication
/usr/share/snmp/snmpconf-data/snmptrapd-data/formatting
/usr/share/snmp/snmpconf-data/snmptrapd-data/logging
/usr/share/snmp/snmpconf-data/snmptrapd-data/runtime
/usr/share/snmp/snmpconf-data/snmptrapd-data/snmpconf-config
/usr/share/snmp/snmpconf-data/snmptrapd-data/traphandle
/var/run/snmpd
(END) 
[root@localhost ~]# service snmpd start(启用snmpd服务)
Starting snmpd:                                            [  OK  ]
[root@localhost ~]# netstat -unlp(查看系统服务,-u代表udp,-n以数字显示,-l监听端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
udp        0      0 0.0.0.0:43547               0.0.0.0:*                               3701/avahi-daemon   
udp        0      0 0.0.0.0:161                 0.0.0.0:*                               4039/snmpd          
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               2973/dhclient       
udp        0      0 0.0.0.0:846                 0.0.0.0:*                               3214/rpc.statd      
udp        0      0 0.0.0.0:849                 0.0.0.0:*                               3214/rpc.statd      
udp        0      0 0.0.0.0:5353                0.0.0.0:*                               3701/avahi-daemon   
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               3175/portmap        
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               3527/cupsd          
udp        0      0 :::40122                    :::*                                    3701/avahi-daemon   
udp        0      0 :::5353                     :::*                                    3701/avahi-daemon   
提示:udp的161端口启动起来了;
[root@localhost ~]# snmpwalk -v 2c -c public localhost host(使用getnext方法监控本地host相关信息,-v指定snmp版本,-c指定团体字)
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (98792) 0:16:27.92
HOST-RESOURCES-MIB::hrSystemUptime.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
[root@localhost ~]# snmpwalk -v 2c -c public localhost(使用getnext方法监控本地所有信息,-v指定snmp版本,-c指定团体字)     
SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-308.el5 #1 SMP Fri Jan 27 17:21:15 EST 2012 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (28311) 0:04:43.11
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (5) 0:00:00.05
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.7 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.8 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.6 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.8 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (5) 0:00:00.05
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (5) 0:00:00.05
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (5) 0:00:00.05
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (113530) 0:18:55.30
HOST-RESOURCES-MIB::hrSystemUptime.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
提示:系统默认启用了两个mib让获取资源,一个是snmpv2-mib,一个叫resources-mib,还有一个叫disman-event-mib;
[root@localhost ~]# ls /usr/share/snmp/mibs/(查看/usr/share/snmp/mibs目录文件及子目录)
AGENTX-MIB.txt                       IP-FORWARD-MIB.txt         NOTIFICATION-LOG-MIB.txt    SNMP-USM-DH-OBJECTS-MIB.txt
DISMAN-EVENT-MIB.txt                 IP-MIB.txt                 RFC1155-SMI.txt             SNMPv2-CONF.txt
DISMAN-SCHEDULE-MIB.txt              IPV6-ICMP-MIB.txt          RFC1213-MIB.txt             SNMPv2-MIB.txt
DISMAN-SCRIPT-MIB.txt                IPV6-MIB.txt               RFC-1215.txt                SNMPv2-SMI.txt
EtherLike-MIB.txt                    IPV6-TCP-MIB.txt           RMON-MIB.txt                SNMPv2-TC.txt
HCNUM-TC.txt                         IPV6-TC.txt                SCTP-MIB.txt                SNMPv2-TM.txt
HOST-RESOURCES-MIB.txt               IPV6-UDP-MIB.txt           SMUX-MIB.txt                SNMP-VIEW-BASED-ACM-MIB.txt
HOST-RESOURCES-TYPES.txt             LM-SENSORS-MIB.txt         SNMP-COMMUNITY-MIB.txt      TCP-MIB.txt
IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt  MTA-MIB.txt                SNMP-FRAMEWORK-MIB.txt      TRANSPORT-ADDRESS-MIB.txt
IANAifType-MIB.txt                   NET-SNMP-AGENT-MIB.txt     SNMP-MPD-MIB.txt            UCD-DEMO-MIB.txt
IANA-LANGUAGE-MIB.txt                NET-SNMP-EXAMPLES-MIB.txt  SNMP-NOTIFICATION-MIB.txt   UCD-DISKIO-MIB.txt
IANA-RTPROTO-MIB.txt                 NET-SNMP-EXTEND-MIB.txt    SNMP-PROXY-MIB.txt          UCD-DLMOD-MIB.txt
IF-INVERTED-STACK-MIB.txt            NET-SNMP-MIB.txt           SNMP-TARGET-MIB.txt         UCD-IPFWACC-MIB.txt
IF-MIB.txt                           NET-SNMP-TC.txt            SNMP-USER-BASED-SM-MIB.txt  UCD-SNMP-MIB.txt
INET-ADDRESS-MIB.txt                 NETWORK-SERVICES-MIB.txt   SNMP-USM-AES-MIB.txt        UDP-MIB.txt
[root@localhost ~]# vim /etc/snmp/snmpd.conf(编辑snmpd.conf配置文件)  

view    systemview    included   .1.3.6.1.2.1.1(定义可以查看那些对应mib库上对应的资源)
view    systemview    included   .1.3.6.1.2.1.25.1.1

[root@localhost ~]# cd /usr/share/snmp/(切换到/usr/share/snmp目录)
[root@localhost snmp]# cd mibs/(切换到mibs/目录)
[root@localhost mibs]# less SNMPv2-MIB.txt(分页显示SNMPv2-MIB.txt) 

snmpMIBObjects OBJECT IDENTIFIER ::= { snmpMIB 1 }

--  ::= { snmpMIBObjects 1 }        this OID is obsolete
--  ::= { snmpMIBObjects 2 }        this OID is obsolete
--  ::= { snmpMIBObjects 3 }        this OID is obsolete

[root@localhost mibs]# snmpget -v 2c -c public localhost HOST-RESOURCES-MIB::hrSystemUptime.0(获取指定资源信息,-v指定snmp版本,-c指定团体字)
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (90537) 0:15:05.37
[root@localhost mibs]# snmpget -v 2c -c public localhost HOST-RESOURCES-MIB::hrSystemUptime.1(获取指定资源信息,-v指定snmp版本,-c指定团体字)
HOST-RESOURCES-MIB::hrSystemUptime.1 = No Such Instance currently exists at this OID
[root@localhost mibs]# ls(查看当前目录文件及子目录)
AGENTX-MIB.txt                       IP-FORWARD-MIB.txt         NOTIFICATION-LOG-MIB.txt    SNMP-USM-DH-OBJECTS-MIB.txt
DISMAN-EVENT-MIB.txt                 IP-MIB.txt                 RFC1155-SMI.txt             SNMPv2-CONF.txt
DISMAN-SCHEDULE-MIB.txt              IPV6-ICMP-MIB.txt          RFC1213-MIB.txt             SNMPv2-MIB.txt
DISMAN-SCRIPT-MIB.txt                IPV6-MIB.txt               RFC-1215.txt                SNMPv2-SMI.txt
EtherLike-MIB.txt                    IPV6-TCP-MIB.txt           RMON-MIB.txt                SNMPv2-TC.txt
HCNUM-TC.txt                         IPV6-TC.txt                SCTP-MIB.txt                SNMPv2-TM.txt
HOST-RESOURCES-MIB.txt               IPV6-UDP-MIB.txt           SMUX-MIB.txt                SNMP-VIEW-BASED-ACM-MIB.txt
HOST-RESOURCES-TYPES.txt             LM-SENSORS-MIB.txt         SNMP-COMMUNITY-MIB.txt      TCP-MIB.txt
IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt  MTA-MIB.txt                SNMP-FRAMEWORK-MIB.txt      TRANSPORT-ADDRESS-MIB.txt
IANAifType-MIB.txt                   NET-SNMP-AGENT-MIB.txt     SNMP-MPD-MIB.txt            UCD-DEMO-MIB.txt
IANA-LANGUAGE-MIB.txt                NET-SNMP-EXAMPLES-MIB.txt  SNMP-NOTIFICATION-MIB.txt   UCD-DISKIO-MIB.txt
IANA-RTPROTO-MIB.txt                 NET-SNMP-EXTEND-MIB.txt    SNMP-PROXY-MIB.txt          UCD-DLMOD-MIB.txt
IF-INVERTED-STACK-MIB.txt            NET-SNMP-MIB.txt           SNMP-TARGET-MIB.txt         UCD-IPFWACC-MIB.txt
IF-MIB.txt                           NET-SNMP-TC.txt            SNMP-USER-BASED-SM-MIB.txt  UCD-SNMP-MIB.txt
INET-ADDRESS-MIB.txt                 NETWORK-SERVICES-MIB.txt   SNMP-USM-AES-MIB.txt        UDP-MIB.txt
[root@localhost mibs]# less TCP-MIB.txt(分页显示TCP-MIB.txt文件内容)
......
tcp      OBJECT IDENTIFIER ::= { mib-2 6 }
......
[root@localhost mibs]# vim /etc/snmp/snmpd.conf(编辑snmpd.conf配置文件) 

view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
view    systemview    included   .1.3.6.1.2.1.6

[root@localhost ~]# service snmpd restart(重启snmpd服务)
Stopping snmpd:                                            [  OK  ]
Starting snmpd:                                            [  OK  ]
[root@localhost ~]# snmpwalk -v 2c -c public localhost tcp(查看tcp相关信息,-v指定版本,-c指定团体字)
TCP-MIB::tcpRtoAlgorithm.0 = INTEGER: other(1)
TCP-MIB::tcpRtoMin.0 = INTEGER: 200 milliseconds
TCP-MIB::tcpRtoMax.0 = INTEGER: 120000 milliseconds
TCP-MIB::tcpMaxConn.0 = INTEGER: -1
TCP-MIB::tcpActiveOpens.0 = Counter32: 0
TCP-MIB::tcpPassiveOpens.0 = Counter32: 2
TCP-MIB::tcpAttemptFails.0 = Counter32: 0
TCP-MIB::tcpEstabResets.0 = Counter32: 0
TCP-MIB::tcpCurrEstab.0 = Gauge32: 2
TCP-MIB::tcpInSegs.0 = Counter32: 1660
TCP-MIB::tcpOutSegs.0 = Counter32: 1471
TCP-MIB::tcpRetransSegs.0 = Counter32: 2
TCP-MIB::tcpConnState.0.0.0.0.22.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.111.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.916.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.25.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.199.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.631.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.2207.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.2208.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.6010.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.6011.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.172.16.100.1.22.172.16.100.254.3020 = INTEGER: established(5)
TCP-MIB::tcpConnState.172.16.100.1.22.172.16.100.254.3361 = INTEGER: established(5)
TCP-MIB::tcpConnLocalAddress.0.0.0.0.22.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.0.0.0.0.111.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.0.0.0.0.916.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.127.0.0.1.25.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.199.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.631.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.2207.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.2208.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.6010.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.6011.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.172.16.100.1.22.172.16.100.254.3020 = IpAddress: 172.16.100.1
TCP-MIB::tcpConnLocalAddress.172.16.100.1.22.172.16.100.254.3361 = IpAddress: 172.16.100.1
TCP-MIB::tcpConnLocalPort.0.0.0.0.22.0.0.0.0.0 = INTEGER: 22
TCP-MIB::tcpConnLocalPort.0.0.0.0.111.0.0.0.0.0 = INTEGER: 111
TCP-MIB::tcpConnLocalPort.0.0.0.0.916.0.0.0.0.0 = INTEGER: 916
TCP-MIB::tcpConnLocalPort.127.0.0.1.25.0.0.0.0.0 = INTEGER: 25
TCP-MIB::tcpConnLocalPort.127.0.0.1.199.0.0.0.0.0 = INTEGER: 199
TCP-MIB::tcpConnLocalPort.127.0.0.1.631.0.0.0.0.0 = INTEGER: 631
TCP-MIB::tcpConnLocalPort.127.0.0.1.2207.0.0.0.0.0 = INTEGER: 2207
TCP-MIB::tcpConnLocalPort.127.0.0.1.2208.0.0.0.0.0 = INTEGER: 2208
TCP-MIB::tcpConnLocalPort.127.0.0.1.6010.0.0.0.0.0 = INTEGER: 6010
TCP-MIB::tcpConnLocalPort.127.0.0.1.6011.0.0.0.0.0 = INTEGER: 6011
TCP-MIB::tcpConnLocalPort.172.16.100.1.22.172.16.100.254.3020 = INTEGER: 22
TCP-MIB::tcpConnLocalPort.172.16.100.1.22.172.16.100.254.3361 = INTEGER: 22
TCP-MIB::tcpConnRemAddress.0.0.0.0.22.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.0.0.0.0.111.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.0.0.0.0.916.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.25.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.199.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.631.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.2207.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.2208.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.6010.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.6011.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.172.16.100.1.22.172.16.100.254.3020 = IpAddress: 172.16.100.254
TCP-MIB::tcpConnRemAddress.172.16.100.1.22.172.16.100.254.3361 = IpAddress: 172.16.100.254
TCP-MIB::tcpConnRemPort.0.0.0.0.22.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.0.0.0.0.111.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.0.0.0.0.916.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.25.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.199.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.631.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.2207.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.2208.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.6010.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.6011.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.172.16.100.1.22.172.16.100.254.3020 = INTEGER: 3020
TCP-MIB::tcpConnRemPort.172.16.100.1.22.172.16.100.254.3361 = INTEGER: 3361
TCP-MIB::tcpInErrs.0 = Counter32: 0
TCP-MIB::tcpOutRsts.0 = Counter32: 0
TCP-MIB::tcpConnectionState.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3020 = INTEGER: established(5)
TCP-MIB::tcpConnectionState.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3361 = INTEGER: established(5)
TCP-MIB::tcpConnectionProcess.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3020 = Gauge32: 3908
TCP-MIB::tcpConnectionProcess.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3361 = Gauge32: 3947
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".22 = Gauge32: 3584
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".111 = Gauge32: 3239
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".916 = Gauge32: 3278
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".25 = Gauge32: 3633
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".199 = Gauge32: 4062
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".631 = Gauge32: 3596
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".2207 = Gauge32: 3568
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".2208 = Gauge32: 3563
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".6010 = Gauge32: 3908
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".6011 = Gauge32: 3947
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00".22 = Gauge32: 3584
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01".6010 = Gauge32: 3908
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01".6011 = Gauge32: 3947
[root@localhost ~]# snmpwalk -v 2c -c public localhost tcp | grep established | wc -l(查看tcp相关信息,-v指定版本,-c指定团体字,只显示establ
ished相关,并统计行数)
4
[root@localhost ~]# vim /etc/snmp/snmpd.conf(编辑snmpd.conf配置文件) 

#       sec.name(标识符)  source(来自那些主机可以可以获取资源)          community
#com2sec notConfigUser  default(默认主机或所有主机)       public
com2sec notConfigUser  127.0.0.1       mypublic
com2sec notConfigUser  172.16.0.0/16       mypublic

[root@localhost ~]# service snmpd restart(重启snmpd服务)
Stopping snmpd:                                            [  OK  ]
Starting snmpd:                                            [  OK  ]
[root@localhost ~]# snmpwalk -v 2c -c public 172.16.100.1 tcp(获取tcp相关信息,-v指定版本,-c指定团体字)
[root@localhost ~]# snmpwalk -v 2c -c mypublic 172.16.100.1 tcp(获取tcp相关信息,-v指定版本,-c指定团体字)
TCP-MIB::tcpRtoAlgorithm.0 = INTEGER: other(1)
TCP-MIB::tcpRtoMin.0 = INTEGER: 200 milliseconds
TCP-MIB::tcpRtoMax.0 = INTEGER: 120000 milliseconds
TCP-MIB::tcpMaxConn.0 = INTEGER: -1
TCP-MIB::tcpActiveOpens.0 = Counter32: 0
TCP-MIB::tcpPassiveOpens.0 = Counter32: 2
TCP-MIB::tcpAttemptFails.0 = Counter32: 0
TCP-MIB::tcpEstabResets.0 = Counter32: 0
TCP-MIB::tcpCurrEstab.0 = Gauge32: 2
TCP-MIB::tcpInSegs.0 = Counter32: 2266
TCP-MIB::tcpOutSegs.0 = Counter32: 1990
TCP-MIB::tcpRetransSegs.0 = Counter32: 3
TCP-MIB::tcpConnState.0.0.0.0.22.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.111.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.0.0.0.0.916.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.25.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.199.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.631.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.2207.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.2208.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.6010.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.127.0.0.1.6011.0.0.0.0.0 = INTEGER: listen(2)
TCP-MIB::tcpConnState.172.16.100.1.22.172.16.100.254.3020 = INTEGER: established(5)
TCP-MIB::tcpConnState.172.16.100.1.22.172.16.100.254.3361 = INTEGER: established(5)
TCP-MIB::tcpConnLocalAddress.0.0.0.0.22.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.0.0.0.0.111.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.0.0.0.0.916.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnLocalAddress.127.0.0.1.25.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.199.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.631.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.2207.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.2208.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.6010.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.127.0.0.1.6011.0.0.0.0.0 = IpAddress: 127.0.0.1
TCP-MIB::tcpConnLocalAddress.172.16.100.1.22.172.16.100.254.3020 = IpAddress: 172.16.100.1
TCP-MIB::tcpConnLocalAddress.172.16.100.1.22.172.16.100.254.3361 = IpAddress: 172.16.100.1
TCP-MIB::tcpConnLocalPort.0.0.0.0.22.0.0.0.0.0 = INTEGER: 22
TCP-MIB::tcpConnLocalPort.0.0.0.0.111.0.0.0.0.0 = INTEGER: 111
TCP-MIB::tcpConnLocalPort.0.0.0.0.916.0.0.0.0.0 = INTEGER: 916
TCP-MIB::tcpConnLocalPort.127.0.0.1.25.0.0.0.0.0 = INTEGER: 25
TCP-MIB::tcpConnLocalPort.127.0.0.1.199.0.0.0.0.0 = INTEGER: 199
TCP-MIB::tcpConnLocalPort.127.0.0.1.631.0.0.0.0.0 = INTEGER: 631
TCP-MIB::tcpConnLocalPort.127.0.0.1.2207.0.0.0.0.0 = INTEGER: 2207
TCP-MIB::tcpConnLocalPort.127.0.0.1.2208.0.0.0.0.0 = INTEGER: 2208
TCP-MIB::tcpConnLocalPort.127.0.0.1.6010.0.0.0.0.0 = INTEGER: 6010
TCP-MIB::tcpConnLocalPort.127.0.0.1.6011.0.0.0.0.0 = INTEGER: 6011
TCP-MIB::tcpConnLocalPort.172.16.100.1.22.172.16.100.254.3020 = INTEGER: 22
TCP-MIB::tcpConnLocalPort.172.16.100.1.22.172.16.100.254.3361 = INTEGER: 22
TCP-MIB::tcpConnRemAddress.0.0.0.0.22.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.0.0.0.0.111.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.0.0.0.0.916.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.25.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.199.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.631.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.2207.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.2208.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.6010.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.127.0.0.1.6011.0.0.0.0.0 = IpAddress: 0.0.0.0
TCP-MIB::tcpConnRemAddress.172.16.100.1.22.172.16.100.254.3020 = IpAddress: 172.16.100.254
TCP-MIB::tcpConnRemAddress.172.16.100.1.22.172.16.100.254.3361 = IpAddress: 172.16.100.254
TCP-MIB::tcpConnRemPort.0.0.0.0.22.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.0.0.0.0.111.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.0.0.0.0.916.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.25.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.199.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.631.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.2207.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.2208.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.6010.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.127.0.0.1.6011.0.0.0.0.0 = INTEGER: 0
TCP-MIB::tcpConnRemPort.172.16.100.1.22.172.16.100.254.3020 = INTEGER: 3020
TCP-MIB::tcpConnRemPort.172.16.100.1.22.172.16.100.254.3361 = INTEGER: 3361
TCP-MIB::tcpInErrs.0 = Counter32: 0
TCP-MIB::tcpOutRsts.0 = Counter32: 0
TCP-MIB::tcpConnectionState.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3020 = INTEGER: established(5)
TCP-MIB::tcpConnectionState.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3361 = INTEGER: established(5)
TCP-MIB::tcpConnectionProcess.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3020 = Gauge32: 3908
TCP-MIB::tcpConnectionProcess.ipv4."172.16.100.1".22.ipv4."172.16.100.254".3361 = Gauge32: 3947
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".22 = Gauge32: 3584
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".111 = Gauge32: 3239
TCP-MIB::tcpListenerProcess.ipv4."0.0.0.0".916 = Gauge32: 3278
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".25 = Gauge32: 3633
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".199 = Gauge32: 4124
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".631 = Gauge32: 3596
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".2207 = Gauge32: 3568
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".2208 = Gauge32: 3563
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".6010 = Gauge32: 3908
TCP-MIB::tcpListenerProcess.ipv4."127.0.0.1".6011 = Gauge32: 3947
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00".22 = Gauge32: 3584
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01".6010 = Gauge32: 3908
TCP-MIB::tcpListenerProcess.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01".6011 = Gauge32: 3947
[root@localhost ~]# man snmpnetstat(查看snmpnetstat的man帮助)

       snmpnetstat - display networking status and configuration information from a network entity via SNMP(通过snmp协议获取另一个主机相
关信息)

       snmpnetstat [common options] [-Ca] [-Cn] AGENT
       snmpnetstat [common options] [-Ci] [-Co] [-Cr] [-Cn] [-Cs] AGENT
       snmpnetstat [common options] [-Ci] [-Cn] [-CI interface] AGENT [interval]
       snmpnetstat [common options] [-Ca] [-Cn] [-Cs] [-Cp protocol] AGENT

       -Ca With the default display, show the state of all sockets; normally sockets used by server processes are not(默认配置)
       shown.

       -Cp protocol Show statistics about protocol, which is either a well-known name for a protocol or an alias  for
       it.   Some  protocol names and aliases are listed in the file /etc/protocols.  A null response typically means
       that there are no interesting numbers to report.  The program will complain if protocol is unknown or if there
       is no statistics routine for it.(指定协议)

[root@localhost ~]# snmpnetstat -v 2c -c mypublic -Ca -Cp tcp 172.16.100.1(查看172.16.100.1主机tcp相关信息,-v指定版本,-c指定团体字,-Ca默
认配置,-Cp指定协议)
Active Internet (tcp) Connections (including servers)
Proto Local Address          Remote Address         (state)
tcp   *.ssh                  *.*                   LISTEN
tcp   *.sunrpc               *.*                   LISTEN
tcp   *.916                  *.*                   LISTEN
tcp   localhost.smtp         *.*                   LISTEN
tcp   localhost.smux         *.*                   LISTEN
tcp   localhost.ipp          *.*                   LISTEN
tcp   localhost.2207         *.*                   LISTEN
tcp   localhost.2208         *.*                   LISTEN
tcp   localhost.x11-ssh-     *.*                   LISTEN
tcp   localhost.6011         *.*                   LISTEN
tcp   172.16.100.1.ssh       172.16.100.254.cifs   ESTABLISHED
tcp   172.16.100.1.ssh       172.16.100.254.kv-agenESTABLISHED
[root@localhost ~]# snmpnetstat -v 2c -c mypublic -Can -Cp tcp 172.16.100.1(查看172.16.100.1主机tcp相关信息,-v指定版本,-c指定团体字,-Can
默认配置以数字显示,-Cp指定协议)
Active Internet (tcp) Connections (including servers)
Proto Local Address          Remote Address         (state)
tcp   *.22                   *.*                   LISTEN
tcp   *.111                  *.*                   LISTEN
tcp   *.916                  *.*                   LISTEN
tcp   127.0.0.1.25           *.*                   LISTEN
tcp   127.0.0.1.199          *.*                   LISTEN
tcp   127.0.0.1.631          *.*                   LISTEN
tcp   127.0.0.1.2207         *.*                   LISTEN
tcp   127.0.0.1.2208         *.*                   LISTEN
tcp   127.0.0.1.6010         *.*                   LISTEN
tcp   127.0.0.1.6011         *.*                   LISTEN
tcp   172.16.100.1.22        172.16.100.254.3020   ESTABLISHED
tcp   172.16.100.1.22        172.16.100.254.3361   ESTABLISHED
[root@localhost ~]# chkconfig snmpd on(让snmpd开机自动启动)
[root@localhost ~]# lftp 172.16.0.1(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd Sources/rrdtool/(切换到Sources/rrdtool目录)
lftp 172.16.0.1:/pub/Sources/rrdtool> mget rrdtool-1.4.7-1.mage.i386.rpm rrdtool-devel-1.4.7-1.mage.i386.rpm rrdtool-perl-1.4.7-1.mage
.i386.rpm(下载rrd-tool、rrdtool-devel、rrdtool-perl软件包)
937655 bytes transferred
Total 3 files transferred
lftp 172.16.0.1:/pub/Sources/rrdtool> bye(退出)
[root@localhost ~]# ls(查看当前目录文件及子目录)
anaconda-ks.cfg  install.log.syslog                rrdtool-devel-1.4.7-1.el5.wrl.i386.rpm
install.log      rrdtool-1.4.7-1.el5.wrl.i386.rpm  rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm
[root@localhost ~]# rpm -ivh rrdtool-1.4.7-1.el5.wrl.i386.rpm(安装rrdtool,-i安装,-v显示过程,-h安装进度条) 
error: Failed dependencies:
	perl(RRDp) is needed by rrdtool-1.4.7-1.wrl.i386
	perl(RRDs) is needed by rrdtool-1.4.7-1.wrl.i386
	ruby is needed by rrdtool-1.4.7-1.wrl.i386
[root@localhost ~]# rpm -ivh rrdtool-1.4.7-1.el5.wrl.i386.rpm rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm(安装rrdtool和rrdtool-perl,-i安装,-
v显示安装过程,-h安装进度条)
error: Failed dependencies:
	ruby is needed by rrdtool-1.4.7-1.wrl.i386
[root@localhost ~]# yum -y --nogpgcheck install rrdtool-1.4.7-1.el5.wrl.i386.rpm rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm(通过yum源安装rrd
tool和rrdtool-perl,-y所有询问回答yes,--nogpgcheck不做gpg检查) 
[root@localhost ~]# rrdtool create test.rrd --step 5 DS:testds:GAUGE:8:0:U RRA:AVERAGE:0.5:1:17280 RRA:AVERAGE:0.5:10:3456 RRA:AVERAGE
:0.5:100:1210(创建test.rrd文件,--step 5每5秒接受一个值,不指定300秒,--start指定开始时间,不指定从10秒之前开始,DS数据源,testds数据源名称自己取,GA
UGE数据源类型,8所能接受数据最长时间,8秒内来就接受,来不了就不接受,0最小值,U最大值不确定,RRA做聚合,AVERAGE求平均值,0.5每5秒平均一次,1每一个平均一次,
17280=86400/5保存一天的,)
[root@localhost ~]# ll -h(查看当前目录文件及子目录)
total 1.2M
-rw------- 1 root root 1.1K Nov 22  2014 anaconda-ks.cfg
-rw-r--r-- 1 root root  28K Nov 22  2014 install.log
-rw-r--r-- 1 root root 3.6K Nov 22  2014 install.log.syslog
-rw-r--r-- 1 root root 873K Nov 22 04:55 rrdtool-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root  12K Nov 22 04:55 rrdtool-devel-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root  31K Nov 22 04:55 rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root 173K Nov 22 05:12 test.rrd
[root@localhost ~]# rrdtool info test.rrd(查看test.rrd文件格式) 
filename = "test.rrd"(文件名)
rrd_version = "0003"(版本)
step = 5(步进)
last_update = 1416604310(上次更新时间)
header_size = 928
ds[testds].index = 0
ds[testds].type = "GAUGE"(数据源类型)
ds[testds].minimal_heartbeat = 8(心跳时间)
ds[testds].min = 0.0000000000e+00(最小值)
ds[testds].max = NaN(最大值未知)
ds[testds].last_ds = "U"(上个值未知)
ds[testds].value = 0.0000000000e+00
ds[testds].unknown_sec = 0
rra[0].cf = "AVERAGE"(求平均值)
rra[0].rows = 17280
rra[0].cur_row = 6401
rra[0].pdp_per_row = 1
rra[0].xff = 5.0000000000e-01
rra[0].cdp_prep[0].value = NaN
rra[0].cdp_prep[0].unknown_datapoints = 0
rra[1].cf = "AVERAGE"
rra[1].rows = 3456
rra[1].cur_row = 408
rra[1].pdp_per_row = 10
rra[1].xff = 5.0000000000e-01
rra[1].cdp_prep[0].value = NaN
rra[1].cdp_prep[0].unknown_datapoints = 2
rra[2].cf = "AVERAGE"
rra[2].rows = 1210
rra[2].cur_row = 1174
rra[2].pdp_per_row = 100
rra[2].xff = 5.0000000000e-01
rra[2].cdp_prep[0].value = NaN
rra[2].cdp_prep[0].unknown_datapoints = 62

rrdtool update(在指定时间间隔内向rrdtool create所创建的数据库文件提供数据)

rrdtool {update | updatev} filename(数据库文件) [--template|-t ds-name[:ds-name]...]

[--]N|timestamp(时间戳):value[:value...(值)]

filename

--template|-t ds-name[:ds-name]...

rrd,

DS

DS

rrdtool update test.rrd timestamp:32:24

rrdtool create test.rrd DS:ds1 DS:ds2

rrdtool update test.rrd N:30:40

rrdtool update test.rrd -t ds2:ds1 40:30

 

rrdtool graph(绘图命令)

rrdtool graph|graphy filename(生成图片的文件名) [option ...]

[data definition ...](取得数据) [data calculation ...](运算)

[variable definition ...](变量) [graph element ...](图形元素)

[print element ...](显示图形)

[-s|--start time] [-e|--end time](多长时间内的数据)[-S|--step seconds](解析度)

[-t|--title string](图形名称标题)[-v|--vertical-label string](竖向标签)

[-w|--width pixels](宽度)[-h|--height pixels](高度)[-j|--only-graph](只绘制预览)[-D|--full-size-mode](可以自动缩放)

Graph Limits(图形绘制多大)

[-u|--upper-limit value](数值上限)[-l|--lower-limit value](数值下限)[-r|--rigid](固定不变,不会自动缩放)

[-A|--alt-autoscale](自动缩放)

[-J|--alt-autoscale-min](自动缩放最小值)

[-M|--alt-autoscale-max](自动缩放最大值)

[-N|--no-gridfit](不显示网格线)

X-Axis(指定横轴使用标识)

[-x|--x-grid GTM:GST(基准网格线):MTM:MST(主网格线):LTM:LST(横轴网格线对应标志多久显示一次):LPR:LFM](时间显示格式)

[-x|--x-grid none]

e.g --x-grid MINUTE:10:HOUR:1:HOUR:4:0:%X

Y-Axis(指定纵轴刻度)

[-y|--y-grid grid step:label factor](多长时间显示纵轴刻度,卷表显示时间)

[-y|--y-grid none]

[-Y|--alt-y-grid]

 

Miscellaneous

[-c--color COLORTAG#rrggbb[aa]](指定线槽颜色)

BACK backgroud(背景色)

CANVAS for the background of the actual graph(画布色)

SHADEA for the left and top border(左边和上边边界线颜色)

SHADEB for the right and bottom border(下边和右边边界线颜色)

GRID,MGRID for the major grid(主网格线颜色)

FONT for the color of the font(字体色)

AXIS for the axis of the graph(坐标色)

FRAME for the line around the color spots(边框色)

ARROW for the arrow head pointing up and forward(箭头色)

-n|--font FONTTAG:size:[font](指定字体)

[-R|--font-render-mode {normal,light,mono}](字体格式)

[-a|--imgformat PNG|SVG|EPS|PDF](图片输出格式)

[-W|--watermark string](图片加水印)

 

Data and variables(获取数据)

DEF:vname=rrdfile:ds-(定义数据获取方式)

name(数据源名称):CF[:step=step][:start=time][:end=time]

CDEF:vname=RRN expression

VDEF:vname=RPN expression

You need at least one DEF and

one LINE,AREA,GPRINT,PRINT statement to generate anything useful

 

graph

LINE(线状图)[width]:value(变量内容绘图)[#color](线条颜色)[:[legend][:STACK]][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offsef]]

AREA(面积图):value[#color][:[legend][:STACK]]

width can be a floating point number

If the color is not specified,the drawing is done 'invisibly'

Also optional is the legend box and string which will be printed in the legend section if specified

The valuecan be generated by DEF,VDEF,and CDEF

If the optional STACK modifier is used,this line is stacked on top of the previous element which can be a LINE or an AREA

GPRINT(在图上打印字符串):vname(变量值):CF(聚合函数):format(格式)

COMMENT:text

 

[root@localhost ~]# rrdtool update test.rrd N:$RANDOM(给test.rrd数据文件提供随机数据,N当前时间,$RANDOM随机值,环境变量)
[root@localhost ~]# rrdtool fetch test.rrd AVERAGE(从test.rrd取得数据做聚合函数)
1416526495: nan(nan表示unknown,没有任何对应数据)
1416526500: nan
1416526505: nan
1416526510: nan
1416526515: nan
1416526520: nan
1416526525: nan
1416526530: nan
1416526535: nan
1416526540: nan
1416526545: nan
1416526550: nan
1416526555: nan
1416526560: nan
1416526565: nan
1416526570: nan
1416526575: nan
1416526580: nan
1416526585: nan
1416526590: nan
1416526595: nan
[root@localhost ~]# vim genval.sh(编辑genval.sh脚本)

#!/bin/bash
#
while true;do
  rrdtool update test.rrd N:$RANDOM
  sleep 5
done

[root@localhost ~]# bash -n genval.sh(检查genval.sh脚本语法) 
[root@localhost ~]# bash -x genval.sh(执行genval.sh脚本) 
+ true
+ rrdtool update test.rrd N:540
+ sleep 5
+ true
+ rrdtool update test.rrd N:3089
+ sleep 5
+ true
+ rrdtool update test.rrd N:26624
+ sleep 5
+ true
+ rrdtool update test.rrd N:25460
+ sleep 5
+ true
+ rrdtool update test.rrd N:18897
+ sleep 5
+ true
+ rrdtool update test.rrd N:25194
+ sleep 5
+ true
+ rrdtool update test.rrd N:2767
+ sleep 5
[root@localhost ~]# man rrdfetch(查看rrdfetch的man帮助)
[root@localhost ~]# rrdtool fetch -r 5 test.rrd AVERAGE(从test.rrd取得数据做聚合函数,-r指定每5秒平均值)
1416613610: nan
1416613615: nan
1416613620: nan
1416613625: nan
1416613630: nan
1416613635: 3.0298919850e+03
1416613640: 2.1522661661e+04
1416613645: 2.5713828824e+04
1416613650: 2.0338313556e+04
1416613655: 2.3769529183e+04
1416613660: 7.8946868530e+03
1416613665: 1.2367522475e+04
1416613670: 1.6487653125e+04
1416613675: 2.6614931411e+04
1416613680: 1.9220308107e+04
1416613685: 2.1918416958e+04
1416613690: 1.5460822891e+04
1416613695: 2.3787300530e+04
[root@localhost ~]# rrdtool fetch -r 50 test.rrd AVERAGE(从test.rrd取得数据做聚合函数,-r指定50秒平均值)
1416613550: nan
1416613600: nan
1416613650: nan
1416613700: 1.9635305221e+04
1416613750: 1.2152931035e+04
1416613800: 2.1378752239e+04
1416613850: 1.6016728388e+04
1416613900: nan
[root@localhost ~]# rrdtool fetch -r 10 test.rrd AVERAGE(从test.rrd取得数据做聚合函数,-r指定10秒平均值)
1416613620: nan
1416613625: nan
1416613630: nan
1416613635: 3.0298919850e+03
1416613640: 2.1522661661e+04
1416613645: 2.5713828824e+04
1416613650: 2.0338313556e+04
1416613655: 2.3769529183e+04
1416613660: 7.8946868530e+03
1416613665: 1.2367522475e+04
1416613670: 1.6487653125e+04
1416613675: 2.6614931411e+04
1416613680: 1.9220308107e+04
1416613685: 2.1918416958e+04
1416613690: 1.5460822891e+04
1416613695: 2.3787300530e+04
1416613700: 2.8831880675e+04
1416613705: 1.7005905403e+04
[root@localhost ~]# rrdtool graph a.png --step 5 -s 1416613545  DEF:vartest=/root/test.rrd:testds:AVERAGE LINE1:vartest#FF0000:"testl
ine"(--step指定解析度,-s指定起始时间,DEF:vtest=test.rrd从test.rrd取得数据,AVERAGE聚合函数)
481x155

将创建的图片复制到windows系统打开查看:

[root@localhost ~]# rrdtool graph a.png --step 50 -s 1416613545  DEF:vartest=/root/test.rrd:testds:AVERAGE LINE1:vartest#FF0000:"test
line"(--step指定解析度,-s指定起始时间,DEF:vtest=test.rrd从test.rrd取得数据,AVERAGE聚合函数)
481x155

将创建的图片复制到windows系统打开查看:

[root@localhost ~]# rrdtool graph a.png -s 1416613545  DEF:vartest=/root/test.rrd:testds:AVERAGE:step=5 DEF:vartest2=/root/test.rrd:tes
tds:AVERAGE:step=50  LINE1:vartest#FF0000:"testline" LINE1:vartest2#00FF00:"testline2"(--step指定解析度,-s指定起始时间,DEF:vtest=test.rr
d从test.rrd取得数据,AVERAGE聚合函数)
481x155

将创建的图片复制到windows系统打开查看:

[root@localhost ~]# mysql(连接mysql数据库)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SHOW GLOBAL STATUS LIKE 'com_select';(查看mysql全局变量com_select相关)
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select    | 1     | 
+---------------+-------+
1 row in set (0.00 sec)

mysql> \q(退出)
Bye
[root@localhost ~]# rrdtool create mysql.rrd --step 3 DS:myselect:COUNTER:5:0:U RRA:AVERAGE:0.5:1:28800 RRA:AVERAGE:0.5:10:2880 RRA:MAX
:0.5:10:2880 RRA:LAST:0.5:10:2880(创建mysql.rrd数据文件,--step 3每3秒接受一次数据,DS定义数据源:myselect数据源名称:COUNTER数据源类型:5在5秒内接受
值,超过不接受:0最小值:U最大值不确定,RRA定义聚合函数:AVERAGE取平均值:0.5:28800,)
[root@localhost ~]# ll -h(查看当前目录文件及子目录详细信息,-h做单位换算)
total 1.5M
-rw------- 1 root root 1.1K Nov 22 09:31 anaconda-ks.cfg
-rw-r--r-- 1 root root  12K Nov 22 09:20 a.png
-rw-r--r-- 1 root root   79 Nov 22 07:37 genval.sh
-rw-r--r-- 1 root root  28K Nov 22 09:31 install.log
-rw-r--r-- 1 root root 3.6K Nov 22 09:30 install.log.syslog
-rw-r--r-- 1 root root 294K Nov 22 09:51 mysql.rrd
-rw-r--r-- 1 root root 873K Nov 22 04:55 rrdtool-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root  12K Nov 22 04:55 rrdtool-devel-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root  31K Nov 22 04:55 rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root 173K Nov 22 08:50 test.rrd
[root@localhost ~]# mysql -e "SHOW GLOBAL STATUS LIKE 'com_select'"(显示mysql的全局变量com_select相关,-e直接执行命令)
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select    | 3     | 
+---------------+-------+
[root@localhost ~]# mysql --batch -e "SHOW GLOBAL STATUS LIKE 'com_select'"(显示mysql的全局变量com_select相关,-e直接执行命令,--batch不显示
表格,-e直接在shell中执行sql语句)
Variable_name	Value
Com_select	4
[root@localhost ~]# mysql --batch -e "SHOW GLOBAL STATUS LIKE 'com_select'" | awk '/Com_select/{print $2}'(显示mysql的全局变量com_select
相关,-e直接执行命令,--batch不显示表格,-e直接在shell中执行sql语句,将结果送给awk查找Com_slect相关的端取得第二段)
5
[root@localhost ~]# vim getselect.sh(编辑getselect.sh脚本)

#!/bin/bash
#
while true; do
  mysql --batch -e "SHOW GLOBAL STATUS LIKE 'com_select'" | awk '/Com_select/{print $2}'
  sleep 3
done

[root@localhost ~]# bash -x getselect.sh(前台执行getselect.sh脚本) 
+ true
+ mysql --batch -e 'SHOW GLOBAL STATUS LIKE '\''com_select'\'''
+ awk '/Com_select/{print $2}'
6
+ sleep 3
[root@localhost ~]# vim getselect.sh(编辑getselect.sh脚本)

#!/bin/bash
#
while true; do
  SELECT=`mysql --batch -e "SHOW GLOBAL STATUS LIKE 'com_select'" | awk '/Com_select/{print $2}'`
  rrdtool update mysql.rrd N:$SELECT
  sleep 3
done

[root@localhost ~]# bash -x getselect.sh(前台执行getselect.sh脚本)
+ true
++ mysql --batch -e 'SHOW GLOBAL STATUS LIKE '\''com_select'\'''
++ awk '/Com_select/{print $2}'
+ SELECT=16
+ rrdtool update mysql.rrd N:16
+ sleep 3
[root@localhost ~]# mysql(连接mysql数据库)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SHOW DATABASES;(显示数据库)
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
| test               | 
+--------------------+
3 rows in set (0.00 sec)

mysql> CREATE DATABASE testdb;(创建testdb库)
Query OK, 1 row affected (0.00 sec)

mysql> CREATE TABLE tb1(ID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,NAME CHAR(50) NOT NULL);(创建表tb1,字段ID,INT整型,UNSIGNED
无符号,NOT NULL不允许为空,AUTO_INCREMENT自动增长,PRIMARY  KEY主键,NAME字段,CHAR(50)字符型,最长50字符,NOT NULL不允许为空)
Query OK, 0 rows affected (0.00 sec)

mysql> \q(退出)
Bye
[root@localhost ~]# vim insert.sh(编辑insert.sh脚本)

#!/bin/bash
#
for I in {1..200000};do
  mysql -e "INSERT INTO testdb.tb1(NAME) VALUES ('stu$I')"
  mysql -e "SELECT * FROM testdb.tb1" &> /dev/null
done

[root@localhost ~]# bash -n insert.sh(检查insert.sh脚本语法)
[root@localhost ~]# bash -x insert.sh(前台执行insert.sh脚本)
+ for I in '{1..200000}'
+ mysql -e 'INSERT INTO testdb.tb1(NAME) VALUES ('\''stu1'\'')'
+ mysql -e 'SELECT * FROM testdb.tb1'
+ for I in '{1..200000}'
+ mysql -e 'INSERT INTO testdb.tb1(NAME) VALUES ('\''stu2'\'')'
+ mysql -e 'SELECT * FROM testdb.tb1'
+ for I in '{1..200000}'
+ mysql -e 'INSERT INTO testdb.tb1(NAME) VALUES ('\''stu3'\'')'
+ mysql -e 'SELECT * FROM testdb.tb1'
+ for I in '{1..200000}'
+ mysql -e 'INSERT INTO testdb.tb1(NAME) VALUES ('\''stu4'\'')'
+ mysql -e 'SELECT * FROM testdb.tb1'
[root@localhost ~]# rrdtool fetch -r 5 mysql.rrd AVERAGE(从mysql.rrd数据文件每5秒获取数据取平均值)
1416621594: nan
1416621597: nan
1416621600: 3.2915883256e-01
1416621603: 3.2798021927e-01
1416621606: 3.3046830956e-01
1416621609: 3.3018655615e-01
1416621612: 3.3125570725e-01
1416621615: 3.3052847717e-01
1416621618: 3.3035517544e-01
1416621621: 3.2998406611e-01
1416621624: 3.2962570496e-01
1416621627: 3.3083352879e-01
1416621630: 3.3054882774e-01
1416621633: 3.3053688815e-01
1416621636: 3.3020041305e-01
1416621639: 3.2742716440e-01
[root@localhost ~]# rrdtool fetch -r 30 mysql.rrd AVERAGE(从mysql.rrd数据文件取得每30秒的平均值)
1416621540: nan
1416621570: nan
1416621600: nan
1416621630: 3.3017665724e-01
1416621660: 3.6258741757e-01
1416621690: 3.3048060663e-01
1416621720: 3.3046300956e-01
1416621750: 3.3030262361e-01
1416621780: 3.6413501331e-01
1416621810: 3.3046736786e-01
1416621840: 3.3047538462e-01
1416621870: 3.3033258931e-01
1416621900: 3.3004622105e-01
1416621930: 3.3058142239e-01
1416621960: 3.3040870552e-01
[root@localhost ~]# rrdtool fetch -r 30 mysql.rrd MAX(从mysql.rrd数据文件取得每30秒的最大值)
1416621300: nan
1416621330: nan
1416621360: nan
1416621390: nan
1416621420: nan
1416621450: nan
1416621480: nan
1416621510: nan
1416621540: nan
1416621570: nan
1416621600: nan
1416621630: 3.3125570725e-01
1416621660: 6.3269270609e-01
1416621690: 3.3131339424e-01
1416621720: 3.3064808155e-01
1416621750: 3.3063684831e-01
1416621780: 5.5789266242e-01
1416621810: 3.3080243604e-01
1416621840: 3.3104295069e-01
1416621870: 3.3056361059e-01
1416621900: 3.3078814821e-01
1416621930: 3.3192705472e-01
1416621960: 3.3068030079e-01
[root@localhost ~]# rrdtool fetch -r 30 mysql.rrd LAST(从mysql.rrd数据文件取得30秒上次的值)
1416621360: nan
1416621390: nan
1416621420: nan
1416621450: nan
1416621480: nan
1416621510: nan
1416621540: nan
1416621570: nan
1416621600: nan
1416621630: 3.3054882774e-01
1416621660: 3.2986865851e-01
1416621690: 3.3046249982e-01
1416621720: 3.3059153730e-01
1416621750: 3.3030197671e-01
1416621780: 3.3139078488e-01
[root@localhost ~]# rrdtool last test.rrd(查看test.rrd数据文件上一个值)
1416617431
[root@localhost ~]# rrdtool fetch -r 30 mysql.rrd AVERAGE(从mysql.rrd数据文件取得30秒平均值)
1416620490: nan
1416620520: nan
1416620550: nan
1416620580: nan
1416620610: nan
1416620640: nan
1416620670: nan
1416620700: nan
1416620730: nan
1416620760: nan
1416620790: nan
1416620820: nan
1416620850: nan
1416620880: nan
1416620910: nan
1416620940: nan
1416620970: nan
1416621000: nan
1416621030: nan
1416621060: nan
1416621090: nan
1416621120: nan
1416621150: nan
1416621180: nan
1416621210: nan
1416621240: nan
1416621270: nan
1416621300: nan
1416621330: nan
1416621360: nan
1416621390: nan
1416621420: nan
1416621450: nan
1416621480: nan
1416621510: nan
1416621540: nan
1416621570: nan
1416621600: nan
1416621630: 3.3017665724e-01
1416621660: 3.6258741757e-01
1416621690: 3.3048060663e-01
1416621720: 3.3046300956e-01
1416621750: 3.3030262361e-01
1416621780: 3.6413501331e-01
1416621810: 3.3046736786e-01
1416621840: 3.3047538462e-01
1416621870: 3.3033258931e-01
1416621900: 3.3004622105e-01
1416621930: 3.3058142239e-01
1416621960: 3.3040870552e-01
1416621990: 3.3050509275e-01
1416622020: 3.3054441566e-01
1416622050: 3.3078807289e-01
1416622080: 3.2938846832e-01
1416622110: 3.3031814470e-01
1416622140: 3.3035150284e-01
1416622170: 3.3018446850e-01
1416622200: 6.3823560215e+00
1416622230: 3.7897330944e+01
1416622260: 4.1957000793e+01
1416622290: 2.1638642307e+02
1416622320: 1.9571490665e+02
1416622350: 1.7974944286e+02
1416622380: 1.6669577200e+02
1416622410: 1.5797727619e+02
1416622440: 1.4779799988e+02
1416622470: 1.3987206363e+02
1416622500: 1.3351129727e+02
1416622530: 1.1283841730e+02
1416622560: 1.2095043519e+02
1416622590: 1.1730096743e+02
1416622620: 1.1178812264e+02
1416622650: 1.0855442657e+02
1416622680: 1.0056748732e+02
1416622710: 1.0215690908e+02
1416622740: 9.8727816199e+01
1416622770: 9.8970824662e+01
1416622800: 9.6746056351e+01
[root@localhost ~]# rrdtool graph mysql.png -s 1416620490 -t "mysql select" -v "select/3" DEF:select3=mysql.rrd:myselect:AVERAGE:step=3
 LINE1:select3#FF0000:"SELECT"(绘图mysql.png,-s指定起始时间,-t指定指定标题,-v垂直标签,DEF数据源:select3=mysql.rrd 3秒取值:myselect数据源:AVER
AGE平均值:step=3 3秒,LINE1线图:select3#FF0000颜色,SELECT线条名称)
497x173

将创建的图片复制到windows系统打开查看:

[root@localhost ~]# rrdtool graph mysql.png -s 1416620490 -t "mysql select" -v "select/3" DEF:select30=mysql.rrd:myselect:AVERAGE:step
=30 LINE1:select30#FF0000:"SELECT"(绘图mysql.png,-s指定起始时间,-t指定指定标题,-v垂直标签,DEF数据源:select30=mysql.rrd 30秒取值:myselect数据
源:AVERAGE平均值:step=30 30秒,LINE1线图:select30#FF0000颜色,SELECT线条名称)
497x173

将创建的图片复制到windows系统打开查看:

[root@localhost ~]# rrdtool graph mysql.png -s 1416620490 -t "mysql select" -v "selects/3" DEF:select30=mysql.rrd:myselect:AVERAGE:step
=30 DEF:max30=mysql.rrd:myselect:MAX:step=30 LINE1:select30#FF0000:"SELECT" GPRINT:max30:MAX:"%6.3lf"(绘图mysql.png,-s指定起始时间,-t指
定指定标题,-v垂直标签,DEF数据源:select30=mysql.rrd 30秒取值:myselect数据源:AVERAGE平均值:step=30 30秒,LINE1线图:select30#FF0000颜色,SELECT线
条名称)
497x173

将创建的图片复制到windows系统打开查看:

[root@localhost ~]# rrdtool graph mysql.png -s 1416620490 -t "mysql select" -v "selects/3" DEF:select30=mysql.rrd:myselect:AVERAGE:ste
p=30 DEF:max30=mysql.rrd:myselect:MAX:step=30 LINE1:select30#FF0000:"SELECT" GPRINT:max30:MAX:"MAXIMUM\: %6.3lf"(绘图mysql.png,-s指定
起始时间,-t指定指定标题,-v垂直标签,DEF数据源:select30=mysql.rrd 30秒取值:myselect数据源:AVERAGE平均值:step=30 30秒,LINE1线图:select30#FF0000
颜色,SELECT线条名称)
497x173 

将创建的图片复制到windows系统打开查看:

[root@localhost ~]# rrdtool graph mysql.png -s 1416620490 -t "mysql select" -v "selects/3" DEF:select30=mysql.rrd:myselect:AVERAGE:
step=30 DEF:max30=mysql.rrd:myselect:MAX:step=30 DEF:last30=mysql.rrd:myselect:LAST:step=30 LINE1:select30#FF0000:"SELECT" GPRINT:
last30:LAST:"CURRENT\: %10.2lf" GPRINT:max30:MAX:"MAXIMUM\: %6.3lf"(绘图mysql.png,-s指定起始时间,-t指定指定标题,-v垂直标签,DEF数据源:s
elect30=mysql.rrd 30秒取值:myselect数据源:AVERAGE平均值:step=30 30秒,LINE1线图:select30#FF0000颜色,SELECT线条名称)
497x173

将创建的图片复制到windows系统打开查看:

cacti

  rrdtool create

  周期性执行能够取得数据的命令,并将取回的数据保存至刚创建的rrd文件当中

  利用rrdtool绘图并展示

php开发网页程序

  LAMP, LNMP

  --enable-sockets php安装选项

插件机制

  thold 报警功能

模版:

  图形模版 定义图是如何绘制

  数据模版 定义如何获得数据,获得以后怎么保存,保存到什么文件中

  主机模版 归好类的图形模版和数据模版

 

cacti

  脚本

  SNMP

  ssh

保存数据

图形模版

/var/www/html/cacti

http://172.16.100.1/cacti/

/web/vhosts/cacti

http://cacti.magedu.com/cacti

poller.php单线程,速度慢,在大批量要将poller.php缓存spine(官网提供)

 

收集方法:数据收集方法

  数据查询:一些事先定义好的xml格式数据手机方法

  数据输入方法:命令或者脚本

    脚本:

      只需要指定如何获取数据,并且获取到的数据经过处理后要按规定格式输出;

        TAG:data TAG:data(标签加数据格式,不能有多余空格)

        input:30 output:40

 

安装snmp和rrd-tools:

[root@localhost ~]# yum -y install net-snmp net-snmp-utils(通过yum源安装net-snmp和net-snmp-utils软件)
[root@localhost ~]# service snmpd start(启用snmpd服务)
Starting snmpd:                                            [  OK  ]
[root@localhost ~]# netstat -unlp(查看系统服务,-u代表udp,-n以数字显示,-l监听端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
udp        0      0 0.0.0.0:43547               0.0.0.0:*                               3701/avahi-daemon   
udp        0      0 0.0.0.0:161                 0.0.0.0:*                               4039/snmpd          
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               2973/dhclient       
udp        0      0 0.0.0.0:846                 0.0.0.0:*                               3214/rpc.statd      
udp        0      0 0.0.0.0:849                 0.0.0.0:*                               3214/rpc.statd      
udp        0      0 0.0.0.0:5353                0.0.0.0:*                               3701/avahi-daemon   
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               3175/portmap        
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               3527/cupsd          
udp        0      0 :::40122                    :::*                                    3701/avahi-daemon   
udp        0      0 :::5353                     :::*                                    3701/avahi-daemon   
提示:udp的161端口启动起来了;
[root@localhost ~]# chkconfig snmpd on(让snmpd开机自动启动)
[root@localhost ~]# vim /etc/snmp/snmpd.conf 

view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
view    systemview    included   .1.3.6.1.2.1.6
[root@localhost ~]# service snmpd restart(启动snmpd服务)
Stopping snmpd:                                            [  OK  ]
Starting snmpd:                                            [  OK  ]
[root@localhost ~]# ll(查看当前目录文件及子目录详细信息)
total 196808
-rw-------  1 root      root       1074 Nov 22  2014 anaconda-ks.cfg
drwxr-sr-x 26      5000 10001      4096 Nov 22 02:05 apr-1.4.6
-rw-r--r--  1 root      root     785724 Nov 22 01:58 apr-1.4.6.tar.bz2
drwxr-xr-x 20      1000  1000      4096 Nov 22 02:07 apr-util-1.5.2
-rw-r--r--  1 root      root     693258 Nov 22 01:58 apr-util-1.5.2.tar.bz2
-rw-r--r--  1 root      root    2273280 Aug 31  2016 cacti-0.8.8a.tar.gz
drwxr-xr-x 12 cactiuser games      4096 Nov 22 02:27 httpd-2.4.4
-rw-r--r--  1 root      root    4780289 Sep 11  2015 httpd-2.4.4.tar.bz2
-rw-r--r--  1 root      root      28330 Nov 22  2014 install.log
-rw-r--r--  1 root      root       3672 Nov 22  2014 install.log.syslog
-rw-r--r--  1 root      root     126663 Sep 20  2015 libmcrypt-2.5.7-5.el5.i386.rpm
-rw-r--r--  1 root      root     105196 Sep 20  2015 libmcrypt-devel-2.5.7-5.el5.i386.rpm
-rw-r--r--  1 root      root  179907710 Sep 15  2015 mysql-5.5.28-linux2.6-i686.tar.gz
drwxr-xr-x 18 cactiuser games      4096 Nov 22 03:57 php-5.4.13
-rw-r--r--  1 root      root   11545777 Sep 20  2015 php-5.4.13.tar.bz2
-rw-r--r--  1 root      root     893831 Aug 24  2016 rrdtool-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r--  1 root      root      12168 Aug 24  2016 rrdtool-devel-1.4.7-1.el5.wrl.i386.rpm
-rw-r--r--  1 root      root      31739 Aug 24  2016 rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm
[root@localhost ~]# yum -y --nogpgcheck install rrdtool-1.4.7-1.el5.wrl.i386.rpm rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm(通过yum源安装rrd
tool和rrdtool-perl,-y所有询问回答yes,--nogpgcheck不做gpg检查) 
安装LAMP平台:
[root@localhost httpd-2.4.4]# yum -y groupinstall "Development Libraries" "Development Tools"(安装开发库和开发工具)
[root@localhost ~]# tar jvxf apr-1.4.6.tar.bz2(解压apr,j bz2压缩格式文件,v显示过程,x解压,f后面跟文件) 
[root@localhost ~]# cd apr-1.4.6(切换到arp-1.4.6目录)
[root@localhost apr-1.4.6]# yum -y install gcc(安装gcc)
[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr(配置apr,--prefix指定安装目录)
[root@localhost apr-1.4.6]# make && make install(编译并安装)
[root@localhost apr-1.4.6]# cd(切换到用户家目录)
[root@localhost ~]# tar jvxf apr-util-1.5.2.tar.bz2(解压arp-util,j bz2压缩格式文件,-v显示过程,x解压,f后面跟文件)
[root@localhost ~]# cd apr-util-1.5.2(切换到arp-util目录)
[root@localhost apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr(配置arp-util,--prefix指定安装目录,
--with-arp指定apr安装路径)
[root@localhost apr-util-1.5.2]# make && make install(编译并安装)
[root@localhost apr-1.4.6]# cd(切换到用户家目录)
[root@localhost ~]# tar jvxf httpd-2.4.4.tar.bz2(解压httpd,j bz2压缩格式文件,v显示过程,x解压,f后面跟文件)
[root@localhost ~]# cd httpd-2.4.4(切换到httpd-2.4.4目录)
[root@localhost httpd-2.4.4]# yum -y install pcre-devel(安装pcre-devel软件)
[root@localhost httpd-2.4.4]# yum -y install openssl-devel(安装openssl-devel软件)
[root@localhost httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --en
able-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-
shared=all --with-mpm=event(编译httpd,--prefix指定安装路径,--sysconfdir指定配置文件路径,--enable-so支持动态共享模块,--enable-rewirte支持url重
写,--enable-ssl启用ssl功能,--enable-cgi支持cgi,--enable-cgid支持cgid,被线程MPM使用,使用event或worker用MPM需要启用cgid,--enable-modules支持
模块,--enable-mods是否启用共享模块,--enable-mpm-shared启用那些MPM,而且以共享方式启用,--with-apr指定apr安装路径,--with-apr-util指定apr-util安装
路径,)
[root@localhost httpd-2.4.4]# make && make install(编译并安装)
[root@localhost httpd-2.4.4]# vim /etc/httpd/httpd.conf(编辑httpd.conf配置文件)

PidFile  "/var/run/httpd.pid"

[root@localhost httpd-2.4.4]# vim /etc/rc.d/init.d/httpd(编辑httpd服务脚本)

#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#	       HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc -p ${pidfile} -d 10 $httpd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
    echo -n $"Reloading $prog: "
    if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
        RETVAL=$?
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        status -p ${pidfile} $httpd
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  condrestart)
	if [ -f ${pidfile} ] ; then
		stop
		start
	fi
	;;
  reload)
        reload
	;;
  graceful|help|configtest|fullstatus)
	$apachectl $@
	RETVAL=$?
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
	exit 1
esac

exit $RETVAL

[root@localhost httpd-2.4.4]# chmod +x /etc/rc.d/init.d/httpd(给httpd执行权限)
[root@localhost httpd-2.4.4]# chkconfig --add httpd(将Httpd添加系统服务)
[root@localhost ~]# vim /etc/profile.d/httpd.sh(编辑httpd二进制命令环境变量)

export PATH=$PATH:/usr/local/apache/bin/

[root@localhost ~]# . /etc/profile.d/httpd.sh(重读httpd.sh文件) 
[root@localhost ~]# fdisk /dev/sda(管理磁盘分区,进入交互模式)

The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p(显示当前分区情况)

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2624    20972857+  83  Linux
/dev/sda3            2625        2755     1052257+  82  Linux swap / Solaris

Command (m for help): n(新建分区)
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4(分区号)
First cylinder (2756-6527, default 2756): 
Using default value 2756
Last cylinder or +size or +sizeM or +sizeK (2756-6527, default 6527): 
Using default value 6527

Command (m for help): n(新建分区)
First cylinder (2756-6527, default 2756): 
Using default value 2756
Last cylinder or +size or +sizeM or +sizeK (2756-6527, default 6527): +20G(创建20G分区)

Command (m for help): t(更改分区类型)
Partition number (1-5): 5(分区号)
Hex code (type L to list codes): 8e(类型为LVM)
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): p(显示当前分区情况)

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2624    20972857+  83  Linux
/dev/sda3            2625        2755     1052257+  82  Linux swap / Solaris
/dev/sda4            2756        6527    30298590    5  Extended
/dev/sda5            2756        5188    19543041   8e  Linux LVM

Command (m for help): w(保存退出)
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]# partprobe /dev/sda(让内核重读分区表)
[root@localhost ~]# pvcreate /dev/sda5(将/dev/sda5创建为PV物理卷) 
  Writing physical volume data to disk "/dev/sda5"
  Physical volume "/dev/sda5" successfully created
[root@localhost ~]# vgcreate myvg /dev/sda5(创建/dev/sda5创建为卷组)
  Volume group "myvg" successfully created
[root@localhost ~]# lvcreate -n mydata -L 5G myvg(创建LV逻辑卷,-L大小为5G,-n名字mydata)
  Logical volume "mydata" created
[root@localhost ~]# lvs(查看系统上LV逻辑卷信息)
  LV     VG   Attr   LSize Origin Snap%  Move Log Copy%  Convert
  mydata myvg -wi-a- 5.00G      
[root@localhost ~]# mkfs.ext3 /dev/myvg/mydata(将/dev/myvg/mydata格式化为ext3类型文件系统) 
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]# mkdir /mydata(创建mydata目录)
[root@localhost ~]# vim /etc/fstab (编辑开机自动挂载配置文件)

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/dev/myvg/mydata        /mydata                 ext3    defaults        0 0

[root@localhost ~]# mount -a(挂载/etc/fstab文件中所有文件系统)
[root@localhost ~]# mount(查看系统所有挂载的文件系统)
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sr0 on /media type iso9660 (ro)
/dev/mapper/myvg-mydata on /mydata type ext3 (rw)
[root@localhost ~]# mkdir /mydata/data(创建data目录)
[root@localhost ~]# ll /mydata/(查看/mydata目录文件及子目录详细信息)
total 24
drwxr-xr-x 2 root root  4096 Nov 22 02:48 data
drwx------ 2 root root 16384 Nov 22 02:45 lost+found
[root@localhost ~]# groupadd -r mysql(创建系统组mysql)
[root@localhost ~]# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql(创建mysql用户,-g指定基本组,-r指定系统用户,-s指定默认shell
,-M不创建家目录,-d指定家目录)
[root@localhost ~]# chown -R mysql:mysql /mydata/data/(更改/mydata/data属主属组为mysql,-R递归更改)
[root@localhost ~]# tar zvxf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local/(解压mysql,z gizp压缩格式,v显示过程,x解压,f后面跟文件,-C更改
解压目录)
[root@localhost ~]# cd /usr/local/(切换到/usr/local目录)
[root@localhost local]# ln -sv mysql-5.5.28-linux2.6-i686 mysql(为mysql-5.5.28创建软连接叫mysql,-s软连接,-v显示创建过程)
create symbolic link `mysql' to `mysql-5.5.28-linux2.6-i686'
[root@localhost local]# cd mysql(切换到mysql)
[root@localhost mysql]# chown -R mysql:mysql ./*(更改当前目录所有文件属主属组为mysql,-R递归更改)
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data(初始化mysql,--user指定运行mysql服务用户,--datadir指
定数据文件 目录)
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

You have mail in /var/spool/mail/root
[root@localhost mysql]# chown -R root ./*(更改当前目录所有文件的属主为root,-R递归更改)
[root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf(复制my-large.cnf到/etc/my.cnf配置文件)

thread_concurrency = 2

datadir         = /mydata/data

[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld(复制服务脚本)
[root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld(给mysqld文件执行权限)
[root@localhost mysql]# chkconfig --add mysqld(将mysqld添加系统服务)
[root@localhost mysql]# chkconfig mysqld on(让mysqld服务在相应系统级别开机自动启动)
[root@localhost mysql]# vim /etc/man.config(编辑man.conf配置文件)

MANPATH /usr/man
MANPATH /usr/share/man
MANPATH /usr/local/man
MANPATH /usr/local/share/man
MANPATH /usr/X11R6/man
MANPATH /usr/local/mysql/man

[root@localhost mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql(输出mysql的头文件至系统头文件路径,创建软连接,-s软连接,-v显示创
建过程)
create symbolic link `/usr/include/mysql' to `/usr/local/mysql/include/'
[root@localhost mysql]# echo '/usr/local/mysql/lib/' > /etc/ld.so.conf.d/mysql.conf(输出mysql的库文件给系统库查找路径)
[root@localhost mysql]# ldconfig(让系统重新载入系统库) 
[root@localhost bin]# vim /etc/profile.d/mysql.sh

export PATH=$PATH:/usr/local/mysql/bin

[root@localhost bin]# . /etc/profile.d/mysql.sh(重读mysql.sh环境变量配置文件) 
[root@localhost bin]# cd(切换到用户家目录)
[root@localhost ~]# yum -y groupinstall "X Software Development" (通过yum源安装X software development,-y所有询问回答yes)
[root@localhost ~]# yum -y localinstall --nogpgcheck libmcrypt-2.5.7-5.el5.i386.rpm libmcrypt-devel-2.5.7-5.el5.i386.rpm(安装本地rpm包,
-y所有询问回答yes,--nogpgcheck不做gpg校验) 
[root@localhost ~]# tar jvxf php-5.4.13.tar.bz2(解压php,j bz2格式压缩,v显示过程,x解压,f后面跟文件) 
[root@localhost ~]# cd php-5.4.13(切换到php-5.4.13目录)
[root@localhost php-5.4.13]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local
/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enab
le-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-d
ir=/etc/php.d --with-bz2  --enable-maintainer-zts(配置php)
[root@localhost php-5.4.13]# make(编译)
[root@localhost php-5.4.13]# make test(编译测试)
Do you want to send this report now? [Yns]: y

Please enter your email address.
(Your address will be mangled so that it will not go out on any
mailinglist in plain text): yamadie

Posting to http://qa.php.net/buildtest-process.php

Thank you for helping to make PHP better.
[root@localhost php-5.4.13]# make install(安装)
[root@localhost php-5.4.13]# cp php.ini-production /etc/php.ini(复制php配置文件)
[root@localhost php-5.4.13]# vim /etc/httpd/httpd.conf(编辑httpd.conf配置文件)

    AddType application/x-httpd-php  .php
    AddType application/x-httpd-php-source  .phps

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>


[root@localhost ~]# service httpd start(启动httpd服务)
Starting httpd:                                            [  OK  ]
[root@localhost ~]# service mysqld start(启动mysqld服务)
Starting MySQL...                                          [  OK  ]
[root@localhost ~]# vim /etc/httpd/httpd.conf(编辑httpd.conf配置文件)

#DocumentRoot "/usr/local/apache/htdocs"(注释中心主机)

# Virtual hosts
Include /etc/httpd/extra/httpd-vhosts.conf

[root@localhost ~]# vim /etc/httpd/extra/httpd-vhosts.conf(编辑httpd-vhosts.conf配置文件) 

<VirtualHost *:80>
    ServerName cacti.magedu.com
    DocumentRoot /web/vhosts/cacti
    <Directory "/web/vhosts/cacti">
        Optons Indexes
        AllowOverride none
        Require all granted
    </Directory>
    ErrorLog "logs/cacti-error_log"
    CustomLog "logs/cacti-access_log" common
</VirtualHost>

[root@localhost ~]# ls(查看当前目录文件及子目录)
anaconda-ks.cfg    apr-util-1.5.2          httpd-2.4.4          install.log.syslog                    mysql-5.5.28-linux2.6-i686.tar.gz
apr-1.4.6          apr-util-1.5.2.tar.bz2  httpd-2.4.4.tar.bz2  libmcrypt-2.5.7-5.el5.i386.rpm        php-5.4.13
apr-1.4.6.tar.bz2  cacti-0.8.8a.tar.gz     install.log          libmcrypt-devel-2.5.7-5.el5.i386.rpm  php-5.4.13.tar.bz2
[root@localhost ~]# mkdir -pv /web/vhosts(创建/web/vhosts目录)
mkdir: created directory `/web'
mkdir: created directory `/web/vhosts'
[root@localhost ~]# tar zxvf cacti-0.8.8a.tar.gz -C /web/vhosts/(解压cacti到/web/vhots目录,-z gip格式文件,x解压,v显示过程,f后面跟文件,-C
更改解压目录)
[root@localhost ~]# cd /web/vhosts/(切换到/web/vhosts目录)
[root@localhost vhosts]# ls(查看当前目录文件及子目录)
cacti-0.8.8a
[root@localhost vhosts]# ln -sv cacti-0.8.8a cacti(给cacti-0.8.8a创建软连接叫cacti,-s软连接,-v显示创建过程)
create symbolic link `cacti' to `cacti-0.8.8a'
[root@localhost vhosts]# ll(查看当前目录文件及子目录)
total 12
lrwxrwxrwx  1 root root    12 Nov 22 04:27 cacti -> cacti-0.8.8a
drwxr-xr-x 13 1000 users 4096 Apr 23  2012 cacti-0.8.8a
[root@localhost vhosts]# service httpd restart(重启httpd服务)
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@localhost vhosts]# cd cacti(切换到cacti目录)
[root@localhost cacti]# ls(查看当前目录文件及子目录)
about.php                cmd.php             docs                graphs_new.php              graph_xport.php     install
plugins.php              rra                 templates_export.php                            auth_changepassword.php
color.php                gprint_presets.php  graphs.php          host.php                    lib                 poller_commands.php
rra.php                  templates_import.php                    auth_login.php              data_input.php      graph_image.php
graph_templates_inputs.php                   host_templates.php  LICENSE                     poller_export.php   scripts
tree.php                 cacti.sql(sql脚本设定了cacti所用表的所有语句,但是没有指定创建数据库的语句) data_queries.php    graph.php
graph_templates_items.php                    images              log                         poller.php          script_server.php
user_admin.php           cdef.php            data_sources.php    graph_settings.php          graph_templates.php include
logout.php               README              script_server.pl    utilities.php               cli                 data_templates.php
graphs_items.php         graph_view.php      index.php           plugins                     resource            settings.php
[root@localhost cacti]# mysqladmin create cactidb(创建cactidb数据库)
[root@localhost cacti]# mysql cactidb < cacti.sql(将cacti.sql语句创建的表导入到cactidb库中) 
[root@localhost cacti]# mysql -e "GRANT ALL ON cactidb.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'"(直接在shell中执行sql语句,创建
cactiuser用户密码cactiuser,授权对cactidb库所有表所有权限)
[root@localhost cacti]# mysqladmin flush-privileges(刷新授权表)
[root@localhost cacti]# mysql -ucactiuser -p(通过cactiuser连接mysql数据库)
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.28-log MySQL Community Server (GPL)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW DATABASES;(显示库)
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cactidb            |
| test               |
+--------------------+
3 rows in set (0.04 sec)

mysql> \q(退出)
Bye
[root@localhost cacti]# ls(查看当前目录文件及子目录)
about.php                data_templates.php          graph_templates.php  log(日志)                  scripts(脚本)
auth_changepassword.php  docs                        graph_view.php       logout.php           script_server.php
auth_login.php           gprint_presets.php          graph_xport.php      plugins(插件)              script_server.pl
cacti.sql                graph_image.php             host.php             plugins.php          settings.php
cdef.php                 graph.php                   host_templates.php   poller_commands.php  templates_export.php
cli                      graph_settings.php          images(cacti图片)               poller_export.php    templates_import.php
cmd.php                  graphs_items.php            include              poller.php           tree.php
color.php                graphs_new.php              index.php            README               user_admin.php
data_input.php           graphs.php                  install(安装目录)              resource(xml模版资源)             utilities.php
data_queries.php         graph_templates_inputs.php  lib(库)                  rra(保存rrd文件)
data_sources.php         graph_templates_items.php   LICENSE              rra.php
[root@localhost cacti]# cd include/(切换到include目录)
[root@localhost include]# ls(查看当前目录文件及子目录)
auth.php           global_arrays.php     global.php           layout.js    top_graph_header.php  zoom.js
bottom_footer.php  global_constants.php  global_settings.php  main.css     top_header.php
config.php(配置文件)         global_form.php       jscalendar           plugins.php  treeview
[root@localhost include]# vim config.php(编辑config.php文件)

$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";
$database_ssl = false;

//$url_path = "/cacti/";
$url_path = "/";

[root@localhost include]# useradd cactiuser(创建cactiuser用户)
[root@localhost include]# cd ..(切换到上级目录)
[root@localhost cacti]# pwd(查看当前所处路径)
/web/vhosts/cacti
[root@localhost cacti]# chown -R cactiuser:cactiuser rra/ log(更改rra和log目录属主属组为cactiuser,-R递归更改)
[root@localhost cacti]# ll(查看当前目录文件及子目录详细信息)
total 1320
-rw-r--r-- 1      1000 users       5945 Apr 23  2012 about.php
-rw-r--r-- 1      1000 users       5348 Apr 23  2012 auth_changepassword.php
-rw-r--r-- 1      1000 users      14288 Apr 23  2012 auth_login.php
-rw-r--r-- 1      1000 users     178349 Apr 23  2012 cacti.sql
-rw-r--r-- 1      1000 users      21658 Apr 23  2012 cdef.php
drwxr-xr-x 2      1000 users       4096 Apr 23  2012 cli
-rw-r--r-- 1      1000 users      26620 Apr 23  2012 cmd.php
-rw-r--r-- 1      1000 users       6974 Apr 23  2012 color.php
-rw-r--r-- 1      1000 users      25068 Apr 23  2012 data_input.php
-rw-r--r-- 1      1000 users      35505 Apr 23  2012 data_queries.php
-rw-r--r-- 1      1000 users      60117 Apr 23  2012 data_sources.php
-rw-r--r-- 1      1000 users      32920 Apr 23  2012 data_templates.php
drwxr-xr-x 5      1000 users       4096 Apr 23  2012 docs
-rw-r--r-- 1      1000 users       6107 Apr 23  2012 gprint_presets.php
-rw-r--r-- 1      1000 users       3657 Apr 23  2012 graph_image.php
-rw-r--r-- 1      1000 users      13469 Apr 23  2012 graph.php
-rw-r--r-- 1      1000 users       9208 Apr 23  2012 graph_settings.php
-rw-r--r-- 1      1000 users      17426 Apr 23  2012 graphs_items.php
-rw-r--r-- 1      1000 users      40166 Apr 23  2012 graphs_new.php
-rw-r--r-- 1      1000 users      60571 Apr 23  2012 graphs.php
-rw-r--r-- 1      1000 users      10006 Apr 23  2012 graph_templates_inputs.php
-rw-r--r-- 1      1000 users      18542 Apr 23  2012 graph_templates_items.php
-rw-r--r-- 1      1000 users      26703 Apr 23  2012 graph_templates.php
-rw-r--r-- 1      1000 users      40313 Apr 23  2012 graph_view.php
-rw-r--r-- 1      1000 users       6022 Apr 23  2012 graph_xport.php
-rw-r--r-- 1      1000 users      60031 Apr 23  2012 host.php
-rw-r--r-- 1      1000 users      20031 Apr 23  2012 host_templates.php
drwxr-xr-x 2      1000 users       4096 Apr  4  2012 images
drwxr-xr-x 4      1000 users       4096 Nov 22 04:42 include
-rw-r--r-- 1      1000 users       2313 Apr 23  2012 index.php
drwxr-xr-x 2      1000 users       4096 Apr 23  2012 install
drwxr-xr-x 3      1000 users       4096 Apr 23  2012 lib
-rw-r--r-- 1      1000 users      15141 Apr  4  2012 LICENSE
drwxr-xr-x 2 cactiuser cactiuser   4096 Apr  4  2012 log
-rw-r--r-- 1      1000 users       2838 Apr 23  2012 logout.php
drwxr-xr-x 2      1000 users       4096 Apr 23  2012 plugins
-rw-r--r-- 1      1000 users      27362 Apr 23  2012 plugins.php
-rw-r--r-- 1      1000 users       4310 Apr 23  2012 poller_commands.php
-rw-r--r-- 1      1000 users       2243 Apr 23  2012 poller_export.php
-rw-r--r-- 1      1000 users      18056 Apr 23  2012 poller.php
-rw-r--r-- 1      1000 users         48 Apr  4  2012 README
drwxr-xr-x 5      1000 users       4096 Apr  4  2012 resource
drwxr-xr-x 2 cactiuser cactiuser   4096 Apr  4  2012 rra
-rw-r--r-- 1      1000 users       7394 Apr 23  2012 rra.php
drwxr-xr-x 2      1000 users       4096 Apr 23  2012 scripts
-rw-r--r-- 1      1000 users      10820 Apr 23  2012 script_server.php
-rw-r--r-- 1      1000 users        353 Apr  4  2012 script_server.pl
-rw-r--r-- 1      1000 users       5761 Apr 23  2012 settings.php
-rw-r--r-- 1      1000 users       6345 Apr 23  2012 templates_export.php
-rw-r--r-- 1      1000 users       5835 Apr 23  2012 templates_import.php
-rw-r--r-- 1      1000 users      19529 Apr 23  2012 tree.php
-rw-r--r-- 1      1000 users      44997 Apr 23  2012 user_admin.php
-rw-r--r-- 1      1000 users      65635 Apr 23  2012 utilities.php
提示:最好事先将cacti目录文件及子目录更改为root用户root组;

安装cacti:

通过编辑windows的hosts文件解析172.16.100.1对应的域名cacti.magedu.com,在windows的ie浏览器输入http://cacti.magedu.com;

点击下一步,新安装还是升级,选择New Install点击Next;

RRDTool Binary Path:/usr/local/bin/rrdtool rrdtool路径
PHP Binary Path:/usr/local/php/bin/php php执行程序路径
snmpwalk Binary Path:/usr/local/bin/snmpwalk snmp工具当中所提供命令的路径;
snmpget Binary Path:/usr/local/bin/snmpget
snmpbulkwalk Binary Path:/usr/local/bin/snmpbulkwalk
snmpgetnext Binary Path:/usr/local/bin/snmpgetnext
Cacti Log File Path: /web/vhosts/cacti-0.8.8a/log/cacti.log cactil日志;
SNMP Utility Version:snmp utility 版本
设置完正确的路径,点击完成;

安装完成,默认用户名admin,密码admin,点击Login;

第一次登录要更改默认密码;

 

登录成功;

console:控制台,所有编辑控制都在控制台;

graphs:监控那些主机,每台主机图形;

Create:创建内容

New Graphs:创建新图像

Management: 管理

Collection Methods:数据收集定义;

Templates: 模版;

Import/Export: 导入导出模版;

Configuration: 配置cacti的工作特性的;

Utilities: 管理cacti工具;

[root@localhost cacti]# ls
about.php                data_queries.php    graphs_new.php              images      plugins.php          script_server.php
auth_changepassword.php  data_sources.php    graphs.php                  include     poller_commands.php  script_server.pl
auth_login.php           data_templates.php  graph_templates_inputs.php  index.php   poller_export.php    settings.php
cacti.sql                docs                graph_templates_items.php   install     poller.php(周期性任务计划脚本,会把定义好的数据查询和
数据输入方法已经被确定要收集数据的,而且知道收集完以后保存到什么地方的数据每隔一段时间执行一次,php写的功能很弱,而且只支持单线程)           templates_export.php
cdef.php                 gprint_presets.php  graph_templates.php         lib         README               templates_import.php
cli                      graph_image.php     graph_view.php              LICENSE     resource             tree.php
cmd.php                  graph.php           graph_xport.php             log         rra                  user_admin.php
color.php                graph_settings.php  host.php                    logout.php  rra.php              utilities.php
data_input.php           graphs_items.php    host_templates.php          plugins     scripts
[root@localhost cacti]# cd(切换到用户家目录)
[root@localhost ~]# echo '*/5 * * * * /usr/local/php/bin/php /web/vhosts/cacti/poller.php &> /dev/null' > /var/spool/cron/cactiuser
(给cactiuser创建任务计划,每隔5分钟使用php执行poller.php脚本)
[root@localhost ~]# crontab -u cactiuser -e(给cactiuser创建任务计划)

*/5 * * * * /usr/local/php/bin/php /web/vhosts/cacti/poller.php &> /dev/null

[root@localhost ~]# su - cactiuser(切换到cactiuser用户)
[cactiuser@localhost ~]$ /usr/local/php/bin/php /web/vhosts/cacti/poller.php(通过php执行poller.php)  
提示:如果报错,是因为编译安装的php没有指定时区,要给它指定时区;
[cactiuser@localhost ~]$ exit(退出cactiuser用户)
logout
[root@localhost ~]# vim /etc/php.ini(编辑php.ini配置文件)

date.timezone = Asia/Shanghai

/date
[root@localhost ~]# service httpd restart(重启httpd服务)
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@localhost ~]# su - cactiuser(切换到cactiuser用户)
[cactiuser@localhost ~]$ /usr/local/php/bin/php /web/vhosts/cacti/poller.php(通过php执行poller.php) 
11/22/2014 06:34:43 AM - SYSTEM STATS: Time:0.1226 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:0
 RRDsProcessed:0
[cactiuser@localhost ~]$ cd /web/vhosts/cacti/log(切换到/web/vhosts/cacti/log目录)
[cactiuser@localhost log]$ ls(查看当前目录文件及子目录)
cacti.log
[cactiuser@localhost log]$ tail cacti.log(查看cacti.log日志文件后10行) 
11/21/2014 10:25:01 PM - SYSTEM STATS: Time:0.1864 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:0
 RRDsProcessed:0
11/21/2014 10:30:01 PM - SYSTEM STATS: Time:0.1203 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:0
 RRDsProcessed:0
11/22/2014 06:34:43 AM(时间) - SYSTEM STATS: Time:0.1226(执行了多长时间) Method:cmd.php Processes:1(有几个进程) Threads:N/A(线程)
 Hosts:2(主机数) HostsPerProcess:2 DataSources:0(几个数据源) RRDsProcessed:0(几个rrd文件)
[cactiuser@localhost log]$ ls ../rra(查看rra目录文件及子目录)
[cactiuser@localhost log]$ date(查看系统时间)
Sat Nov 22 06:42:08 CST 2014
[cactiuser@localhost ~]$ exit(退出当前用户)
logout
[root@localhost ~]# hwclock -s(将硬件时间同步到系统时间)
[root@localhost ~]# date(查看系统时间)
Wed Sep  7 22:09:33 CST 2016
[root@localhost ~]# service httpd restart(重启httpd服务)
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@localhost ~]# su - cactiuser(切换到cactiuser用户)
[cactiuser@localhost ~]$ /usr/local/php/bin/php /web/vhosts/cacti/poller.php(通过php执行poller.php)
[cactiuser@localhost ~]$ exit(退出当前用户)
logout

配置cacti:

Graph Management: 管理此前的图像

Graph Trees: 图形树,能够将监控的所有对象进行分类存放;

DataSources:数据源

Devices: 设备,所监控的主机,要监控主机先添加设备,默认添加localhost;

点击Device,status为unknown,因为还没配置监控状态,点击localhost;

 

Description: 当前主机描述

Hostname: 主机名字为IP地址;

Host Template: 主机模版,Local Linux Machine 本地linux主机;

Number of Collection Threads: 几个收集线程,只能有1个,使用poller.php,如果使用spine可以使用n个线程,现在使用poller最好不要调整;

Disable Host: 禁用当前主机;

Downed Device Detection: 检查当前主机是否在线;

Downed Device Detection: 设备检测;

Ping Method:ping方法;

Ping Timeout Value: ping超时值;

Ping Retry Count: ping重试计数;

SNMP Version: SNMP版本;

SNMP Community: SNMP团体字;

SNMP Port: SNMP端口;

SNMP Timeout: SNMP超时时间;

Maximum OID' per Get Request: OID查询机制;

选择snmp版本为version2,点击保存;

[root@localhost ~]# vim /etc/snmp/snmpd.conf(查看snmpd.conf配置文件) 

com2sec notConfigUser  default       public

 

点击Devices,过一会Status可能会变成up,当这里变成up以后,localhost底下附加的数据源;

Associated Graph Templates:相关图模版;

Graph Template Name:图模版名称;

Associated Data Queries:相关数据查询;

Data Query Name:数据查询名称;

点击Data Sources,已有五个数据源,这五个数据源就是为这个设备localhost这几个图形提供数据的,所以只有定义好的数据源所产生的以后才能画图的;

 

点击Localhost-Processes;

Selected Data Template:数据模版

Host: 关联到那个主机上;

Data Source Path:数据源路径

 

点击Turn On Data Source Debug Mode(开启数据源调试模式),这是模版自动生成的命令,把数据方法结合数据模版应用到主机上这就叫数据源

Data Source Debug

/usr/bin/rrdtool create \

/web/vhosts/cacti-0.8.8a/rra/localhost_proc_7.rrd \(数据文件是什么)

--step 300  \(解析度)

DS:proc:GAUGE:600:0:1000 \(数据源,数据源类型)

RRA:AVERAGE:0.5:1:600 \(每1个进行平均,每个数据300秒,过去5分钟的平均值,一共创建600个)

RRA:AVERAGE:0.5:6:700 \(每半小时平均值)

RRA:AVERAGE:0.5:24:775 \(每两小时平均值)

RRA:AVERAGE:0.5:288:797 \(每天12小时平均值,保存797个)

RRA:MAX:0.5:1:600 \(每5分钟最大值)

RRA:MAX:0.5:6:700 \(每半小时平均值)

RRA:MAX:0.5:24:775 \(每两小时平均值)

RRA:MAX:0.5:288:797 \(每12小时平均值)

点击graphs()

Graph Template: Linux - Memory Usage

Graph Template: Unix - Load Average

Graph Template: Unix - Logged in Users

Graph Template: Unix - Processes

 

[root@localhost ~]# cd /web/vhosts/cacti/rra/(切换到/web/vhosts/cacti/rra/目录)
[root@localhost rra]# ls(查看当前目录文件及子目录)
localhost_load_1min_5.rrd  localhost_mem_buffers_3.rrd  localhost_mem_swap_4.rrd  localhost_proc_7.rrd  localhost_users_6.rrd
[root@localhost rra]# rrdtool fetch -r 300 localhost_mem_buffers_3.rrd AVERAGE(fetch获取收据,-r指定解析度,查看平均值)
1473259200: nan
1473259500: nan
1473259800: 2.7238034952e+04
1473260100: 2.6641853333e+04
1473260400: 2.5715093333e+04
1473260700: 2.5715986667e+04
1473261000: 2.4671013333e+04
1473261300: 1.3585053333e+04
1473261600: 2.5834906667e+04
1473261900: nan
[root@localhost rra]# date +%s(查看当前时间戳)
[root@localhost rra]# rrdtool fetch -r 300 localhost_mem_buffers_3.rrd AVERAGE(fetch获取收据,-r指定解析度,查看平均值)
1473261875
1473259200: nan
1473259500: nan
1473259800: 2.7238034952e+04
1473260100: 2.6641853333e+04
1473260400: 2.5715093333e+04
1473260700: 2.5715986667e+04
1473261000: 2.4671013333e+04
1473261300: 1.3585053333e+04
1473261600: 2.5834906667e+04
1473261900: 2.5369693333e+04
1473262200: nan

为本地主机监控别的数据:

1、首先获取数据;

2、数据收集怎么保存,要有数据模版;

3、有了数据模版再应用到主机上就是数据源;

4、接下来绘图;

点击Data Input Methods(数据收集方法)

点击Data Templates(数据模版)

 

定义数据源,点击Data Sources,点击Add添加数据源,点击create;

Selected Data Template(数据收集方法模版)

Host:指定主机;

 

Name:文件名字;

Data Source Path:数据源路径rrd文件保存到什么位置;

<path_rr>:cacti内置变量,引用cacti安装目录里面的rra目录;

Data Source Item Fields [traffic_in]:数据源in的最大值;

Maximum Value('U' for No Maximum):所能接受最大值,U未知;

Data Source Item Fields [traffic_out]: 数据源out的最大值;

点击New Graphs(创建新图像)

[root@localhost ~]# snmpnetstat -v 2c -c public -Can -Cp tcp localhost(查看当前主机tcp相关信息,-v指定版本,-c指定团体字,-Ca默认配置,-Cp指定协议)
Active Internet (tcp) Connections (including servers)
Proto Local Address          Remote Address         (state)
tcp   *.*                    *.*                   0
[root@localhost ~]# which snmpstatus(查看snmpstatus全路径)
/usr/bin/snmpstatus
[root@localhost ~]# vim tcpconn.sh(编辑tcpconn.sh脚本)

#!/bin/bash
#
# $1: hostname or IP
# $2: snmp community
SNMPNETSTAT=/usr/bin/snmpnetstat

$SNMPNEtSTAT -v 2c -c $2 -Can -Cp tcp $1

[root@localhost ~]# chmod +x tcpconn.sh(给tcpconn.sh执行权限) 
[root@localhost ~]# ./tcpconn.sh localhost public(执行tcpconn.sh脚本)
Active Internet (tcp) Connections (including servers)
Proto Local Address          Remote Address         (state)
tcp   *.*                    *.*                   0
[root@localhost ~]# vim tcpconn.sh(编辑tcpconn.sh脚本)

#!/bin/bash
#
# $1: hostname or IP
# $2: snmp community
SNMPNETSTAT=/usr/bin/snmpnetstat

$SNMPNETSTAT -v 2c -c $2 -Can -Cp tcp $1 | grep -i 'established' | wc -l

[root@localhost ~]# ./tcpconn.sh localhost public(执行ttcpconn.sh脚本)
0
[root@localhost ~]# vim tcpconn.sh(编辑tcpconn.sh脚本)

#!/bin/bash
#
# $1: hostname or IP
# $2: snmp community
SNMPNETSTAT=/usr/bin/snmpnetstat

ESTABLISHED=`$SNMPNETSTAT -v 2c -c $2 -Can -Cp tcp $1 | grep -i 'established' | wc -l`

echo -n "established:$ESTABLISHED"

[root@localhost ~]# ./tcpconn.sh localhost public(执行tcpconn.sh脚本)
established:0[root@localhost ~]# 
[root@localhost ~]# cp tcpconn.sh /web/vhosts/cacti/scripts/(复制tcpconn.sh到/web/vhosts/cacti/scripts目录)

打开console(控制台)--Data Input Methods;

点击Add,

Name: 名字

Input Type: 类型选择Script/Command

Input String: 脚本路径,<path_cacti>引用cacti路径

点击Create;

在Input Fields处点击Add;

Input Fields:参数;

Output Fields:

Field [Input]: 参数;

Friendly Name:给用户一个能够看懂的名字;

Allow Empty Input: 是否允许为空;

Special Type Code: 如果用户不填写到那里继承参数;

点击Create;

继续在Input Fields点击Add;

点击Create

在Output Fields(输出数据)处点击Add;

Field [Output]: 输出那个值

点击Create;

这个Data Input数据方法就创建好了;

点击Data Templates(定义数据模版)--Add;

Data Templates[new]: 数据模版

Name: 模版名字

Data Source: 数据源

Name: 数据源名字,|host_descrition|因为主机描述;

Data Input Method:数据源方法;

Associated RRA's:聚合函数如何聚合;

Use Per-Data Source Value(Ignore this Value): 数据生成时间;

Internal Data Source Name:数据源名字,tcpestablished,DS名称;

Minimum Value('U' for No Minimum):能够接受的最小值;

Maximum Value ('U' for No Maximum):能够接受最大值;

Data Source Type: 数据源类型;

Hearbeat:能接受的值在多少范围内;

点击Create;

点击Data Sources(开始添加数据源)--Add;

Selected Data Template:指定数据模版;

Host:指定主机;

点击Create;

[root@localhost ~]# cd /web/vhosts/cacti/rra(切换到/web/vhosts/cacti/rra目录)
[root@localhost rra]# ls(查看当前目录文件及子目录)
localhost_load_1min_5.rrd  localhost_mem_buffers_3.rrd  localhost_mem_swap_4.rrd  localhost_proc_7.rrd  localhost_users_6.rrd

点击Graph Templates(图片模版)--Add;

Name:模版名称;

Title(--title):图片名字

Image Format(--imgformat):图像格式;

Auto Scale:自动大小;

Vertical Label(--vertical-label):纵轴名称;

点击Create;

在Graph Template Items[edit: SNMP-TCP Connections]--Add;

Data Source:数据源;

Color:图片颜色;

Graph Item Type:图像类型;

Consolidation Function: 关联的函数;

点击Create;

点击Graph Management--Add;

点击Create;

点击graphs;

点击console--Graph Templates;找到TCP Connections;

在Graph Template Items[edit:SNMP-TCP Connections]点击Add;

点击Create;

点击graphs;

点击console--Graph Templates;找到TCP Connections;

在Graph Template Items[edit:SNMP-TCP Connections]点击Add;

点击Create;

点击console--Graph Templates;找到TCP Connections;

在Graph Template Items[edit:SNMP-TCP Connections]点击Add;

点击Create;

点击graphs:

 

[root@localhost rra]# ll(查看当前目录文件及子目录详细信息)
total 408
-rw-r--r-- 1 cactiuser cactiuser 141488 Sep  8 02:00 localhost_load_1min_5.rrd
-rw-r--r-- 1 cactiuser cactiuser  47840 Sep  8 02:00 localhost_mem_buffers_3.rrd
-rw-r--r-- 1 cactiuser cactiuser  47840 Sep  8 02:00 localhost_mem_swap_4.rrd
-rw-r--r-- 1 cactiuser cactiuser  47840 Sep  8 02:00 localhost_proc_7.rrd
-rw-r--r-- 1 cactiuser cactiuser  47840 Sep  8 02:00 localhost_tcpconn_1.rrd
-rw-r--r-- 1 cactiuser cactiuser  47840 Sep  8 02:00 localhost_users_6.rrd
[root@localhost rra]# rrdtool fetch localhost_tcpconn_1.rrd AVERAGE(查看localhost_tcpconn_1.rrd数据文件平均值)
1473269700: nan
1473270000: nan
1473270300: nan
1473270600: nan
1473270900: nan
1473271200: nan
1473271500: nan
1473271800: nan
[root@localhost rra]# date +%s(查看时间戳)
1473271551
[root@localhost ~]# ab -c 2 -n 1000 http://172.16.100.1/index.php(压力测试,-c 每次2个连接,-n总共1000请求)
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.100.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.4
Server Hostname:        172.16.100.1
Server Port:            80

Document Path:          /index.php
Document Length:        1462 bytes

Concurrency Level:      2
Time taken for tests:   31.080 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1910000 bytes
HTML transferred:       1462000 bytes
Requests per second:    32.18 [#/sec] (mean)
Time per request:       62.160 [ms] (mean)
Time per request:       31.080 [ms] (mean, across all concurrent requests)
Transfer rate:          60.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       1
Processing:    26   62 477.9     30   14421
Waiting:        0   62 477.9     30   14421
Total:         26   62 477.9     30   14421

Percentage of the requests served within a certain time (ms)
  50%     30
  66%     33
  75%     39
  80%     53
  90%     79
  95%     96
  98%    117
  99%    176
 100%  14421 (longest request)
[root@localhost ~]# vim tcpconn.sh(编辑tcpconn.sh脚本)

#!/bin/bash
#
# $1: hostname or IP
# $2: snmp community
SNMPNETSTAT=/usr/bin/snmpnetstat
TEMPFILE=`mktemp /tmp/$1_tcpconn.XXXXXXXX`

$SNMPNETSTAT -v 2c -c $2 -Can -Cp tcp $1 > $TEMPFILE

ESTABLISHED=`grep -i "ESTABLISHED" $TEMPFILE | wc -l`
TIMEWAIT=`grep -i "TIMEWAIT" $TEMPFILE | wc -l`
SYNRECEIVED=`grep -i "SYNRECEIVED" $TEMPFILE | wc -l`

echo -n "established:$ESTABLISHED timewait:$TIMEWAIT synreceived:$SYNRECEIVED"

[root@localhost ~]# ./tcpconn.sh localhost public(执行tcpconn.sh脚本)
established:2 timewait:0 synreceived:0[root@localhost ~]# 
[root@localhost ~]# ab -c 2 -n 1000 http://172.16.100.1/index.php(http压力测试,-c一次2个请求,-n总共1000请求)
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.100.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.4
Server Hostname:        172.16.100.1
Server Port:            80

Document Path:          /index.php
Document Length:        1462 bytes

Concurrency Level:      2
Time taken for tests:   29.787 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1910000 bytes
HTML transferred:       1462000 bytes
Requests per second:    33.57 [#/sec] (mean)
Time per request:       59.574 [ms] (mean)
Time per request:       29.787 [ms] (mean, across all concurrent requests)
Transfer rate:          62.62 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.8      0      42
Processing:    26   59 354.8     30    9383
Waiting:        0   59 354.8     30    9383
Total:         26   60 354.8     30    9383

Percentage of the requests served within a certain time (ms)
  50%     30
  66%     35
  75%     49
  80%     56
  90%     79
  95%     92
  98%    117
  99%    141
 100%   9383 (longest request)
[root@localhost ~]# ./tcpconn.sh localhost public(执行tcpconn.sh脚本)
established:4 timewait:0 synreceived:0[root@localhost ~]# 
[root@localhost ~]# cp tcpconn.sh /web/vhosts/cacti/scripts/tcp3.sh(复制tcpconn.sh到/web/vhosts/cacti/scripts叫tcp3.sh)

点击console--Data Input Methods(数据输入方法)--Add,填写完成,点击Create;

在Input Fields--Add,添加完成点击Create;

继续点击Add;

在Output Fields--Add;

继续点击Add;

再点击Add;

点击Data Templates--Add;

点击Data Sources-Add;

点击Graph Templates--Add;

在Graph Template ITems[edit:SNMP-TCP 3conn]--Add;

继续添加;

继续添加;

继续添加;

继续添加;

继续添加;

继续添加;

继续添加;

继续添加;

继续添加;

继续添加;

继续添加;

点击Graph Management--Add;

点击graphs;

点击console--Export Templates(导出模版)

点击Plugin Management(插件管理)

[root@localhost ~]# lftp 172.16.0.1(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd Sources/cacti/(切换到Sources/cacti目录)
lftp 172.16.0.1:/pub/Sources/cacti> get thold-v0.4.9-3.tgz settings-v0.71-1.tgz(下载thold和setting文件)
137949 bytes transferred
Total 2 files transferred
lftp 172.16.0.1:/pub/Sources/cacti> bye(退出)
[root@localhost ~]# ls(查看当前目录文件及子目录)
anaconda-ks.cfg         httpd-2.4.4                           mysql-5.5.28-linux2.6-i686.tar.gz       settings-v0.7-1.tgz
apr-1.4.6               httpd-2.4.4.tar.bz2                   php-5.4.13                              tcpconn.sh
apr-1.4.6.tar.bz2       install.log                           php-5.4.13.tar.bz2                      thold-v0.4.9-3.tgz
apr-util-1.5.2          install.log.syslog                    rrdtool-1.4.7-1.el5.wrl.i386.rpm
apr-util-1.5.2.tar.bz2  libmcrypt-2.5.7-5.el5.i386.rpm        rrdtool-devel-1.4.7-1.el5.wrl.i386.rpm
cacti-0.8.8a.tar.gz     libmcrypt-devel-2.5.7-5.el5.i386.rpm  rrdtool-perl-1.4.7-1.el5.wrl.i386.rpm
[root@localhost ~]# tar zvxf thold-v0.4.9-3.tgz -C /web/vhosts/cacti/plugins/(解压thold,z代表giz类型压缩,v显示过程,x解压,f后面跟文件,-C更
改解压目录)
[root@localhost ~]# tar zvxf settings-v0.7-1.tgz -C /web/vhosts/cacti/plugins/(解压settings,z代表giz类型压缩,v显示过程,x解压,f后面跟文件,
-C更改解压目录)
[root@localhost ~]# ls /web/vhosts/cacti/plugins(查看/web/vhosts/cacti/plugins目录文件及子目录)
index.php  settings  thold
[root@localhost ~]# cd /web/vhosts/cacti(切换到/web/vhosts/cacti目录)
[root@localhost cacti]# vim include/config.php(编辑config.php文件)

点击Plugin Management,插件出现了,点击Actions安装并启用插件;

点击thold: