当前位置:首页 » 编程软件 » cacti监控脚本

cacti监控脚本

发布时间: 2022-06-20 04:04:02

❶ 如何使用CactiEZ进行监控Windows主机

如何使用CactiEZ进行监控:
1.要监视一台linux主机,需要在被监控的主机上安装net-snmp相关软件包,CentOS安装可使用“yum -y install net-snmp”命令:
# yum -y install net-snmp
……
Complete!
2.修改配置文件命令:
# vi /etc/snmp/snmpd.conf 确保snmpd.conf文件中包含以下内容:
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1
access notConfigGroup "" any noauth exact systemview none none
syslocation www.cactiez.com #系统的物理位置
syscontact Root [email protected] # 联系人
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
保存并退出
3.开启snmpd服务:
# service snmpd start
4.设置snmpd每次开机时自动启动:
# chkconfig snmpd on。该命令执行完成后不会返回任何结果
5.检查snmpd服务是否已在运行:
# netstat -nlup | grep ":161"
udp 0 0 0.0.0.0:161 0.0.0.0:* 16986/snmpd
该命令检查本地是否已在监听UDP端口161,如果返回类似以上结果,表明snmpd服务启动成功。
6.登录CactiEZ-Web界面,依次点击:“控制台”,“主机”,“添加”。添加以下设置:
如何使用CactiEZ进行监控Linux主机
7.如果一切正常,您将会看到类似以下信息:
如何使用CactiEZ进行监控Linux主机
如果不正常,请检查团体名称,IP地址,防火墙等。
8.主机添加后,需要添加图形,点击右上方的“为这个主机添加图形”。
8.1在“图形模板”区域钩选所有对象:
添加: ucd/net - CPU使用率
添加: ucd/net - 负载平均值
添加: ucd/net - TCP记数器
添加: ucd/net - TCP连接数
添加: ucd/net - 内存使用率
添加: 主机MIB - 进程数量
添加: 主机MIB - 已登录用户
8.2在“数据查询 [SNMP - 获取磁盘IO]”区域钩选您需要监控的磁盘名称:
如sda,sdb,hda等。
注意:磁盘IO有两个指标需要监控,一个是“磁盘IO 字节/秒”,另一个是“磁盘IO 传输/秒”,但一次只能添加一个,如果要监控两个指标,需要添加两次。
8.3在“数据查询 [SNMP - 获取处理器信息]”区域钩选您的逻辑处理器,
如果您只有一个逻辑处理器,那么这里将不可选择。
8.4在“数据查询 [SNMP - 获取已挂载分区]”区域钩选您需要监控的磁盘名称:
如“Real Memory”,“Swap Space”,“/”等,根据您的需求钩选。
8.5在“数据查询 [SNMP - 接口统计]”区域钩选您的网络设备,如“eth0”。
如果该主机为64位主机,请选择“流入/流出 位(64位)”。
如果该主机为32位主机,请选择“流入/流出 位”即可。
9.再次点击“添加”已完成设置。
10.查看主机状态,点击上方的“监视器”按钮,显示绿色表示正常。

❷ 如何使cacti监控mysql服务器

cacti监控mysql数据库的方法


环境:


Cactiez或者cacti主机:192.168.12.5


被监控mysql数据库主机:192.168.5.231


1. 安装监控插件


cd /opt

tar -xzvf mysql-cacti-templates-1.1.2.tar.gz

cp /opt/mysql-cacti-templates-1.1.2/ss_get_mysql_stats.php /var/www/html/scripts/

其实里面我们要监控mysql用到的是:acti_host_template_x_db_server_ht_0.8.6i.xml和mysql_definitions.pl


其他则是监控Apache和Nginx的,接下来我们会介绍到,这里不再详细的讲了。


chown -R apache.apache /var/www/html/scripts

chmod -R 755 /var/www/html/scripts

使用 http 访问 cacti主机 导入


/opt/mysql-cacti-templates-1.1.2/cacti_host_template_x_db_server_ht_0.8.6i.xml

http://192.168.12.5

默认CactiEZ 和Cacti别是 admin admin


控制台 - 导入导出 - 模板导入 - 浏览


选中 cacti_host_template_x_db_server_ht_0.8.6i.xml


保存


2. 配置cacti的mysql插件


修改 ss_get_mysql_stats.php


vi /var/www/html/scripts/ss_get_mysql_stats.php

$mysql_user = 'cacti';

$mysql_pass = 'cacti';

$cache_dir = "/tmp/cacti/cache/";

这个账户和密码是 被监控端主机 给 Cacti主机 授权的 账户和密码


Cacti需要这个账户和密码去连接 被监控机 查询状态


mkdir -p /tmp/cacti/cache

chown -R apache.apache /tmp/cacti

chmod -R 755 /tmp/cacti

设置 cacti 缓存目录在 /tmp/cacti/cache/ 并给予权限


3. 配置被监控端(192.168.5.231)的mysql 给 cacti 主机授权


mysql -uroot -p

grant process,super on *.* to 'cacti'@'192.168.12.5' identified by 'cacti';

exit

grant process,super on *.* to '账户'@'Cacti主机IP地址' identified by '密码';此命令意义


只允许IP为 192.168.12.5 的主机 以账户 cacti 密码 cacti 去访问 本机数据


4. 在Cacti主机上(192.168.12.5) 监控Mysql


