├── .gitignore ├── .mailmap ├── .travis.yml ├── CHANGES ├── CONTRIBUTORS ├── COPYING ├── LISEZMOI ├── Makefile.in ├── README.md ├── TODO ├── acinclude.m4 ├── aclocal.m4 ├── config.guess ├── config.sub ├── configure ├── configure.ac ├── debian ├── changelog ├── compat ├── control ├── copyright ├── docs ├── rules └── tsung.dirs ├── docs ├── Makefile ├── README ├── _static │ └── README ├── _templates │ └── README ├── acknowledgment.rst ├── benchmark.rst ├── changelog.rst ├── conf-advanced-features.rst ├── conf-client-server.rst ├── conf-file.rst ├── conf-load.rst ├── conf-monitoring.rst ├── conf-options.rst ├── conf-sessions.rst ├── conf.py ├── configuration.rst ├── dtd.rst ├── errorslist.rst ├── faq.rst ├── features.rst ├── images │ ├── connected.png │ ├── ldap-hierarchy.png │ ├── ldap-results.png │ ├── logo_tsung.png │ ├── tsung-dashboard.png │ ├── tsung-graph.png │ └── tsung-report.png ├── index.rst ├── installation.rst ├── introduction.rst ├── proxy.rst ├── references.rst ├── reports.rst └── tsung-help.txt ├── ebin └── .keepme ├── examples ├── amqp.xml.in ├── bosh.xml.in ├── fs-nfs.xml.in ├── http-digest.xml.in ├── http-oauth.xml.in ├── http_distributed.xml.in ├── http_setdynvars.xml.in ├── http_simple.xml.in ├── http_tag.xml.in ├── jabber.xml.in ├── jabber_muc.xml.in ├── jabber_node.xml.in ├── jabber_privacy.xml.in ├── jabber_register.xml.in ├── jabber_roster.xml.in ├── jabber_starttls.xml.in ├── ldap.xml.in ├── mqtt.xml.in ├── mysql.xml.in ├── pgsql.xml.in ├── raw.xml.in ├── thinks.xml.in ├── thinks2.xml.in └── websocket.xml.in ├── include ├── ELDAPv3.hrl ├── eldap.hrl ├── mqtt.hrl ├── rabbit.hrl ├── rabbit_framing.hrl ├── ts_amqp.hrl ├── ts_config.hrl ├── ts_fs.hrl ├── ts_http.hrl ├── ts_jabber.hrl ├── ts_job.hrl ├── ts_ldap.hrl ├── ts_macros.hrl ├── ts_mqtt.hrl ├── ts_mysql.hrl ├── ts_os_mon.hrl ├── ts_pgsql.hrl ├── ts_profile.hrl ├── ts_raw.hrl ├── ts_recorder.hrl ├── ts_shell.hrl └── ts_websocket.hrl ├── install-sh ├── man ├── Design.txt ├── Design_fr.txt ├── Jabber.txt ├── Makefile ├── ts_template.erl ├── tsplot.1 ├── tsplot.1.sgml ├── tsung-inside.dia ├── tsung-inside.png ├── tsung-recorder.1 ├── tsung-recorder.1.sgml ├── tsung.1 └── tsung.1.sgml ├── src ├── lib │ ├── mochijson2.erl │ ├── mochinum.erl │ ├── mochiutf8.erl │ ├── mochiweb_charref.erl │ ├── mochiweb_headers.erl │ ├── mochiweb_html.erl │ ├── mochiweb_util.erl │ ├── mochiweb_xpath.erl │ ├── mochiweb_xpath_functions.erl │ ├── mochiweb_xpath_parser.erl │ ├── mochiweb_xpath_utils.erl │ ├── mqtt_frame.erl │ ├── oauth.erl │ ├── oauth_hmac_sha1.erl │ ├── oauth_http.erl │ ├── oauth_plaintext.erl │ ├── oauth_rsa_sha1.erl │ ├── oauth_unix.erl │ ├── oauth_uri.erl │ ├── pgsql_proto.erl │ ├── pgsql_util.erl │ ├── rabbit_binary_generator.erl │ ├── rabbit_binary_parser.erl │ ├── rabbit_command_assembler.erl │ ├── rabbit_framing_amqp_0_9_1.erl │ ├── rabbit_misc.erl │ ├── rfc4515_parser.erl │ ├── uuid.erl │ └── websocket.erl ├── log2tsung.pl.in ├── templates │ ├── footer.thtml │ ├── graph.thtml │ ├── graph_dy.thtml │ ├── header.thtml │ ├── report.thtml │ └── style │ │ ├── bootstrap.min.css │ │ ├── bootstrap.min.js │ │ ├── dashboard.css │ │ ├── docs.min.css │ │ ├── dygraph-combined.js │ │ └── jquery.min.js ├── test │ ├── badpop.xml.in │ ├── ifcfg.out │ ├── ipcfg.out │ ├── netstat_test.txt │ ├── netstat_test2.txt │ ├── netstat_test3.txt │ ├── procnetdev_test.txt │ ├── procnetdev_test7chars.txt │ ├── test_file_server.csv │ ├── test_file_server2.csv │ ├── test_file_server_pipe.csv │ ├── thinkfirst.xml.in │ ├── ts_test_all.erl │ ├── ts_test_client.erl │ ├── ts_test_config.erl │ ├── ts_test_dynvars_api.erl │ ├── ts_test_file_server.erl │ ├── ts_test_http.erl │ ├── ts_test_interaction.erl │ ├── ts_test_jabber.erl │ ├── ts_test_match.erl │ ├── ts_test_mochi.erl │ ├── ts_test_mon.erl │ ├── ts_test_mqtt.erl │ ├── ts_test_options.erl │ ├── ts_test_pgsql.erl │ ├── ts_test_proxy.erl │ ├── ts_test_recorder.erl │ ├── ts_test_search.erl │ ├── ts_test_stats.erl │ ├── ts_test_user_server.erl │ ├── ts_test_utils.erl │ ├── ts_test_websocket.erl │ └── xmpp-muc.xml.in ├── tsung-plotter │ ├── fs.plots.en.conf │ ├── http.plots.en.conf │ ├── http.plots.fr.conf │ ├── index-http.html │ ├── pgsql.plots.en.conf │ ├── pgsql.plots.fr.conf │ ├── tsplot.py.in │ └── tsung │ │ ├── __init__.py │ │ ├── stats.conf │ │ └── tsung.py ├── tsung-rrd.pl.in ├── tsung │ ├── gen_ts_transport.erl │ ├── ts_amqp.erl │ ├── ts_bosh.erl │ ├── ts_bosh_ssl.erl │ ├── ts_client.erl │ ├── ts_client_sup.erl │ ├── ts_cport.erl │ ├── ts_digest.erl │ ├── ts_dynvars.erl │ ├── ts_erlang.erl │ ├── ts_fs.erl │ ├── ts_http.erl │ ├── ts_http_common.erl │ ├── ts_ip_scan.erl │ ├── ts_jabber.erl │ ├── ts_jabber_common.erl │ ├── ts_job.erl │ ├── ts_launcher.erl │ ├── ts_launcher_mgr.erl │ ├── ts_launcher_static.erl │ ├── ts_ldap.erl │ ├── ts_ldap_common.erl │ ├── ts_local_mon.erl │ ├── ts_mon_cache.erl │ ├── ts_mqtt.erl │ ├── ts_mysql.erl │ ├── ts_pgsql.erl │ ├── ts_plugin.erl │ ├── ts_raw.erl │ ├── ts_search.erl │ ├── ts_server_websocket.erl │ ├── ts_server_websocket_ssl.erl │ ├── ts_session_cache.erl │ ├── ts_shell.erl │ ├── ts_ssl.erl │ ├── ts_ssl6.erl │ ├── ts_ssl_session_cache.erl │ ├── ts_stats.erl │ ├── ts_sup.erl │ ├── ts_tcp.erl │ ├── ts_tcp6.erl │ ├── ts_udp.erl │ ├── ts_udp6.erl │ ├── ts_utils.erl │ ├── ts_webdav.erl │ ├── ts_websocket.erl │ ├── tsung.app.in │ ├── tsung.erl │ └── tsung.rel.src ├── tsung_controller │ ├── ts_api.erl │ ├── ts_config.erl │ ├── ts_config_amqp.erl │ ├── ts_config_fs.erl │ ├── ts_config_http.erl │ ├── ts_config_jabber.erl │ ├── ts_config_job.erl │ ├── ts_config_ldap.erl │ ├── ts_config_mqtt.erl │ ├── ts_config_mysql.erl │ ├── ts_config_pgsql.erl │ ├── ts_config_raw.erl │ ├── ts_config_server.erl │ ├── ts_config_shell.erl │ ├── ts_config_websocket.erl │ ├── ts_controller_sup.erl │ ├── ts_file_server.erl │ ├── ts_interaction_server.erl │ ├── ts_job_notify.erl │ ├── ts_match_logger.erl │ ├── ts_mon.erl │ ├── ts_msg_server.erl │ ├── ts_os_mon.erl │ ├── ts_os_mon_erlang.erl │ ├── ts_os_mon_munin.erl │ ├── ts_os_mon_snmp.erl │ ├── ts_os_mon_sup.erl │ ├── ts_stats_mon.erl │ ├── ts_timer.erl │ ├── ts_user_server.erl │ ├── ts_user_server_sup.erl │ ├── ts_web.erl │ ├── tsung_controller.app.in │ ├── tsung_controller.erl │ └── tsung_controller.rel.src ├── tsung_percentile.pl.in ├── tsung_recorder │ ├── ts_client_proxy.erl │ ├── ts_client_proxy_sup.erl │ ├── ts_proxy_http.erl │ ├── ts_proxy_listener.erl │ ├── ts_proxy_pgsql.erl │ ├── ts_proxy_recorder.erl │ ├── ts_proxy_webdav.erl │ ├── ts_recorder_sup.erl │ ├── tsung_recorder.app.in │ ├── tsung_recorder.erl │ └── tsung_recorder.rel.src └── tsung_stats.pl.in ├── tsung-1.0.dtd ├── tsung-recorder.sh.in ├── tsung.sh.in ├── tsung.spec.in └── vsn.mk /.gitignore: -------------------------------------------------------------------------------- 1 | ### .gitignore --- 2 | 3 | *~ 4 | 5 | ebin/*.beam 6 | ebin/*.app 7 | examples/*.xml 8 | 9 | aclocal.m4 10 | configure 11 | install-sh 12 | stamp-* 13 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Nicolas Niclausse 2 | Nicolas Niclausse 3 | Nicolas Niclausse 4 | Pablo Polvorin ppolvorin 5 | Rodolphe Quiédeville Rodolphe Quiedeville 6 | Christopher Meng Christopher Meng 7 | Sebastian Cohnen 8 | Sumit Roy 9 | Michael Bridgen 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: erlang 2 | otp_release: 3 | - 17.1 4 | - R16B03-1 5 | - R15B03 6 | - R14B04 7 | script: ./configure && make test 8 | notifications: 9 | email: nicolas@niclux.org 10 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | $Id$ 2 | 3 | AUTHOR: 4 | ====================== 5 | 6 | o Nicolas Niclausse : Maintainer; 7 | 8 | CONTRIBUTORS: 9 | ====================== 10 | 11 | o Jean François Lecomte : several enhancements for Jabber 12 | 13 | o Mickaël Rémond : erlang server monitoring; 14 | various patches for HTTP; configure support; SOAP support; initial 15 | dynamic substitution implementation. 16 | 17 | o Jérome Sautret: Multiple file patch for file_server, costum header 18 | for HTTP, bug reports 19 | 20 | o Jason Tucker: Solaris testing and fixes, jabber patches (sip_digest, 21 | roster and presence enhancements, bidi support for presence:subscribe ). 22 | 23 | o Pablo Polvorin: LDAP plugin, set_dynvars, xpath search for html, 24 | for/repeat loop, dynvars_api, hibernate. PubSub and MUC support. 25 | 26 | o Gregoire Reboul: MySQL plugin. 27 | 28 | o Dimitri Fontaine: SNMP & postgresql testing, patch for snmp, tsung-plotter 29 | 30 | o Oleg Nitz: Fix for Cookies over https, fix rewrite of POST (http recorder) 31 | o David Jez: allow substitutions in match 32 | o Will Brant: load info for monitoring, fix for tsplot 33 | o Jonathan Bresler: Jabber testing and bug reporting 34 | o Gordon Guthrie: tips for ssh setup on Suse 35 | o Romain Lenglet: Suggestions for ts_os_mon 36 | o Johann Messner: Bug reports 37 | o Anders Nygren: Documentation updates/suggestions, fix for recorder 38 | o Adam Spotton: Bug reports and tests (status, HTTP proxy load testing) 39 | o Matthew Schulkind: small fix to freemem computation 40 | o t ty: plugin tutorial 41 | o Jesper Wilhelmsson: testing 42 | 43 | New contributors since the migration to git are available here: 44 | https://github.com/processone/tsung/graphs/contributors 45 | -------------------------------------------------------------------------------- /LISEZMOI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/LISEZMOI -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tsung README 2 | 3 | ## Introduction 4 | 5 | This document gives pointers for information on this package which is 6 | distributed under the GNU General Public License version 2 (see file 7 | COPYING). 8 | 9 | ## What This Package Is 10 | 11 | Tsung is multi-protocol distributed load testing tool. 12 | 13 | It can be used to test the scalability and performances of IP based 14 | client/server applications (supported protocols: HTTP, WebDAV, SOAP, 15 | PostgreSQL, MySQL, LDAP, MQTT, AMQP and Jabber/XMPP) 16 | 17 | A User's manual is available : 18 | http://tsung.erlang-projects.org/user_manual/ 19 | 20 | ## Problems/Bugs 21 | 22 | Join the mailing-list: 23 | https://lists.process-one.net/mailman/listinfo/tsung-users 24 | 25 | or use the tracker https://github.com/processone/tsung/issues 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | See https://support.process-one.net/browse/TSUN 2 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl as-ac-expand.m4 0.2.0 -*- autoconf -*- 2 | dnl autostars m4 macro for expanding directories using configure's prefix 3 | 4 | dnl (C) 2003, 2004, 2005 Thomas Vander Stichele 5 | 6 | dnl Copying and distribution of this file, with or without modification, 7 | dnl are permitted in any medium without royalty provided the copyright 8 | dnl notice and this notice are preserved. 9 | 10 | dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) 11 | 12 | dnl example: 13 | dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) 14 | dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local 15 | 16 | AC_DEFUN([AS_AC_EXPAND], 17 | [ 18 | EXP_VAR=[$1] 19 | FROM_VAR=[$2] 20 | 21 | dnl first expand prefix and exec_prefix if necessary 22 | prefix_save=$prefix 23 | exec_prefix_save=$exec_prefix 24 | 25 | dnl if no prefix given, then use /usr/local, the default prefix 26 | if test "x$prefix" = "xNONE"; then 27 | prefix="$ac_default_prefix" 28 | fi 29 | dnl if no exec_prefix given, then use prefix 30 | if test "x$exec_prefix" = "xNONE"; then 31 | exec_prefix=$prefix 32 | fi 33 | 34 | full_var="$FROM_VAR" 35 | dnl loop until it doesn't change anymore 36 | while true; do 37 | new_full_var="`eval echo $full_var`" 38 | if test "x$new_full_var" = "x$full_var"; then break; fi 39 | full_var=$new_full_var 40 | done 41 | 42 | dnl clean up 43 | full_var=$new_full_var 44 | AC_SUBST([$1], "$full_var") 45 | 46 | dnl restore prefix and exec_prefix 47 | prefix=$prefix_save 48 | exec_prefix=$exec_prefix_save 49 | ]) 50 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | # generated automatically by aclocal 1.10 -*- Autoconf -*- 2 | 3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 4 | # 2005, 2006 Free Software Foundation, Inc. 5 | # This file is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 | # PARTICULAR PURPOSE. 13 | 14 | m4_include([acinclude.m4]) 15 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: tsung 2 | Section: net 3 | Priority: optional 4 | Maintainer: Nicolas Niclausse 5 | Build-Depends: debhelper (>= 4.0.0), erlang-nox (>= 10.b.5-1) , python-sphinx, erlang-src, erlang-dev, autoconf 6 | Standards-Version: 3.6.0 7 | 8 | Package: tsung 9 | Architecture: all 10 | Depends: erlang-nox (>= 10.b.5-1) 11 | Recommends: gnuplot, perl, ssh, libtemplate-perl, python-matplotlib 12 | Description: A distributed multi-protocol load testing tool. 13 | Tsung is a distributed load testing tool. 14 | It is protocol-independent and can currently be used to stress and 15 | benchmark HTTP, Jabber/XMPP, LDAP, MySQL and PostgreSQL servers. 16 | It simulates user behaviour using an XML description file, reports 17 | many measurements in real time (statistics can be customized with 18 | transactions, and graphics generated using gnuplot). 19 | For HTTP, it supports 1.0 and 1.1, has a proxy mode to record 20 | sessions, supports GET and POST methods, Cookies, and Basic 21 | WWW-authentication. It also has support for SSL. 22 | . 23 | More information is available at http://tsung.erlang-projects.org/ . 24 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Nicolas Niclausse on 2 | Tue, 10 Feb 2004 12:09:23 +0100. 3 | 4 | It was downloaded from http://tsung.erlang-projects.org/ 5 | 6 | Upstream Author(s): Nicolas Niclausse 7 | 8 | Copyright: 9 | 10 | Tsung is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | Tsung is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | See /usr/share/common-licenses/GPL 21 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | CHANGES 2 | docs/_build/singlehtml 3 | CONTRIBUTORS 4 | README.md 5 | TODO 6 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Sample debian/rules that uses debhelper. 3 | # GNU copyright 1997 to 1999 by Joey Hess. 4 | 5 | # Uncomment this to turn on verbose mode. 6 | #export DH_VERBOSE=1 7 | 8 | # This is the debhelper compatibility version to use. 9 | export DH_COMPAT=4 10 | 11 | 12 | configure: configure-stamp 13 | configure-stamp: 14 | dh_testdir 15 | # Add here commands to configure the package. 16 | ./configure 17 | touch configure-stamp 18 | 19 | 20 | build: build-stamp 21 | 22 | build-stamp: configure-stamp 23 | dh_testdir 24 | 25 | # Add here commands to compile the package. 26 | $(MAKE) 27 | $(MAKE) -C docs singlehtml 28 | touch build-stamp 29 | 30 | 31 | clean: 32 | dh_testdir 33 | dh_testroot 34 | rm -f build-stamp configure-stamp 35 | 36 | # Add here commands to clean up after the build process. 37 | -$(MAKE) clean 38 | 39 | dh_clean 40 | 41 | install: build 42 | dh_testdir 43 | dh_testroot 44 | #dh_clean -k 45 | dh_installdirs 46 | 47 | # Add here commands to install the package into debian/tsung 48 | make install DESTDIR=$(CURDIR)/debian/tsung 49 | 50 | 51 | # Build architecture-independent files here. 52 | binary-indep: build install 53 | # We have nothing to do by default. 54 | dh_testdir 55 | dh_testroot 56 | dh_installdocs 57 | dh_installchangelogs 58 | dh_link 59 | dh_strip 60 | dh_compress 61 | dh_fixperms 62 | # dh_makeshlibs 63 | dh_installdeb 64 | # dh_perl 65 | dh_shlibdeps 66 | dh_gencontrol 67 | dh_md5sums 68 | dh_builddeb 69 | 70 | binary: binary-indep 71 | .PHONY: build clean binary-indep install configure 72 | -------------------------------------------------------------------------------- /debian/tsung.dirs: -------------------------------------------------------------------------------- 1 | usr/bin/ 2 | usr/lib/tsung 3 | usr/share/tsung/templates 4 | -------------------------------------------------------------------------------- /docs/README: -------------------------------------------------------------------------------- 1 | These list of package are needed to generate the doc in pdf format 2 | under Debian Wheezy 3 | 4 | ii texlive 2012.20120611-5 all TeX Live: A decent selection of the TeX Live packages 5 | ii texlive-base 2012.20120611-5 all TeX Live: Essential programs and files 6 | ii texlive-binaries 2012.20120530-2+b1 i386 Binaries for TeX Live 7 | ii texlive-common 2012.20120611-1 all TeX Live: Base component 8 | ii texlive-doc-base 2012.20120611-1 all TeX Live: TeX Live documentation 9 | ii texlive-fonts-recommended 2012.20120611-5 all TeX Live: Recommended fonts 10 | ii texlive-lang-english 2012.20120611-2 all TeX Live: US and UK English 11 | ii texlive-lang-french 2012.20120611-2 all TeX Live: French 12 | ii texlive-latex-base 2012.20120611-5 all TeX Live: Basic LaTeX packages 13 | ii texlive-latex-extra 2012.20120611-2 all TeX Live: LaTeX supplementary packages 14 | ii texlive-latex-recommended 2012.20120611-5 all TeX Live: LaTeX recommended packages 15 | ii texlive-pictures 2012.20120611-5 all TeX Live: Graphics packages and programs 16 | -------------------------------------------------------------------------------- /docs/_static/README: -------------------------------------------------------------------------------- 1 | Static files used by make html 2 | -------------------------------------------------------------------------------- /docs/_templates/README: -------------------------------------------------------------------------------- 1 | HTML Templates 2 | -------------------------------------------------------------------------------- /docs/acknowledgment.rst: -------------------------------------------------------------------------------- 1 | =============== 2 | Acknowledgments 3 | =============== 4 | 5 | The first version of this document was based on a talk given by Mickael 6 | Rémond [#1]_ during an Object 7 | Web benchmarking workshop in April 2004 (more info at 8 | http://jmob.objectweb.org/). 9 | 10 | .. [#1] mickael.remond@erlang-fr.org 11 | -------------------------------------------------------------------------------- /docs/changelog.rst: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | .. literalinclude:: ../CHANGES 5 | -------------------------------------------------------------------------------- /docs/conf-file.rst: -------------------------------------------------------------------------------- 1 | .. _sec-file-structure-label: 2 | 3 | File structure 4 | ============== 5 | 6 | The default :index:`encoding` is utf-8. You can use a different encoding, like in: 7 | 8 | .. code-block:: xml 9 | 10 | 11 | 12 | Scenarios are enclosed into **tsung** tags: 13 | 14 | .. code-block:: xml 15 | 16 | 17 | 18 | 19 | ... 20 | 21 | 22 | .. index:: dumptraffic 23 | 24 | If you add the attribute **dumptraffic="true"**, all the 25 | traffic will be logged to a file. 26 | 27 | .. warning:: 28 | 29 | this will considerably slow down Tsung, so use with care. It is 30 | useful for debugging purpose. You can use the attribute 31 | **dumptraffic="light"** to dump only the first 44 bytes. 32 | 33 | Since version **1.4.0**, you have also a specific logging per 34 | protocol, using **dumptraffic="protocol"**. It's currently 35 | only implemented for HTTP: this will log all requests in a CSV file, 36 | with the following data: 37 | 38 | .. code-block:: text 39 | 40 | #date;pid;id;http method;host;URL;HTTP status;size;duration;transaction;match;error;tag 41 | 42 | Where: 43 | 44 | =========== ===================================================================================== 45 | field description 46 | =========== ===================================================================================== 47 | date timestamp at the end of the request (seconds since 1970-01-01 00:00:00 UTC) 48 | pid erlang process id 49 | id tsung user id 50 | host server hostname 51 | url URL (relative) 52 | HTTP status HTTP reponse status (200, 304, etc.) 53 | size reponse size (in bytes) 54 | duration request duration (msec) 55 | transaction name of the transaction (if any) this request was made in 56 | match if a match is defined in the request: match|nomatch (last if several are defined) 57 | error name of http error (or empty) 58 | tag tag name if the request was tagged; empty otherwise 59 | =========== ===================================================================================== 60 | 61 | .. warning:: 62 | 63 | In the general case (several Tsung clients used), the resulting 64 | file will not be sorted, so you may have to sort it before analyzing it. 65 | 66 | For heavy load testing (tens of thousands requests per second), the 67 | **protocol** logging may overload the controller. In this case, you can 68 | use **protocol_local** instead. In this case, the log files will be 69 | written on each slave locally. You will have to manually merged the 70 | logs at the end of the test. 71 | 72 | .. index:: loglevel 73 | 74 | The **loglevel** can also have a great impact on performance: 75 | For high load, **warning** is recommended. 76 | 77 | Possible values are: 78 | 79 | * emergency 80 | * critical 81 | * error 82 | * warning 83 | * notice *(default)* 84 | * info 85 | * debug 86 | 87 | 88 | For REALLY verbose logging, recompile tsung with :command:`make debug` 89 | and set **loglevel** to **debug**. 90 | -------------------------------------------------------------------------------- /docs/configuration.rst: -------------------------------------------------------------------------------- 1 | ========================================== 2 | Understanding tsung.xml configuration file 3 | ========================================== 4 | 5 | .. toctree:: 6 | :maxdepth: 6 7 | 8 | conf-file 9 | conf-client-server 10 | conf-monitoring 11 | conf-load 12 | conf-options 13 | conf-sessions 14 | conf-advanced-features 15 | -------------------------------------------------------------------------------- /docs/dtd.rst: -------------------------------------------------------------------------------- 1 | .. index:: dtd 2 | 3 | tsung-1.0.dtd 4 | ============= 5 | 6 | .. literalinclude:: ../tsung-1.0.dtd 7 | -------------------------------------------------------------------------------- /docs/errorslist.rst: -------------------------------------------------------------------------------- 1 | =========== 2 | Errors list 3 | =========== 4 | 5 | 6 | error_closed 7 | ------------ 8 | 9 | Only for non persistent session (XMPP); the server unexpectedly closed 10 | the connection; the session is aborted. 11 | 12 | error_inet_ 13 | ---------------------- 14 | 15 | Network error; see http://www.erlang.org/doc/man/inet.html for the list of all errors. 16 | 17 | error_unknown_data 18 | ------------------ 19 | 20 | Data received from the server during a thinktime (not for unparsed 21 | protocol like XMPP). The session is aborted. 22 | 23 | error_unknown_msg 24 | ----------------- 25 | 26 | Unknown message received (see the log files for more information). The session is aborted. 27 | 28 | error_unknown 29 | ------------- 30 | 31 | Abnormal termination of a session, see log file for more information. 32 | 33 | error_repeat_ 34 | ------------------------- 35 | 36 | Error in a repeat loop (undefined dynamic variable usually). 37 | 38 | error_send_ 39 | ---------------------- 40 | 41 | Error while sending data to the server, see 42 | http://www.erlang.org/doc/man/inet.html for the list of all errors. 43 | 44 | error_send 45 | ---------- 46 | 47 | Unexpected error while sending data to the server, 48 | see the logfiles for more information. 49 | 50 | error_connect_ 51 | ------------------------- 52 | 53 | Error while establishing a connection to the server. See 54 | http://www.erlang.org/doc/man/inet.html for the list of all errors. 55 | 56 | 57 | error_no_online 58 | --------------- 59 | 60 | XMPP: No online user available (usually for a chat message destinated 61 | to a online user) 62 | 63 | error_no_offline 64 | ---------------- 65 | 66 | XMPP: No offline user available (usually for a chat message destinated 67 | to a offline user) 68 | 69 | error_no_free_userid 70 | -------------------- 71 | 72 | For XMPP: all users Id are already used (``userid_max`` is too low ?) 73 | 74 | 75 | error_next_session 76 | ------------------ 77 | 78 | A clients fails to gets its session parameter from the config_server; 79 | the controller may be overloaded ? 80 | 81 | error_mysql_ 82 | ------------------- 83 | 84 | Error reported by the mysql server (see 85 | http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html) 86 | 87 | error_mysql_badpacket 88 | --------------------- 89 | 90 | Bad packet received for mysql server while parsing data. 91 | 92 | error_pgsql 93 | ----------- 94 | 95 | Error reported by the postgresql server. 96 | 97 | 98 | -------------------------------------------------------------------------------- /docs/images/connected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/docs/images/connected.png -------------------------------------------------------------------------------- /docs/images/ldap-hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/docs/images/ldap-hierarchy.png -------------------------------------------------------------------------------- /docs/images/ldap-results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/docs/images/ldap-results.png -------------------------------------------------------------------------------- /docs/images/logo_tsung.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/docs/images/logo_tsung.png -------------------------------------------------------------------------------- /docs/images/tsung-dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/docs/images/tsung-dashboard.png -------------------------------------------------------------------------------- /docs/images/tsung-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/docs/images/tsung-graph.png -------------------------------------------------------------------------------- /docs/images/tsung-report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/docs/images/tsung-report.png -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. Tsung documentation master file, created by 2 | sphinx-quickstart on Thu Sep 19 12:07:49 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Tsung's documentation! 7 | ================================= 8 | 9 | .. rubric:: Everything you need to know about Tsung 10 | 11 | .. sidebar:: About Tsung 12 | 13 | Tsung is a high-performance benchmark framework for various protocols 14 | including HTTP, XMPP, LDAP, etc 15 | 16 | * **Website**: `tsung.erlang-projects.org `_ 17 | * **Source code**: `github.com/processone/tsung `_ 18 | * **Bugtracker**: ` ` 19 | 20 | .. toctree:: 21 | :maxdepth: 2 22 | :numbered: 23 | 24 | introduction 25 | features 26 | installation 27 | benchmark 28 | proxy 29 | configuration 30 | reports 31 | references 32 | acknowledgment 33 | faq 34 | errorslist 35 | changelog 36 | dtd 37 | 38 | 39 | Indices and tables 40 | ================== 41 | 42 | * :ref:`genindex` 43 | * :ref:`search` 44 | 45 | -------------------------------------------------------------------------------- /docs/proxy.rst: -------------------------------------------------------------------------------- 1 | 2 | .. index:: proxy 3 | .. index:: tsung-recorder 4 | .. _tsung-recorder: 5 | 6 | ======================== 7 | Using the proxy recorder 8 | ======================== 9 | 10 | The recorder has three plugins: for HTTP, WebDAV and for PostgreSQL. 11 | 12 | To start it, run :command:`tsung-recorder -p start`, where **PLUGIN** can be 13 | *http*, *webdav* or *pgsql* for PostgreSQL. The default plugin is **http**. 14 | 15 | 16 | The proxy is listening to port **8090**. You can change the port with 17 | :option:`-L portnumber`. 18 | 19 | To stop it, use :command:`tsung-recorder stop`. 20 | 21 | The recorded session is created as 22 | :file:`~/.tsung/tsung_recorderYYYMMDD-HH:MM.xml`; if it doesn't work, 23 | take a look at :file:`~/.tsung/log/tsung.log-tsung_recorder@hostname` 24 | 25 | .. index:: record_tag 26 | 27 | During the recording, you can add custom tag in the XML file, this can 28 | be useful to set transactions or comments: 29 | :command:`tsung-recorder record_tag "''` 30 | 31 | Once a session has been created, you can insert it in your main configuration 32 | file, either by editing by hand the file, or by using an ENTITY 33 | declaration, like: 34 | 35 | .. code-block:: xml 36 | 37 | 39 | ]> 40 | ... 41 | 42 | &mysession1; 43 | 44 | 45 | 46 | PostgreSQL 47 | ========== 48 | 49 | For PostgreSQL, the proxy will connect to the server at IP 127.0.0.1 50 | and port 5432. Use **-I serverIP** to change the IP and 51 | **-P portnumber** to change the port. 52 | 53 | HTTP and WEBDAV 54 | =============== 55 | 56 | For HTTPS recording, use **http://-** instead of 57 | **https://** in your browser 58 | 59 | **New in 1.2.2**: For HTTP, you can configure the recorder to use a parent proxy (but this will not work for https). Add the :option:`-u` 60 | option to enable parent proxy, and use **-I serverIP** to set the IP and **-P portnumber** to set the port of the parent. 61 | -------------------------------------------------------------------------------- /docs/references.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | References 3 | ========== 4 | 5 | * Tsung home page: http://tsung.erlang-projects.org/ 6 | 7 | * Tsung description (French) [#1]_ 8 | 9 | * Erlang web site http://www.erlang.org/ 10 | 11 | * Erlang programmation, Mickaël Rémond, Editions Eyrolles, 2003 [#2]_ 12 | 13 | * **Making reliable system in presence of software errors**, Doctoral Thesis, 14 | Joe Armstrong, Stockholm, 2003 [#3]_ 15 | 16 | * **Tutorial on How to write a Tsung plugin**, written by t ty, 17 | http://www.process-one.net/en/wiki/Writing_a_Tsung_plugin/ 18 | 19 | 20 | .. [#1] http://www.erlang-projects.org/Members/mremond/events/dossier_de_presentat/block_10766817551485/file 21 | .. [#2] http://www.editions-eyrolles.com/php.accueil/Ouvrages/ouvrage.php3?ouv_ean13=9782212110791 22 | .. [#3] http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf 23 | -------------------------------------------------------------------------------- /docs/tsung-help.txt: -------------------------------------------------------------------------------- 1 | $ tsung -h 2 | Usage: tsung start|stop|debug|status 3 | Options: 4 | -f set configuration file (default is ~/.tsung/tsung.xml) 5 | (use - for standard input) 6 | -l set log directory where YYYYMMDD-HHMM dirs are created (default is ~/.tsung/log/) 7 | -i set controller id (default is empty) 8 | -r set remote connector (default is ssh) 9 | -s enable erlang smp on client nodes 10 | -p set maximum erlang processes per vm (default is 250000) 11 | -X add additional erlang load paths (multiple -X arguments allowed) 12 | -m write monitoring output on this file (default is tsung.log) 13 | (use - for standard output) 14 | -F use long names (FQDN) for erlang nodes 15 | -L SSL session lifetime (600sec by default) 16 | -w warmup delay (default is 1 sec) 17 | -n disable web GUI (started by default on port 8091) 18 | -k keep web GUI (and controller) alive after the test has finished 19 | -v print version information and exit 20 | -6 use IPv6 for Tsung internal communications 21 | -x list of requests tag to be excluded from the run (separated by comma) 22 | -t erlang inet listening TCP port min (default: 64000) 23 | -T erlang inet listening TCP port max (default: 65500) 24 | -h display this help and exit 25 | -------------------------------------------------------------------------------- /ebin/.keepme: -------------------------------------------------------------------------------- 1 | keepme 2 | -------------------------------------------------------------------------------- /examples/bosh.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /examples/http-digest.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /examples/http-oauth.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /examples/http_setdynvars.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/http_simple.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /examples/http_tag.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /examples/jabber_muc.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /examples/jabber_privacy.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /examples/jabber_register.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | error 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /examples/jabber_roster.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /examples/jabber_starttls.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /examples/ldap.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | organizationalPerson 67 | inetOrgPerson 68 | person 69 | 70 | %%_new_user_cn%% 71 | fffs 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | SomeSN 82 | some@mail.com 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /examples/mqtt.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | test_message 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /examples/mysql.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | SHOW TABLES 34 | 35 | 36 | SELECT * FROM gens 37 | 38 | 39 | SELECT * FROM te 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /examples/pgsql.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | SELECT * from accounts; 42 | 43 | 44 | 45 | 46 | SELECT * from users; 47 | 48 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /examples/raw.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/thinks.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /examples/thinks2.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /examples/websocket.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {"user":"user", "password":"password"} 27 | 28 | 29 | 30 | ok 31 | {"uid":"%%_uid%%", "data":"data"} 32 | 33 | 34 | 35 | {"key":"value"} 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /include/ELDAPv3.hrl: -------------------------------------------------------------------------------- 1 | %% Generated by the Erlang ASN.1 compiler version:2.0.1 2 | %% Purpose: Erlang record definitions for each named and unnamed 3 | %% SEQUENCE and SET, and macro definitions for each value 4 | %% definition,in module ELDAPv3 5 | 6 | 7 | 8 | -record('LDAPMessage',{ 9 | messageID, protocolOp, controls = asn1_NOVALUE}). 10 | 11 | -record('AttributeValueAssertion',{ 12 | attributeDesc, assertionValue}). 13 | 14 | -record('Attribute',{ 15 | type, vals}). 16 | 17 | -record('LDAPResult',{ 18 | resultCode, matchedDN, errorMessage, referral = asn1_NOVALUE}). 19 | 20 | -record('Control',{ 21 | controlType, criticality = asn1_DEFAULT, controlValue = asn1_NOVALUE}). 22 | 23 | -record('BindRequest',{ 24 | version, name, authentication}). 25 | 26 | -record('SaslCredentials',{ 27 | mechanism, credentials = asn1_NOVALUE}). 28 | 29 | -record('BindResponse',{ 30 | resultCode, matchedDN, errorMessage, referral = asn1_NOVALUE, serverSaslCreds = asn1_NOVALUE}). 31 | 32 | -record('SearchRequest',{ 33 | baseObject, scope, derefAliases, sizeLimit, timeLimit, typesOnly, filter, attributes}). 34 | 35 | -record('SubstringFilter',{ 36 | type, substrings}). 37 | 38 | -record('MatchingRuleAssertion',{ 39 | matchingRule = asn1_NOVALUE, type = asn1_NOVALUE, matchValue, dnAttributes = asn1_DEFAULT}). 40 | 41 | -record('SearchResultEntry',{ 42 | objectName, attributes}). 43 | 44 | -record('PartialAttributeList_SEQOF',{ 45 | type, vals}). 46 | 47 | -record('ModifyRequest',{ 48 | object, modification}). 49 | 50 | -record('ModifyRequest_modification_SEQOF',{ 51 | operation, modification}). 52 | 53 | -record('AttributeTypeAndValues',{ 54 | type, vals}). 55 | 56 | -record('AddRequest',{ 57 | entry, attributes}). 58 | 59 | -record('AttributeList_SEQOF',{ 60 | type, vals}). 61 | 62 | -record('ModifyDNRequest',{ 63 | entry, newrdn, deleteoldrdn, newSuperior = asn1_NOVALUE}). 64 | 65 | -record('CompareRequest',{ 66 | entry, ava}). 67 | 68 | -record('ExtendedRequest',{ 69 | requestName, requestValue = asn1_NOVALUE}). 70 | 71 | -record('ExtendedResponse',{ 72 | resultCode, matchedDN, errorMessage, referral = asn1_NOVALUE, responseName = asn1_NOVALUE, response = asn1_NOVALUE}). 73 | 74 | -record('PasswdModifyRequestValue',{ 75 | userIdentity = asn1_NOVALUE, oldPasswd = asn1_NOVALUE, newPasswd = asn1_NOVALUE}). 76 | 77 | -record('PasswdModifyResponseValue',{ 78 | genPasswd = asn1_NOVALUE}). 79 | 80 | -define('maxInt', 2147483647). 81 | -define('passwdModifyOID', [49,46,51,46,54,46,49,46,52,46,49,46,52,50,48,51,46,49,46,49,49,46,49]). 82 | 83 | -------------------------------------------------------------------------------- /include/eldap.hrl: -------------------------------------------------------------------------------- 1 | -ifndef( _ELDAP_HRL ). 2 | -define( _ELDAP_HRL , 1 ). 3 | 4 | %%% 5 | %%% Search input parameters 6 | %%% 7 | -record(eldap_search, { 8 | base = [], % Baseobject 9 | filter = [], % Search conditions 10 | scope, % Search scope 11 | attributes = [], % Attributes to be returned 12 | types_only = false, % Return types+values or types 13 | timeout = 0 % Timelimit for search 14 | }). 15 | 16 | %%% 17 | %%% Returned search result 18 | %%% 19 | -record(eldap_search_result, { 20 | entries = [], % List of #eldap_entry{} records 21 | referrals = [] % List of referrals 22 | }). 23 | 24 | %%% 25 | %%% LDAP entry 26 | %%% 27 | -record(eldap_entry, { 28 | object_name = "", % The DN for the entry 29 | attributes = [] % List of {Attribute, Value} pairs 30 | }). 31 | 32 | -endif. 33 | -------------------------------------------------------------------------------- /include/mqtt.hrl: -------------------------------------------------------------------------------- 1 | %% The MIT License (MIT) 2 | %% 3 | %% Copyright (c) <2013> 4 | %% 5 | %% Permission is hereby granted, free of charge, to any person obtaining a copy 6 | %% of this software and associated documentation files (the "Software"), to deal 7 | %% in the Software without restriction, including without limitation the rights 8 | %% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | %% copies of the Software, and to permit persons to whom the Software is 10 | %% furnished to do so, subject to the following conditions: 11 | %% 12 | %% The above copyright notice and this permission notice shall be included in 13 | %% all copies or substantial portions of the Software. 14 | %% 15 | %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | %% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | %% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | %% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | %% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | %% THE SOFTWARE. 22 | 23 | %% 24 | %% An erlang client for MQTT (http://www.mqtt.org/) 25 | %% 26 | 27 | -define(LOG(Msg), io:format("{~p:~p ~p}: ~p~n", [?MODULE, ?LINE, self(), Msg])). 28 | 29 | -define(MQTT_PORT, 1883). 30 | 31 | -define(PROTOCOL_NAME, "MQIsdp"). 32 | -define(PROTOCOL_VERSION, 3). 33 | 34 | -define(UNUSED, 0). 35 | 36 | -define(USERNAME, undefined). 37 | -define(PASSWORD, undefined). 38 | 39 | -define(DEFAULT_KEEPALIVE, 120). 40 | -define(DEFAULT_RETRY, 120). 41 | -define(DEFAULT_CONNECT_TIMEOUT, 5). 42 | 43 | -define(CONNECT, 1). 44 | -define(CONNACK, 2). 45 | -define(PUBLISH, 3). 46 | -define(PUBACK, 4). 47 | -define(PUBREC, 5). 48 | -define(PUBREL, 6). 49 | -define(PUBCOMP, 7). 50 | -define(SUBSCRIBE, 8). 51 | -define(SUBACK, 9). 52 | -define(UNSUBSCRIBE, 10). 53 | -define(UNSUBACK, 11). 54 | -define(PINGREQ, 12). 55 | -define(PINGRESP, 13). 56 | -define(DISCONNECT, 14). 57 | 58 | -record(connect_options, { 59 | protocol_name = ?PROTOCOL_NAME, 60 | protocol_version = ?PROTOCOL_VERSION, 61 | client_id, 62 | clean_start = true, 63 | will, 64 | keepalive = ?DEFAULT_KEEPALIVE, 65 | username = ?USERNAME, 66 | password = ?PASSWORD, 67 | retry = ?DEFAULT_RETRY, 68 | connect_timeout = ?DEFAULT_CONNECT_TIMEOUT 69 | }). 70 | 71 | -record(mqtt, { 72 | id, 73 | type, 74 | dup = 0, 75 | qos = 0, 76 | retain = 0, 77 | arg 78 | }). 79 | 80 | -record(sub, { 81 | topic, 82 | qos = 0 83 | }). 84 | 85 | -record(publish_options, { 86 | qos = 0, 87 | retain = 0 88 | }). 89 | 90 | -record(will, { 91 | topic, 92 | message, 93 | publish_options = #publish_options{} 94 | }). 95 | -------------------------------------------------------------------------------- /include/ts_amqp.hrl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by Zhihui Jiao(jzhihui521@gmail.com). 2 | %%% 3 | %%% Copyright (C) 2013 Zhihui Jiao 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | %%% In addition, as a special exception, you have the permission to 20 | %%% link the code of this program with any library released under 21 | %%% the EPL license and distribute linked combinations including 22 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23 | %%% Public License) is based on, is included in this exception. 24 | 25 | -vc('$Id$ '). 26 | -author('jzhihui521@gmail.com'). 27 | 28 | -define(AMQP_USER, "guest"). 29 | -define(AMQP_PASSWORD, "guest"). 30 | 31 | -define(PROTOCOL_VERSION_MAJOR, 0). 32 | -define(PROTOCOL_VERSION_MINOR, 9). 33 | -define(PROTOCOL_HEADER, <<"AMQP", 0, 0, 9, 1>>). 34 | -define(PROTOCOL, rabbit_framing_amqp_0_9_1). 35 | -define(MAX_CHANNEL_NUMBER, 65535). 36 | 37 | -define(CLIENT_CAPABILITIES, [{<<"publisher_confirms">>, bool, true}, 38 | {<<"exchange_exchange_bindings">>, bool, true}, 39 | {<<"basic.nack">>, bool, true}, 40 | {<<"consumer_cancel_notify">>, bool, true}]). 41 | 42 | %% use by the client to create the request 43 | -record(amqp_request, { 44 | version = "0_9_1", % default is 0.9.1 45 | type, 46 | username, 47 | password, 48 | heartbeat, 49 | vhost, 50 | channel = "1", 51 | exchange, 52 | routing_key, 53 | confirm, 54 | prefetch_size, 55 | prefetch_count, 56 | persistent, 57 | payload, 58 | payload_size, 59 | queue, 60 | ack 61 | }). 62 | 63 | -record(amqp_dyndata, { 64 | none 65 | } 66 | ). 67 | 68 | -record(ch, { 69 | ack, 70 | next_pub_seqno, 71 | unconfirmed_set 72 | } 73 | ). 74 | 75 | -record(amqp_session, { 76 | vhost, 77 | protocol, 78 | channel_max = 65535, 79 | map_num_pa, 80 | ack_buf, 81 | status, % status of handshake 82 | waiting = none % waiting state: {Channel, Expecting} 83 | }). 84 | 85 | -------------------------------------------------------------------------------- /include/ts_fs.hrl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2010 © INRIA 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 13 january 2010 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | 28 | -vc('$Id$ '). 29 | -author('nicolas.niclausse@niclux.org'). 30 | 31 | %% use by the client to create the request 32 | 33 | -record(fs_session, 34 | { 35 | position=0, 36 | iodev 37 | } 38 | ). 39 | 40 | -record(fs, { 41 | command, 42 | mode, 43 | path, 44 | iodev, 45 | size, 46 | dest, 47 | position 48 | }). 49 | 50 | 51 | -------------------------------------------------------------------------------- /include/ts_job.hrl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2011 © INRIA 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 4 mai 2011 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | 28 | -author('nicolas.niclausse@inria.fr'). 29 | 30 | %% use by the client to create the request 31 | 32 | -record(job_dyndata, 33 | { 34 | fixme 35 | } 36 | ). 37 | 38 | -record(job, { 39 | script, 40 | resources, 41 | walltime, 42 | queue, 43 | duration, 44 | jobid, 45 | req, % submit|stat|delete 46 | type, % oar|torque 47 | notify_port, 48 | notify_script, 49 | name, 50 | user, 51 | options, 52 | args 53 | }). 54 | 55 | -record(job_session, { 56 | jobid, 57 | owner, 58 | submission_time, 59 | queue_time, 60 | start_time, 61 | end_time, 62 | dump, 63 | status 64 | }). 65 | 66 | 67 | -------------------------------------------------------------------------------- /include/ts_ldap.hrl: -------------------------------------------------------------------------------- 1 | %%% Copyright (C) 2008 Pablo Polvorin 2 | %%% 3 | %%% This program is free software; you can redistribute it and/or modify 4 | %%% it under the terms of the GNU General Public License as published by 5 | %%% the Free Software Foundation; either version 2 of the License, or 6 | %%% (at your option) any later version. 7 | %%% 8 | %%% This program is distributed in the hope that it will be useful, 9 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | %%% GNU General Public License for more details. 12 | %%% 13 | %%% You should have received a copy of the GNU General Public License 14 | %%% along with this program; if not, write to the Free Software 15 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 16 | %%% 17 | %%% In addition, as a special exception, you have the permission to 18 | %%% link the code of this program with any library released under 19 | %%% the EPL license and distribute linked combinations including 20 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 21 | %%% Public License) is based on, is included in this exception. 22 | 23 | 24 | -vc('$Id: ts_http.hrl 826 2008-04-01 16:07:38Z nniclausse $ '). 25 | 26 | -record(ldap_request, 27 | { type, 28 | user, 29 | password, 30 | base, 31 | filter, 32 | result_var, 33 | attributes, 34 | scope, 35 | cacertfile, 36 | keyfile, 37 | certfile, 38 | dn, 39 | attrs, 40 | modifications 41 | }). 42 | -------------------------------------------------------------------------------- /include/ts_macros.hrl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2012 © nicolas niclausse 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 22 août 2012 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | 22 | -vc('$Id: ts_macros.hrl,v 0.0 2012/08/22 09:07:50 nniclaus Exp $ '). 23 | -author('nniclaus@sophia.inria.fr'). 24 | 25 | -ifndef(new_time_api). 26 | -define(NOW, erlang:now()). 27 | -define(TIMESTAMP, erlang:now()). 28 | -else. 29 | -define(NOW, erlang:monotonic_time()). 30 | -define(TIMESTAMP, erlang:timestamp()). 31 | -endif. 32 | 33 | -define(CRLF, "\r\n"). 34 | -define(CR,13). 35 | -define(LF,10). 36 | 37 | %% retry sending message after this timeout (in microsec.) 38 | -define(config(Var), ts_utils:get_val(Var)). 39 | 40 | %% errors messages 41 | 42 | -define(LOGF(Msg, Args, Level), 43 | ts_utils:debug(?MODULE, Msg, Args, Level)). 44 | -define(LOG(Msg, Level), 45 | ts_utils:debug(?MODULE, Msg, Level)). 46 | 47 | %% Debug messages can be completely disabled if DEBUG is not defined 48 | -ifdef(DEBUG). 49 | -define(TRACE, [{debug, [trace]}]). 50 | -define(DebugF(Msg, Args), 51 | ts_utils:debug(?MODULE, Msg, Args, ?DEB)). 52 | -define(Debug(Msg), 53 | ts_utils:debug(?MODULE, Msg, ?DEB)). 54 | -else. 55 | -define(TRACE, []). 56 | -define(DebugF(Msg, Args), ok). 57 | -define(Debug(Msg), ok). 58 | -endif. 59 | 60 | -define(EMERG, 0). % The system is unusable. 61 | -define(ALERT, 1). % Action should be taken immediately to address the problem. 62 | -define(CRIT, 2). % A critical condition has occurred. 63 | -define(ERR, 3). % An error has occurred. 64 | -define(WARN, 4). % A significant event that may require attention has occurred. 65 | -define(NOTICE, 5).% An event that does not affect system operation has occurred. 66 | -define(INFO, 6). % An normal operation has occurred. 67 | -define(DEB, 7). % Debugging info 68 | 69 | -define(TIMEOUT_PARALLEL_SPAWN, 60000). 70 | -define(MAX_PHASE_EXCEED_PERCENT, 20). 71 | -define(MAX_PHASE_EXCEED_NUSERS, 10). 72 | 73 | 74 | -define(restart_sleep, 2000). 75 | -define(infinity_timeout, 15000). 76 | -define(config_timeout, 60000). 77 | -define(check_noclient_timeout, 60000). 78 | -define(fast_check_noclient_timeout, 5000). 79 | -define(retries, 4). 80 | 81 | 82 | -------------------------------------------------------------------------------- /include/ts_mqtt.hrl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by Zhihui Jiao(jzhihui521@gmail.com). 2 | %%% 3 | %%% Copyright (C) 2013 Zhihui Jiao 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | %%% In addition, as a special exception, you have the permission to 20 | %%% link the code of this program with any library released under 21 | %%% the EPL license and distribute linked combinations including 22 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23 | %%% Public License) is based on, is included in this exception. 24 | 25 | 26 | -vc('$Id$ '). 27 | -author('jzhihui521@gmail.com'). 28 | 29 | %% use by the client to create the request 30 | -record(mqtt_request, { 31 | type, 32 | clean_start = true, 33 | keepalive = 10, % 10s 34 | will_topic, 35 | will_qos, 36 | will_msg, 37 | will_retain, 38 | topic, 39 | qos = 0, 40 | retained = false, 41 | payload, 42 | username, 43 | password 44 | }). 45 | 46 | -record(mqtt_dyndata, { 47 | none 48 | } 49 | ). 50 | 51 | -record(mqtt_session, { 52 | ack_buf = <<>>, 53 | ping_pid, 54 | keepalive, 55 | curr_id = 0, 56 | wait, % wait code 57 | status % connection status 58 | }). 59 | -------------------------------------------------------------------------------- /include/ts_mysql.hrl: -------------------------------------------------------------------------------- 1 | %%% Created : July 2008 by Grégoire Reboul 2 | %%% From : ts_pgsql.hrl by Nicolas Niclausse 3 | %%% Note : Based on erlang-mysql by Magnus Ahltorp & Fredrik Thulin 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | 20 | %%% In addition, as a special exception, you have the permission to 21 | %%% link the code of this program with any library released under 22 | %%% the EPL license and distribute linked combinations including 23 | %%% the two. 24 | 25 | -author('gregoire.reboul@laposte.net'). 26 | 27 | %% use by the client to create the request 28 | -record(mysql_request, { 29 | type, 30 | username, 31 | passwd, 32 | salt, 33 | database, 34 | sql 35 | }). 36 | 37 | %% 38 | -record(mysql_session, 39 | { 40 | salt 41 | } 42 | ). 43 | 44 | %% Support for MySQL 4.1.x et 5.0.x 45 | -define(MYSQL_4_0, 40). 46 | -define(MYSQL_4_1, 41). 47 | -define(LONG_PASSWORD, 1). 48 | -define(LONG_FLAG, 4). 49 | -define(PROTOCOL_41, 512). 50 | -define(TRANSACTIONS, 8192). 51 | -define(SECURE_CONNECTION, 32768). 52 | -define(CONNECT_WITH_DB, 8). 53 | -define(MAX_PACKET_SIZE, 1000000). 54 | -define(MYSQL_QUERY_OP, 3). 55 | -define(MYSQL_CLOSE_OP, 1). 56 | -------------------------------------------------------------------------------- /include/ts_os_mon.hrl: -------------------------------------------------------------------------------- 1 | %%% Copyright (C) 2008 Nicolas Niclausse 2 | %%% 3 | %%% This program is free software; you can redistribute it and/or modify 4 | %%% it under the terms of the GNU General Public License as published by 5 | %%% the Free Software Foundation; either version 2 of the License, or 6 | %%% (at your option) any later version. 7 | %%% 8 | %%% This program is distributed in the hope that it will be useful, 9 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | %%% GNU General Public License for more details. 12 | %%% 13 | %%% You should have received a copy of the GNU General Public License 14 | %%% along with this program; if not, write to the Free Software 15 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 16 | %%% 17 | %%% In addition, as a special exception, you have the permission to 18 | %%% link the code of this program with any library released under 19 | %%% the EPL license and distribute linked combinations including 20 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 21 | %%% Public License) is based on, is included in this exception. 22 | 23 | 24 | -define(INTERVAL, 10000). 25 | -define(INIT_WAIT, 1000). 26 | -------------------------------------------------------------------------------- /include/ts_pgsql.hrl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright © Nicolas Niclausse 2005 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 6 Nov 2005 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | 28 | -vc('$Id$ '). 29 | -author('nicolas.niclausse@niclux.org'). 30 | 31 | %% use by the client to create the request 32 | -record(pgsql_request, { 33 | type, 34 | username, 35 | passwd, 36 | salt, 37 | auth_method, 38 | database, 39 | name_portal, 40 | name_prepared, 41 | equery, 42 | parameters, 43 | formats, 44 | formats_results, 45 | max_rows, % used for type='execute' 46 | sql 47 | }). 48 | 49 | -record(pgsql_session, 50 | { 51 | auth_method, 52 | username, 53 | salt 54 | } 55 | ). 56 | 57 | %%% Version 3.0 of the protocol. 58 | %%% Supported in postgres from version 7.4 59 | -define(PROTOCOL_MAJOR, 3). 60 | -define(PROTOCOL_MINOR, 0). 61 | 62 | -define(PG_PASSWORD_MSG, $p). 63 | 64 | -define(PG_AUTH_OK, 0). 65 | -define(PG_AUTH_KRB4, 1). 66 | -define(PG_AUTH_KRB5, 2). 67 | -define(PG_AUTH_PASSWD, 3). 68 | -define(PG_AUTH_CRYPT, 4). 69 | -define(PG_AUTH_MD5, 5). 70 | -------------------------------------------------------------------------------- /include/ts_raw.hrl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by IDEALX (http://IDEALX.org/) and 2 | %%% contributors (their names can be found in the CONTRIBUTORS file). 3 | %%% Copyright (C) 2000-2001 IDEALX 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | %%% In addition, as a special exception, you have the permission to 20 | %%% link the code of this program with any library released under 21 | %%% the EPL license and distribute linked combinations including 22 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23 | %%% Public License) is based on, is included in this exception. 24 | 25 | -vc('$Id$ '). 26 | -author('nicolas.niclausse@IDEALX.com'). 27 | 28 | -record(raw, { 29 | data, 30 | datasize, 31 | bug %% FIXME: ugly: if only a single name is set, handle_next_request will fail with add_dynparams (it will think that the server has changed) 32 | }). 33 | 34 | -------------------------------------------------------------------------------- /include/ts_recorder.hrl: -------------------------------------------------------------------------------- 1 | 2 | 3 | -define(tcp_buffer, 65536). 4 | -define(lifetime, 120000). 5 | 6 | -record(state_rec, {log_file, % logfile name 7 | logfd, % logfile IODevice 8 | prev_port, % previous port 9 | prev_scheme, % previous scheme 10 | prev_host, % previous hostname 11 | timestamp=0, % last request date 12 | ext_file_id, % counter of external files (use for ex. in HTTP POST req) 13 | plugin_state, % can be used by the plugin to store some state 14 | plugin, 15 | thinktime_low = 1000 % dot not record thinktime less than this 16 | % value (msec) 17 | }). 18 | 19 | 20 | -record(proxy, { 21 | clientsock, 22 | http_version, 23 | close, % must close client socket (connection:close header was send by server) 24 | parse_status = new, %% http status = body|new 25 | body_size = 0, 26 | content_length = 0, 27 | parent_proxy = false, 28 | buffer = [], 29 | plugin, 30 | serversock 31 | }). 32 | 33 | -------------------------------------------------------------------------------- /include/ts_shell.hrl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2010 © INRIA 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 13 january 2010 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | 28 | -vc('$Id$ '). 29 | -author('nicolas.niclausse@niclux.org'). 30 | 31 | %% use by the client to create the request 32 | 33 | 34 | -record(shell, { command, 35 | args 36 | }). 37 | 38 | -record(shell_sess, { fixme }). 39 | 40 | 41 | -------------------------------------------------------------------------------- /include/ts_websocket.hrl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by Zhihui Jiao(jzhihui521@gmail.com). 2 | %%% 3 | %%% Copyright (C) 2013 Zhihui Jiao 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | %%% In addition, as a special exception, you have the permission to 20 | %%% link the code of this program with any library released under 21 | %%% the EPL license and distribute linked combinations including 22 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23 | %%% Public License) is based on, is included in this exception. 24 | 25 | -vc('$Id$ '). 26 | -author('jzhihui521@gmail.com'). 27 | 28 | %% use by the client to create the request 29 | -record(websocket_request, { 30 | version = "13", % default is 13(rfc6455) 31 | type, % connect or message 32 | path, % connection path 33 | frame = "binary", 34 | subprotos = [], % subprotocols 35 | data % websocket data 36 | }). 37 | 38 | -record(websocket_dyndata, { 39 | none 40 | } 41 | ). 42 | 43 | -record(websocket_session, { 44 | status, % status of handshake 45 | accept % Sec-Websocket-Accept header value 46 | }). 47 | 48 | %% opcode of websocket 49 | -define(OP_CONT, 0). 50 | -define(OP_TEXT, 1). 51 | -define(OP_BIN, 2). 52 | -define(OP_CLOSE, 8). 53 | -define(OP_PING, 9). 54 | -define(OP_PONG, 10). 55 | -------------------------------------------------------------------------------- /man/Design.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/man/Design.txt -------------------------------------------------------------------------------- /man/Design_fr.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/man/Design_fr.txt -------------------------------------------------------------------------------- /man/Jabber.txt: -------------------------------------------------------------------------------- 1 | Requirements: 2 | ============ 3 | 4 | users has to be already registered: 5 | 6 | tsung users name : cXX 7 | passwd: pasXX 8 | 9 | where XX is a integer between 1 and the maximum number of users (say 1000000). 10 | 11 | or you can use jabber_register (see below). 12 | 13 | optional parameters: (can be set in tsung.xml file) 14 | ================== 15 | 16 | jabber_domain=mydomain.com 17 | 18 | modules implemented for the Jabber protocol: 19 | ============================================ 20 | 21 | - jabber_common: module regrouping common functions for building 22 | messages 23 | 24 | NOTE: currently, no XML parsing is done by the receiving process (it 25 | would be very time consuming to parse thousands of simultaneous XML 26 | flows). It use acknoledgements instead based on the first packet 27 | received after the request has been sent. 28 | 29 | -------------------------------------------------------------------------------- /man/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/man/Makefile -------------------------------------------------------------------------------- /man/tsung-inside.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/man/tsung-inside.dia -------------------------------------------------------------------------------- /man/tsung-inside.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/man/tsung-inside.png -------------------------------------------------------------------------------- /man/tsung-recorder.1: -------------------------------------------------------------------------------- 1 | .\" auto-generated by docbook2man-spec from docbook-utils package 2 | .TH "TSUNG-RECORDER" "1" "March 2009" "" "" 3 | .SH NAME 4 | tsung-recorder \- Proxy recorder for the tsung load testing tool. 5 | .SH SYNOPSIS 6 | .sp 7 | \fBtsung-recorder\fR [ \fB-l log file\fR ] [ \fB-r command\fR ] [ \fB-p plugin\fR ] [ \fB-L listen port\fR ] [ \fB-I IP\fR ] [ \fB-P port\fR ] [ \fB-u \fR ] [ \fBstart|stop|restart|record_tag\fR ] 8 | .SH "DESCRIPTION" 9 | .PP 10 | \fBtsung\fR is a distributed load testing 11 | tool. It is protocol-independent and can currently be used to 12 | stress and benchmark HTTP, WebDAV, LDAP, PostgreSQL, MySQL and 13 | Jabber/XMPP servers. \fBtsung-recorder\fR can be 14 | used to record sessions (only for HTTP, WebDAV and Postgresql) that can be edited and replayed later by tsung 15 | .PP 16 | tsung-recorder is a proxy that records a session in the 17 | tsung native XML format; it can be used by your favorite client (browser in the case of the http plugin). 18 | .TP 19 | \fBstart\fR 20 | start the proxy recorder (listening port is 8090). By default the HTTP recorder is started. With the \fB-p\fR option, you can select another plugin. The resulting files will be created as \fI~/.tsung/tsung_recorderYYYMMDD-HH:MM.xml\fR; if it doesn't work, take a look at \fI~/.tsung/log/tsung.log-tsunami_recorder@hostname\fR 21 | .TP 22 | \fBstop\fR 23 | stop the proxy recorder 24 | .TP 25 | \fBrecord_tag value\fR 26 | add a string (comment or tag) while recording a 27 | session. This is useful for example to add transaction tag 28 | while recording a session. 29 | .SH "MANUAL" 30 | .PP 31 | A manual should be available at 32 | \fI/usr/share/doc/tsung/user_manual.html\fR\&. It 33 | is also available online at 34 | .sp 35 | .RS 36 | .sp 37 | .nf 38 | http://tsung.erlang-projects.org/user_manual.html 39 | .sp 40 | .fi 41 | .RE 42 | .sp 43 | .SH "OPTIONS" 44 | .TP 45 | \fB-l logfile\fR 46 | Specifies the log file to use. The default log file name is \fI~/tsung/log/tsung.log\fR 47 | .TP 48 | \fB-p plugin\fR 49 | Specifies the plugin used for the recorder. Default is 50 | http, available: http, pgsql, webdav 51 | .TP 52 | \fB-L port\fR 53 | Listening port for the recorder. Default is 8090 54 | .TP 55 | \fB-I IP\fR 56 | For the pgsql recorder (or parent proxy): server IP. default is 127.0.0.1 57 | .TP 58 | \fB-P port\fR 59 | For the pgsql recorder (or parent proxy): server port. Default is 5432 60 | .TP 61 | \fB-u\fR 62 | For the http recorder: use a parent proxy 63 | .SH "BUGS" 64 | .PP 65 | Please reports bugs to the mailing list 66 | , see 67 | .sp 68 | .RS 69 | .sp 70 | .nf 71 | https://lists.process-one.net/mailman/listinfo/tsung-users 72 | .sp 73 | .fi 74 | .RE 75 | .sp 76 | for 77 | archives. 78 | .SH "SEE ALSO" 79 | .PP 80 | \fBerlang\fR(3) 81 | and \fBtsung\fR(1) 82 | .SH "AUTHORS" 83 | .PP 84 | \fBTsung\fR is written by Nicolas Niclausse 85 | \&. Contributors list 86 | is available in 87 | \fI/usr/share/doc/tsung/CONTRIBUTORS\fR 88 | -------------------------------------------------------------------------------- /src/lib/mochiweb_xpath_parser.erl: -------------------------------------------------------------------------------- 1 | %% @author Pablo Polvorin 2 | %% @doc Compile XPath expressions. 3 | %% This module uses the xpath parser of xmerl.. that interface isn't documented 4 | %% so could change between OTP versions.. its know to work with OTP R12B2 5 | %% created on 2008-05-07 6 | -module(mochiweb_xpath_parser). 7 | 8 | -export([compile_xpath/1]). 9 | 10 | %% Return a compiled XPath expression 11 | compile_xpath(XPathString) -> 12 | {ok,XPath} = xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens(XPathString)), 13 | simplify(XPath). 14 | 15 | 16 | 17 | %% @doc Utility functions to convert between the *internal* representation of 18 | % xpath expressions used in xmerl(using lists and atoms), to a 19 | % representation using only binaries, to match the way in 20 | % which the mochiweb html parser represents data 21 | simplify({path, union, {Path1, Path2}})-> 22 | %% "expr1 | expr2 | expr3" 23 | {path, union, {simplify(Path1), simplify(Path2)}}; 24 | simplify({path,Type,Path}) -> 25 | {path,Type,simplify_path(Path)}; 26 | simplify({comp,Comp,A,B}) -> 27 | {comp,Comp,simplify(A),simplify(B)}; 28 | simplify({literal,L}) -> 29 | {literal,list_to_binary(L)}; 30 | simplify({number,N}) -> 31 | {number,N}; 32 | simplify({negative, Smth}) -> 33 | {negative, simplify(Smth)}; 34 | simplify({bool, Comp, A, B}) -> 35 | {bool, Comp, simplify(A), simplify(B)}; 36 | simplify({function_call,Fun,Args}) -> 37 | {function_call,Fun,lists:map(fun simplify/1,Args)}; 38 | simplify({arith, Op, Arg1, Arg2}) -> 39 | {arith, Op, simplify(Arg1), simplify(Arg2)}. 40 | 41 | 42 | simplify_path({step,{Axis,NodeTest,Predicates}}) -> 43 | {step,{Axis, 44 | simplify_node_test(NodeTest), 45 | simplify_predicates(Predicates)}}; 46 | simplify_path({refine,Path1,Path2}) -> 47 | {refine,simplify_path(Path1),simplify_path(Path2)}. 48 | 49 | 50 | simplify_node_test({name,{Tag,Prefix,Local}}) -> 51 | {name,{to_binary(Tag),Prefix,Local}}; 52 | 53 | simplify_node_test(A={node_type, _Type}) -> 54 | A; 55 | simplify_node_test({processing_instruction, Name}) -> 56 | {processing_instruction, list_to_binary(Name)}; % strictly, this must be node_type too! 57 | simplify_node_test(A={wildcard,wildcard}) -> 58 | A; 59 | simplify_node_test({prefix_test, Prefix}) -> 60 | %% [37] /prefix:*/ - namespace test 61 | {prefix_test, list_to_binary(Prefix)}. 62 | 63 | 64 | simplify_predicates(X) -> lists:map(fun simplify_predicate/1,X). 65 | simplify_predicate({pred,Pred}) -> 66 | {pred,simplify(Pred)}. 67 | 68 | to_binary(X) when is_atom(X) -> list_to_binary(atom_to_list(X)). 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/lib/mochiweb_xpath_utils.erl: -------------------------------------------------------------------------------- 1 | %% xpath_utils.erl 2 | %% @author Pablo Polvorin 3 | %% @doc Utility functions, mainly for type conversion 4 | %% Conversion rules taken from http://www.w3.org/TR/1999/REC-xpath-19991116 5 | %% created on 2008-05-07 6 | -module(mochiweb_xpath_utils). 7 | 8 | -export([string_value/1, 9 | number_value/1, 10 | node_set_value/1, 11 | boolean_value/1, 12 | convert/2]). 13 | 14 | -spec string_value(mochiweb_xpath:indexed_xpath_return()) -> binary(). 15 | string_value(N) when is_list(N)-> 16 | case N of 17 | [X|_] -> string_value(X); 18 | [] -> <<>> 19 | end; 20 | string_value({_,_,Contents,_}) -> 21 | %% Node 22 | L = lists:filter(fun 23 | ({_,_,_,_}) ->false; 24 | (B) when is_binary(B) -> true 25 | end,Contents), 26 | list_to_binary(L); 27 | string_value({_Name, Value}) -> 28 | %% attribute 29 | Value; 30 | string_value(N) when is_integer(N) -> 31 | list_to_binary(integer_to_list(N)); 32 | string_value(B) when is_binary(B) -> 33 | B; 34 | string_value(B) when is_atom(B) -> 35 | list_to_binary(atom_to_list(B)); 36 | string_value(Expr) -> 37 | %% string_value(mochiweb_xpath:execute_expr(Expr, Ctx)). 38 | throw({not_implemented, "String from expression", Expr}). 39 | 40 | -spec node_set_value(mochiweb_xpath:indexed_xpath_return()) -> [mochiweb_xpath:indexed_html_node()]. 41 | node_set_value(List) when is_list(List) -> 42 | List; 43 | node_set_value(N) -> 44 | throw({node_set_expected,N}). 45 | 46 | -spec number_value(mochiweb_xpath:indexed_xpath_return() | binary()) -> number(). 47 | number_value(N) when is_integer(N) or is_float(N) -> 48 | N; 49 | number_value({number, N}) when is_integer(N) or is_float(N) -> 50 | N; 51 | number_value({negative, Exp}) -> 52 | N = number_value(Exp), 53 | - N; 54 | number_value(N) when is_binary(N)-> 55 | String = binary_to_list(N), 56 | case erl_scan:string(String) of 57 | {ok, [{integer,1,I}],1} -> I; 58 | {ok, [{float,1,F}],1} -> F 59 | end; 60 | 61 | number_value(N) -> 62 | number_value(string_value(N)). 63 | 64 | -spec boolean_value(mochiweb_xpath:indexed_xpath_return()) -> boolean(). 65 | boolean_value([]) -> 66 | false; 67 | boolean_value([_|_]) -> 68 | true; 69 | boolean_value(N) when is_number(N) -> 70 | N /= 0; 71 | boolean_value(B) when is_binary(B) -> 72 | size(B) /= 0; 73 | boolean_value(B) when is_boolean(B) -> 74 | B; 75 | boolean_value({_, _, _Contents, _}) -> 76 | true; % TODO: rly? 77 | boolean_value(_Expr) -> 78 | throw({not_implemented, "Boolean from expression"}). 79 | 80 | 81 | 82 | 83 | convert(Value,number) -> 84 | number_value(Value); 85 | convert(Value,string) -> 86 | string_value(Value); 87 | convert(Value,node_set) -> 88 | node_set_value(Value); 89 | convert(Value, boolean) -> 90 | boolean_value(Value). 91 | -------------------------------------------------------------------------------- /src/lib/oauth_hmac_sha1.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2008-2009 Tim Fletcher 2 | %% Copyright (c) 2015 Christoher Meng 3 | %% 4 | %% Permission is hereby granted, free of charge, to any person 5 | %% obtaining a copy of this software and associated documentation 6 | %% files (the "Software"), to deal in the Software without 7 | %% restriction, including without limitation the rights to use, 8 | %% copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | %% copies of the Software, and to permit persons to whom the 10 | %% Software is furnished to do so, subject to the following 11 | %% conditions: 12 | %% 13 | %% The above copyright notice and this permission notice shall be 14 | %% included in all copies or substantial portions of the Software. 15 | %% 16 | %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | %% OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | -module(oauth_hmac_sha1). 26 | 27 | -export([signature/3, verify/4]). 28 | 29 | -spec signature(string(), string(), string()) -> string(). 30 | signature(BaseString, CS, TS) -> 31 | Key = oauth_uri:calate("&", [CS, TS]), 32 | base64:encode_to_string(sha2hmac(Key, BaseString)). 33 | 34 | sha2hmac(Key, Data) -> 35 | case erlang:function_exported(crypto, hmac, 3) of 36 | true -> 37 | crypto:hmac(sha, Key, Data); 38 | false -> 39 | crypto:sha_mac(Key, Data) 40 | end. 41 | 42 | -spec verify(string(), string(), string(), string()) -> boolean(). 43 | verify(Signature, BaseString, CS, TS) -> 44 | Signature =:= signature(BaseString, CS, TS). 45 | -------------------------------------------------------------------------------- /src/lib/oauth_http.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2008-2009 Tim Fletcher 2 | %% 3 | %% Permission is hereby granted, free of charge, to any person 4 | %% obtaining a copy of this software and associated documentation 5 | %% files (the "Software"), to deal in the Software without 6 | %% restriction, including without limitation the rights to use, 7 | %% copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | %% copies of the Software, and to permit persons to whom the 9 | %% Software is furnished to do so, subject to the following 10 | %% conditions: 11 | %% 12 | %% The above copyright notice and this permission notice shall be 13 | %% included in all copies or substantial portions of the Software. 14 | %% 15 | %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | %% OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -module(oauth_http). 25 | 26 | -export([get/1, post/2, put/2, response_params/1, response_body/1, response_code/1]). 27 | 28 | -type http_status() :: {string(), integer(), string()}. 29 | 30 | -spec get(string()) -> {ok, {Status::http_status(), Headers::[{string(), string()}], Body::string()}} | {error, term()}. 31 | get(URL) -> 32 | request(get, {URL, []}). 33 | 34 | -spec post(string(), term()) -> {ok, {Status::http_status(), Headers::[{string(), string()}], Body::string()}} | {error, term()}. 35 | post(URL, Data) -> 36 | request(post, {URL, [], "application/x-www-form-urlencoded", Data}). 37 | 38 | -spec put(string(), term()) -> {ok, {Status::http_status(), Headers::[{string(), string()}], Body::string()}} | {error, term()}. 39 | put(URL, Data) -> 40 | request(put, {URL, [], "application/x-www-form-urlencoded", Data}). 41 | 42 | -spec request(httpc:method(), tuple()) -> {ok, {Status::http_status(), Headers::[{string(), string()}], Body::string()}} | {error, term()}. 43 | request(Method, Request) -> 44 | httpc:request(Method, Request, [{autoredirect, false}], []). 45 | 46 | -spec response_params({http_status(), [{string(), string()}], string()}) -> [{string(), string()}]. 47 | response_params(Response) -> 48 | oauth_uri:params_from_string(response_body(Response)). 49 | 50 | -spec response_body({http_status(), [{string(), string()}], string()}) -> string(). 51 | response_body({{_, _, _}, _, Body}) -> 52 | Body. 53 | 54 | -spec response_code({http_status(), [{string(), string()}], string()}) -> integer(). 55 | response_code({{_, Code, _}, _, _}) -> 56 | Code. 57 | -------------------------------------------------------------------------------- /src/lib/oauth_plaintext.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2008-2009 Tim Fletcher 2 | %% 3 | %% Permission is hereby granted, free of charge, to any person 4 | %% obtaining a copy of this software and associated documentation 5 | %% files (the "Software"), to deal in the Software without 6 | %% restriction, including without limitation the rights to use, 7 | %% copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | %% copies of the Software, and to permit persons to whom the 9 | %% Software is furnished to do so, subject to the following 10 | %% conditions: 11 | %% 12 | %% The above copyright notice and this permission notice shall be 13 | %% included in all copies or substantial portions of the Software. 14 | %% 15 | %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | %% OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -module(oauth_plaintext). 25 | 26 | -export([signature/2, verify/3]). 27 | 28 | -spec signature(string(), string()) -> string(). 29 | signature(CS, TS) -> 30 | oauth_uri:calate("&", [CS, TS]). 31 | 32 | -spec verify(string(), string(), string()) -> boolean(). 33 | verify(Signature, CS, TS) -> 34 | Signature =:= signature(CS, TS). 35 | -------------------------------------------------------------------------------- /src/lib/oauth_rsa_sha1.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2008-2009 Tim Fletcher 2 | %% 3 | %% Permission is hereby granted, free of charge, to any person 4 | %% obtaining a copy of this software and associated documentation 5 | %% files (the "Software"), to deal in the Software without 6 | %% restriction, including without limitation the rights to use, 7 | %% copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | %% copies of the Software, and to permit persons to whom the 9 | %% Software is furnished to do so, subject to the following 10 | %% conditions: 11 | %% 12 | %% The above copyright notice and this permission notice shall be 13 | %% included in all copies or substantial portions of the Software. 14 | %% 15 | %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | %% OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -module(oauth_rsa_sha1). 25 | 26 | -export([signature/2, verify/3]). 27 | 28 | -include_lib("public_key/include/public_key.hrl"). 29 | 30 | -spec signature(string(), string()) -> string(). 31 | signature(BaseString, PrivateKeyPath) -> 32 | {ok, Contents} = file:read_file(PrivateKeyPath), 33 | [Info] = public_key:pem_decode(Contents), 34 | PrivateKey = public_key:pem_entry_decode(Info), 35 | base64:encode_to_string(public_key:sign(list_to_binary(BaseString), sha, PrivateKey)). 36 | 37 | -spec verify(string(), string(), term()) -> boolean(). 38 | verify(Signature, BaseString, PublicKey) -> 39 | public_key:verify(to_binary(BaseString), sha, base64:decode(Signature), public_key(PublicKey)). 40 | 41 | to_binary(Term) when is_list(Term) -> 42 | list_to_binary(Term); 43 | to_binary(Term) when is_binary(Term) -> 44 | Term. 45 | 46 | public_key(Path) when is_list(Path) -> 47 | {ok, Contents} = file:read_file(Path), 48 | [{'Certificate', DerCert, not_encrypted}] = public_key:pem_decode(Contents), 49 | public_key( public_key:pkix_decode_cert(DerCert, otp)); 50 | public_key(#'OTPCertificate'{tbsCertificate=Cert}) -> 51 | public_key(Cert); 52 | public_key(#'OTPTBSCertificate'{subjectPublicKeyInfo=Info}) -> 53 | public_key(Info); 54 | public_key(#'OTPSubjectPublicKeyInfo'{subjectPublicKey=Key}) -> 55 | Key. 56 | -------------------------------------------------------------------------------- /src/lib/oauth_unix.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2008-2009 Tim Fletcher 2 | %% 3 | %% Permission is hereby granted, free of charge, to any person 4 | %% obtaining a copy of this software and associated documentation 5 | %% files (the "Software"), to deal in the Software without 6 | %% restriction, including without limitation the rights to use, 7 | %% copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | %% copies of the Software, and to permit persons to whom the 9 | %% Software is furnished to do so, subject to the following 10 | %% conditions: 11 | %% 12 | %% The above copyright notice and this permission notice shall be 13 | %% included in all copies or substantial portions of the Software. 14 | %% 15 | %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | %% OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -module(oauth_unix). 25 | 26 | -export([timestamp/0]). 27 | 28 | -spec timestamp() -> integer(). 29 | timestamp() -> 30 | timestamp(calendar:universal_time()). 31 | 32 | timestamp(DateTime) -> 33 | seconds(DateTime) - epoch(). 34 | 35 | epoch() -> 36 | seconds({{1970,1,1},{00,00,00}}). 37 | 38 | seconds(DateTime) -> 39 | calendar:datetime_to_gregorian_seconds(DateTime). 40 | -------------------------------------------------------------------------------- /src/lib/rabbit_misc.erl: -------------------------------------------------------------------------------- 1 | -module(rabbit_misc). 2 | -include("rabbit.hrl"). 3 | -include("rabbit_framing.hrl"). 4 | 5 | -export([method_record_type/1]). 6 | -export([amqp_error/4]). 7 | -export([frame_error/2]). 8 | -export([protocol_error/3, protocol_error/4, protocol_error/1]). 9 | 10 | method_record_type(Record) -> 11 | element(1, Record). 12 | 13 | amqp_error(Name, ExplanationFormat, Params, Method) -> 14 | Explanation = format(ExplanationFormat, Params), 15 | #amqp_error{name = Name, explanation = Explanation, method = Method}. 16 | 17 | format(Fmt, Args) -> lists:flatten(io_lib:format(Fmt, Args)). 18 | 19 | frame_error(MethodName, BinaryFields) -> 20 | protocol_error(frame_error, "cannot decode ~w", [BinaryFields], MethodName). 21 | 22 | protocol_error(Name, ExplanationFormat, Params) -> 23 | protocol_error(Name, ExplanationFormat, Params, none). 24 | 25 | protocol_error(Name, ExplanationFormat, Params, Method) -> 26 | protocol_error(amqp_error(Name, ExplanationFormat, Params, Method)). 27 | 28 | protocol_error(#amqp_error{} = Error) -> 29 | exit(Error). 30 | 31 | -------------------------------------------------------------------------------- /src/templates/footer.thtml: -------------------------------------------------------------------------------- 1 |
2 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/templates/header.thtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | [% title %] - [% subtitle %] 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 42 | 43 |
44 |
45 | 76 |
77 | -------------------------------------------------------------------------------- /src/templates/style/dashboard.css: -------------------------------------------------------------------------------- 1 | /* 2 | * * Base structure 3 | * */ 4 | 5 | /* Move down content because we have a fixed navbar that is 50px tall */ 6 | body { 7 | padding-top: 50px; 8 | } 9 | 10 | 11 | /* 12 | * * Global add-ons 13 | * */ 14 | 15 | .sub-header { 16 | padding-bottom: 10px; 17 | border-bottom: 1px solid #eee; 18 | } 19 | 20 | 21 | /* 22 | * * Sidebar 23 | * */ 24 | 25 | /* Hide for mobile, show later */ 26 | .sidebar { 27 | display: none; 28 | } 29 | @media (min-width: 768px) { 30 | .sidebar { 31 | position: fixed; 32 | top: 51px; 33 | bottom: 0; 34 | left: 0; 35 | z-index: 1000; 36 | display: block; 37 | padding: 20px; 38 | overflow-x: hidden; 39 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ 40 | background-color: #f5f5f5; 41 | border-right: 1px solid #eee; 42 | } 43 | } 44 | 45 | /* Sidebar navigation */ 46 | .nav-sidebar { 47 | margin-right: -21px; /* 20px padding + 1px border */ 48 | margin-bottom: 20px; 49 | margin-left: -20px; 50 | } 51 | .nav-sidebar > li > a { 52 | padding-right: 20px; 53 | padding-left: 20px; 54 | } 55 | .nav-sidebar > .active > a { 56 | color: #fff; 57 | background-color: #428bca; 58 | } 59 | 60 | 61 | /* 62 | * * Main content 63 | * */ 64 | 65 | .main { 66 | padding: 20px; 67 | } 68 | @media (min-width: 768px) { 69 | .main { 70 | padding-right: 40px; 71 | padding-left: 40px; 72 | } 73 | } 74 | .main .page-header { 75 | margin-top: 0; 76 | } 77 | 78 | 79 | /* 80 | * * Placeholder dashboard ideas 81 | * */ 82 | 83 | .placeholders { 84 | margin-bottom: 30px; 85 | text-align: center; 86 | } 87 | .placeholders h4 { 88 | margin-bottom: 0; 89 | } 90 | .placeholder { 91 | margin-bottom: 20px; 92 | } 93 | .placeholder img { 94 | display: inline-block; 95 | border-radius: 50%; 96 | } 97 | 98 | /* .ts_tooltip { */ 99 | /* font-size: 80%; background: #FFFFAA; */ 100 | /* border-bottom: 1px dotted #000000; color: #000000; outline: none; */ 101 | /* cursor: help; text-decoration: none; */ 102 | /* position: relative; */ 103 | /* } */ 104 | 105 | /* .ts_tooltip span { */ 106 | /* display: none; */ 107 | /* } */ 108 | 109 | /* .ts_tooltip:hover span { */ 110 | /* display:block; */ 111 | /* position:absolute; z-index: 99; */ 112 | /* top:2em; left:2em; width:15em; */ 113 | /* text-align: center} */ 114 | 115 | /* .ts_tooltip:hover img { */ 116 | /* border: 0; margin: -10px 0 0 -55px; */ 117 | /* float: left; position: absolute; */ 118 | /* } */ 119 | 120 | /* .ts_tooltip:hover em { */ 121 | /* font-family: Candara, Tahoma, Geneva, sans-serif; font-size: 1.2em; font-weight: bold; */ 122 | /* display: block; padding: 0.2em 0 0.6em 0; */ 123 | /* } */ 124 | 125 | /* .classic { padding: 0.8em 1em; } */ 126 | 127 | .collapse { 128 | display: none; 129 | } 130 | 131 | .collapse.in { 132 | display: block; 133 | } 134 | 135 | .collapsing { 136 | position: relative; 137 | height: 0; 138 | overflow: hidden; 139 | -webkit-transition: height 0.35s ease; 140 | transition: height 0.35s ease; 141 | } 142 | -------------------------------------------------------------------------------- /src/test/badpop.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/test/ifcfg.out: -------------------------------------------------------------------------------- 1 | eth0 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 2 | inet addr:192.168.76.183 Bcast:192.168.79.255 Mask:255.255.248.0 3 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 4 | RX packets:2853444 errors:0 dropped:0 overruns:0 frame:0 5 | TX packets:1157524 errors:0 dropped:0 overruns:0 carrier:0 6 | collisions:0 txqueuelen:1000 7 | RX bytes:342116836 (326.2 MiB) TX bytes:147190992 (140.3 MiB) 8 | Interrupt:122 Memory:fb000000-fb7fffff 9 | 10 | eth0:0 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 11 | inet addr:192.168.76.184 Bcast:192.168.79.255 Mask:255.255.248.0 12 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 13 | Interrupt:122 Memory:fb000000-fb7fffff 14 | 15 | eth0:1 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 16 | inet addr:192.168.76.185 Bcast:192.168.79.255 Mask:255.255.248.0 17 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 18 | Interrupt:122 Memory:fb000000-fb7fffff 19 | 20 | eth0:2 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 21 | inet addr:192.168.76.186 Bcast:192.168.79.255 Mask:255.255.248.0 22 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 23 | Interrupt:122 Memory:fb000000-fb7fffff 24 | 25 | eth0:3 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 26 | inet addr:192.168.76.187 Bcast:192.168.79.255 Mask:255.255.248.0 27 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 28 | Interrupt:122 Memory:fb000000-fb7fffff 29 | 30 | eth0:4 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 31 | inet addr:192.168.76.188 Bcast:192.168.79.255 Mask:255.255.248.0 32 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 33 | Interrupt:122 Memory:fb000000-fb7fffff 34 | 35 | eth0:5 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 36 | inet addr:192.168.76.189 Bcast:192.168.79.255 Mask:255.255.248.0 37 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 38 | Interrupt:122 Memory:fb000000-fb7fffff 39 | 40 | eth0:6 Link encap:Ethernet HWaddr 68:B5:99:79:71:5C 41 | inet addr:192.168.76.190 Bcast:192.168.79.255 Mask:255.255.248.0 42 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 43 | Interrupt:122 Memory:fb000000-fb7fffff 44 | -------------------------------------------------------------------------------- /src/test/ipcfg.out: -------------------------------------------------------------------------------- 1 | 5: eth0 inet 192.12.0.1/32 scope global eth0 2 | 5: eth0 inet 192.12.0.2/32 scope global eth0:0 3 | 5: eth0 inet 192.12.0.3/32 scope global eth0:1 4 | 5: eth0 inet 192.12.0.4/32 scope global eth0:2 5 | 5: eth0 inet 192.12.0.5/32 scope global eth0:3 6 | 5: eth0 inet 192.12.0.6/32 scope global eth0:4 7 | 5: eth0 inet 192.12.0.7/32 scope global eth0:5 8 | 5: eth0 inet 192.12.0.8/32 scope global eth0:6 9 | 5: eth0 inet 192.12.0.9/32 scope global eth0:7 10 | 5: eth0 inet 192.12.0.10/32 scope global eth0:8 11 | 5: eth0 inet 192.12.0.11/32 scope global eth0:9 12 | 5: eth0 inet 192.12.0.12/32 scope global eth0:10 13 | -------------------------------------------------------------------------------- /src/test/netstat_test.txt: -------------------------------------------------------------------------------- 1 | Table d'interfaces noyau 2 | Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg 3 | wlan0 1500 0 0 0 0 0 0 0 0 0 BMU 4 | lo 16436 0 13186 0 0 0 13186 0 0 0 LRU 5 | eth0 1500 0 7823989 0 2 0 4272908 0 0 0 BMRU 6 | -------------------------------------------------------------------------------- /src/test/netstat_test3.txt: -------------------------------------------------------------------------------- 1 | Table d'interfaces noyau 2 | Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg 3 | eth0 1500 0 11887768 0 0 0 833748 0 0 0 BMRU 4 | eth0:0 1500 0 - no statistics available - BMRU 5 | eth0:1 1500 0 - no statistics available - BMRU 6 | eth0:3 1500 0 - no statistics available - BMRU 7 | eth0:4 1500 0 - no statistics available - BMRU 8 | eth0:8 1500 0 - no statistics available - BMRU 9 | eth1 1500 0 40621236 0 0 0 40325942 0 0 0 BMRU 10 | eth1:0 1500 0 - no statistics available - BMRU 11 | eth1:1 1500 0 - no statistics available - BMRU 12 | eth1:2 1500 0 - no statistics available - BMRU 13 | eth1:3 1500 0 - no statistics available - BMRU 14 | eth1:4 1500 0 - no statistics available - BMRU 15 | eth2 1500 0 5825149 0 0 0 4149195 0 0 0 BMRU 16 | eth3 1500 0 0 0 0 0 4 0 0 0 BMRU 17 | lo 16436 0 10530106 0 0 0 10530106 0 0 0 LRU 18 | -------------------------------------------------------------------------------- /src/test/procnetdev_test.txt: -------------------------------------------------------------------------------- 1 | Inter-| Receive | Transmit 2 | face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed 3 | lo:48910337 16323 0 0 0 0 0 0 48910337 16323 0 0 0 0 0 0 4 | eth0:2949197601 10106167 0 0 0 0 0 19182 419719531 2609645 0 0 0 0 0 0 5 | eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | virbr0: 0 0 0 0 0 0 0 0 4012 25 0 0 0 0 0 0 7 | -------------------------------------------------------------------------------- /src/test/procnetdev_test7chars.txt: -------------------------------------------------------------------------------- 1 | Inter-| Receive | Transmit 2 | face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed 3 | lo:48910337 16323 0 0 0 0 0 0 48910337 16323 0 0 0 0 0 0 4 | eth0:2949197601 10106167 0 0 0 0 0 19182 419719531 2609645 0 0 0 0 0 0 5 | eth1.14: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | virbr0: 0 0 0 0 0 0 0 0 4012 25 0 0 0 0 0 0 7 | -------------------------------------------------------------------------------- /src/test/test_file_server.csv: -------------------------------------------------------------------------------- 1 | username1;glop; 2 | username2;; 3 | username3;glop4; 4 | -------------------------------------------------------------------------------- /src/test/test_file_server2.csv: -------------------------------------------------------------------------------- 1 | user1;sesame 2 | -------------------------------------------------------------------------------- /src/test/test_file_server_pipe.csv: -------------------------------------------------------------------------------- 1 | conv%2F99%2F589%2Finfo.txt|99|589 2 | conv%2F99%2F938%2Finfo.txt|99|938 3 | -------------------------------------------------------------------------------- /src/test/thinkfirst.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/test/ts_test_dynvars_api.erl: -------------------------------------------------------------------------------- 1 | %% ts_test_dynvars_api.erl 2 | %% @author Pablo Polvorin 3 | %% @doc Test for the ts_dynvars module 4 | %% created on 2008-08-22 5 | -module(ts_test_dynvars_api). 6 | -compile(export_all). 7 | 8 | -include_lib("eunit/include/eunit.hrl"). 9 | 10 | 11 | from_keyval_list(KeyValues) -> 12 | lists:foldl(fun({K,V},DynVars) -> 13 | ts_dynvars:set(K,V,DynVars) 14 | end, 15 | ts_dynvars:new(), 16 | KeyValues 17 | ). 18 | test() -> 19 | ok. 20 | 21 | dynvars_new_ok_test() -> 22 | Keys = [one,two,three,four], 23 | Values = [1,2,"three",4], 24 | ?assertEqual([{one,1},{two,2},{three,"three"},{four,4}], 25 | ts_dynvars:new(Keys, Values)). 26 | 27 | dynvars_array_test() -> 28 | Keys = [one,two,three,four], 29 | Values = [[10,11,12],2,"three",4], 30 | DynVars= ts_dynvars:new(Keys, Values), 31 | ?assertEqual({ok,[10,11,12]}, ts_dynvars:lookup(one, DynVars)), 32 | ?assertEqual({ok,11}, ts_dynvars:lookup({one,2}, DynVars)). 33 | 34 | dynvars_new_more_test() -> 35 | Keys = [one,two,three], 36 | Values = [1,2,"three",[]], 37 | ?assertEqual([{one,1},{two,2},{three,"three"}], 38 | ts_dynvars:new(Keys, Values)). 39 | 40 | dynvars_new_less_test() -> 41 | Keys = [one,two,three,four], 42 | Values = [1,2,"three"], 43 | ?assertEqual([{one,1},{two,2},{three,"three"},{four,""}], 44 | ts_dynvars:new(Keys, Values)). 45 | 46 | 47 | dynvars_set_test() -> 48 | KeyValues = [one,two,three,four], 49 | DynVars = from_keyval_list([{K,K} || K <- KeyValues]), 50 | ?assertEqual([{ok,K} || K <- KeyValues], 51 | [ts_dynvars:lookup(Key, DynVars) || Key <- KeyValues]). 52 | 53 | dynvars_set2_test() -> 54 | D = ts_dynvars:set(one,two, ts_dynvars:set(one,one, ts_dynvars:new())), 55 | ?assertEqual({ok,two},ts_dynvars:lookup(one,D)). 56 | 57 | dynvars_undefined_test() -> 58 | ?assertEqual(false,ts_dynvars:lookup(one, ts_dynvars:new())). 59 | 60 | dynvars_default_test() -> 61 | ?assertEqual({ok,default},ts_dynvars:lookup(one,ts_dynvars:new(), default)). 62 | 63 | dynvars_entries_test() -> 64 | KeyValues = [{K,K} || K <- [one,two,three,four]], 65 | ?assertEqual(lists:reverse(KeyValues), 66 | ts_dynvars:entries(from_keyval_list(KeyValues))). 67 | 68 | dynvars_map_test() -> 69 | KeyValues = [{K,K} || K <- [one,two,three,four]], 70 | ?assertEqual({ok,[two,two]},ts_dynvars:lookup(two,ts_dynvars:map(fun(X) -> [X,X] end, 71 | two, 72 | default, 73 | from_keyval_list(KeyValues)) 74 | )). 75 | 76 | dynvars_map_default_test() -> 77 | KeyValues = [{K,K} || K <- [one,two,three,four]], 78 | ?assertEqual({ok,[one]},ts_dynvars:lookup(five, ts_dynvars:map(fun(X) -> [one|X] end, 79 | five, 80 | [], 81 | from_keyval_list(KeyValues)) 82 | )). 83 | -------------------------------------------------------------------------------- /src/test/ts_test_interaction.erl: -------------------------------------------------------------------------------- 1 | %%%------------------------------------------------------------------- 2 | %%% File : ts_test_interaction.erl 3 | %%% Author : Nicolas Niclausse 4 | %%% Description : 5 | %%% 6 | %%% Created : 28 Aug 2012 by Nicolas Niclausse 7 | %%%------------------------------------------------------------------- 8 | -module(ts_test_interaction). 9 | 10 | -compile(export_all). 11 | 12 | -include("ts_profile.hrl"). 13 | -include("ts_config.hrl"). 14 | 15 | -include_lib("eunit/include/eunit.hrl"). 16 | 17 | 18 | test()-> 19 | ok. 20 | 21 | notify_test()-> 22 | myset_env(0), 23 | ts_interaction_server:start(), 24 | ts_interaction_server:send({chat,now()}), 25 | ts_interaction_server:notify({'receive',chat,self()}), 26 | ts_interaction_server:rcv({chat,now()}), 27 | Res = receive 28 | Data -> 29 | erlang:display(["received 1",Data]), 30 | ok 31 | after 1000 -> 32 | timeout 33 | end, 34 | ?assertMatch(ok, Res ). 35 | 36 | notify_to_test()-> 37 | myset_env(0), 38 | ts_interaction_server:notify({send,chat2,self()}), 39 | ts_interaction_server:send({chat2,now()}), 40 | Res = receive 41 | Data -> 42 | erlang:display(["received 2",Data]), 43 | ok 44 | after 2000 -> 45 | timeout 46 | end, 47 | ?assertMatch(ok, Res ). 48 | 49 | myset_env()-> 50 | myset_env(0). 51 | myset_env(Val)-> 52 | application:set_env(stdlib,dumpstats_interval,550), 53 | application:set_env(stdlib,mon_file,"test-mon.log"), 54 | application:set_env(stdlib,debug_level,Val). 55 | 56 | -------------------------------------------------------------------------------- /src/test/ts_test_mochi.erl: -------------------------------------------------------------------------------- 1 | -module(ts_test_mochi). 2 | 3 | -compile(export_all). 4 | 5 | -include_lib("eunit/include/eunit.hrl"). 6 | 7 | xpath_parse_test() -> 8 | Data="\r\n\r\n", 9 | XPath = "//a/@href", 10 | Tree = mochiweb_html:parse(list_to_binary(Data)), 11 | ?assertEqual({<<"html">>,[], 12 | [{<<"body">>,[], 13 | [{<<"a">>, 14 | [{<<"href">>, <<"/index.html?name=A&value=B&C">>}], [] 15 | }] 16 | }] 17 | }, 18 | Tree). 19 | -------------------------------------------------------------------------------- /src/test/ts_test_options.erl: -------------------------------------------------------------------------------- 1 | %% ts_test_rate.erl 2 | %% @author Nicolas Niclausse 3 | %% @doc Test for options like rate limiting feature 4 | %% created on 2011-03-14 5 | -module(ts_test_options). 6 | -compile(export_all). 7 | 8 | -include_lib("eunit/include/eunit.hrl"). 9 | 10 | 11 | test() -> 12 | ok. 13 | 14 | rate1_test() -> 15 | R=10000 div 1000, 16 | B=15000, 17 | T0={0,0,0}, 18 | T1={0,10,0}, 19 | P1=14000, 20 | Res = ts_client:token_bucket(R,B,0,T0,P1,T1,false), 21 | ?assertEqual({1000,0},Res). 22 | 23 | rate2_test() -> 24 | R=10000 div 1000, 25 | B=15000, 26 | T0={0,0,0}, 27 | T1={0,10,0}, 28 | T2={0,11,0}, 29 | P1=14000, 30 | P2=14000, 31 | {S2,0} = ts_client:token_bucket(R,B,0,T0,P1,T1,false), 32 | Res = ts_client:token_bucket(R,B,S2,T1,P2,T2,false), 33 | ?assertEqual({0,300},Res). 34 | 35 | -------------------------------------------------------------------------------- /src/test/ts_test_stats.erl: -------------------------------------------------------------------------------- 1 | %%%------------------------------------------------------------------- 2 | %%% File : ts_test_stats.erl 3 | %%% Author : Nicolas Niclausse 4 | %%% Description : 5 | %%% 6 | %%% Created : 12 Jul 2011 by Nicolas Niclausse 7 | %%%------------------------------------------------------------------- 8 | -module(ts_test_stats). 9 | 10 | -compile(export_all). 11 | 12 | -include_lib("eunit/include/eunit.hrl"). 13 | -include_lib("ts_profile.hrl"). 14 | -include_lib("ts_config.hrl"). 15 | 16 | set_dynvar_random_test() -> 17 | Min=1, 18 | Max=10, 19 | R=lists:map(fun(_)->ts_stats:uniform(Min,Max) end, lists:seq(1,1000)), 20 | ?assertEqual(Max,lists:max(R)), 21 | ?assertEqual(Min,lists:min(R)). 22 | -------------------------------------------------------------------------------- /src/tsung-plotter/fs.plots.en.conf: -------------------------------------------------------------------------------- 1 | # tsung plotter configuration 2 | # 3 | # Define in this file the plots you want tsung-plotter to generate 4 | 5 | [DEFAULT] 6 | encoding = latin-1 7 | dpi = 150 8 | tn_dpi = 50 9 | imgtype = png 10 | xlabel = Minutes elapsed 11 | xfactor = 60 12 | yfactor = 1 13 | 14 | [users] 15 | title = Simultaneous Users 16 | ylabel = Users 17 | stats = users.count 18 | legend = Users 19 | 20 | [connected] 21 | title = Connected Users 22 | ylabel = Simultaneous connections 23 | stats = connected.totalcount 24 | legend = Connected users 25 | position = best 26 | 27 | [read_file_count] 28 | title = Reads per second 29 | ylabel = Reads per second 30 | stats = tr_read_file.count 31 | legend = Reads 32 | 33 | [write_file_count] 34 | title = Writes per second 35 | ylabel = Writes per second 36 | stats = tr_write_file.count 37 | legend = Writes 38 | 39 | [read_file_mean] 40 | title = Reads duration 41 | ylabel = Duration in seconds 42 | stats = tr_read_file.mean 43 | legend = Reads 44 | yfactor = 1000 45 | 46 | [write_file_mean] 47 | title = Writes duration 48 | ylabel = Duration in seconds 49 | stats = tr_write_file.mean 50 | legend = Writes 51 | yfactor = 1000 52 | 53 | [read_file_gmean] 54 | title = Reads duration (global mean) 55 | ylabel = Duration in seconds 56 | stats = tr_read_file.gmean 57 | legend = Reads 58 | yfactor = 1000 59 | 60 | [write_file_gmean] 61 | title = Writes duration (global mean) 62 | ylabel = Duration in seconds 63 | stats = tr_write_file.gmean 64 | legend = Writes 65 | yfactor = 1000 66 | 67 | [size_sent] 68 | title = Network Throughput (emit) 69 | ylabel = Mbps 70 | stats = size_sent.count 71 | legend = Sent 72 | yfactor = 1310720 73 | position = 2 74 | 75 | [size_rcv] 76 | title = Network Throughput (received) 77 | ylabel = Mbps 78 | stats = size_rcv.count 79 | legend = Received 80 | yfactor = 1310720 81 | 82 | [finish] 83 | title = Ending users per second 84 | ylabel = Ending users per second 85 | stats = finish_users_count.count 86 | legend = Ending users - 87 | 88 | [request_count] 89 | title = Requests per second 90 | ylabel = number of requests per second 91 | stats = request.count 92 | legend = Requests 93 | 94 | [request_mean] 95 | title = Mean duration of requests 96 | ylabel = Duration in seconds 97 | stats = request.mean 98 | legend = Requests 99 | yfactor = 1000 100 | 101 | [page_count] 102 | title = Page per seconds 103 | ylabel = Page per seconds 104 | stats = page.count 105 | legend = Pages 106 | 107 | [page_mean] 108 | title = Mean duration of pages 109 | ylabel = Duration in seconds 110 | stats = page.mean 111 | legend = Pages 112 | yfactor = 1000 113 | -------------------------------------------------------------------------------- /src/tsung-plotter/http.plots.en.conf: -------------------------------------------------------------------------------- 1 | # tsung plotter configuration 2 | # 3 | # Define in this file the plots you want tsung-plotter to generate 4 | 5 | [DEFAULT] 6 | encoding = latin-1 7 | dpi = 150 8 | tn_dpi = 50 9 | imgtype = png 10 | xlabel = Minutes elapsed 11 | xfactor = 60 12 | yfactor = 1 13 | 14 | [users] 15 | title = Simultaneous Users 16 | ylabel = Users 17 | stats = users.count 18 | legend = Users 19 | 20 | [connected] 21 | title = Connected Users 22 | ylabel = Simultaneous connections 23 | stats = connected.totalcount 24 | legend = Connected users 25 | position = best 26 | 27 | [http] 28 | title = HTTP requests per second 29 | ylabel = HTTP requests per second 30 | stats = 200.count 404.count 31 | styles = b- g+ r- cx 32 | legend = http OK, http 404 33 | yfactor = 10 34 | 35 | [size_sent] 36 | title = Network Throughput (emit) 37 | ylabel = Mbps 38 | stats = size_sent.count 39 | legend = Sent 40 | yfactor = 1310720 41 | position = 2 42 | 43 | [size_rcv] 44 | title = Network Throughput (received) 45 | ylabel = Mbps 46 | stats = size_rcv.count 47 | legend = Received 48 | yfactor = 1310720 49 | 50 | [finish] 51 | title = Ending users per second 52 | ylabel = Ending users per second 53 | stats = finish_users_count.count 54 | legend = Ending users - 55 | 56 | [request_count] 57 | title = Requests per second 58 | ylabel = number of requests per second 59 | stats = request.count 60 | legend = Requests 61 | 62 | [request_mean] 63 | title = Mean duration of requests 64 | ylabel = Duration in seconds 65 | stats = request.mean 66 | legend = Requests 67 | yfactor = 1000 68 | 69 | [page_count] 70 | title = Page per seconds 71 | ylabel = Page per seconds 72 | stats = page.count 73 | legend = Pages 74 | 75 | [page_mean] 76 | title = Mean duration of pages 77 | ylabel = Duration in seconds 78 | stats = page.mean 79 | legend = Pages 80 | yfactor = 1000 81 | -------------------------------------------------------------------------------- /src/tsung-plotter/http.plots.fr.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/src/tsung-plotter/http.plots.fr.conf -------------------------------------------------------------------------------- /src/tsung-plotter/index-http.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | Tsung: comparison charts 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 20 | 21 | 22 | 23 | 26 | 29 | 30 | 31 | 32 | 35 | 38 | 39 | 40 | 41 | 44 | 47 | 48 | 49 | 50 | 53 | 56 | 57 | 58 | 59 | 65 | 66 | 67 |
15 | 16 | 18 | 19 |
24 | 25 | 27 | 28 |
33 | 34 | 36 | 37 |
42 | 43 | 45 | 46 |
51 | 52 | 54 | 55 |
60 |

61 | Graphs generated by tsung-plotter, Tsung 63 |

64 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /src/tsung-plotter/pgsql.plots.en.conf: -------------------------------------------------------------------------------- 1 | # tsung pgsql plotter configuration 2 | # 3 | # Define in this file the plots you want tsung-plotter to generate 4 | 5 | [DEFAULT] 6 | encoding = latin-1 7 | dpi = 150 8 | tn_dpi = 50 9 | imgtype = png 10 | xlabel = Seconds elapsed 11 | xfactor = 1 12 | yfactor = 1 13 | styles = b- r- g- 14 | 15 | [users] 16 | title = Simultaneous Users 17 | ylabel = Simultaneous Users 18 | stats = users.count 19 | legend = Users 20 | yfactor = 0.1 21 | 22 | [finish] 23 | title = Ending users per second 24 | ylabel = Ending users per second 25 | stats = finish_users_count.count 26 | legend = Ending users - 27 | 28 | [request_count] 29 | title = SQL requests per second 30 | ylabel = Number of sql requests per second 31 | stats = request.count 32 | legend = Requests 33 | 34 | [request_mean] 35 | title = Mean duration of SQL requests 36 | ylabel = Duration in seconds 37 | stats = request.mean 38 | legend = Requests 39 | yfactor = 1000 40 | 41 | [connect_count] 42 | title = PostgreSQL connections per second 43 | ylabel = Number of pgsql connections per second 44 | stats = connect.count 45 | legend = Connection 46 | 47 | [connect_mean] 48 | title = Mean duration of connection establishment 49 | ylabel = Duration in seconds 50 | stats = connect.mean 51 | legend = Connections 52 | yfactor = 1000 53 | 54 | [session_count] 55 | title = PostgreSQL sessions per second 56 | ylabel = Number of pgsql sessions per second 57 | stats = connect.count 58 | legend = Sessions 59 | 60 | [session_mean] 61 | title = Mean duration of PostgreSQL sessions 62 | ylabel = Duration in seconds 63 | stats = session.mean 64 | legend = Sessions 65 | yfactor = 1000 66 | 67 | [timeout] 68 | title = Non established connections because of timeout 69 | ylabel = Number of timeouts per second 70 | stats = error_connect_etimedout.count 71 | legend = Timeout 72 | 73 | [trafic] 74 | title = Network Traffic 75 | ylabel = kbits/sec 76 | stats = size_sent.count, size_rcv.count 77 | legend = sent, received 78 | styles = b+ b- r+ r- g+ g- 79 | yfactor = 1310720 80 | 81 | [cpu] 82 | title = Mean CPU load 83 | ylabel = Mean CPU load 84 | stats = {cpu,"os_mon@localhost"}.mean 85 | legend = CPU 86 | 87 | [freemem] 88 | title = Free memory 89 | ylabel = Free memory 90 | stats = {freemem,"os_mon@localhost"}.mean 91 | legend = RAM 92 | -------------------------------------------------------------------------------- /src/tsung-plotter/pgsql.plots.fr.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weibomobile/tsung/6a317093923415c9189b7706ee12aa6491f50ecf/src/tsung-plotter/pgsql.plots.fr.conf -------------------------------------------------------------------------------- /src/tsung-plotter/tsung/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tsung log data parser. 3 | """ 4 | -------------------------------------------------------------------------------- /src/tsung-plotter/tsung/stats.conf: -------------------------------------------------------------------------------- 1 | # tsung plotter configuration 2 | # 3 | # tsung provides three types of statistics: 4 | # 5 | # sample: 'name';'count(during the last 10sec)';mean;stddev;max;min;globalmean;globalcount 6 | # counter: 'name';'count in the last 10sec interval';globalcount(since the beginning) 7 | # gauge: 'name';'current value'; max since the beginning 8 | # 9 | 10 | # matching between internal representation of tsung stats: 11 | # sample: sample, sample_counter 12 | # counter: sum, count 13 | # gauge: only 'users' data (special case) 14 | 15 | # This file associates name stats with their type 16 | 17 | [all] 18 | request = sample 19 | connect = sample 20 | reconnect = sample 21 | page = sample 22 | session = sample 23 | size_rcv = counter 24 | size_sent = counter 25 | connected = counter 26 | users = gauge 27 | users_count = counter 28 | finish_users_count = counter 29 | match = counter 30 | match_(\w+) = counter 31 | nomatch = counter 32 | newphase = counter 33 | 34 | [errors] 35 | error_(\w+) = counter 36 | 37 | [transactions] 38 | tr_(\w+) = sample 39 | 40 | [monitoring] 41 | {freemem(.*) = sample 42 | {cpu(.*) = sample 43 | {load(.*) = sample 44 | {sentpackets(.*) = sample 45 | {recvpackets(.*) = sample 46 | 47 | [http] 48 | ^(\d+)$ = counter 49 | 50 | [jabber] 51 | request_noack = counter 52 | async_unknown_data_rcv = counter 53 | async_data_sent = counter 54 | -------------------------------------------------------------------------------- /src/tsung/gen_ts_transport.erl: -------------------------------------------------------------------------------- 1 | %%% Copyright (C) 2012 Nicolas Niclausse 2 | %%% 3 | %%% This program is free software; you can redistribute it and/or modify 4 | %%% it under the terms of the GNU General Public License as published by 5 | %%% the Free Software Foundation; either version 2 of the License, or 6 | %%% (at your option) any later version. 7 | %%% 8 | %%% This program is distributed in the hope that it will be useful, 9 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | %%% GNU General Public License for more details. 12 | %%% 13 | %%% You should have received a copy of the GNU General Public License 14 | %%% along with this program; if not, write to the Free Software 15 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 16 | %%% 17 | %%% Created : 7 Sep 2012 by Nicolas Niclausse 18 | 19 | %%% In addition, as a special exception, you have the permission to 20 | %%% link the code of this program with any library released under 21 | %%% the EPL license and distribute linked combinations including 22 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23 | %%% Public License) is based on, is included in this exception. 24 | 25 | -module(gen_ts_transport). 26 | 27 | -export([behaviour_info/1]). 28 | 29 | behaviour_info(callbacks) -> 30 | [{connect, 4}, 31 | {send, 3}, 32 | {close, 1}, 33 | {set_opts, 2}, 34 | {protocol_options, 1}, 35 | {normalize_incomming_data, 2}]; 36 | 37 | behaviour_info(_Other) -> 38 | undefined. 39 | -------------------------------------------------------------------------------- /src/tsung/ts_bosh_ssl.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2010 © ProcessOne 3 | %%% 4 | %%% Author : Eric Cestari 5 | %%% 6 | %%% This program is free software; you can redistribute it and/or modify 7 | %%% it under the terms of the GNU General Public License as published by 8 | %%% the Free Software Foundation; either version 2 of the License, or 9 | %%% (at your option) any later version. 10 | %%% 11 | %%% This program is distributed in the hope that it will be useful, 12 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | %%% GNU General Public License for more details. 15 | %%% 16 | %%% You should have received a copy of the GNU General Public License 17 | %%% along with this program; if not, write to the Free Software 18 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | %%% 20 | %%% In addition, as a special exception, you have the permission to 21 | %%% link the code of this program with any library released under 22 | %%% the EPL license and distribute linked combinations including 23 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 24 | %%% Public License) is based on, is included in this exception. 25 | 26 | -module(ts_bosh_ssl). 27 | 28 | -export([ connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]). 29 | 30 | -behaviour(gen_ts_transport). 31 | 32 | %% This is exactly like ts_bosh, but using ssl instead of plain connections. 33 | %% It is easier (fewer tsung modifications required) to have two separate modules, 34 | %% and delegate from here to the original. 35 | connect(Host, Port, Opts, Timeout) -> 36 | ts_bosh:connect(Host, Port, Opts, Timeout, ssl). 37 | 38 | send(Pid, Data, _Opts) -> 39 | ts_bosh:send(Pid, Data, _Opts). 40 | 41 | close(Pid) -> 42 | ts_bosh:close(Pid). 43 | 44 | set_opts(Pid, _Opts) -> 45 | ts_bosh:set_opts(Pid, _Opts). 46 | 47 | protocol_options(_P) -> 48 | ts_bosh:protocol_options(_P). 49 | 50 | normalize_incomming_data(_Socket, X) -> 51 | X. %% nothing to do here, ts_bosh uses a special process to handle http requests, 52 | %% the incoming data is already delivered to ts_client as {gen_ts_transport, ..} instead of gen_tcp | ssl 53 | -------------------------------------------------------------------------------- /src/tsung/ts_client_sup.erl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by IDEALX (http://IDEALX.org/) and 2 | %%% contributors (their names can be found in the CONTRIBUTORS file). 3 | %%% Copyright (C) 2000-2001 IDEALX 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | 20 | %%% In addition, as a special exception, you have the permission to 21 | %%% link the code of this program with any library released under 22 | %%% the EPL license and distribute linked combinations including 23 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 24 | %%% Public License) is based on, is included in this exception. 25 | 26 | -module(ts_client_sup). 27 | -vc('$Id$ '). 28 | -author('nicolas.niclausse@niclux.org'). 29 | 30 | -behaviour(supervisor). 31 | 32 | -include("ts_macros.hrl"). 33 | 34 | %% External exports 35 | -export([start_link/0, start_child/1, active_clients/0]). 36 | 37 | %% supervisor callbacks 38 | -export([init/1]). 39 | 40 | %%%---------------------------------------------------------------------- 41 | %%% API 42 | %%%---------------------------------------------------------------------- 43 | start_link() -> 44 | supervisor:start_link({local, ?MODULE}, ?MODULE, []). 45 | 46 | start_child(Profile) -> 47 | supervisor:start_child(?MODULE,[Profile]). 48 | 49 | %%%---------------------------------------------------------------------- 50 | %%% Callback functions from supervisor 51 | %%%---------------------------------------------------------------------- 52 | 53 | %%-------------------------------------------------------------------- 54 | %% @spec active_clients() -> [tuple()] 55 | %% @doc returns the list of all active children on this beam's 56 | %% client supervisor. @end 57 | %%-------------------------------------------------------------------- 58 | active_clients()-> 59 | length(supervisor:which_children(?MODULE)). 60 | 61 | %%---------------------------------------------------------------------- 62 | %% Func: init/1 63 | %% Returns: {ok, {SupFlags, [ChildSpec]}} | 64 | %% ignore | 65 | %% {error, Reason} 66 | %%---------------------------------------------------------------------- 67 | init([]) -> 68 | ?LOG("Starting ~n", ?INFO), 69 | SupFlags = {simple_one_for_one,1, ?restart_sleep}, 70 | ChildSpec = [ 71 | {ts_client,{ts_client, start, []}, 72 | temporary,2000,worker,[ts_client]} 73 | ], 74 | % fprof:start(), 75 | % Res = fprof:trace(start, "/tmp/tsung.fprof"), 76 | % ?LOGF("starting profiler: ~p~n",[Res], ?WARN), 77 | 78 | {ok, {SupFlags, ChildSpec}}. 79 | 80 | 81 | %%%---------------------------------------------------------------------- 82 | %%% Internal functions 83 | %%%---------------------------------------------------------------------- 84 | 85 | -------------------------------------------------------------------------------- /src/tsung/ts_erlang.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2009 © INRIA 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 20 août 2009 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | -module(ts_erlang). 28 | -vc('$Id: ts_erlang.erl,v 0.0 2009/08/20 16:31:58 nniclaus Exp $ '). 29 | -author('nniclaus@sophia.inria.fr'). 30 | 31 | -behaviour(gen_ts_transport). 32 | 33 | -define(TIMEOUT,36000000). % 1 hour 34 | 35 | -include("ts_profile.hrl"). 36 | 37 | -export([ connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2, 38 | client/4]). 39 | 40 | client(MasterPid,Server,Port,Opts)-> 41 | receive 42 | {Module, Fun, Args, _Size} -> 43 | Res=apply(Module,Fun,Args), 44 | MasterPid ! {erlang,self(),{Module,Fun,Args,Res}}, 45 | client(MasterPid,Server,Port,Opts) 46 | after ?TIMEOUT -> 47 | MasterPid ! timeout 48 | end. 49 | 50 | 51 | protocol_options(_Opts) -> 52 | []. 53 | 54 | %% -> {ok, Socket} 55 | connect(Host, Port, Opts, _Timeout) -> 56 | Pid=spawn_link(ts_erlang,client,[self(),Host,Port,Opts]), 57 | {ok, Pid}. 58 | 59 | %% send/3 -> ok | {error, Reason} 60 | send(Pid, Data, _Opts) -> 61 | Pid ! Data, 62 | ok. 63 | 64 | close(_Socket) -> ok. 65 | 66 | set_opts(Socket, _Opts) -> 67 | Socket. 68 | 69 | 70 | 71 | normalize_incomming_data(_Socket, Data={timeout,_,_}) -> 72 | Data; 73 | normalize_incomming_data(Socket, Data) -> 74 | {gen_ts_transport, Socket, Data}. 75 | -------------------------------------------------------------------------------- /src/tsung/ts_plugin.erl: -------------------------------------------------------------------------------- 1 | %%% Copyright (C) 2011 Nicolas Niclausse 2 | %%% 3 | %%% This program is free software; you can redistribute it and/or modify 4 | %%% it under the terms of the GNU General Public License as published by 5 | %%% the Free Software Foundation; either version 2 of the License, or 6 | %%% (at your option) any later version. 7 | %%% 8 | %%% This program is distributed in the hope that it will be useful, 9 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | %%% GNU General Public License for more details. 12 | %%% 13 | %%% You should have received a copy of the GNU General Public License 14 | %%% along with this program; if not, write to the Free Software 15 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 16 | %%% 17 | %%% Created : 3 Mar 2011 by Nicolas Niclausse 18 | 19 | %%% In addition, as a special exception, you have the permission to 20 | %%% link the code of this program with any library released under 21 | %%% the EPL license and distribute linked combinations including 22 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23 | %%% Public License) is based on, is included in this exception. 24 | 25 | -module(ts_plugin). 26 | 27 | -export([dump/2, parse_bidi/2]). 28 | 29 | -export([behaviour_info/1]). 30 | 31 | behaviour_info(callbacks) -> 32 | [{add_dynparams, 4}, 33 | {get_message, 2}, 34 | {session_defaults, 0}, 35 | {dump, 2}, 36 | {parse, 2}, 37 | {parse_bidi, 2}, 38 | {parse_config, 2}, 39 | {decode_buffer, 2}, 40 | {new_session, 0}]; 41 | behaviour_info(_Other) -> 42 | undefined. 43 | 44 | 45 | %% @spec dump(protocol, {Request::term(),Session::term(), Id::integer(), 46 | %% Host::string(),DataSize::integer()}) -> ok 47 | %% @doc It can be used to send specific data to the current plugin back to ts_mon 48 | %% @end 49 | dump(_Type,_Data) -> 50 | ok. 51 | 52 | %% @spec parse_bidi(Data::binary(),State::record(state_rcv)) -> 53 | %% {NewData::binary()|nodata, NewState::record(state_rcv), think|continue} 54 | %% @doc Parse a block of data from the server. No reply will be sent 55 | %% if the return value is nodata, otherwise the Data binary will be 56 | %% sent back to the server immediately. If the last argument is 57 | %% 'think', it will continue to wait; if it's 'continue', it will 58 | %% handle the next action (request, thinktime, ...) 59 | %% @end 60 | parse_bidi(_Data, State) -> 61 | {nodata, State, think}. 62 | -------------------------------------------------------------------------------- /src/tsung/ts_ssl.erl: -------------------------------------------------------------------------------- 1 | -module(ts_ssl). 2 | 3 | -export([ connect/2, connect/3, connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]). 4 | 5 | -behaviour(gen_ts_transport). 6 | 7 | -include("ts_profile.hrl"). 8 | -include("ts_config.hrl"). 9 | 10 | 11 | protocol_options(#proto_opts{ssl_versions=Versions, ssl_ciphers=Ciphers, certificate = Cert, 12 | is_first_connect = First, reuse_sessions =Reuse}) when First or not Reuse-> 13 | [binary, {active, once}, {reuse_sessions, false} ] ++ Cert ++ set_ciphers(Ciphers) ++ set_versions(Versions); 14 | protocol_options(#proto_opts{ssl_versions=Versions, ssl_ciphers=Ciphers, certificate = Cert}) -> 15 | [binary, {active, once}] ++ Cert ++ set_ciphers(Ciphers) ++ set_versions(Versions). 16 | 17 | set_ciphers(negotiate)-> []; 18 | set_ciphers(Ciphers) -> [{ciphers, Ciphers}]. 19 | 20 | set_versions(negotiate)-> []; 21 | set_versions(Versions) -> [{versions, Versions}]. 22 | 23 | 24 | %% -> {ok, Socket} 25 | connect(Host, Port, Opts) when is_list(Host) -> 26 | connect(Host, Port, opts_to_tcp_opts(Opts), infinity); 27 | 28 | connect(Socket, Opts, ConnectTimeout) -> 29 | ssl:connect(Socket, opts_to_tcp_opts(Opts), ConnectTimeout). 30 | 31 | connect(Host, Port, Opts, ConnectTimeout) -> 32 | ssl:connect(Host, Port, opts_to_tcp_opts(Opts), ConnectTimeout). 33 | 34 | connect(Socket, Opts) -> 35 | connect(Socket, Opts, infinity). 36 | 37 | 38 | opts_to_tcp_opts(Opts) -> Opts. 39 | 40 | %% send/3 -> ok | {error, Reason} 41 | send(Socket, Data, _Opts) -> 42 | ssl:send(Socket, Data). 43 | 44 | close(none) -> ok; 45 | close(Socket) -> 46 | ssl:close(Socket). 47 | 48 | % set_opts/2 -> socket() 49 | set_opts(none, _Opts) -> none; 50 | set_opts(Socket, Opts) -> 51 | ssl:setopts(Socket, Opts), 52 | Socket. 53 | 54 | normalize_incomming_data(Socket, {ssl, Socket, Data}) -> 55 | {gen_ts_transport, Socket, Data}; 56 | normalize_incomming_data(Socket, {ssl_closed, Socket}) -> 57 | {gen_ts_transport, Socket, closed}; 58 | normalize_incomming_data(Socket, {ssl_error, Socket, Error}) -> 59 | {gen_ts_transport, Socket, error, Error}; 60 | normalize_incomming_data(_Socket, X) -> 61 | X. %%Other, non gen_tcp packet. 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/tsung/ts_ssl6.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2012 © Nicolas Niclausse 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 7 sep 2012 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | -module(ts_ssl6). 28 | 29 | -export([ connect/2, connect/3, connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]). 30 | 31 | -behaviour(gen_ts_transport). 32 | 33 | -include("ts_profile.hrl"). 34 | -include("ts_config.hrl"). 35 | 36 | 37 | protocol_options(Opts) -> 38 | [inet6]++ts_ssl:protocol_options(Opts). 39 | 40 | %% -> {ok, Socket} 41 | connect(Host, Port, Opts) when is_list(Host) -> 42 | connect(Host, Port, Opts, infinity); 43 | 44 | connect(Socket, Opts, ConnectTimeout) -> 45 | ssl:connect(Socket, Opts, ConnectTimeout). 46 | 47 | connect(Host, Port, Opts, ConnectTimeout) -> 48 | ssl:connect(Host, Port, Opts, ConnectTimeout). 49 | 50 | connect(Socket, Opts) -> 51 | connect(Socket, Opts, infinity). 52 | 53 | %% send/3 -> ok | {error, Reason} 54 | send(Socket, Data, _Opts) -> 55 | ssl:send(Socket, Data). 56 | 57 | close(none) -> ok; 58 | close(Socket) -> 59 | ssl:close(Socket). 60 | 61 | % set_opts/2 -> socket() 62 | set_opts(none, _Opts) -> none; 63 | set_opts(Socket, Opts) -> 64 | ssl:setopts(Socket, Opts), 65 | Socket. 66 | 67 | normalize_incomming_data(Socket, Data) -> 68 | ts_ssl:normalize_incomming_data(Socket,Data). 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/tsung/ts_ssl_session_cache.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2014 (c) Nicolas Niclausse 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 15 avril 2014 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | 22 | -module(ts_ssl_session_cache). 23 | -vc('$Id: ts_ssl_session_cache.erl,v 0.0 2014/04/15 07:28:58 nniclaus Exp $ '). 24 | -author('nicolas@niclux.org'). 25 | 26 | -behaviour(ssl_session_cache_api). 27 | 28 | -include("ts_macros.hrl"). 29 | 30 | -export([init/1, terminate/1, lookup/2, update/3, delete/2, foldl/3, 31 | select_session/2, size/1]). 32 | 33 | -ifndef(new_time_api). % otp < R18 34 | -define(SELECT(Cache,PartialKey), 35 | ets:select(Cache, [{{{PartialKey,'$1'}, '$2'},[],['$$']}])). 36 | -else. 37 | -define(SELECT(Cache,PartialKey), 38 | ets:select(Cache, [{{{PartialKey,'_'}, '$1'},[],['$1']}])). 39 | -endif. 40 | 41 | %%-------------------------------------------------------------------- 42 | %% Description: Return table reference. Called by ssl_manager process. 43 | %%-------------------------------------------------------------------- 44 | init(_) -> 45 | ets:new(cache_name(), [protected]). 46 | 47 | terminate(Cache) -> 48 | ets:delete(Cache). 49 | 50 | lookup(Cache, Key) -> 51 | ?DebugF("Lookup key ~p from session cache",[Key]), 52 | case ets:lookup(Cache, Key) of 53 | [{Key, Session}] -> 54 | Session; 55 | [] -> 56 | undefined 57 | end. 58 | 59 | update(Cache, Key, Session) -> 60 | case application:get_env(tsung,ssl_session_cache) of 61 | {ok, 0} -> 62 | ?Debug("SSL session cache is disabled, skip"); 63 | _ -> 64 | ?DebugF("SSL update entry ~p ~p",[Key,Session]), 65 | ets:insert(Cache, {Key, Session}) 66 | end. 67 | delete(Cache, Key) -> 68 | ?DebugF("Delete key from session cache ~p",[Key]), 69 | ets:delete(Cache, Key). 70 | 71 | foldl(Fun, Acc0, Cache) -> 72 | ets:foldl(Fun, Acc0, Cache). 73 | 74 | select_session(Cache, PartialKey) -> 75 | ?DebugF("SSL cache select ~p",[PartialKey]), 76 | ?SELECT(Cache,PartialKey). 77 | 78 | size(Cache) -> 79 | ets:info(Cache, size). 80 | 81 | %%-------------------------------------------------------------------- 82 | %%% Internal functions 83 | %%-------------------------------------------------------------------- 84 | cache_name() -> 85 | ts_ssl_session_cache. 86 | -------------------------------------------------------------------------------- /src/tsung/ts_tcp.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2010 © ProcessOne 3 | %%% 4 | %%% Author : Eric Cestari 5 | %%% 6 | %%% This program is free software; you can redistribute it and/or modify 7 | %%% it under the terms of the GNU General Public License as published by 8 | %%% the Free Software Foundation; either version 2 of the License, or 9 | %%% (at your option) any later version. 10 | %%% 11 | %%% This program is distributed in the hope that it will be useful, 12 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | %%% GNU General Public License for more details. 15 | %%% 16 | %%% You should have received a copy of the GNU General Public License 17 | %%% along with this program; if not, write to the Free Software 18 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | %%% 20 | %%% In addition, as a special exception, you have the permission to 21 | %%% link the code of this program with any library released under 22 | %%% the EPL license and distribute linked combinations including 23 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 24 | %%% Public License) is based on, is included in this exception. 25 | 26 | -module(ts_tcp). 27 | 28 | -export([ connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]). 29 | 30 | -behaviour(gen_ts_transport). 31 | 32 | -include("ts_profile.hrl"). 33 | -include("ts_config.hrl"). 34 | 35 | protocol_options(Proto=#proto_opts{tcp_reuseport = true}) -> 36 | Opts= [{raw, 1, 15, <<1:32/native>>}] ++ protocol_options(Proto#proto_opts{tcp_reuseport = false}), 37 | ?DebugF("TCP Real opts: ~p ~n", [Opts]), 38 | Opts; 39 | protocol_options(Proto=#proto_opts{ip_transparent = true}) -> 40 | Opts= [{raw, 0, 19, <<1:32/native>>} ] ++ protocol_options(Proto#proto_opts{ip_transparent = false}), 41 | ?DebugF("TCP Real opts: ~p ~n", [Opts]), 42 | Opts; 43 | protocol_options(#proto_opts{tcp_rcv_size = Rcv, tcp_snd_size = Snd, 44 | tcp_reuseaddr = Reuseaddr}) -> 45 | [binary, 46 | {active, once}, 47 | {reuseaddr, Reuseaddr}, 48 | {recbuf, Rcv}, 49 | {sndbuf, Snd}, 50 | {keepalive, true} %% FIXME: should be an option 51 | ]. 52 | %% -> {ok, Socket} 53 | 54 | connect(Host, Port, Opts, ConnectTimeout) -> 55 | gen_tcp:connect(Host, Port, opts_to_tcp_opts(Opts), ConnectTimeout). 56 | 57 | opts_to_tcp_opts(Opts) -> Opts. 58 | 59 | %% send/3 -> ok | {error, Reason} 60 | send(Socket, Data, _Opts) -> 61 | gen_tcp:send(Socket, Data). 62 | 63 | close(none) -> ok; 64 | close(Socket) -> 65 | gen_tcp:close(Socket). 66 | 67 | % set_opts/2 -> socket() 68 | set_opts(none, _Opts) -> none; 69 | set_opts(Socket, Opts) -> 70 | inet:setopts(Socket, Opts), 71 | Socket. 72 | 73 | 74 | normalize_incomming_data(Socket, {tcp, Socket, Data}) -> 75 | {gen_ts_transport, Socket, Data}; 76 | normalize_incomming_data(Socket, {tcp_closed, Socket}) -> 77 | {gen_ts_transport, Socket, closed}; 78 | normalize_incomming_data(Socket, {tcp_error, Socket, Error}) -> 79 | {gen_ts_transport, Socket, error, Error}; 80 | normalize_incomming_data(_Socket, X) -> 81 | X. %%Other, non gen_tcp packet. 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/tsung/ts_tcp6.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2012 © Nicolas Niclausse 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 7 sep 2012 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | -module(ts_tcp6). 28 | 29 | -export([ connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]). 30 | 31 | -behaviour(gen_ts_transport). 32 | 33 | -include("ts_profile.hrl"). 34 | -include("ts_config.hrl"). 35 | 36 | protocol_options(Opts) -> 37 | [inet6]++ts_tcp:protocol_options(Opts). 38 | 39 | connect(Host, Port, Opts, ConnectTimeout) -> 40 | gen_tcp:connect(Host, Port, Opts, ConnectTimeout). 41 | 42 | %% send/3 -> ok | {error, Reason} 43 | send(Socket, Data, _Opts) -> 44 | gen_tcp:send(Socket, Data). 45 | 46 | close(Socket) -> 47 | ts_tcp:close(Socket). 48 | 49 | % set_opts/2 -> socket() 50 | set_opts(none, _Opts) -> none; 51 | set_opts(Socket, Opts) -> 52 | inet:setopts(Socket, Opts), 53 | Socket. 54 | 55 | normalize_incomming_data(Socket,Data) -> 56 | ts_tcp:normalize_incomming_data(Socket,Data). 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/tsung/ts_udp.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2012 © Nicolas Niclausse 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 7 sep 2012 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | -module(ts_udp). 28 | 29 | -export([ connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]). 30 | 31 | -behaviour(gen_ts_transport). 32 | 33 | -include("ts_profile.hrl"). 34 | -include("ts_config.hrl"). 35 | 36 | protocol_options(#proto_opts{udp_rcv_size=Rcv, udp_snd_size=Snd}) -> 37 | [binary, 38 | {active, once}, 39 | {recbuf, Rcv}, 40 | {sndbuf, Snd} 41 | ]. 42 | 43 | %% -> {ok, Socket} 44 | connect(_Host, _Port, Opts, _Timeout) -> 45 | gen_udp:open(0, Opts). 46 | 47 | %% send/3 -> ok | {error, Reason} 48 | send(Socket, Data, [{host, Host}, {port, Port}]) -> 49 | gen_udp:send(Socket, Host,Port, Data). 50 | 51 | close(none) -> ok; 52 | close(Socket) -> 53 | gen_udp:close(Socket). 54 | 55 | % set_opts/2 -> socket() 56 | set_opts(none, _Opts) -> none; 57 | set_opts(Socket, Opts) -> 58 | inet:setopts(Socket, Opts), 59 | Socket. 60 | 61 | 62 | normalize_incomming_data(Socket, {udp, Socket,_IP,_InPortNo, Data}) -> 63 | ?DebugF("UDP packet received: size=~p ~n",[size(Data)]), 64 | {gen_ts_transport, Socket, Data}; 65 | normalize_incomming_data(_Socket, X) -> 66 | X. %%Other, non gen_udp packet. 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/tsung/ts_udp6.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2012 © Nicolas Niclausse 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 7 sep 2012 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | -module(ts_udp6). 28 | 29 | -export([ connect/4, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]). 30 | 31 | -behaviour(gen_ts_transport). 32 | 33 | -include("ts_profile.hrl"). 34 | -include("ts_config.hrl"). 35 | 36 | protocol_options(Opts) -> 37 | [inet6] ++ ts_udp:protocol_options(Opts). 38 | 39 | %% -> {ok, Socket} 40 | connect(_Host, _Port, Opts, _Timeout) -> 41 | gen_udp:open(0, Opts). 42 | 43 | %% send/3 -> ok | {error, Reason} 44 | send(Socket, Data, Opts) -> 45 | ts_udp:send(Socket, Data, Opts). 46 | 47 | close(Socket) -> 48 | ts_udp:close(Socket). 49 | 50 | % set_opts/2 -> socket() 51 | set_opts(none, _Opts) -> none; 52 | set_opts(Socket, Opts) -> 53 | inet:setopts(Socket, Opts), 54 | Socket. 55 | 56 | normalize_incomming_data(Socket, Data) -> 57 | ts_udp:normalize_incomming_data(Socket,Data). 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/tsung/tsung.erl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by IDEALX (http://IDEALX.org/) and 2 | %%% contributors (their names can be found in the CONTRIBUTORS file). 3 | %%% Copyright (C) 2000-2001 IDEALX 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | 20 | %%% In addition, as a special exception, you have the permission to 21 | %%% link the code of this program with any library released under 22 | %%% the EPL license and distribute linked combinations including 23 | %%% the two. 24 | 25 | -module(tsung). 26 | -vc('$Id$ '). 27 | -author('nicolas.niclausse@niclux.org'). 28 | 29 | -export([start/0, start/2, stop/1]). 30 | -behaviour(application). 31 | 32 | -include("ts_macros.hrl"). 33 | 34 | %% start the application with it's dependencies 35 | start() -> 36 | ts_utils:ensure_all_started(tsung, permanent). 37 | 38 | %%---------------------------------------------------------------------- 39 | %% Func: start/2 40 | %% Returns: {ok, Pid} | 41 | %% {ok, Pid, State} | 42 | %% {error, Reason} 43 | %%---------------------------------------------------------------------- 44 | start(_Type, _StartArgs) -> 45 | % error_logger:tty(false), 46 | ?LOG("open logfile ~n",?DEB), 47 | LogFileEnc = ts_config_server:decode_filename(?config(log_file)), 48 | LogFile = filename:join(LogFileEnc, atom_to_list(node()) ++ ".log"), 49 | LogDir = filename:dirname(LogFile), 50 | ok = ts_utils:make_dir(LogDir), 51 | error_logger:logfile({open, LogFile}), 52 | ?LOG("ok~n",?DEB), 53 | case ts_sup:start_link() of 54 | {ok, Pid} -> 55 | {ok, Pid}; 56 | Error -> 57 | ?LOGF("Can't start supervisor ! ~p ~n",[Error],?ERR), 58 | Error 59 | end. 60 | 61 | 62 | %%---------------------------------------------------------------------- 63 | %% Func: stop/1 64 | %% Returns: any 65 | %%---------------------------------------------------------------------- 66 | stop(_State) -> 67 | stop. 68 | -------------------------------------------------------------------------------- /src/tsung/tsung.rel.src: -------------------------------------------------------------------------------- 1 | {release, {"tsung", "&tsung_vsn&"}, {erts, "&erts_vsn&"}, 2 | [ 3 | {kernel,"&kernel_vsn&"}, 4 | {ssl,"&ssl_vsn&"}, 5 | {stdlib,"&stdlib_vsn&"}]}. 6 | -------------------------------------------------------------------------------- /src/tsung_controller/ts_api.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2014 Nicolas Niclausse 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 23 avril 2014 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | 22 | -module(ts_api). 23 | -vc('$Id: ts_web.erl,v 0.0 2014/04/23 12:12:17 nniclaus Exp $ '). 24 | -author('nicolas@niclux.org'). 25 | 26 | -include("ts_macros.hrl"). 27 | -include_lib("kernel/include/file.hrl"). 28 | 29 | -export([status/3]). 30 | 31 | status(SessionID, _Env, _Input) -> 32 | {ok, Nodes, Ended_Beams, MaxPhases} = ts_config_server:status(), 33 | Active = Nodes - Ended_Beams, 34 | {Clients, ReqRate, Connected, Interval, Phase, Cpu} = ts_mon:status(), 35 | NPhase = case Phase of 36 | error -> 1; 37 | {ok,N} -> (N div Nodes) + 1 38 | end, 39 | JSON = "{\"phase\": "++ integer_to_list(NPhase) ++ "," 40 | ++ "\"phase_total\": "++ integer_to_list(MaxPhases) ++ "," 41 | ++ "\"users\": "++ integer_to_list(Clients) ++ "," 42 | ++ "\"connected_users\": "++ integer_to_list(Connected) ++ "," 43 | ++ "\"request_rate\": "++ ts_web:number_to_list(ReqRate/Interval) ++ "," 44 | ++ "\"active_beams\": "++ integer_to_list(Active) ++ "," 45 | ++ "\"cpu_controller\": "++ ts_web:number_to_list(Cpu) 46 | ++ "}", 47 | mod_esi:deliver(SessionID, [ 48 | "Content-Type: application/json\r\n\r\n", 49 | JSON 50 | ]). 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/tsung_controller/ts_config_shell.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright 2010 © INRIA 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 18 août 2010 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | 28 | -module(ts_config_shell). 29 | -vc('$Id$ '). 30 | -author('nicolas.niclausse@sophia.inria.fr'). 31 | 32 | -export([parse_config/2]). 33 | 34 | -include("ts_profile.hrl"). 35 | -include("ts_http.hrl"). 36 | -include("ts_config.hrl"). 37 | 38 | -include("xmerl.hrl"). 39 | 40 | -include("ts_shell.hrl"). 41 | 42 | %% @spec parse_config(#xmlElement{}, Config::term()) -> NewConfig::term() 43 | %% @doc Parses a tsung.xml configuration file xml element for this 44 | %% protocol and updates the Config term. 45 | %% @end 46 | parse_config(Element = #xmlElement{name=dyn_variable}, Conf = #config{}) -> 47 | ts_config:parse(Element,Conf); 48 | parse_config(Element = #xmlElement{name=shell}, 49 | Config=#config{curid = Id, session_tab = Tab, 50 | sessions = [CurS | _], dynvar=DynVar, 51 | subst = SubstFlag, match=MatchRegExp}) -> 52 | 53 | Cmd = ts_config:getAttr(string,Element#xmlElement.attributes, cmd), 54 | Args = ts_config:getAttr(string,Element#xmlElement.attributes, args, ""), 55 | 56 | Request = #shell{command=Cmd,args=Args}, 57 | Msg= #ts_request{ack = parse, 58 | endpage = true, 59 | dynvar_specs = DynVar, 60 | subst = SubstFlag, 61 | match = MatchRegExp, 62 | param = Request}, 63 | 64 | ts_config:mark_prev_req(Id-1, Tab, CurS), 65 | ets:insert(Tab,{{CurS#session.id, Id},Msg}), 66 | lists:foldl( fun(A,B)->ts_config:parse(A,B) end, Config#config{dynvar=[]}, 67 | Element#xmlElement.content); 68 | %% Parsing other elements 69 | parse_config(Element = #xmlElement{}, Conf = #config{}) -> 70 | ts_config:parse(Element,Conf); 71 | %% Parsing non #xmlElement elements 72 | parse_config(_, Conf = #config{}) -> 73 | Conf. 74 | -------------------------------------------------------------------------------- /src/tsung_controller/ts_os_mon.erl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by Mickael Remond 2 | %%% and contributors (their names can 3 | %%% be found in the CONTRIBUTORS file). Copyright (C) 2003 Mickael 4 | %%% Remond 5 | %%% 6 | %%% This program is free software; you can redistribute it and/or modify 7 | %%% it under the terms of the GNU General Public License as published by 8 | %%% the Free Software Foundation; either version 2 of the License, or 9 | %%% (at your option) any later version. 10 | %%% 11 | %%% This program is distributed in the hope that it will be useful, 12 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | %%% GNU General Public License for more details. 15 | %%% 16 | %%% You should have received a copy of the GNU General Public License 17 | %%% along with this program; if not, write to the Free Software 18 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | %%% 20 | %%% In addition, as a special exception, you have the permission to 21 | %%% link the code of this program with any library released under 22 | %%% the EPL license and distribute linked combinations including 23 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 24 | %%% Public License) is based on, is included in this exception. 25 | 26 | %%% Created : 23 Dec 2003 by Mickael Remond 27 | 28 | -module(ts_os_mon). 29 | -author('mickael.remond@erlang-fr.org'). 30 | -modifiedby('nicolas@niclux.org'). 31 | -vc('$Id$ '). 32 | 33 | 34 | %%-------------------------------------------------------------------- 35 | %% Include files 36 | %%-------------------------------------------------------------------- 37 | -include("ts_macros.hrl"). 38 | -include("ts_os_mon.hrl"). 39 | 40 | %%-------------------------------------------------------------------- 41 | %% External exports 42 | -export([activate/0, send/2]). 43 | 44 | %%% send data back to the controlling node 45 | send(Mon_Server, Data) when is_pid(Mon_Server) -> 46 | Mon_Server ! {add, Data}; 47 | send(Mon_Server, Data) -> 48 | gen_server:cast(Mon_Server, {add, Data}). 49 | 50 | %%-------------------------------------------------------------------- 51 | %% Function: activate/0 52 | %% Purpose: This is used by tsung to start the cluster monitor service 53 | %% It will only be started if there are cluster/monitor@host element 54 | %% in the config file. 55 | %%-------------------------------------------------------------------- 56 | activate() -> 57 | {ok, Controller} = ts_utils:node_to_hostname(node()), 58 | case ts_config_server:get_monitor_hosts() of 59 | [] -> 60 | ?LOG("Add monitoring of controller node",?DEB), 61 | ts_os_mon_sup:start_child(erlang, {Controller,[],?INTERVAL, {global,ts_mon}}), 62 | ok; 63 | Hosts -> 64 | NewHosts = case lists:keyfind(Controller, 1, Hosts) of 65 | false -> 66 | ?LOG("Force monitoring of controller node",?DEB), 67 | Hosts++[{Controller, {erlang,[]}}]; 68 | _ -> 69 | Hosts 70 | end, 71 | Fun = fun({HostStr,{Type,Options}}) -> 72 | Args= {HostStr, Options, ?INTERVAL,{global, ts_mon}}, 73 | ts_os_mon_sup:start_child(Type, Args) 74 | end, 75 | lists:foreach(Fun,NewHosts) 76 | end. 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/tsung_controller/ts_os_mon_sup.erl: -------------------------------------------------------------------------------- 1 | %%% Copyright (C) 2009 Nicolas Niclausse 2 | %%% 3 | %%% This program is free software; you can redistribute it and/or modify 4 | %%% it under the terms of the GNU General Public License as published by 5 | %%% the Free Software Foundation; either version 2 of the License, or 6 | %%% (at your option) any later version. 7 | %%% 8 | %%% This program is distributed in the hope that it will be useful, 9 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | %%% GNU General Public License for more details. 12 | %%% 13 | %%% You should have received a copy of the GNU General Public License 14 | %%% along with this program; if not, write to the Free Software 15 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 16 | %%% 17 | %%% In addition, as a special exception, you have the permission to 18 | %%% link the code of this program with any library released under 19 | %%% the EPL license and distribute linked combinations including 20 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 21 | %%% Public License) is based on, is included in this exception. 22 | 23 | -module(ts_os_mon_sup). 24 | -vc('$Id: ts_client_sup.erl 953 2008-11-23 16:57:05Z nniclausse $ '). 25 | -author('nicolas.niclausse@niclux.org'). 26 | 27 | -behaviour(supervisor). 28 | 29 | -include("ts_macros.hrl"). 30 | 31 | %% External exports 32 | -export([start_link/1, start_child/2]). 33 | 34 | %% supervisor callbacks 35 | -export([init/1]). 36 | 37 | %%%---------------------------------------------------------------------- 38 | %%% API 39 | %%%---------------------------------------------------------------------- 40 | start_link(Plugin) -> 41 | Module=get_module(Plugin), 42 | supervisor:start_link({local,Module}, ?MODULE, [Plugin]). 43 | 44 | start_child(Plugin, Args) -> 45 | ?LOGF("Starting child for plugin ~p with args ~p~n",[Plugin,Args], ?DEB), 46 | Module=get_module(Plugin), 47 | supervisor:start_child(Module,[Args]). 48 | 49 | %%%---------------------------------------------------------------------- 50 | %%% Callback functions from supervisor 51 | %%%---------------------------------------------------------------------- 52 | 53 | %%---------------------------------------------------------------------- 54 | %% Func: init/1 55 | %% Returns: {ok, {SupFlags, [ChildSpec]}} | 56 | %% ignore | 57 | %% {error, Reason} 58 | %%---------------------------------------------------------------------- 59 | init([Plugin]) -> 60 | ?LOGF("Starting with args ~p~n",[Plugin], ?INFO), 61 | SupFlags = {simple_one_for_one, 20, 20}, 62 | {ok, {SupFlags, get_spec(Plugin)}}. 63 | 64 | %% internal funs 65 | 66 | get_spec(Plugin) -> 67 | Module=get_module(Plugin), 68 | [{Module,{Module, start, []}, permanent, 2000, worker,[Module]}]. 69 | 70 | get_module(Plugin) when is_atom(Plugin)-> 71 | ModuleStr="ts_os_mon_" ++ atom_to_list(Plugin), 72 | list_to_atom(ModuleStr). 73 | -------------------------------------------------------------------------------- /src/tsung_controller/ts_user_server_sup.erl: -------------------------------------------------------------------------------- 1 | %%% This program is free software; you can redistribute it and/or modify 2 | %%% it under the terms of the GNU General Public License as published by 3 | %%% the Free Software Foundation; either version 2 of the License, or 4 | %%% (at your option) any later version. 5 | %%% 6 | %%% This program is distributed in the hope that it will be useful, 7 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | %%% GNU General Public License for more details. 10 | %%% 11 | %%% You should have received a copy of the GNU General Public License 12 | %%% along with this program; if not, write to the Free Software 13 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 14 | %%% 15 | %%% In addition, as a special exception, you have the permission to 16 | %%% link the code of this program with any library released under 17 | %%% the EPL license and distribute linked combinations including 18 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 19 | %%% Public License) is based on, is included in this exception. 20 | %%% 21 | %%% ts_user_server_sup.erl 22 | %%% @author Pablo Polvorin 23 | %%% @doc 24 | %%% created on 2008-09-09 25 | 26 | -module(ts_user_server_sup). 27 | 28 | -export([start_link/0,init/1,start_user_server/1,all_children/0]). 29 | 30 | -behaviour(supervisor). 31 | 32 | start_link() -> 33 | {ok,Pid} = supervisor:start_link({global,?MODULE},?MODULE,[]), 34 | start_default_user_server(), 35 | %default user_server is always started 36 | {ok,Pid}. 37 | 38 | init([]) -> 39 | SupFlags = {simple_one_for_one,1,1 }, 40 | ChildSpec = [ 41 | {ts_user_server,{ts_user_server, start, []}, 42 | temporary,2000,worker,[ts_user_server]} 43 | ], 44 | {ok, {SupFlags, ChildSpec}}. 45 | 46 | start_user_server(Name) -> 47 | supervisor:start_child({global,?MODULE},[Name]). 48 | 49 | start_default_user_server() -> 50 | supervisor:start_child({global,?MODULE},[]). 51 | 52 | 53 | all_children() -> 54 | [ Pid ||{_,Pid,_,_} <- supervisor:which_children({global,?MODULE})]. 55 | -------------------------------------------------------------------------------- /src/tsung_controller/tsung_controller.rel.src: -------------------------------------------------------------------------------- 1 | {release, {"tsung_controller", "&tsung_controller_vsn&"}, {erts, "&erts_vsn&"}, 2 | [ 3 | {kernel,"&kernel_vsn&"}, 4 | {ssl,"&ssl_vsn&"}, 5 | {stdlib,"&stdlib_vsn&"}]}. 6 | -------------------------------------------------------------------------------- /src/tsung_recorder/ts_client_proxy_sup.erl: -------------------------------------------------------------------------------- 1 | %%% This code was developped by IDEALX (http://IDEALX.org/) and 2 | %%% contributors (their names can be found in the CONTRIBUTORS file). 3 | %%% Copyright (C) 2000-2001 IDEALX 4 | %%% 5 | %%% This program is free software; you can redistribute it and/or modify 6 | %%% it under the terms of the GNU General Public License as published by 7 | %%% the Free Software Foundation; either version 2 of the License, or 8 | %%% (at your option) any later version. 9 | %%% 10 | %%% This program is distributed in the hope that it will be useful, 11 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | %%% GNU General Public License for more details. 14 | %%% 15 | %%% You should have received a copy of the GNU General Public License 16 | %%% along with this program; if not, write to the Free Software 17 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 | %%% 19 | %%% In addition, as a special exception, you have the permission to 20 | %%% link the code of this program with any library released under 21 | %%% the EPL license and distribute linked combinations including 22 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 23 | %%% Public License) is based on, is included in this exception. 24 | 25 | -module(ts_client_proxy_sup). 26 | -vc('$Id$ '). 27 | -author('nicolas.niclausse@niclux.org'). 28 | 29 | -behaviour(supervisor). 30 | 31 | -include("ts_macros.hrl"). 32 | 33 | %% External exports 34 | -export([start_link/0, start_child/1, active_clients/0]). 35 | 36 | %% supervisor callbacks 37 | -export([init/1]). 38 | 39 | %%%---------------------------------------------------------------------- 40 | %%% API 41 | %%%---------------------------------------------------------------------- 42 | start_link() -> 43 | supervisor:start_link({local, ?MODULE}, ?MODULE, []). 44 | 45 | start_child(Profile) -> 46 | supervisor:start_child(?MODULE,[Profile]). 47 | 48 | %%%---------------------------------------------------------------------- 49 | %%% Callback functions from supervisor 50 | %%%---------------------------------------------------------------------- 51 | 52 | %%-------------------------------------------------------------------- 53 | %% Func: active_clients/0 54 | %% Returns: [ Client ] 55 | %% Description: returns the list of all active children on this beam's 56 | %% client supervisor. 57 | %%-------------------------------------------------------------------- 58 | active_clients()-> 59 | length(supervisor:which_children(?MODULE)). 60 | 61 | %%---------------------------------------------------------------------- 62 | %% Func: init/1 63 | %% Returns: {ok, {SupFlags, [ChildSpec]}} | 64 | %% ignore | 65 | %% {error, Reason} 66 | %%---------------------------------------------------------------------- 67 | init([]) -> 68 | ?LOG("Starting ~n", ?INFO), 69 | SupFlags = {simple_one_for_one,1, ?restart_sleep}, 70 | ChildSpec = [ 71 | {ts_client_proxy,{ts_client_proxy, start, []}, 72 | temporary,2000,worker,[ts_client_proxy]} 73 | ], 74 | {ok, {SupFlags, ChildSpec}}. 75 | 76 | 77 | %%%---------------------------------------------------------------------- 78 | %%% Internal functions 79 | %%%---------------------------------------------------------------------- 80 | 81 | -------------------------------------------------------------------------------- /src/tsung_recorder/tsung_recorder.app.in: -------------------------------------------------------------------------------- 1 | {application, tsung_recorder, 2 | [{description, "tsung recorder"}, 3 | {vsn, "@PACKAGE_VERSION@"}, 4 | {modules, [ 5 | tsung_recorder, 6 | ts_recorder_sup, 7 | ts_client_proxy_sup, 8 | ts_proxy_recorder, 9 | ts_proxy_listener 10 | ]}, 11 | {registered, [ 12 | ts_proxy_recorder, 13 | ts_proxy_listener 14 | ]}, 15 | {env, [ 16 | {debug_level, 6}, 17 | {ts_cookie, "humhum"}, 18 | {log_file, "./tsung.log"}, 19 | {plugin, ts_proxy_http}, 20 | {parent_proxy, false}, 21 | {pgsql_server, "127.0.0.1"}, 22 | {pgsql_port, 5432}, 23 | {proxy_log_file, "./tsung_recorder"}, 24 | {proxy_listen_port, 8090} 25 | ]}, 26 | {applications, [@ERLANG_APPLICATIONS@]}, 27 | {mod, {tsung_recorder, []}} 28 | ]}. 29 | -------------------------------------------------------------------------------- /src/tsung_recorder/tsung_recorder.erl: -------------------------------------------------------------------------------- 1 | %%% 2 | %%% Copyright © IDEALX S.A.S. 2003 3 | %%% 4 | %%% Author : Nicolas Niclausse 5 | %%% Created: 22 Dec 2003 by Nicolas Niclausse 6 | %%% 7 | %%% This program is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This program is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% You should have received a copy of the GNU General Public License 18 | %%% along with this program; if not, write to the Free Software 19 | %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | %%% 21 | %%% In addition, as a special exception, you have the permission to 22 | %%% link the code of this program with any library released under 23 | %%% the EPL license and distribute linked combinations including 24 | %%% the two; the MPL (Mozilla Public License), which EPL (Erlang 25 | %%% Public License) is based on, is included in this exception. 26 | 27 | %%%------------------------------------------------------------------- 28 | %%% File : tsung_recorder.erl 29 | %%% Author : 30 | %%% Description : tsung_recorder application 31 | %%% Created : 22 Dec 2003 by Nicolas Niclausse 32 | %%%------------------------------------------------------------------- 33 | 34 | -module(tsung_recorder). 35 | -vc('$Id$ '). 36 | -author('nicolas.niclausse@niclux.org'). 37 | 38 | -export([start/0, start/2, stop/1, stop_all/1]). 39 | -behaviour(application). 40 | 41 | -include("ts_macros.hrl"). 42 | 43 | 44 | %% start the application with it's dependencies 45 | start() -> 46 | ts_utils:ensure_all_started(tsung_recorder, permanent). 47 | 48 | %%---------------------------------------------------------------------- 49 | %% Func: start/2 50 | %% Returns: {ok, Pid} | 51 | %% {ok, Pid, State} | 52 | %% {error, Reason} 53 | %%---------------------------------------------------------------------- 54 | start(_Type, _StartArgs) -> 55 | error_logger:tty(false), 56 | error_logger:logfile({open, ?config(log_file) ++ "-" ++ atom_to_list(node())}), 57 | case ts_recorder_sup:start_link() of 58 | {ok, Pid} -> 59 | {ok, Pid}; 60 | Error -> 61 | ?LOGF("Can't start ! ~p ~n",[Error], ?ERR), 62 | Error 63 | end. 64 | 65 | %%---------------------------------------------------------------------- 66 | %% Func: stop/1 67 | %% Returns: any 68 | %%---------------------------------------------------------------------- 69 | stop(_State) -> 70 | stop. 71 | 72 | %%---------------------------------------------------------------------- 73 | %% Func: stop_all/1 74 | %% Returns: any 75 | %%---------------------------------------------------------------------- 76 | stop_all(Arg) -> 77 | ts_utils:stop_all(Arg,'ts_proxy_listener', "tsung recorder", 78 | fun ts_proxy_recorder:stop/1). 79 | -------------------------------------------------------------------------------- /src/tsung_recorder/tsung_recorder.rel.src: -------------------------------------------------------------------------------- 1 | {release, {"tsung_recorder", "&tsung_recorder_vsn&"}, {erts, "&erts_vsn&"}, 2 | [ 3 | {kernel,"&kernel_vsn&"}, 4 | {stdlib,"&stdlib_vsn&"}]}. 5 | -------------------------------------------------------------------------------- /tsung.spec.in: -------------------------------------------------------------------------------- 1 | %define name tsung 2 | %define version @PACKAGE_VERSION@ 3 | %define release 1 4 | 5 | Name: %{name} 6 | Version: %{version} 7 | Release: %{release}%{?dist} 8 | Summary: A distributed multi-protocol load testing tool 9 | 10 | Group: Development/Tools 11 | License: GPLv2 12 | URL: http://tsung.erlang-projects.org/ 13 | Source0: http://tsung.erlang-projects.org/dist/%{name}-%{version}.tar.gz 14 | Vendor: Process-one 15 | Packager: Nicolas Niclausse 16 | 17 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 18 | 19 | BuildRequires: erlang doxygen-latex python-sphinx texlive-titlesec texlive-framed texlive-threeparttable texlive-wrapfig 20 | 21 | Requires: erlang 22 | Requires: perl(Template) 23 | 24 | %description 25 | tsung is a distributed load testing tool. 26 | It is protocol-independent and can currently be used to stress and 27 | benchmark HTTP, Jabber/XMPP, PostgreSQL, MySQL and LDAP servers. 28 | It simulates user behaviour using an XML description file, reports 29 | many measurements in real time (statistics can be customized with 30 | transactions, and graphics generated using gnuplot). 31 | For HTTP, it supports 1.0 and 1.1, has a proxy mode to record 32 | sessions, supports GET and POST methods, Cookies, and Basic 33 | WWW-authentication. It also has support for SSL. 34 | 35 | More information is available at http://tsung.erlang-projects.org/ . 36 | 37 | %prep 38 | %setup -q 39 | 40 | %build 41 | %configure --docdir=%{_docdir}/%{name}-%{version} 42 | make %{?_smp_mflags} 43 | 44 | %install 45 | rm -rf $RPM_BUILD_ROOT 46 | make install DESTDIR=$RPM_BUILD_ROOT 47 | 48 | install -p -m 644 CHANGES CONTRIBUTORS COPYING README.md TODO \ 49 | $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}/ 50 | 51 | %clean 52 | rm -rf $RPM_BUILD_ROOT 53 | 54 | %files 55 | %defattr(-,root,root,-) 56 | %doc %{_docdir}/%{name}-%{version}/* 57 | %{_bindir}/tsung 58 | %{_bindir}/tsung-recorder 59 | %{_bindir}/tsplot 60 | %{_libdir}/tsung 61 | %{_datadir}/tsung 62 | %{_mandir}/man1/tsung.1* 63 | %{_mandir}/man1/tsplot.1* 64 | %{_mandir}/man1/tsung-recorder.1* 65 | 66 | %changelog 67 | * Wed Sep 20 2006 Nicolas Niclausse 1.2.1-1 68 | - update 'requires': erlang (as in fedora extra) instead of erlang-otp 69 | * Wed Apr 27 2005 Nicolas Niclausse 1.0.2-1 70 | - new release 71 | * Thu Nov 18 2004 Nicolas Niclausse 1.0.1-1 72 | - new release 73 | * Mon Aug 9 2004 Nicolas Niclausse 1.0-1 74 | - new release 75 | * Mon Aug 9 2004 Nicolas Niclausse 1.0.beta7-2 76 | - fix doc 77 | * Mon Aug 9 2004 Nicolas Niclausse 1.0.beta7-1 78 | - initial rpm 79 | 80 | # end of file 81 | -------------------------------------------------------------------------------- /vsn.mk: -------------------------------------------------------------------------------- 1 | 1.6.1_git 2 | --------------------------------------------------------------------------------