ubuntu 安装tsar
贝浩歌
2023-12-01
1.安装tsar
sudo apt-get install alien
sudo alien --script tsar-2.1.0-0.el4.x86_64.rpm
sudo dpkg -i tsar_2.1.0-1_amd64.deb
sudo apt-get install libwrap0-dev
apt-get install libmysql++-dev
apt-get install libmysqlclient15-dev
sudo tar -xzvf tsar.tar.gz
sudo chmod 777 tsar
cd tsar/
sudo make clean
sudo make
sudo make install
测试:tsar -l
2.配置tsar输出到数据库
cd /etc/tsar/
sudo vi tsar.conf 修改如下内容
output_interface file,db
output_db_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
output_db_addr localhost:56677
3.创建tsar数据库
mysql -u root --password='123456'
create database tsar;
4.安装tsar2db
sudo unzip tsar2db-master.zip
sudo chmod 777 tsar2db-master
cd tsar2db-master/
mkdir /etc/httpd/conf/include/
mkdir /home/a/share/cgi-bin/
sudo make clean
sudo make
sudo make install
5.创建tsar表
cd /etc/tsar2db/
./cleanmysql.sh
mysql -uroot -p tsar <init.sql
mysql -uroot -p tsar <tsar.sql
6.配置tsar2db
sudo vi tsar2db.cfg 修改如下内容
db_name=tsar
db_user=root
db_pw=123456
7.运行tsar2db
cd /etc/tsar2db/
./tsar_server
8.测试是否写数据到数据库
tsar -l
mysql -u root --password='123456'
use tsar;
select * from cpu;
9.定时任务
/etc/cron.d/tsar