它通过snmpget来获取数据,使用RRDTool绘图,但使用者无须了解RRDTool复杂的参数。它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结构、主机设备以及任何一张图,还可以与LDAP 结合进行用户认证,同时也能自定义模板,在历史数据的展示监控方面,其功能相当不错。
Cacti通过添加模板,使不同设备的监控添加具有可复用性,并且具备可自定义绘图的功能,具有强大的运算能力(数据的叠加功能)
1.2Nagios
Nagios是一款开源的免费网络监视工具,能有效监控windows、Linux和Unix的主机状态,交换机、打印机、路由器等网络设备。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
nagios主要的特征是监控告警,最强大的就是告警功能,可支持多种告警方式,但缺点是没有强大的数据收集机制,并且数据出图也很简陋,当监控的主机越来越多时,添加主机也非常麻烦,配置文件都是基于文本配置的,不支持web方式管理和配置,这样很容易出错,不宜维护。
1.3Zabbix
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各种网络参数,保证服务器系统的安全运营并提供强大的通知机制以让系统运维人员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。zabbix server可以通过SNMP,zabbix,agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,os x等平台上。
zabbix解决了cacti没有告警的不足,也解决了nagios不能通过web配置的缺点,同时还支持分布式部署,这使得它迅速流行起来,zabbix也成为目前中小企业监控最流行的运维监控平台。当然,zabbix也有不足之处,它消耗的资源比较多,如果监控的主机非常多时(服务器数量超过500台),可能会出现监控超时、告警超时、告警系统单点故障等现象,不过也有很多解决办法,比如提高硬件性能、改变zabbix监控模式等。
① agent代理:专门的代理服务方式进行监控,专属的协议,装有zabbix-agent的主机就可以被zabbix-server监控,主
动或被动的方式,把数据给到server进行处理。
② ssh/telent:linux主机支持ssh/telent协议
③ snmp:网络设备路由器、交换机不能安装第三方程序(agent),使用简单网络协议。大多数的路由器设备支持SNMP协议
④ ipmi:通过ipmi接口进行监控,我们可以通过标准的ipmi硬件接口,监控被监控对象的物理特征,比如电压,温度,
风扇状态电源情况,被广泛使用服务监控中,包括采集cpu温度,风扇转速,主板温度,及远程开关机等等,而且ipmi独立于硬件和 *** 作系统,无论是cpu,bios还是os出现故障,都不会影响ipmi的工作,因为ipmi的硬件设备BMC(bashboard management controller)是独立的板卡,独立供电
⑤ zabbix核心组件介绍
Zabbix Server:
Zabbix软件实现监控的核心程序,主要功能是与Zabbixproxies和Agents进行交互、触发器计算、发送告警通知并将数据集中保存。与prometheus的类似可以保存收集到的数据,但是prometheus告警需要使用altermanager组件
Database storage:
存储配置信息以及收集到的数据
web Interface:
Zabbix的GUI接口,通常与server运行在同一台机器上
Proxy:
可选组件,常用于分布式监控环境中,一个帮助zabbix Server收集数据,分担zabbix Server的负载的程序
Agent:
部署在被监控主机上,负责收集数据发送给server
1.5Prometheus
borg.kubernetes
borgmon(监控系统) 对应克隆的版本:prometheus(go语言)
所以prometheus 特别适合K8S 的架构上
而作为一个数据监控解决方案,它由一个大型社区支持,有来自700多家公司的6300个贡献者,13500个代码提交和7200个拉取请求
Prometheus具有以下特性:
① 多维的数据模型(基于时间序列的Key、value键值对)
② 灵活的查询和聚合语言PromQL(难)
③ 提供本地存储和分布式存储
④ 通过基于HTTP和HTTPS的Pull模型采集时间序列数据(pull数据的拉取,时间序列:每段
时间点的数据值指标,持续性的产生。横轴标识时间,纵轴为数据值,一段时间内数值的动态变化,所有的点连线形成大盘式的折线图)
⑤ 可利用Pushgateway (Prometheus的可选中间件)实现Push模式
⑥ 可通过动态服务发现或静态配置发现目标机器(通过consul自动发现和收缩)
⑦ 支持多种图表和数据大盘
open-Falcaon是小米开源的企业级监控工具,用GO语言开发,包括小米、滴滴、美团等在内的互联网公司都在使用它,是一款灵活、可拓展并且高性能的监控方案。
常用的有:1.cactio
实际上cacti不是监控工具,而是个依赖于SNMP的数据采集和数据呈现的工具。但是很多人喜欢用来当监控(因为其功能可以很好的完成这个工作)
功能:数据采集、 保存数据[SQL, txt].
数据展示(rrdtool 绘图)。
数据分析和报警(很一般)。
2. nagios。
功能:数据报警(报警功能是Nagios的特色功能) [ 故障触发,故障恢复都可以。
依赖分析报警(能自动的识别到关键设备的故障,关联设备不会报警)。
数据采集(采集的数据是弱项,他只关心警戒位,只关心正常与否的状态,状态转换时可以实现报警,所以它采集的数据不需要保存),当然也有插件弥补这个不足,如PNP4Nagios。
3. zabbix (php)(推荐)
Nagiostcacti整合互相弥补不足!I
nagios和 cacti不适合超大规模的监控、由于大规模的带宽和网络限制,会导致监控的延迟等问题,所以有很多是 nagios+ cacti整合,但是依然不适合在大规模的环境中,不适合分布式部署, Nagios在大规模中就会出现延迟,失
去 Nagios本事的特色。
那么 zabbix同时整合了 cacti和 Nagios特点的工具,而且还具有了前两者不具有的工具,支持分布式等等。
4. 补充工具:
netdata:托管在github上的一款类型zabbix的开源监控工具https:/
/github. com/firehol/netdata
open- falcon:小米公司开源的企业级监控工具(python)(推荐)
Ganglia类似于 zabbix,大型分布式监控系统
开源监控工具对比http://www.oschina.net/news/67525/monitoring-tools
5. 监控软件数据采集的方式
SNMP 协议。
agent 代理的方式去采集数据。
shell 脚本api 接口
6. 数据展示方式
php html app
7. 数据告警
mail,msm,微信,电话,钉钉机器人
apache2.2.8+mysql5.0.51+php5.2.5+snmp5.14+rrdtool+cacti 配置OS fedora7 安装选包定制
全选开发包
服务器 一个没选
本机IP 192.168.1.254
安装 mysql
所有安装程序 在 /usr/local下
[root@localhost usr]# groupadd mysql
[root@localhost usr]# useradd -g mysql mysql
[root@localhost usr]# cd /usr/local
[root@localhost local]# tar -zxvf mysql-5.0.51.tar.gz
[root@localhost local]# cd mysql-5.0.51
[root@localhost mysql-5.0.51# ./configure --prefix=/usr/local/mysql
[root@localhost mysql-5.0.51]# make
[root@localhost mysql-5.0.51]# make install
[root@localhost mysql-5.0.51]# cd ../mysql
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql var
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql &
[root@localhost mysql]# ./bin/mysqladmin -uroot password mysql
[root@localhost mysql]# cp ../mysql-5.0.51/support-files/my-large.cnf /etc/my.cnf
[root@localhost mysql]# cp ../mysql-5.0.51/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --level mysqld 345 on
[root@localhost mysql]# chkconfig --list mysqld
[root@localhost mysql]#
Mysql 安装结束
安装apache
[root@localhost usr]# tar -zxvf httpd-2.2.8.tar.gz
[root@localhost usr]# cd httpd-2.2.8
[root@localhost httpd-2.2.8]# ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so
[root@localhost httpd-2.2.8]# makemake install
[root@localhost httpd-2.2.8]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@localhost httpd-2.2.8]# cd /etc/rc3.d
[root@localhost rc3.d]# ln -s /etc/init.d/httpd S85httpd
[root@localhost rc3.d]# ln -s /etc/init.d/httpd K85httpd
[root@localhost rc3.d]# /usr/local/apache/bin/apachectl star
Apache 安装完毕
安装PHP
安装支持图形处理,自己可以找最新的安装。
##### zlib#####
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
cd ..
##### FreeType ##### freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype
make
make install
cd ..
##### LibPNG #####
cd libpng-1.2.20
cp scripts/makefile.linux makefile
make test
make install
cd ..
##### Jpeg ##### jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make
make install
cd ..
##### gd ##### gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg \
--with-freetype=/usr/local/freetype \
--with-png \
--with-zlib
[root@localhost local# tar -zxvf php-5.2.5.tar.gz
[root@localhost local# cd php-5.2.5
[root@localhost php-5.2.5]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-
mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc --with-openssl=/usr/local/ssl --with-gd=/usr/local/gd --
with-gdbm=/usr/lib --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg --with-png-dir --with-
zlib=/usr/local/zlib --enable-mbstring --enable-sockets
[root@localhost php-5.2.5]# makemake install
[root@localhost php-5.2.5]# cp php.ini-dist /usr/local/php/etc/php.ini
[root@localhost php-5.2.5]# vi /usr/local/apache/conf/httpd.conf
按 I 键 添加 AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
DirectoryIndex index.php index.html index.html.var
保存退出 :wq
[root@localhost php-5.2.5]# /usr/local/apache/bin/apachectl restart
Php安装完毕
设置mysql
[root@localhost httpd-2.2.8]# /usr/local/mysql/bin/mysql -u root -pmysql
mysql>create database cactidb
mysql>grant all on cactidb.* to root
mysql>grant all on cactidb.* to root@localhost
mysql>grant all on cactidb.* to cactiuser
mysql>grant all on cactidb.* to cactiuser@localhost
mysql>set password for cactiuser@localhost=password('cactipw')
注:以上语句输出 Query OK, 0 rows affected (0.01 sec) 表示成功
mysql>exit
Mysql设置完毕
检测apache + php + mysql
[root @tsai usr]# cd /www/htdocs
[root @tsai htdocs]# touch info.php
[root @tsai htdocs]# vi info.php
<?
phpinfo( )
?>
保存退出 :wq
[root @tsai htdocs]# touch mydqltest.html
[root @tsai htdocs]# vi mysqltest.html
<html>
<body>
<?
$link=mysql_connect('localhost','root')
mysql_select_db('mysql')
$str="select * from user"
$result=mysql_query($str,$link)
$show=mysql_num_rows($result)
mysql_close($link)
for ($i=0$i <$show$i++)
{
$arr[$i]=mysql_fetch_array($result)
}
?>
<table align=center border=1>
<tr align=center>
<td>Host</td>
<td>User</td>
<td>Password</td>
</tr>
<?for ($i=0$i<$show$i++){?>
<tr>
<td><?echo $arr[$i][Host]?></td>
<td><?echo $arr[$i][User]?></td>
<td><?echo $arr[$i][Password]?></td>
</tr>
<?}?>
</body>
</html>
保存退出 :wq
重启mysql + apache 服务
[root @localhost htdocs]# service mydql restart
[root @localhost htdocs]# service httpd restart
进入浏览器检查
http://192.168.1.254/info.php 和 http://192.168.1.254/mysqltest.html
安装rrdtool
[root@localhost usr]# tar zxvf rrdtool-1.0.50.tar.gz
[root@localhost usr]# cd rrdtool-1.0.50
[root@localhost rrdtool-1.0.50]# ./configure
[root@localhost rrdtool-1.0.50]# make &&make install
我的是fedora 7,用下面的方法。
[root@localhost usr] yum install rrdtool
Rrdtool安装完毕
安装net-snmp、snmpwalk和snmpget命令
[root@localhost usr]# rpm -qa | grep net-snmp
net-snmp-5.0.9-2.30E.15
net-snmp-devel-5.0.9-2.30E.15
net-snmp-libs-5.0.9-2.30E.15
net-snmp-utils-5.0.9-2.30E.15
[root@localhost usr]# vi /etc/snmp/snmpd.conf
更改 1、com2sec notConfigUser default public
改为:com2sec notConfigUser 127.0.0.1 public
2、access notConfigGroup "" any noauthexact systemview none none
改为:access notConfigGroup "" any noauthexact all none none
3、#view allincluded .1 80
将前面的 # 注释 去掉。
保存退出 :wq
[root@localhost usr]# service snmpd restart
使用yum安装更方便:
[root@localhost usr]# yum install net-snmp
[root@localhost usr]# yum update net-snmp
配置还是使用上面的方法修改。
或者使用:net-snmp-5.1.4.tar.gz安装
[root@localhost local]# tar -zxvf net-snmp-5.1.4.tar.gz
[root@localhost local]# cd net-snmp-5.1.4
[root@localhost local]# ./configure
[root@localhost local]# make
[root@localhost local]# make install
运行snmpconf -g basic_setup,会在当前目录下生成一个snmpd.conf配置文件:
[root@localhost local]# snmpconf -g basic_setup
运行后会出现一个询问菜单,按如下步骤进行回答:CODE:[Copy to clipboard]Do you want to configure the information returned in
the system MIB group (contact info, etc)? (default = y): y
The location of the system: Shenzhen, China
The contact information: [email protected]
Do you want to properly set the value of the sysServices.0 OID (if you don't know, just say no)? (default = y): y
does this host offer physical services (eg, like a repeater) [answer 0 or 1]: 1
does this host offer datalink/subnetwork services (eg, like a bridge): 0
does this host offer internet services (eg, supports IP): 1
does this host offer end-to-end services (eg, supports TCP): 1
does this host offer application services (eg, supports SMTP): 1
Do you want to configure the agent's access control? (default = y): y
Do you want to allow SNMPv3 read-write user based access (default = y): n
Do you want to allow SNMPv3 read-only user based access (default = y): n
Do you want to allow SNMPv1/v2c read-write community access (default = y): n
Do you want to allow SNMPv1/v2c read-only community access (default = y): y
The community name to add read-only access for: public
The hostname or network address to accept this community name from [RETURN for all]: (RETURN)
The OID that this community should be restricted to [RETURN for no-restriction]: (RETURN)
Do you want to configure where and if the agent will send traps? (default = y): n
Do you want to configure the agent's ability to monitor various aspects of your system? (default = y): y
Do you want to configure the agents ability to monitor processes? (default = y): y
Name of the process you want to check on: sshd(需要监控的进程)
Maximum number of processes named ' sshd' that should be running [default = 0]: 1
Minimum number of processes named ' sshd' that should be running [default = 0]: 0
Do another proc line? (default = y): n
Do you want to configure the agents ability to monitor disk space? (default = y): y
Enter the mount point for the disk partion to be checked on: /
Enter the minimum amount of space that should be available on /var: %100
Do another disk line? (default = y): y
Enter the mount point for the disk partion to be checked on: /var
Enter the minimum amount of space that should be available on /var: %100
Do another disk line? (default = y): y
Enter the mount point for the disk partion to be checked on: /usr
Enter the minimum amount of space that should be available on /usr: %100
Do another disk line? (default = y): y
Enter the mount point for the disk partion to be checked on: /home
Enter the minimum amount of space that should be available on /home: %100
Do another disk line? (default = y): n
Do you want to configure the agents ability to monitor load average? (default = y): y
Enter the maximum allowable value for the 1 minute load average: 12
Enter the maximum allowable value for the 5 minute load average: 12
Enter the maximum allowable value for the 15 minute load average: 12
Do another load line? (default = y): n
Do you want to configure the agents ability to monitor file sizes? (default = y): n(如果想监控文件的大小,可以选y)
4.运行net-snmp:
# snmpd -c /path/snmpd.conf (要上面生成的绝对路径)
测试一下看看net-snmp是否配置成功:
#snmpwalk -v 1 -c public localhost .1 (是否可以从.1开始采集服务器数据)
#snmpwalk -v 1 -c public localhost dskPercent.1 (看看刚配置过的硬盘监测是否成功)
如果有数据了,恭喜你snmp安装成功了。
注:如果你机器内没有snmpwalk和snmpge命令,请到安装盘里查找 net-snmp-utils 包,rpm -ivh net-snmp-utils-*.rpm 只后这两个命令就
在系统里了。其他包也都在安装盘里 确保安装这四个包就OK
安装/ 配置cacti
[root@localhost usr]# useradd cactiuser -g users
[root@localhost usr]# passwd cactiuser (pwd:cactipw)
[root@localhost usr]# cp cacti-0.8.7.tar.gz /var/www/html
[root@localhost usr]# cd /var/www/html
[root@localhost html]# tar -zxvf cacti-0.8.7.tar.gz
[root@localhost html]# mv cacti-0.8.6g cacti
[root@localhost html]# cd cacti
[root@localhost cacti]# /usr/local/mysql/bin/mysql -u root -p cactidb <cacti.sql
passwork:
[root@localhost cacti]# chown -R cactiuser rra/ log/
[root@localhost cacti]# cd scripts
[root@localhost scripts]# chown cactiuser:users *
[root@localhost scripts]# vi /www/htdocs/cacti/include/config.php
$database_type = “mysql”
$database_default = “cactidb”
$database_hostname = “localhost”
$database_username = “cactiuser”
$database_password = “cactipw”
更改用户、密码 等项 与上面给出的对应 保存退出
[root@localhost scripts]# crontab -u cactiuser -e
加入
*/5 * * * * /usr/local/php/bin/php /var/www/html/cacti/poller.php >/dev/null 2>&1
保存退出:wq
全部设置完毕。
打开浏览器 http://192.168.1.254/cacti 进入cacti的初始设置页面
第一次默认登陆账号:admin 密码 admin
登陆后在新改个密码就OK
需要说明的还有路径
snmpwalk Binary Path : /usr/bin/snmpwalk
snmpget Binary Path: /usr/bin/snmpget
RRDTool Binary Path: /usr/bin/rrdtool
PHP Binary Path: /usr/local/php/bin/php
Cacti Log File Path: /var/www/html/cacti/log/cacti.log
Cactid Poller File Path:/var/www/html/cacti/poller.php
如果你是按我的步骤做的 那上面的路径一定不会错。
注:此时graphs还不能显示图形,需要将服务重新启动一下
[root@localhost scripts]# service snmpd restart
[root@localhost scripts]# service mysql restart
[root@localhost scripts]# service httpd restart
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)