- High Performance: the load can be distributed on a cluster of client machines
- Multi-protocols using a plugin system: HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP , XMPP/Jabber, BOSH, MQTT and AMQP are currently supported. SSL is also supported.
- Several IP addresses can be used on a single machine using the underlying OS IP Aliasing
- OS monitoring (CPU, memory and network traffic) using SNMP, Munin or Erlang agents on remote servers.
- XML configuration system; several sessions can be used to simulate different type of users. Dynamic sessions can be easily described in XML (this can be used to retrieve at runtime an ID from the server output and use it later in the session).
- In order to generate a realistic traffic, user think-times and the arrival rate can be randomize using a probability distribution
- HTML reports can be generated during the load to view response times measurement, server CPU, etc.
Tsung is developed in Erlang,運行Tsung,需要相關erlang依賴包支持。
一.安裝Tsung
sudo apt-get update sudo apt-get -y install tsung
或自行下載Tsung源碼包安裝:http://tsung.erlang-projects.org/
二.啓用SNMP agent(snmpd)監視系統運行
- 在目標系統上安裝snmpd: apt-get install snmpd
- 修改配置文檔/etc/snmp/snmpd.conf:
1)開啓所有監視端訪問:註釋行agentAddress udp:127.0.0.1:161,然後啓用行agentAddress udp:161,udp6:[::1]:161 2)設置snmp agent可監視(OID分支)範圍:註釋行view systemonly included .1.3.6.1.2.1.1和view systemonly included .1.3.6.1.2.1.25.1,然後添加行view systemonly included .1 3)rocommunity public default -V systemonly行和rocommunity public default -V systemonly行public爲默認community,可更改自定義 4)如果在docker中運行snmpd,修改配置文檔/etc/snmp/snmpd.conf後,執行service snmpd [command],這對已啓動的snmpd是無效的。因此本人通過重啓snmpd所運行的容器(expose 161),然後再執行service snmpd start是可行的方案
-
啓動snmpd:service snmpd start
- 監視端安裝snmp來檢測監視目標系統snmp agent
sudo apt-get install snmp snmpwalk -v 2c -c public [agent主機名或ip]
三.試運行Tsung並生成統計報告
cd ~ mkdir .tsung cp /usr/share/doc/tsung/examples/http_simple.xml .tsung/tsung.xml tsung start
注意事項:
1)/usr/share/doc/tsung/examples:Tsung安裝後,該目錄下有多種配置文檔樣例可參考 2)~/.tsung/tsung.xml:默認配置文件。如果該文件不存在,則需添加-f選項,tsung -f myconfigfile.xml start 3)~/.tsung/log:運行命令tsung start後將生成該日誌目錄 4)本例中monitor type爲snmp 5)關於tsung.xml的配置可參考:http://tsung.erlang-projects.org/user_manual/
cenze@kylin:~/.tsung$ ls log 20170115-2235 cenze@kylin:~/.tsung$ cd log/20170115-2235 cenze@kylin:~/.tsung/log/20170115-2235$ /usr/lib/tsung/bin/tsung_stats.pl warn, last interval (7) not equal to the first, use the first one (10) No data for Bosh No data for Match No data for Event No data for Async No data for Errors cenze@kylin:~/.tsung/log/20170115-2235$ ls -l 總用量 92 drwxrwxr-x 2 cenze cenze 4096 1月 15 22:51 data -rw-rw-r-- 1 cenze cenze 3344 1月 15 22:51 gnuplot.log drwxrwxr-x 2 cenze cenze 4096 1月 15 22:51 gnuplot_scripts -rw-rw-r-- 1 cenze cenze 7333 1月 15 22:51 graph.html drwxrwxr-x 2 cenze cenze 4096 1月 15 22:51 images -rw-rw-r-- 1 cenze cenze 62 1月 15 22:35 match.log -rw-rw-r-- 1 cenze cenze 8151 1月 15 22:51 report.html -rw-rw-r-- 1 cenze cenze 10157 1月 15 22:45 [email protected] -rw-rw-r-- 1 cenze cenze 36480 1月 15 22:45 tsung.log -rw-rw-r-- 1 cenze cenze 961 1月 15 22:35 tsung.xml
注意事項:
1)/usr/lib/tsung/bin/tsung_stats.pl:如果當前目錄下不存在tsung.log,則需通過選項--stats 指定統計日誌文件,執行該腳本後將在當前目錄下生成相關統計報告目錄及文檔 2)以上爲本機上執行的實際情況,點擊report.html在瀏覽器中打開將看到如下界面: