tsar 使用
常用参数:
https://github.com/alibaba/tsar
安装
$ wget -O tsar.zip https://github.com/alibaba/tsar/archive/master.zip --no-check-certificate
$ unzip tsar.zip
$ cd tsar
$ make
# make install
定时任务配置:/etc/cron.d/tsar,负责每分钟调用tsar执行采集任务;
日志文件轮转配置:/etc/logrotate.d/tsar,每个月会把tsar的本地存储进行轮转;
Tsar配置文件路径:/etc/tsar/tsar.conf,tsar的采集模块和输出的具体配置;
模块路径:/usr/local/tsar/modules,各个模块的动态库so文件;
Tsar的配置主要都在/etc/tsar/tsar.conf中,常用的有:
增加一个模块,添加 mod_<yourmodname> on 到配置文件中
打开或者关闭一个模块,修改mod_<yourmodname> on/off
output_stdio_mod 能够配置执行tsar时的输出模块
output_file_path 采集到的数据默认保存到的文件(如果修改的话需要对应修改轮转的配置/etc/logrotate.d/tsar)
output_interface 指定tsar的数据输出目的,默认file保存本地,nagios/db输出到监控中心/数据库中,这两个功能还需要结合其它配置
常用参数:
--help/-h 显示提示信息和模块信息
[fangyali@1.2 ~]tsar -h
Usage: tsar [options]
Options:
-check display last record for alert
--check/-C display last record for alert.example:tsar --check / tsar --check --cpu --io
--cron/-c run in cron mode, output data to file
--interval/-i specify intervals numbers, in minutes if with --live, it is in seconds
--list/-L list enabled modules
--live/-l running print live mode, which module will print
--file/-f specify a filepath as input
--ndays/-n show the value for the past days (default: 1)
--date/-d show the value for the specify day(n or YYYYMMDD)
--merge/-m merge multiply item to one
--detail/-D do not conver data to K/M/G
--spec/-s show spec field data, tsar --cpu -s sys,util
--item/-I show spec item data, tsar --io -I sda
--help/-h help
Modules Enabled:
--cpu CPU share (user, system, interrupt, nice, & idle)
--mem Physical memory share (active, inactive, cached, free, wired)
--swap swap usage
--tcp TCP traffic (v4)
--udp UDP traffic (v4)
--traffic Net traffic statistics
--io Linux I/O performance
--pcsw Process (task) creation and context switch
--partition Disk and partition usage
--tcpx TCP connection data
--load System Run Queue and load average
--nginx nginx statistics
--live/-l 启用实时模式,类似iostat等,可以配合-i参数和模块参数使用。
--interval/-i 控制时间间隔,在打印历史数据中,单位是分钟,默认显示间隔5分钟;而实时模式(-l)下,单位是秒,默认是5秒。
--ndays/-n 控制显示多长时间的历史数据,默认1,单位天
--merge/-m 对有多个数据的展示,进行汇总,如机器上跑了3个squid,可以用 tsar --squid -m的放式进行展示汇总。
--cron 用于cron运行tsar采集功能。
tsar -i 1 -l 以1秒钟为间隔,实时打印tsar的概述数据
tsar 显示1天内的历史汇总(summury)信息,以默认5分钟为间隔
tsar --cpu -i 1 显示一天内cpu的历史信息,以1分钟为间隔
tsar --live --mem -i 2 以2秒钟为间隔,实时打印mem的数据。
tsar --cpu --mem -i 1 显示一天内的cpu和内存历史数据,以1分钟为间隔。
tsar -l -i 1 --io -I sda 以1秒钟为间隔,实时打印sda的IO数据