4.1 为主机添加mysql模块


控制台 - 管理 - 设备 - 选中之前创建好的主机


然后移到最下面的 添加图形模版 选中 Mysql相关模块 然后保存


4.2 为mysql模块创建图形


控制台 - 创建 - 创建图形 - 选中该主机 - 选中mysql模块 - 创建


4.3 插件mysql性能数据


监视器 - 选中该主机 - 查阅对应的mysql


完毕


-----一些数据库操作语句


mysqld_safe --user=mysql &

mysql -uroot -p

mysql -uroot -proot

grant ALL PRIVILEGES ON *.* to ‘root’@"%" identified by "root" WITH GRANT OPTION;

exit

grant select,insert,update,delete on cacti.* to ‘cacti’@”*”identified by "cacti";

exit

grant process,super on *.* to 'cacti'@'%' identified by 'cacti';

grant all privileges on cacti.* to ‘cacti’@"%" identified by "cacti";

客户端开启Cacti访问本机mysql的权限


grant process,super on *.* to 'cacti'@'192.168.12.5' identified by 'cacti';

grant process,super on *.* to 'cacti'@'192.168.5.231' identified by 'cacti';

= = = = =

mysql -ucacti -pcacti -h 192.168.5.231

❸ linux下的监测工具,这几个哪个最好zabbix、nagios、munin、cacti

报警
绘图 snmp 专用客户端
自定义脚本 web前端 优点 缺点

cacti N
Y Y N Y Y 管理方便 监控有限,
若要添加自定
义图表比较麻烦

munin N Y Y Y Y Y 管理方便 灵活度不高,
监控有限,
若要添加
自定义图
表比较麻烦
zabbix Y Y Y Y Y Y 功能全面 使用较麻烦

opennms Y Y Y

monit Y N N N Y Y 能自动重启服务,
web界面启动或者关闭服务 监控本机比较
方便,不适合
监控远程主机

nagios Y N Y Y
Y Y 报警功能强大

❹ cacti监控

1.交换机和路由器开启snmp服务
2.为交换机及路由器指定snmp数据接收服务器
3.以上两项配置好就可以监控到数据了

同时推荐一款软件cacti,是目前我发现的网络监控最好的软件了

red hat linux 除非你花钱买 红冒的 更新源...
否这你得....至少编译安装这些软件以解决依赖问题
dejavu-lgc-sans-mono-fonts
mysql
net-snmp
php
php-cli
php-common
php-mysql
php-pdo
php-snmp
rrdtool
dejavu-fonts-common
dejavu-sans-fonts
dejavu-sans-mono-fonts
dejavu-serif-fonts
mysql-libs
net-snmp-libs

服务器监控的话,建议使用nagios,非常强大

❺ 哪位Cacti高手可以指点下 Cacti如何用脚本来抓数据和如果把数据画成图。本人新手。

我现在日常就用着cacti,cacti用脚本抓取数据其实很简单的,简单步骤:
1,把脚本放在cacti安装目录下的scripts下
2,脚本获取的数据输出格式为 xxx:123 ,前面的xxx为变量名称,后面的数字为脚本抓到的值
3,到cacti里建立一个数据输入模板,数据类型选择脚本,填上脚本的路径比如<path_cacti>/scripts/host_avg_num_cpu.sh <hostname> (后面<>中为自己定义需要传递给脚本的变量,可以多个)
3.1,新建Input Fields,就是上面自己定义的变量(有部分内置变量,详看Special Type Code的说明)
3.2,新建Output Fields,名称一定要和上面脚本输出的xxx一样,记得选上Update RRA
4,新建数据模板,主要是选择对输入模板名称和输入模板中的Output Fields,数据类型默认的好
5,新建图形模板,选择上一步建立好的数据模板中的数据;画线的话可以选择LINE1,细项自己看一下就清楚了,很简单的。需要注意的是画图一定需要选择average,选择其它会造成不出图;下面的数据限制默认会是100,需要改成0,要不超100的数据也不会画。

❻ cacti使用

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]# make;make 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]# make;make 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 noauth exact systemview none none
改为:access notConfigGroup "" any noauth exact all none none
3、#view all included .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

❼ 用cacti怎样对网络进行监控

cacti监控网络的流量,使用SNMP协议,只要设备支持SNMP协议,都可以进行监控

❽ Linux系统下cacti监控脚本是存放在哪个位置

监控脚本?有这个东西吗?他是通过rrtool进行图形监控的,在rra文件下是你监控服务器的项目文件

热点内容
超级访问陈小春应采儿 发布:2025-05-16 09:43:29 浏览:478
缓存视频合并工具最新版 发布:2025-05-16 09:35:03 浏览:194
花雨庭服务器ip地址和端口 发布:2025-05-16 09:34:58 浏览:239
同时修改多台服务器管理地址工具 发布:2025-05-16 09:20:36 浏览:421
什么配置就能玩地平线 发布:2025-05-16 09:13:46 浏览:82
python旋转图片 发布:2025-05-16 09:13:40 浏览:638
少女前线防检测脚本 发布:2025-05-16 08:59:07 浏览:728
编译器对系统的依赖 发布:2025-05-16 08:37:29 浏览:711
javamap数组 发布:2025-05-16 08:37:28 浏览:451
移动光猫如何自行修改密码 发布:2025-05-16 08:20:15 浏览:125