当前位置: 首页 > 工具软件 > tsar2db > 使用案例 >

Tsar学习笔记---tsar tsar2db mysql 集成调测篇

邰棋
2023-12-01

内容简介:

tsar支持把监控的系统数据进行如下三种方式处理:
1.输出到本地;
2.把监控数据送到mysql的数据库中
3.把监控数据送给nagios
        这里我们描述第二种方式的联调方式,把监控数据送到mysql的数据库中;

步骤一:修改tsar的配置文件

tsar的配置文件默认安装路径在/etc/tsar/tsar.conf,修改完后,是实时生效的;
[root@ip-172-28-0-201 tsar]# cat /etc/tsar/tsar.conf
####debug_level(INFO DEBUG WARN ERROR FATAL)
debug_level ERROR
####[module]      ---选择监控项用on off进行标记
mod_cpu on
mod_mem on
mod_swap on
mod_tcp on
mod_udp on
mod_traffic on
mod_io on
mod_pcsw on
mod_partition on
mod_tcpx on
mod_load on
mod_apache off
mod_lvs off
mod_haproxy off
mod_squid off
mod_nginx off
mod_swift off
mod_swift_code off
mod_swift_domain off
mod_swift_esi off
mod_swift_fwd off
mod_swift_store off
mod_swift_swapdir off
mod_swift_purge off
mod_swift_sys off
mod_swift_tcmalloc off
mod_tmd off
mod_percpu off
mod_tcprt off
mod_proc off pidname
mod_pharos off


####output_interface file,db,nagios         ---选择监控文件输出方式,这里选择db
output_interface db


####[output_file] original data to store
output_file_path /var/log/tsar.data


####[output_stdio] these mod will be show as using tsar command
output_stdio_mod mod_swap,mod_partition,mod_cpu,mod_mem,mod_lvs,mod_haproxy,mod_traffic,mod_squid,mod_load,mod_tcp,mod_udp,mod_tcpx,mod_apache,mod_pcsw,mod_io,mod_percpu


####[output_db]                      ----配置上传数据库的监控数据项;并配置Tsar2db的地址,把数据上传到Tsar2db
output_db_mod mod_swap,mod_partition,mod_cpu,mod_mem,mod_traffic,mod_load,mod_tcp,mod_udp,mod_pcsw,mod_io
output_db_addr 127.0.0.1:56677


####support include other mod conf
include /etc/tsar/conf.d/*.conf


####The IP address or the host running the NSCA daemon
server_addr 127.0.0.1
####The port on which the daemon is running - default is 5667
server_port 56677
####The cycle of send alert to nagios
#cycle_time 300
####nsca client program
#send_nsca_cmd /usr/bin/send_nsca
#send_nsca_conf /home/a/conf/amon/send_nsca.conf


####tsar mod alert config file
####threshold servicename.key;w-min;w-max;c-min;cmax;
#threshold cpu.util;N;N;N;N;

步骤二:搭建Tsar2db,并配置

1. 下载地址 https://codeload.github.com/alibaba/tsar2db/zip/master
tsar2db编译要依赖于mysql-devel模块
下载地址:
 wget http://vault.centos.org/5.3/updates/x86_64/RPMS/mysql-devel-5.0.77-3.el5.x86_64.rpm
  wget http://vault.centos.org/5.3/updates/x86_64/RPMS/mysql-5.0.77-3.el5.x86_64.rpm
  wget http://vault.centos.org/5.3/updates/x86_64/RPMS/mysql-server-5.0.77-3.el5.x86_64.rpm
2.安装完rpm包后,编译安装tsar2db
unzip tsar2db-master.zip
cd tsar2db-master
make
make install
3.配置tsar2db
[root@ip-172-28-0-201 ~]# cat /etc/tsar2db/tsar2db.cfg
#mysql database hostname or ip
db_address=127.0.0.1
#database port default is 3306
db_port=3306
#mysql user info for tsar
db_name=tsar
db_user=tsaruser
db_pw=tsarpw
#tsar2db port.same as output_nagios_addr at /etc/tsar/tsar.conf
server_port=56677
#log for tsar2db.see more@/var/log/message
debug=0
pid_file=/var/run/tsar2db.pid
     
4.启动Tsar2db
/etc/init.d/tsar2db {start|stop|restart|status}
5.调测日志路径
/var/log/message                        
成功启动后,tsar会与tsar2db建立一个socket链接,tsar2db会与mysql建立一个socket链接;数据库的插入sql语句会 在/var/log/message中体现

 类似资料: