﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vi`blog · 唯音 &#187; 监控</title>
	<atom:link href="http://www.viyin.net/tag/%e7%9b%91%e6%8e%a7/feed" rel="self" type="application/rss+xml" />
	<link>http://www.viyin.net</link>
	<description>岂能尽如人意，但求无愧于心</description>
	<lastBuildDate>Mon, 14 Nov 2011 15:43:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>nginx平台架设nagios</title>
		<link>http://www.viyin.net/2010/03/nginx-nagios.html</link>
		<comments>http://www.viyin.net/2010/03/nginx-nagios.html#comments</comments>
		<pubDate>Tue, 23 Mar 2010 04:17:35 +0000</pubDate>
		<dc:creator>vi</dc:creator>
				<category><![CDATA[√linux]]></category>
		<category><![CDATA[√web]]></category>
		<category><![CDATA[√文章精选]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[√nginx]]></category>
		<category><![CDATA[监控]]></category>

		<guid isPermaLink="false">http://www.viyin.net/?p=706</guid>
		<description><![CDATA[nagios作用 1. 监控网络服务（SMTP、POP3、HTTP、NNTP、PING等）； 2. 监控主机资源（处理器负荷、磁盘利用率等）； 3. 简单地插件设计使得用户可以方便地扩展自己服务的检测方法； 4. 并行服务检查机制； 5. 具备定义网络分层结构的能力，用”parent”主机定义来表达网络主机间的关系，这种关系可被用来发现和明晰主机宕机或不可达状态； 6. 当服务或主机问题产生与解决时将告警发送给联系人（通过EMail、短信、用户定义方式）； 7. 具备定义事件句柄功能，它可以在主机或服务的事件发生时获取更多问题定位； 8. 自动的日志回滚； 9. 可以支持并实现对主机的冗余监控； 10. 可选的WEB界面用于查看当前的网络状态、通知和故障历史、日志文件等； Nagios所需要的运行条件是机器必须可以运行Linux（或是Unix变种）并且有C语言编译器。你必须正确地配置TCP/IP协议栈以使大多数的服务检测可以通过网络得以进行。 安装 建立nagios账号 /usr/sbin/useradd nagios &#038;&#038; passwd nagios 创建一个用户组名为nagcmd用于从Web接口执行外部命令。将nagios用户和apache用户都加到这个组中。 /usr/sbin/groupadd nagcmd /usr/sbin/usermod -G nagcmd nagios /usr/sbin/usermod -G nagcmd apache 安装nagios及插件 tar zxvf nagios-3.2.1 cd nagios-3.2.1 ./configure --with-command-group=nagcmd --prefix=/usr/local/nagios make all make install make install-init [...]]]></description>
			<content:encoded><![CDATA[<p>nagios作用<br />
1.<br />
监控网络服务（SMTP、POP3、HTTP、NNTP、PING等）；<br />
2.<br />
监控主机资源（处理器负荷、磁盘利用率等）；<br />
3.<br />
简单地插件设计使得用户可以方便地扩展自己服务的检测方法；<br />
4.<br />
并行服务检查机制；<br />
5.<br />
具备定义网络分层结构的能力，用”parent”主机定义来表达网络主机间的关系，这种关系可被用来发现和明晰主机宕机或不可达状态；<br />
6.<br />
当服务或主机问题产生与解决时将告警发送给联系人（通过EMail、短信、用户定义方式）；<br />
7.<br />
具备定义事件句柄功能，它可以在主机或服务的事件发生时获取更多问题定位；<br />
8.<br />
自动的日志回滚；<br />
9.<br />
可以支持并实现对主机的冗余监控；<br />
10.<br />
可选的WEB界面用于查看当前的网络状态、通知和故障历史、日志文件等；<br />
Nagios所需要的运行条件是机器必须可以运行Linux（或是Unix变种）并且有C语言编译器。你必须正确地配置TCP/IP协议栈以使大多数的服务检测可以通过网络得以进行。</p>
<p>安装</p>
<p>建立nagios账号<br />
/usr/sbin/useradd <a href="http://www.viyin.net/tag/nagios" class="st_tag internal_tag" rel="tag" title="标签 nagios 下的日志">nagios</a> &#038;&#038; passwd <a href="http://www.viyin.net/tag/nagios" class="st_tag internal_tag" rel="tag" title="标签 nagios 下的日志">nagios</a></p>
<p>创建一个用户组名为nagcmd用于从Web接口执行外部命令。将nagios用户和apache用户都加到这个组中。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">/usr/sbin/groupadd nagcmd</li>
<li>/usr/sbin/usermod -G nagcmd nagios</li>
<li>/usr/sbin/usermod -G nagcmd apache</li></ol></div>
<p>安装nagios及插件<br />
<span id="more-706"></span>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">tar zxvf nagios-3.2.1</li>
<li>cd nagios-3.2.1</li>
<li>./configure --with-command-group=nagcmd --prefix=/usr/local/nagios</li>
<li>make all</li>
<li>make install</li>
<li>make install-init</li>
<li>make install-config</li>
<li>make install-commandmode</li></ol></div>
<p>正确安装完毕,/usr/local/nagios目录下将会有这几个文件夹<br />
bin  etc  include  libexec  sbin  share  var</p>
<p>安装nagios‐plugins</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">tar zxvf nagios-plugins-1.4.14</li>
<li>cd nagios-plugins-1.4.14</li>
<li>./configure --with-nagios-user=nagios --with-nagios-group=nagios&nbsp; --perfix=/usr/local/nagios</li>
<li>make &amp;&amp; make install</li></ol></div>
<p>在另一台机上编译安装apache，需要用到htpasswd这工具来生成登陆的用户名和密码<br />
/usr/local/httpd/bin/htpasswd -c /usr/local/nagios/etc/viyin.net viyin</p>
<p>[root@game bin]# ./htpasswd -c /root/viyin.net viyin<br />
New password:<br />
Re-type new password:<br />
Adding password for user viyin</p>
<p>验证配置文件<br />
[root@vi bin]# pwd<br />
/usr/local/nagios/bin<br />
[root@vi bin]# ./nagios -v /usr/local/nagios/etc/nagios.cfg </p>
<p>Nagios Core 3.2.1<br />
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors<br />
Copyright (c) 1999-2009 Ethan Galstad<br />
Last Modified: 03-09-2010<br />
License: GPL</p>
<p>Website: http://www.nagios.org<br />
Reading configuration data&#8230;<br />
   Read main config file okay&#8230;<br />
Processing object config file &#8216;/usr/local/nagios/etc/objects/commands.cfg&#8217;&#8230;<br />
Processing object config file &#8216;/usr/local/nagios/etc/objects/contacts.cfg&#8217;&#8230;<br />
Processing object config file &#8216;/usr/local/nagios/etc/objects/timeperiods.cfg&#8217;&#8230;<br />
Processing object config file &#8216;/usr/local/nagios/etc/objects/templates.cfg&#8217;&#8230;<br />
Processing object config file &#8216;/usr/local/nagios/etc/objects/localhost.cfg&#8217;&#8230;<br />
   Read object config files okay&#8230;</p>
<p>Running pre-flight check on configuration data&#8230;</p>
<p>Checking services&#8230;<br />
        Checked 8 services.<br />
Checking hosts&#8230;<br />
        Checked 1 hosts.<br />
Checking host groups&#8230;<br />
        Checked 1 host groups.<br />
Checking service groups&#8230;<br />
        Checked 0 service groups.<br />
Checking contacts&#8230;<br />
        Checked 1 contacts.<br />
Checking contact groups&#8230;<br />
        Checked 1 contact groups.<br />
Checking service escalations&#8230;<br />
        Checked 0 service escalations.<br />
Checking service dependencies&#8230;<br />
        Checked 0 service dependencies.<br />
Checking host escalations&#8230;<br />
        Checked 0 host escalations.<br />
Checking host dependencies&#8230;<br />
        Checked 0 host dependencies.<br />
Checking commands&#8230;<br />
        Checked 24 commands.<br />
Checking time periods&#8230;<br />
        Checked 5 time periods.<br />
Checking for circular paths between hosts&#8230;<br />
Checking for circular host and service dependencies&#8230;<br />
Checking global event handlers&#8230;<br />
Checking obsessive compulsive processor commands&#8230;<br />
Checking misc settings&#8230;</p>
<p>Total Warnings: 0<br />
Total Errors:   0</p>
<p>Things look okay &#8211; No serious problems were detected during the pre-flight check<br />
[root@vi bin]# </p>
<p>启动nagios服务<br />
service nagios start</p>
<p>将nagios服务加入开机启动<br />
chkconfig &#8211;add nagios<br />
chkconfig nagios on</p>
<p>安装nrpe</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">tar zxvf nrpe-2.12</li>
<li>cd nrpe-2.12</li>
<li>./configure</li>
<li>make all</li>
<li>make installplugin</li>
<li>make install-daemon</li>
<li>make install-daemon-config</li></ol></div>
<p>同样，在被监控机上也要安装nrpe,nagios‐plugins<br />
在监控与被监控机上启动NRPE：<br />
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d</p>
<p>nagios安装完成</p>
<p>nginx cgi的配置</p>
<p>下载nginx-fcgi脚本<br />
wget http://www.nginx.eu/nginx-fcgi/nginx-fcgi.txt </p>
<p>注释掉nginx-fcgi.txt 中的<br />
if ( $> == “0″ ) {<br />
print “\n\tERROR\tRunning as a root!\n”;<br />
print “\tSuggested not to do so !!!\n\n”;<br />
exit 1;<br />
}<br />
否则会提示：ERROR Running as a root! Suggested not to do so !!!</p>
<p>mv nginx-fcgi.txt /usr/local/nginx/sbin/nginx-fcgi</p>
<p>chmod +x /usr/local/nginx/sbin/nginx-fcgi</p>
<p>安装perl cgi模块<br />
wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz<br />
tar -zxvf FCGI-0.67.tar.gz<br />
cd FCGI-0.67<br />
perl Makefile.PL<br />
make &#038;&#038; make install</p>
<p>安装FCGI-ProcManager:<br />
wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz<br />
tar -xzxf FCGI-ProcManager-0.18.tar.gz<br />
cd FCGI-ProcManager-0.18<br />
perl Makefile.PL<br />
make make install</p>
<p>继续安装<br />
wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.39.tar.gz</p>
<p>wget http://search.cpan.org/CPAN/authors/id/J/JV/JV/Getopt-Long-2.38.tar.gz</p>
<p>创建fastcgi_pass 接口<br />
su www  切换到nginx运行用户<br />
/usr/local/nginx/sbin/nginx-fcgi -l /home/wwwroot/nginx-fcgi.log -pid /tmp/nginx-fcgi.pid -S /tmp/nginx-fcgi.sock </p>
<p>无报错</p>
<p>nginx配置文件</p>
<p>server<br />
        {<br />
                listen       80;<br />
                server_name www.6fine.com www.viyin.net;<br />
                index index.html index.htm index.php default.html default.htm de<br />
fault.php;<br />
                root  /usr/local/nagios/share;</p>
<p>                location ~ .*\.(php|php5)?$<br />
                        {<br />
                                fastcgi_pass  unix:/tmp/php-cgi.sock;<br />
                                #fastcgi_pass  127.0.0.1:9000;<br />
                                fastcgi_index index.php;<br />
                                include fcgi.conf;<br />
                        }</p>
<p>location ~ .*\.cgi$ {<br />
        root /usr/local/nagios/sbin;<br />
        rewrite  ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;<br />
        fastcgi_pass  unix:/tmp/nginx-fcgi.sock;<br />
        fastcgi_param  SCRIPT_FILENAME  /usr/local/nagios/sbin$fastcgi_script_na<br />
me;<br />
        include  fcgi.conf;<br />
        auth_basic  “Nagios Access”;<br />
        auth_basic_user_file  /usr/local/nagios/etc/viyin.net;<br />
    }<br />
    location /nagios {<br />
        alias  /usr/local/nagios/share;<br />
    }<br />
    location / {<br />
        auth_basic  “Nagios Access”;<br />
        auth_basic_user_file  /usr/local/nagios/etc/viyin.net;<br />
    }</p>
<p>}</p>
<p>完成<br />
参考：http://bbs.linuxtone.org/viewthread.php?tid=4441&#038;highlight=Nagios</p>
]]></content:encoded>
			<wfw:commentRss>http://www.viyin.net/2010/03/nginx-nagios.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Linux下cacti完整安装指南</title>
		<link>http://www.viyin.net/2009/08/linux-cacti-setup.html</link>
		<comments>http://www.viyin.net/2009/08/linux-cacti-setup.html#comments</comments>
		<pubDate>Wed, 12 Aug 2009 02:24:52 +0000</pubDate>
		<dc:creator>vi</dc:creator>
				<category><![CDATA[√linux]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[rrdtool]]></category>
		<category><![CDATA[snmp]]></category>
		<category><![CDATA[流量]]></category>
		<category><![CDATA[监控]]></category>

		<guid isPermaLink="false">http://www.viyin.net/?p=362</guid>
		<description><![CDATA[初衷： 网上的cacti教程不够全面。vi看了多篇。郁闷了许久。才安装成功。 写此文目的，为自己做个备忘，为后来者做为参考，共同进步。如有误，欢迎指导。 环境：Centos 5.3 Cacti 0.8.7e mysql 5.1.36 apache2.2.3 php 5.2.10 net-snmp 5.3.2.2 一、安装步骤： 1.基本需求：   1).先必须安装LAMP （参见另一篇博文） 2)安装libart_lgpl ,libart_lgpl-devel 2.依次安装net-snmp,rrdtool,cacti 1). [root@vi ~]#yum -y install net-snmp* #如果php之前不支持snmp,必须安装php-snmp 编辑/etc/snmp/snmpd.conf 编辑以下几项： 查找 #sec.name source community com2sec notConfiUser default public 改为 com2sec notConfigUser 127.0.0.1 public 查找 #### # Finally, grant the group read-only access to the systemview [...]]]></description>
			<content:encoded><![CDATA[<p>初衷：</p>
<p>网上的cacti教程不够全面。vi看了多篇。郁闷了许久。才安装成功。</p>
<p>写此文目的，为自己做个备忘，为后来者做为参考，共同进步。如有误，欢迎指导。</p>
<p>环境：<a href="http://www.viyin.net/tag/centos" class="st_tag internal_tag" rel="tag" title="标签 centos 下的日志">Centos</a> 5.3 <a href="http://www.viyin.net/tag/cacti" class="st_tag internal_tag" rel="tag" title="标签 cacti 下的日志">Cacti</a> 0.8.7e<br />
mysql 5.1.36 apache2.2.3 php 5.2.10 net-<a href="http://www.viyin.net/tag/snmp" class="st_tag internal_tag" rel="tag" title="标签 snmp 下的日志">snmp</a> 5.3.2.2</p>
<p>一、安装步骤：</p>
<p>1.基本需求：<br />
 <br />
1).先必须安装LAMP （参见另一篇博文）</p>
<p>2)安装libart_lgpl ,libart_lgpl-devel</p>
<p>2.依次安装net-snmp,<a href="http://www.viyin.net/tag/rrdtool" class="st_tag internal_tag" rel="tag" title="标签 rrdtool 下的日志">rrdtool</a>,cacti</p>
<p><span id="more-362"></span></p>
<p>1). [root@vi ~]#yum -y install net-snmp*<br />
#如果php之前不支持snmp,必须安装php-snmp<br />
编辑/etc/snmp/snmpd.conf 编辑以下几项：<br />
查找<br />
#sec.name source community<br />
com2sec notConfiUser default public 改为 com2sec notConfigUser 127.0.0.1 public<br />
查找</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">####</li>
<li># Finally, grant the group read-only access to the systemview view.</li>
<li># group context sec.model sec.level prefix read write notif</li>
<li>access notConfigGroup “” any noauth exact systemview none none</li></ol></div>
<p>将”read”字段改为all.<br />
代码:<br />
#access notConfigGroup “” any noauth exact all none none<br />
查找<br />
## incl/excl subtree mask<br />
#view all included .1 80<br />
去掉view前面的#<br />
查找</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#       name           incl/excl     subtree         mask(optional)</li>
<li>#view   systemview      included        .1</li>
<li>view    systemview    included   .1.3.6.1.2.1.1</li>
<li>view    systemview    included   .1.3.6.1.2.1.25.1.1</li></ol></div>
<p>将下面两个view前#去掉<br />
启动snmpd服务：/etc/init.d/snmpd start</p>
<p><span style="color: #ff0000;">验证SNMP是否配置正确，可用以下命令：</span></p>
<p><span style="color: #ff0000;">[root@vi ~]# snmpwalk -v 2c -c vivivi 127.0.0.1 if</span></p>
<p><span style="color: #000000;">如果返回以下字段，既成功：</span></p>
<p><span style="color: #000000;"></p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">IF-MIB::ifIndex.1 = INTEGER: 1</li>
<li>IF-MIB::ifIndex.2 = INTEGER: 2</li>
<li>IF-MIB::ifIndex.3 = INTEGER: 3</li>
<li>IF-MIB::ifDescr.1 = STRING: lo</li>
<li>IF-MIB::ifDescr.2 = STRING: eth0</li>
<li>IF-MIB::ifDescr.3 = STRING: sit0</li>
<li>IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)</li>
<li>IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)</li>
<li>IF-MIB::ifType.3 = INTEGER: tunnel(131)</li>
<li>IF-MIB::ifMtu.1 = INTEGER: 16436</li>
<li>IF-MIB::ifMtu.2 = INTEGER: 1500</li>
<li>IF-MIB::ifMtu.3 = INTEGER: 1480</li>
<li>IF-MIB::ifSpeed.1 = Gauge32: 10000000</li>
<li>IF-MIB::ifSpeed.2 = Gauge32: 1000000000</li>
<li>IF-MIB::ifSpeed.3 = Gauge32: 0</li>
<li>IF-MIB::ifPhysAddress.1 = STRING:</li>
<li>IF-MIB::ifPhysAddress.2 = STRING: 0:c:29:4d:ea:47</li>
<li>IF-MIB::ifPhysAddress.3 = STRING:</li>
<li>IF-MIB::ifAdminStatus.1 = INTEGER: up(1)</li>
<li>IF-MIB::ifAdminStatus.2 = INTEGER: up(1)</li>
<li>IF-MIB::ifAdminStatus.3 = INTEGER: down(2)</li>
<li>IF-MIB::ifOperStatus.1 = INTEGER: up(1)</li>
<li>IF-MIB::ifOperStatus.2 = INTEGER: up(1)</li>
<li>IF-MIB::ifOperStatus.3 = INTEGER: down(2)</li>
<li>IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00</li>
<li>IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00</li>
<li>IF-MIB::ifLastChange.3 = Timeticks: (0) 0:00:00.00</li>
<li>IF-MIB::ifInOctets.1 = Counter32: 213202822</li>
<li>IF-MIB::ifInOctets.2 = Counter32: 3312338633</li>
<li>IF-MIB::ifInOctets.3 = Counter32: 0</li>
<li>IF-MIB::ifInUcastPkts.1 = Counter32: 1874738</li>
<li>IF-MIB::ifInUcastPkts.2 = Counter32: 33706098</li>
<li>IF-MIB::ifInUcastPkts.3 = Counter32: 0</li>
<li>IF-MIB::ifInNUcastPkts.1 = Counter32: 0</li>
<li>IF-MIB::ifInNUcastPkts.2 = Counter32: 0</li>
<li>IF-MIB::ifInNUcastPkts.3 = Counter32: 0</li>
<li>IF-MIB::ifInDiscards.1 = Counter32: 0</li>
<li>IF-MIB::ifInDiscards.2 = Counter32: 0</li>
<li>IF-MIB::ifInDiscards.3 = Counter32: 0</li>
<li>IF-MIB::ifInErrors.1 = Counter32: 0</li>
<li>IF-MIB::ifInErrors.2 = Counter32: 0</li>
<li>IF-MIB::ifInErrors.3 = Counter32: 0</li>
<li>IF-MIB::ifInUnknownProtos.1 = Counter32: 0</li>
<li>IF-MIB::ifInUnknownProtos.2 = Counter32: 0</li>
<li>IF-MIB::ifInUnknownProtos.3 = Counter32: 0</li>
<li>IF-MIB::ifOutOctets.1 = Counter32: 213202822</li>
<li>IF-MIB::ifOutOctets.2 = Counter32: 571095627</li>
<li>IF-MIB::ifOutOctets.3 = Counter32: 0</li>
<li>IF-MIB::ifOutUcastPkts.1 = Counter32: 1874738</li>
<li>IF-MIB::ifOutUcastPkts.2 = Counter32: 36540389</li>
<li>IF-MIB::ifOutUcastPkts.3 = Counter32: 0</li>
<li>IF-MIB::ifOutNUcastPkts.1 = Counter32: 0</li>
<li>IF-MIB::ifOutNUcastPkts.2 = Counter32: 0</li>
<li>IF-MIB::ifOutNUcastPkts.3 = Counter32: 0</li>
<li>IF-MIB::ifOutDiscards.1 = Counter32: 0</li>
<li>IF-MIB::ifOutDiscards.2 = Counter32: 0</li>
<li>IF-MIB::ifOutDiscards.3 = Counter32: 0</li>
<li>IF-MIB::ifOutErrors.1 = Counter32: 0</li>
<li>IF-MIB::ifOutErrors.2 = Counter32: 0</li>
<li>IF-MIB::ifOutErrors.3 = Counter32: 0</li>
<li>IF-MIB::ifOutQLen.1 = Gauge32: 0</li>
<li>IF-MIB::ifOutQLen.2 = Gauge32: 0</li>
<li>IF-MIB::ifOutQLen.3 = Gauge32: 0</li>
<li>IF-MIB::ifSpecific.1 = OID: SNMPv2-SMI::zeroDotZero</li>
<li>IF-MIB::ifSpecific.2 = OID: SNMPv2-SMI::zeroDotZero</li>
<li>IF-MIB::ifSpecific.3 = OID: SNMPv2-SMI::zeroDotZero&lt;/span&gt;</li></ol></div>
<p><span style="color: #000000;">不成功的提示如下：</span></p>
<p><span style="color: #ff0000;">Timeout: No Response from 127.0.0.1</span></p>
<p><span style="color: #ff0000;">这时要查看SNMP是否配置正确。 是否正确设置 community</span></p>
<p>2).安装rrdtool<br />
[root@vi ~]# wget <a href="http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.30.tar.gz">http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.30.tar.gz</a><br />
[root@vi ~]# tar zxvf rrd rrdtool-1.2.30.tar.gz<br />
[root@vi ~]# cd rrdtool-1.2.30<br />
[root@vi ~]# ./configure –prefix=/usr/local/rrdtool<br />
[root@vi ~]# make<br />
[root@vi ~]# make install</p>
<p>3).配置mysql,导入脚本<br />
[root@vi ~]# useradd -p cacti -s /sbin/bash cacti<br />
#增加一个用于执行监控的用户cacti<br />
[root@vi ~]# mysqladmin -uroot -p create cacti<br />
#在mysql里增加用户cacti<br />
[root@vi ~]#grant all on cacti.* to <a href="mailto:cacti@localhost">cacti@localhost</a> identified by ‘viyin.net’;<br />
#赋予cacti用户对数据库cacti有全部权限，并且设置密码为viyin.net<br />
[root@vi ~]# flush privileges;<br />
[root@vi ~]# mysql -uroot -p cacti &lt; cacti.sql<br />
#导入脚本文件cacti.sql,这步操作必须在cacti解压缩后的目录上执行，不然可能找不到该文件</p>
<p>4).安装cacti<br />
[root@vi ~]# wget <a href="http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz">http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz</a><br />
[root@vi ~]# tar zxvf cacti-0.8.7e.tar.gz<br />
[root@vi ~]#mv cacti-.8.7e /www/viyinnet/cacti<br />
[root@vi ~]# cd /www/viyinnet/cacti<br />
[root@vi ~]# vi ./include/config.php  <span style="color: #ff0000;">编辑数据库配置文件</span><br />
$database_default = “cacti”;<br />
$database_hostname = “localhost”;<br />
$database_username = “cacti”;<br />
$database_password = “cacti”;<br />
[root@vi ~]#chown -R cacti /www/viyinnet/cacti <span style="color: #ff0000;">改变目录所有者</span></p>
<p>[root@vi ~]#chmod -R 777 /www/viyinnet/cacti   <span style="color: #ff0000;">设置权限</span></p>
<p>5).打开IE，输入<a href="http://10.155.30.64/cacti/">http://你的域名或IP/cacti/</a>  自动转向安装页面,填写路径，如果出现打不开，肯定是路径不对，安装完成后，默认后台管理员用户名和密码都是admin,输入后需要立即修改密码。</p>
<p>6).设置自动获取数据<br />
[root@vi ~]# crontab -u cacti -e<br />
*/5 * * * * <span style="color: #ff0000;">/usr/local/php/bin/php</span> /www/web/viyinnet/cacti/poller.php &gt; /dev/null 2&gt;&amp;1</p>
<p>注意红色字体部份。路径要完整。是php的二进制路径。</p>
<p>写入crtontab 作用是每5分钟生成一次图表。</p>
<p>7).登陆<a href="http://10.155.30.64/cacti">http://IP/cacti</a>进行配置<br />
到目前为止安装已经完成！</p>
<p>二、配置监控设备</p>
<p>1. 监控本机<br />
打开后台console-devices-add-:<br />
Description 写localhost,Hostname是本机IP，Host Template 选择Local Linux Machine,其他默认<br />
然后建立图形，选择Create Graphs for this Host：<br />
勾选Graph Templates 下面所有项，选择create<br />
选择Management–Graph Management 添加模板以及选择主机<br />
然后再Management–Graph Trees 里添加服务器</p>
<p>2.监控远程linux主机</p>
<p>必须先开启远程主机snmpd服务<br />
打开后台console-devices-add-:<br />
Description 写远程主机名,Hostname是远程主机IP，Host Template 选择ucd/net SNMP host,snmp options–snmp version 选择v1,SNMP Community<br />
public,其他默认<br />
然后建立图形，选择Create Graphs for this Host：<br />
勾选Graph Templates 下面所有项，选择create<br />
选择Management–Graph Management 添加模板以及选择主机<br />
然后再Management–Graph Trees 里添加服务器<br />
也可以在官方论坛下载模板：<a href="http://forums.cacti.net/forum-12.html">http://forums.cacti.net/forum-12.html</a></p>
<p>3.监控windows 主机</p>
<p>其他都差不多，首先必须在windows 机器上安装snmp组件，并且将服务属性–安全–勾选“发送身份验证陷进”,团体名称为cacti服务器snmpd.confLi 里设置的public,权限为只读，另外在下面添加cacti主机IP</p>
<p>三、问题集锦</p>
<p>1.编译rrdtool时候出错：</p>
<p>configure: WARNING:<br />
—————————————————————————-<br />
* I found a copy of pkgconfig, but there is no libpng.pc file around.<br />
  You may want to set the PKG_CONFIG_PATH variable to point to its<br />
  location.<br />
—————————————————————————-</p>
<p>configure: WARNING:<br />
—————————————————————————-<br />
* I could not find a working copy of libpng. Check config.log for hints on why<br />
  this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately<br />
  so that compiler and the linker can find libpng and its header files. If<br />
  you have not installed libpng, you can get it either from its original home on</p>
<p>     <a href="http://prdownloads.sourceforge.net/libpng/">http://prdownloads.sourceforge.net/libpng/</a></p>
<p>  You can find also find an archive copy on</p>
<p>     <a href="http://oss.oetiker.ch/rrdtool/pub/libs">http://oss.oetiker.ch/rrdtool/pub/libs</a></p>
<p>  The last tested version of libpng is 1.2.10.</p>
<p>       LIBS=-lz -lart_lgpl_2 -lm<br />
   LDFLAGS=<br />
  CPPFLAGS= -I/usr/include/libart-2.0</p>
<p>—————————————————————————-<br />
               <br />
checking for FT_Init_FreeType in -lfreetype… no<br />
checking for pkg-config… (cached) pkg-config<br />
configure: WARNING:<br />
—————————————————————————-<br />
* I found a copy of pkgconfig, but there is no freetype2.pc file around.<br />
  You may want to set the PKG_CONFIG_PATH variable to point to its<br />
  location.<br />
—————————————————————————-</p>
<p>configure: WARNING:<br />
—————————————————————————-<br />
* I could not find a working copy of freetype2. Check config.log for hints on why<br />
  this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately<br />
  so that compiler and the linker can find libfreetype and its header files. If<br />
  you have not installed freetype2, you can get it either from its original home on</p>
<p>     <a href="http://prdownloads.sourceforge.net/freetype/">http://prdownloads.sourceforge.net/freetype/</a></p>
<p>  You can find also find an archive copy on</p>
<p>     <a href="http://oss.oetiker.ch/rrdtool/pub/libs">http://oss.oetiker.ch/rrdtool/pub/libs</a></p>
<p>  The last tested version of freetype2 is 2.1.10.</p>
<p>       LIBS=-lz -lart_lgpl_2 -lm<br />
   LDFLAGS=<br />
  CPPFLAGS= -I/usr/include/libart-2.0 -I/usr/include/freetype2</p>
<p>—————————————————————————-<br />
               <br />
configure: error: Please fix the library issues listed above and try again.</p>
<p>解决：</p>
<p>将freetype2.pc libpng*.pc 拷贝到/usr/lib/pkgconfig 后正常，之前也有同样提示，是因为系统找不到这些*.pc文件，从/usr/lib/pkgconfig上将这些文件拷贝到rrd目录 /tmp/rrdbuild/lb/lib/pkgconfig</p>
<p><span style="color: #ff0000;">如果以上操作还不能正确编译，那换个低一点版本的rrtool,vi遇到的就是这样，后来换了个低版本。顺利解决。</span></p>
<p>2. 编译rrdtools提示：<br />
/usr/bin/ld: cannot find -lpng<br />
collect2: ld returned 1 exit status<br />
make[4]: *** [blib/arch/auto/RRDs/RRDs.so] Error 1<br />
make[4]: Leaving directory `/opt/rrdtool-1.2.30/bindings/perl-shared’<br />
make[3]: *** [perl_shared] Error 2<br />
make[3]: Leaving directory `/opt/rrdtool-1.2.30/bindings’<br />
make[2]: *** [all-recursive] Error 1<br />
make[2]: Leaving directory `/opt/rrdtool-1.2.30/bindings’<br />
make[1]: *** [all-recursive] Error 1<br />
make[1]: Leaving directory `/opt/rrdtool-1.2.30′<br />
make: *** [all] Error 2</p>
<p>解决：原来是libpng安装有问题，重新执行安装，并不要指定安装路径，然后重新make rrdtool即可！</p>
<p>3.mysql 启动失败</p>
<p>[root@centos ~]# tail /var/log/mysqld.log<br />
090709 14:42:20 [ERROR] Can’t start server: Bind on TCP/IP port: Cannot assign requested address<br />
090709 14:42:20 [ERROR] Do you already have another mysqld server running on port: 3306 ?<br />
090709 14:42:20 [ERROR] Aborting</p>
<p>090709 14:42:20  InnoDB: Starting shutdown…<br />
090709 14:42:22  InnoDB: Shutdown completed; log sequence number 0 168351<br />
090709 14:42:22 [Note] /usr/libexec/mysqld: Shutdown complete<br />
090709 14:42:22  mysqld ended</p>
<p>查看/etc/my.cnf</p>
<p>发现：bind-address = 10.155.30.1<br />
但是目前本机IP是10.155.30.64，将bind-address = 10.155.30.1注释掉或者将IP改为10.155.30.64后正常</p>
<p>4.设置字体路径：</p>
<p>后台–console–configure–settings–path-RRDTool Default Font Path<br />
/usr/local/rrdtool/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf</p>
<p>5.执行snmpwalk测试提示：Timeout: No Response from 127.0.0.1<br />
[root@centos rra]# snmpwalk -v 2c -c public 127.0.0.1 if<br />
Timeout: No Response from 127.0.0.1</p>
<p>解决：</p>
<p>/etc/snmp/snmpd.conf 设置问题，改为：com2sec notConfigUser  127.0.0.1       public</p>
<p>/etc/init.d/snmpd restart</p>
<p>6. 执行# snmpwalk -v 2c -c smallfish 127.0.0.1 if 提示：<br />
IF-MIB::ifTable = No Such Object available on this agent at this OID</p>
<p>解决：<br />
[root@vi ~]# vi /etc/snmp/snmpd.conf 找到：<br />
access  notConfigGroup “”      any       noauth    exact  systemview none none将 systemview 改为all</p>
<p>7.关注最多的，没有图的问题</p>
<p>首先必须确认rra下有*.rrd文件，如果没有，将rra,log权限设置为777，再过5分钟看看，一般设置5分钟自动执行获取数据<br />
或者直接执行执行： /usr/bin/php /var/www/html/cacti/poller.php 产生数据，也可以加参数 –force 强制生成数据</p>
<p>8. 有图没有数据，全部为nan</p>
<p>执行：/opt/rrdtool-1.2.30/src/rrdtool fetch test_proc_8.rrd AVERAGE 测试<br />
                           proc<br />
1247124900: nan<br />
1247125200: nan<br />
1247125500: nan<br />
1247125800: nan<br />
1247126100: nan<br />
1247126400: nan<br />
1247126700: nan<br />
1247127000: nan<br />
1247127300: nan<br />
1247127600: nan<br />
。。。 。。。<br />
先确定有rrd文件，权限都没问题，以及日志是否有错误提示，如果都没问题，可能是模板选择有问题，重新选择模板，另外关注后台console–devices–查看设备状态是否为Unknown</p>
<p>9.没有生成rrd文件</p>
<p>检查设备模板是否正常，以及设备状态(Status)是否为Unknown,正常显示为UP</p>
]]></content:encoded>
			<wfw:commentRss>http://www.viyin.net/2009/08/linux-cacti-setup.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

