设为首页 收藏本站
查看: 834|回复: 0

[经验分享] Cacti 安装详解

[复制链接]

尚未签到

发表于 2019-1-11 12:39:26 | 显示全部楼层 |阅读模式
  1、安装apache
  tar xvf httpd-2.2.15.tar.tar
  cd httpd-2.2.15
  makedir /usr/local/apache2
  ./configure  --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most  --with-mpm=worker --enable-disk-cache --enable-mem-cache
  make
  make install
  2、安装mysql
  安装mysql
  rpm -ivh MySQL-client-community-5.1.49-1.rhel5.i386.rpm
  rpm -ivh MySQL-devel-community-5.1.49-1.rhel5.i386.rpm
  rpm -ivh MySQL-server-community-5.1.49-1.rhel5.i386.rpm
  service mysql stop
  cp /usr/share/mysql/my-medium.cnf  /etc/my.cnf
  service mysql start
  3、安装php(php不能用5.3及以上的版本,因为废除了以前很多函数。导致cacti的程序不兼容)
  3.1、安装jpegsrc.v6b.tar.gz
  mkdir /usr/local/jpeg6
  mkdir /usr/local/jpeg6/bin
  mkdir /usr/local/jpeg6/lib
  mkdir /usr/local/jpeg6/include
  mkdir /usr/local/jpeg6/man
  mkdir /usr/local/jpeg6/man/man1
  gunzip jpegsrc.v6b.tar.gz
  tar xvf jpegsrc.v6b.tar
  cd jpeg-6b/
  ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
  make
  make install
  3.2、安装libpng-1.4.3.tar.gz
  gunzip libpng-1.4.3.tar.gz
  tar xvf libpng-1.4.3.tar
  cd libpng-1.4.3
  ./configure --prefix=/usr/local/libpng
  make
  make install
  3.3、安装freetype-2.4.1.tar.gz
  gunzip freetype-2.4.1.tar.gz
  tar xvf freetype-2.4.1.tar
  cd freetype-2.4.1
  ./configure --prefix=/usr/local/freetype
  make
  make install
  3.4、安装zlib-1.2.5.tar.gz
  gunzip zlib-1.2.5.tar.gz
  tar xvf zlib-1.2.5.tar
  cd zlib-1.2.5
  ./configure --prefix=/usr/local/zlib
  make
  make install
  3.5、安装gd库
  前提是要安装 gettext
  gunzip gettext-0.18.1.1.tar.gz
  tar xvf  gettext-0.18.1.1.tar
  cd gettext-0.18.1.1
  ./configure --prefix=/usr/local/gettext
  make
  make install
  最好装gettext-devel以便能找到对应的库文件,否则会报错
  gunzip gd-2.0.35.tar.gz
  tar xvf gd-2.0.35.tar
  cd gd-2.0.35
  ./configure  --prefix=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6  --with-png=/usr/local/libpng --with-zlib-dir=/usr/local/zilb  --with-freetype=/usr/local/freetype --enable-m4_pattern_allow
  make
  make install
  3.6、安装libxml2-2.7.7.tar.gz
  gunzip libxml2-2.7.7.tar.gz
  tar xvf libxml2-2.7.7.tar
  cd libxml2-2.7.7
  ./configure --prefix=/usr/local/libxml2
  make
  make install
  3.7、安装libxslt-1.1.22.tar.gz
  gunzip libxslt-1.1.22.tar.gz
  tar xvf libxslt-1.1.22.tar
  cd libxslt-1.1.22
  ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
  make
  make install
  3.8、安装php5
  gunzip php-5.2.14.tar.gz
  tar xvf php-5.2.14.tar
  cd php-5.2.14
  ./configure  --prefix=/usr/local/php5  --with-apxs2=/usr/local/apache2/bin/apxs  --with-mysql --with-gd=/usr/local/gd2  --with-ttf  --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg6  --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/zlib  --with-iconv --enable-xml --enable-mbstring  --enable-sockets  --enable-gd-native-ttf  --enable-track-vars --enable-force-cgi-redirect  --with-config-file-path=/usr/local/php5/etc
  make
  make install
  cp php.ini-development  /usr/local/php5/etc/php.ini
  vi  /usr/local/php5/etc/php.ini将register_globals = Off改成register_globals = On
  ;date.timezone =  改为date.timezone = utc
  ;extension=php_mbstring.dll 改为 extension=php_mbstring.dll
  ;mbstring.func_overload = 0修改为:mbstring.func_overload = 7
  配置apache
  最后修改httpd.conf,使apache能使用php,增加如下参数
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps
  AddType image/x-icon .ico
  DirectoryIndex index.php index.html index.html.var
  4、安装rrd
  4.1、安装cgilib
  gunzip cgilib-0.5.tar.gz
  tar xvf cgilib-0.5.tar
  cd cgilib-0.5
  make CC=gcc CFLAGS="-O3 -fPIC -I."
  mkdir -p /usr/local/cgilib/include
  cp *.h /usr/local/cgilib/include/
  mkdir -p /usr/local/cgilib/lib
  cp libcgi* /usr/local/cgilib/lib/
  4.2、安装libart_lgpl-2.3.21.tar.gz
  gunzip libart_lgpl-2.3.21.tar.gz
  tar xvf libart_lgpl-2.3.21.tar
  cd libart_lgpl-2.3.21
  ./configure --disable-shared --prefix=/usr/local/libart_lgpl
  make
  make install
  编辑/etc/ld.so.conf,增加如下参数
  /usr/local/zlib/lib
  /usr/local/freetype/lib
  /usr/local/jpeg6/lib
  /usr/local/cgilib/lib
  /usr/local/libart_lgpl/lib
  配置完后执行ldconfig命令,使用动态装入器装载到共享库
  4.3、安装rrdtool(最好用1.3,目前cacti能支持的最高只到1.3)
  gunzip rrdtool-1.4.4.tar.gz
  tar xvf rrdtool-1.4.4.tar
  cd  rrdtool-1.4.4
  ./configure --prefix=/usr/local/rrdtool --disable-python --disable-tcl
  make
  make install
  5、安装net-snmp
  gunzip net-snmp-5.5.tar.gz
  tar xvf net-snmp-5.5.tar
  cd net-snmp-5.5
  ./configure --prefix=/usr/local/net-snmp --enable-developer
  make
  make install
  ln -s /usr/local/net-snmp/bin/* /usr/local/bin
  cp EXAMPLE.conf  /usr/local/net-snmp/share/snmp/snmpd.conf
  启动net-snmp
  /usr/local/net-snmp/sbin/snmpd
  可以在rc.local里面设置为自动启动
  6、安装cacti
  useradd cactiuser -g users
  passwd cactiuser
  gunzip cacti-0.8.7e-cn-utf8.tar.gz
  gunzip cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff.gz
  cp cacti-0.8.7e-cn-utf8.tar /usr/local/apache2/htdocs/
  cd /usr/local/apache2/htdocs/
  tar xvf cacti-0.8.7e-cn-utf8.tar
  mv cacti-0.8.7e-cn-utf8 cacti
  cd cacti
  mv ./*  ../
  cd ../
  patch -p1 < /root/software/cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff
  mysql -uroot
  mysql>create database cacti default character set utf8;
  mysql>grant all on cacti.* to cactiuser@localhost identified by 'cactiuser';
  mysql>flush privileges;
  mysql>quit
  mysql -uroot cactirrdtool应该程序的版本改成安装的版本(1.3.x)
  路径-->设置不对的文件名,改成正确的路径+文件名
  Cacti的使用简易教程
  1. 监控远程Linux主机
  开启远程主机的SNMPD服务
  2. 在Cacti里,进行如下操作,步骤的过程为:添加Devices(增加设备)->Graphs(增加图象)->Tree(增加到图象树)
  2.1. Console->Management->Devices->add (增加监控设备)
  Description:主机描述,可随便写
  Hostname:主机IP地址
  Host Template:主机模板,可以选UCD/Net snmp Host,也可以选None
  SNMP Community:主机中的Community字段值,默认是public
  SNMP Version:一般选Version1或Version2
  2.2. Console->Management->Devices 选中刚才添加的主机,进入编辑界面(给监控主机增加要生成的&quot;图像模板&quot;和进行的&quot;数据查询&quot;)
  Associated Graph Templates:加入
  1) ucd/net - CPU Usage
  2) ucd/net - Load Average
  3) ucd/net - Memory Usage
  如果是本机,可以加入以下模板:
  1) Linux - Memory Usage
  2) Unix - Ping Latency
  3) Unix - Load Average
  4) Unix - Logged in Users
  5) Unix - Processes
  Associated Data Queries:加入
  1) SNMP - Interface Statistics
  2.3. Console->Create ->New Graphs(生成2.2步骤中增加的图象和数据)
  在列表框中选中刚添加的主机,再选中所有Graph Templates和Data Query,再Create。
  2.4. Console->Management->Graph Trees->Default Tree->Add(使生成的图象和数据能在&quot;查看图象&quot;即在&quot;Graphs&quot;中以图象的方式显示出来)
  Parent Item:父节点,默认是根
  Tree Item Type:节点类型,Host
  Host:选择主机
  Sorting Type:排序方式
  [Create]
  2.5. Graphs->Default Tree->HostName查看看监控结果
  3. 监控本地机
  默认Cacti自动安装了监控本地机的模板,也可以自己重建,可按上面的方式,在第一步的Host Template中,选Local Linux Host就可,或者直接用IP,不用本地方式。
  4. 日志
  日志设置:Console -> Settings -> General -> Poller Logging Level,一般选Low既可,可以选Medium查看SNMPWALK的输出,Debug调试。
  日志查看:Console -> Utilities -> View Log File
  日志清除:Console -> Utilities -> Clear Log File
  5. 图表删除
  直接在Devices里删除主机,将删除相关所有数据。
  在Console -> Graph Management里的Graph Management可单独删除一个图表,在Data Sources可删除一个查询。
  6. 树的管理
  Console -> Graph Trees,可以很方便的管理多台主机,将多台主机组成一个树形结构,并且,可以为树指定用户权限.
  7. 权限的管理
  Console -> User Management,可以管理用户,并指定权限.
  报警的实现:
  如果需要提供报警功能还需要安装其他插件
  1、增加cacti插件的方法:为cacti系统安装Thold、Monitor等插件
  插件下载地址:http://cactiusers.org/downloads/
  注意下载时注意相应版本,版本不对会产生问题。
  monitor插件,提供更简略、直观的设备状态图示;
  thold插件,提供设备异常预警。
  安装thold、monitor插件:注意要先备份一下
  (1)、安装Plugin Architecture补丁,安装后,才能启用thold、monitor插件
  shell> tar zxvf cacti-plugin-arch.tar.gz -C /var/www/cacti
  shell> cd /var/www/cacti/
  shell> patch -p1 -N < cacti-plugin-arch/cacti-plugin-0.8.7a-PA-v2.1.diff
  shell> /opt/mysql/bin/mysql -u cactiuser -p cactidb < pa.sql
  (2)、安装thold、monitor插件
  shell> tar zxvf settings-0.5.tar.gz -C /var/www/cacti/plugins
  shell> tar zxvf thold-0.3.4.tar.gz -C /var/www/cacti/plugins
  shell> tar zxvf monitor-0.8.2.tar.gz -C /var/www/cacti/plugins
  shell> cd /var/www/cacti/plugins/
  shell> /opt/mysql/bin/mysql -u cactiuser -p cactidb < thold/thold.sql
  shell> /opt/mysql/bin/mysql -u cactiuser -p cactidb < monitor/monitor.sql
  (3)、修改config.php配置文件
  shell> vi /var/www/cacti/include/config.php
  $config['url_path'] = &quot;/cacti/&quot;;  //改为cacti对应于web目录下的路径,本处为cacti
  $plugins = array();
  $plugins[] = thold;
  $plugins[] = monitor;
  (4)、刷新cacti系统的web管理界面,可以看到多出两个标签页(thold、monitor)。
  (5)、使用monitor插件
  1>打开“Console->Settings->Misc”,可以调整Monitor的各项配置。例如:勾选“Show Icon Legend”可以在监控页面显示图例;
  “View”可以选用Tiles类型,以显示设备状态表格。
  2>为cacti添加新设备时,勾选上“Monitor Host”项。对已添加的设备可以通过“Management->Devices”进去修改。
  3>单击Web页面上方的“monitor”标签链接,可以进入查看各设备/主机的状态图示。
  (6)、使用thold插件
  1>打开“Console->Settings->Mail/DNS”,可以调整“SMTP Options”和“DNS Options”等配置,用于确保预警邮件能够发出。
  2> 打开“Console->Settings->Alerting/Thold”,可以调整Thold的各项配置。例如:“Dead Host  Notifications Email”处可填写设备当机时发送警告信息到哪个邮箱;勾选“Send alerts as  text”项,可以设置只发送文本格式的邮件。
  3>打开“Templates->Threshold  Templates”,可以添加、取出需要关联到预警系统的模板,例如:可以添加和“Interface-Traffic”模板的关联,选择 “traffic_in”、“traffic_out”数据项,分别设置警告阈值“High  Threshold”(如200000000比特/秒);可以添加和“Unix-Disk Space”模板的关联……。
  4>打开“Create->New Graphs”,选择需要提供预警的设备,单击右侧上方的“Auto-create thresholds”创建预警项目。
  5>打开“Management->Thresholds”,可以管理已经创建的预警项目。
  2、cacti监控硬盘I/O的方法:
  cacti本身的模板只可以监控硬盘的使用大小,而不能监控使用百分率,所以我们可以自定义cdef来监控硬盘使用率,并借助thold插件实现报 警功能。网上找的资料都是在cacti.0.8.6版上实现的,而我用的是cacti.0.8.7版。因此,根据实际情况做如下改动:
  在cacti目录下,vi global_arrays.php
  搜索custom_data_source_types,修改这一段如下:
  $custom_data_source_types = array(
  &quot;CURRENT_DATA_SOURCE&quot; => &quot;Current Graph Item Data Source&quot;,
  &quot;ALL_DATA_SOURCES_NODUPS&quot; => &quot;All Data Sources (Don't Include Duplicates)&quot;,
  &quot;ALL_DATA_SOURCES_DUPS&quot; => &quot;All Data Sources (Include Duplicates)&quot;,
  &quot;SIMILAR_DATA_SOURCES_NODUPS&quot; => &quot;All Similar Data Sources (Don't Include Duplicates)&quot;,
  &quot;SIMILAR_DATA_SOURCES_DUPS&quot; => &quot;All Similar Data Sources (Include Duplicates)&quot;,
  &quot;CURRENT_DS_MINIMUM_VALUE&quot; => &quot;Current Data Source Item: Minimum Value&quot;,
  &quot;CURRENT_DS_MAXIMUM_VALUE&quot; => &quot;Current Data Source Item: Maximum Value&quot;,
  &quot;CURRENT_GRAPH_MINIMUM_VALUE&quot; => &quot;Graph: Lower Limit&quot;,
  //添加以下两行
  &quot;CURRENT_GRAPH_MAXIMUM_VALUE&quot; => &quot;Graph: Upper Limit&quot;,
  &quot;VALUE_OF_HDD_TOTAL&quot; => &quot;Value of hdd_total data source&quot;);
  //中文版汉化为:
  &quot;CURRENT_GRAPH_MAXIMUM_VALUE&quot; => &quot;图像: 上限&quot;,
  &quot;VALUE_OF_HDD_TOTAL&quot; => &quot;所有硬盘数据的值&quot;);
  在cacti界面的Graph Management-cdefs新建cdef模块,名字自己起,添加字段如下:
  Item #1 Special Data Source: CURRENT_DATA_SOURCE
  Item #2 Custom String: 100
  Item #3 Operator: *
  Item #4 Special Data Source: VALUE_OF_HDD_TOTAL
  Item #5 Operator: /
  也就是说
  cdef=CURRENT_DATA_SOURCE,100,*,VALUE_OF_HDD_TOTAL,/
  这样就可以在Threshold Templates里面添加监控硬盘的模块了,我添加的是Host MIB - Hard Drive Space ,最后在Threshold CDEF里面选择刚自定义的cdef,这样就可以正常监控硬盘使用率了。
  官方论坛上有介绍,地址http://forums.cacti.net/about8777-0-asc-0.html
  下面把使用方法摘录如下:
  1. Copy net-snmp_devio.xml to /resource/snmp_queries/net-snmp_devio.xml
  2. Import all *_templ.xml via Cacti &quot;Import Templates&quot; interface - These templates should include all their dependancies
  3. Add &quot;ucd/net - Get Device I/O&quot; Data Query to your SNMP Enabled host using the &quot;Index Count Changed&quot; Re-index Method.
  4. Create Graphs for your desired Disk and/or Memory devices.
  总体注意事项:
  1)、很重要的一点:在cacti的设备中一定要选择snmp的版本为>=2,否则会获取不到cpu和网卡等相关信息。
  2)、cacti自带的local视图内存监控单位是错误的,可以删掉重新创建,就会改正。
  3)、系统监控中,cpu图标的 200m这类数字,表示的是 万分之多少,我的理解cacti是为了方便显示画图。
  4)、权限问题:cacti_path/rra log目录的权限一定要给cacti的新用户,否则会出错:有图,但是没有数据


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662057-1-1.html 上篇帖子: 轻松八步搞定Cacti配置安装(原创视频) 下篇帖子: nagios和cacti的整合
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

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