Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

customizable oids for snmp (TSUN-203)

  • Loading branch information...
commit b476958eef1f402894b4231f14d621abc233496f 1 parent 556e7e5
@nniclausse nniclausse authored
View
60 doc/user_manual.html
@@ -96,7 +96,7 @@
<!--CUT DEF section 1 --><H1 ALIGN=center>Tsung User’s manual</H1><DIV CLASS="center">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1><TR><TD ALIGN=left NOWRAP bgcolor="#F2F2F2"> Version:</TD><TD ALIGN=left NOWRAP>1.4.2</TD></TR>
-<TR><TD ALIGN=left NOWRAP bgcolor="#F2F2F2"> Date :</TD><TD ALIGN=left NOWRAP>October 17, 2011</TD></TR>
+<TR><TD ALIGN=left NOWRAP bgcolor="#F2F2F2"> Date :</TD><TD ALIGN=left NOWRAP>November 29, 2011</TD></TR>
</TABLE>
</DIV><!--TOC section Contents-->
<H2 CLASS="section"><!--SEC ANCHOR -->Contents</H2><!--SEC END --><UL CLASS="toc"><LI CLASS="li-toc">
@@ -1065,7 +1065,31 @@ <H4 CLASS="subsubsection"><!--SEC ANCHOR --><A NAME="htoc46">6.3.2</A>  SNMP</
</TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE><P>The default version is <FONT COLOR=purple>v1</FONT>, default community
-<FONT COLOR=purple>public</FONT> and default port <FONT COLOR=purple>161</FONT>.</P><!--TOC subsubsection Munin-->
+<FONT COLOR=purple>public</FONT> and default port <FONT COLOR=purple>161</FONT>.</P><P>Since version <B>1.4.2</B>, you can also customize the OIDs
+retrieved from the SNMP server, using one or several <FONT COLOR=purple>oid</FONT>
+element:</P><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><TABLE BORDER=0 CELLPADDING=0
+CELLSPACING=0><TR><TD BGCOLOR=black COLSPAN="3"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD></TR>
+<TR><TD BGCOLOR=black COLSPAN="1"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD><TD><TABLE BORDER=0 CELLPADDING="1" CELLSPACING=0><TR><TD><PRE CLASS="verbatim"> &lt;monitor host="127.0.0.1" type="snmp"&gt;
+ &lt;snmp version="v2"&gt;
+ &lt;oid value="1.3.6.1.4.1.42.2.145.3.163.1.1.2.11.0"
+ name="heapused" type="sample" eval="fun(X)-&gt; X/100 end."/&gt;
+ &lt;/snmp&gt;
+ &lt;/monitor&gt;
+</PRE></TD></TR>
+</TABLE></TD><TD BGCOLOR=black COLSPAN="1"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD></TR>
+<TR><TD BGCOLOR=black COLSPAN="3"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD></TR>
+</TABLE></TD></TR>
+</TABLE><P><TT>type</TT> can be <FONT COLOR=purple>sample</FONT>, <FONT COLOR=purple>counter</FONT> or
+<FONT COLOR=purple>sum</FONT>, and optionnaly you can define a function (with erlang
+syntax) to be applied to the value (<TT>eval</TT> attribute).</P><!--TOC subsubsection Munin-->
<H4 CLASS="subsubsection"><!--SEC ANCHOR --><A NAME="htoc47">6.3.3</A>  Munin</H4><!--SEC END --><P>Since version <B>1.3.1</B>, Tsung is able to retrieve data from a munin-node agent
(see <A HREF="http://munin.projects.linpro.no/wiki/munin-node"><TT>http://munin.projects.linpro.no/wiki/munin-node</TT></A>). The <TT>type</TT>
keyword must be set to <FONT COLOR=purple>munin</FONT>, for example:</P><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><TABLE BORDER=0 CELLPADDING=0
@@ -1235,7 +1259,8 @@ <H4 CLASS="subsubsection"><!--SEC ANCHOR --><A NAME="htoc51">6.4.3</A>  Durati
days. <TT>unit</TT> can be <FONT COLOR=purple>second</FONT>, <FONT COLOR=purple>minute</FONT> or
<FONT COLOR=purple>hour</FONT>.</P><!--TOC subsection Setting options-->
<H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc52">6.5</A>  Setting options</H3><!--SEC END --><P>
-<A NAME="sec:options"></A></P><P>Default values can be set-up globally: <TT>thinktime</TT> between requests
+<A NAME="sec:options"></A></P><!--TOC paragraph Thinktimes, SSL, Buffers-->
+<H5 CLASS="paragraph"><!--SEC ANCHOR -->Thinktimes, SSL, Buffers</H5><!--SEC END --><P>Default values can be set-up globally: <TT>thinktime</TT> between requests
in the scenario, SSL cipher algorithms, TCP/UDP buffer sizes (the default
value is 32KB). These values overrides
those set in session configuration tags if override is true.
@@ -1260,7 +1285,8 @@ <H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc52">6.5</A>  Setting opt
</TD></TR>
</TABLE></TD></TR>
</TABLE></TD></TR>
-</TABLE><P>A new option is available in version <B>1.3.1</B>: <TT>hibernate</TT>. This
+</TABLE><!--TOC paragraph Hibernate-->
+<H5 CLASS="paragraph"><!--SEC ANCHOR -->Hibernate</H5><!--SEC END --><P>A new option is available in version <B>1.3.1</B>: <TT>hibernate</TT>. This
is used to reduced memory consumption of simulated users during
thinktimes. By default, hibernation will be activated for thinktimes
higher than 10sec. This value can be changed like this:</P><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><TABLE BORDER=0 CELLPADDING=0
@@ -1278,7 +1304,8 @@ <H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc52">6.5</A>  Setting opt
</TD></TR>
</TABLE></TD></TR>
</TABLE></TD></TR>
-</TABLE><P>To disable hibernation, you must set the value to <FONT COLOR=purple>infinity</FONT>.</P><P>A new option is available in version <B>1.4.0</B>:
+</TABLE><P>To disable hibernation, you must set the value to <FONT COLOR=purple>infinity</FONT>.</P><!--TOC paragraph Rate_limit-->
+<H5 CLASS="paragraph"><!--SEC ANCHOR -->Rate_limit</H5><!--SEC END --><P>A new option is available in version <B>1.4.0</B>:
<TT>rate_limit</TT>. This will limit the bandwidth of each client
(using a token bucket algorithm). The value is in KBytes per
second. You can also specify a maximum burst value
@@ -1299,6 +1326,29 @@ <H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc52">6.5</A>  Setting opt
</TD></TR>
</TABLE></TD></TR>
</TABLE></TD></TR>
+</TABLE><!--TOC paragraph Ports_range-->
+<H5 CLASS="paragraph"><!--SEC ANCHOR -->Ports_range</H5><!--SEC END --><P>
+If you need to open more than 30000 simultaneous connections on a
+client machine, you will be limited by the number of tcp client ports,
+even if you use several IPs (this is true at least on Linux). To
+bypass this limit, Tsung must not delegate the selection of client
+ports and together with using several IP for each client,
+you have to defined a range for available clients ports, for ex:
+</P><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><TABLE BORDER=0 CELLPADDING=0
+CELLSPACING=0><TR><TD BGCOLOR=black COLSPAN="3"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD></TR>
+<TR><TD BGCOLOR=black COLSPAN="1"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD><TD><TABLE BORDER=0 CELLPADDING="1" CELLSPACING=0><TR><TD><PRE CLASS="verbatim"> &lt;option name="ports_range" min="1025" max="65535"/&gt;
+</PRE></TD></TR>
+</TABLE></TD><TD BGCOLOR=black COLSPAN="1"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD></TR>
+<TR><TD BGCOLOR=black COLSPAN="3"><TABLE CELLSPACING="1" CELLPADDING=0 BORDER=0><TR><TD>
+</TD></TR>
+</TABLE></TD></TR>
+</TABLE></TD></TR>
</TABLE><!--TOC subsubsection XMPP/Jabber options-->
<H4 CLASS="subsubsection"><!--SEC ANCHOR --><A NAME="htoc53">6.5.1</A>  XMPP/Jabber options</H4><!--SEC END --><P>
<A NAME="sec:jabber-options"></A></P><P>Default values for specific protocols can be defined. Here is an
View
34 doc/user_manual.tex
@@ -901,6 +901,23 @@ \subsubsection{SNMP}
The default version is \userinput{v1}, default community
\userinput{public} and default port \userinput{161}.
+Since version \strong{1.4.2}, you can also customize the OIDs
+retrieved from the SNMP server, using one or several \userinput{oid}
+element:
+
+\begin{Verbatim}
+ <monitor host="127.0.0.1" type="snmp">
+ <snmp version="v2">
+ <oid value="1.3.6.1.4.1.42.2.145.3.163.1.1.2.11.0"
+ name="heapused" type="sample" eval="fun(X)-> X/100 end."/>
+ </snmp>
+ </monitor>
+\end{Verbatim}
+
+\varname{type} can be \userinput{sample}, \userinput{counter} or
+\userinput{sum}, and optionnaly you can define a function (with erlang
+syntax) to be applied to the value (\varname{eval} attribute).
+
\subsubsection{Munin}
Since version \strong{1.3.1}, Tsung is able to retrieve data from a munin-node agent
@@ -1032,7 +1049,7 @@ \subsubsection{Duration of the load test}
\subsection{Setting options}
\label{sec:options}
-
+\paragraph{Thinktimes, SSL, Buffers}
\par Default values can be set-up globally: \varname{thinktime} between requests
in the scenario, SSL cipher algorithms, TCP/UDP buffer sizes (the default
value is 32KB). These values overrides
@@ -1047,6 +1064,8 @@ \subsection{Setting options}
<option name="udp_rcv_buffer" value="16384"></option>
\end{Verbatim}
+\paragraph{Hibernate}
+
A new option is available in version \strong{1.3.1}: \varname{hibernate}. This
is used to reduced memory consumption of simulated users during
thinktimes. By default, hibernation will be activated for thinktimes
@@ -1058,6 +1077,8 @@ \subsection{Setting options}
To disable hibernation, you must set the value to \userinput{infinity}.
+\paragraph{Rate\_limit}
+
A new option is available in version \strong{1.4.0}:
\varname{rate\_limit}. This will limit the bandwidth of each client
(using a token bucket algorithm). The value is in KBytes per
@@ -1070,6 +1091,17 @@ \subsection{Setting options}
<option name="rate_limit" value="1024"></option>
\end{Verbatim}
+\paragraph{Ports\_range}
+If you need to open more than 30000 simultaneous connections on a
+client machine, you will be limited by the number of tcp client ports,
+even if you use several IPs (this is true at least on Linux). To
+bypass this limit, Tsung must not delegate the selection of client
+ports and together with using several IP for each client,
+you have to defined a range for available clients ports, for ex:
+\begin{Verbatim}
+ <option name="ports_range" min="1025" max="65535"/>
+\end{Verbatim}
+
\subsubsection{XMPP/Jabber options}
\label{sec:jabber-options}
View
1  include/ts_config.hrl
@@ -68,6 +68,7 @@
seed = now, % random seed: (default= current time)
vhost_file = none, % file server user for virtual host jabber testing
user_server_maxuid = none, % user_id max
+ oids=[],
rate_limit,
job_notify_port
}).
View
25 src/tsung_controller/ts_config.erl
@@ -116,6 +116,8 @@ parse(Element = #xmlElement{name=server, attributes=Attrs}, Conf=#config{servers
}|ServerList]},
Element#xmlElement.content);
+
+
%% Parsing the cluster monitoring element (monitor)
parse(Element = #xmlElement{name=monitor, attributes=Attrs},
Conf = #config{monitor_hosts=MHList}) ->
@@ -133,11 +135,13 @@ parse(Element = #xmlElement{name=monitor, attributes=Attrs},
community, ?config(snmp_community)),
Version = getAttr(atom,SnmpEl#xmlElement.attributes,
version, ?config(snmp_version)),
- {snmp, {Port, Community, Version}};
+ %% parse OIDS def
+ TmpConf = lists:foldl(fun parse/2, Conf#config{oids=[]}, SnmpEl#xmlElement.content),
+ {snmp, {Port, Community, Version,TmpConf#config.oids}};
_ ->
{snmp, {?config(snmp_port),
- ?config(snmp_community),
- ?config(snmp_version)}}
+ ?config(snmp_community),
+ ?config(snmp_version),[]}}
end;
munin ->
case lists:keysearch(munin,#xmlElement.name,
@@ -161,6 +165,21 @@ parse(Element = #xmlElement{name=monitor, attributes=Attrs},
Conf#config{monitor_hosts = lists:append(MHList, NewMon)},
Element#xmlElement.content);
+
+parse(#xmlElement{name=oid, attributes=Attrs}, Conf=#config{oids=OIDS}) ->
+ OIDStr = getAttr(Attrs, value),
+ OID = lists:map(fun erlang:list_to_integer/1, string:tokens(OIDStr,".")),
+ Name = getAttr(Attrs, name),
+ Type = case getAttr(atom, Attrs, type, sample) of
+ sample -> sample;
+ counter -> sample_counter;
+ sum -> sum
+ end,
+ Snippet = getAttr(string, Attrs, eval, "fun(X)-> X end."),
+ Fun= ts_utils:eval(Snippet),
+ true = is_function(Fun, 1),
+ Conf#config{oids=[{OID,Name,Type,Fun}| OIDS]};
+
%%
parse(Element = #xmlElement{name=load, attributes=Attrs}, Conf) ->
Loop = getAttr(integer, Attrs, loop, 0),
View
45 src/tsung_controller/ts_os_mon_snmp.erl
@@ -47,6 +47,8 @@
pid, % pid of snmp_mgr
uri, % use as an identifier for the snmp manager
host,
+ oids = [], % custom OIDS
+ funs, % store fun to be applied in a dict
version,
port,
community,
@@ -79,7 +81,7 @@ start(Args) ->
%% ignore |
%% {stop, Reason}
%%--------------------------------------------------------------------
-init({HostStr, {Port, Community, Version}, Interval, MonServer}) ->
+init({HostStr, {Port, Community, Version, DynOIDS}, Interval, MonServer}) ->
{ok, IP} = inet:getaddr(HostStr, inet),
Apps = application:loaded_applications(),
case proplists:is_defined(snmp,Apps) of
@@ -95,12 +97,20 @@ init({HostStr, {Port, Community, Version}, Interval, MonServer}) ->
?LOGF("SNMP initialization: ~p~n", [Res3],?NOTICE)
end,
erlang:start_timer(5, self(), connect ),
+ FunsL= [{?SNMP_CPU_RAW_SYSTEM,cpu_system,sample_counter,fun(X)-> X/(Interval/1000) end},
+ {?SNMP_CPU_RAW_USER,cpu_user,sample_counter,fun(X)-> X/(Interval/1000) end},
+ {?SNMP_MEM_AVAIL,freemem,sample,fun(X)-> X/1000 end},
+ {?SNMP_CPU_LOAD1,load,sample,fun(X)-> X*100 end}] ++ DynOIDS,
+ OIDS=lists:map(fun({Oid,_Name,_Type,_Fun})-> Oid end,FunsL),
+ Funs=lists:foldl(fun({Oid,Name,Type,Fun},Acc)->dict:store(Oid,{Name,Type,Fun},Acc) end,dict:new(),FunsL),
?LOGF("Starting SNMP mgr on ~p~n", [IP], ?DEB),
{ok, #state{ mon_server = MonServer,
host = HostStr,
uri = "snmp://"++HostStr++":" ++ integer_to_list(Port),
port = Port,
addr = IP,
+ oids = OIDS,
+ funs = Funs,
community = Community,
version = Version,
interval = Interval}}.
@@ -148,13 +158,9 @@ handle_info({timeout,_Ref,connect},State=#state{uri=URI, addr=IP,port=Port,commu
erlang:start_timer(State#state.interval, self(), send_request ),
{noreply, State};
-handle_info({timeout,_Ref,send_request},State=#state{uri=URI}) ->
+handle_info({timeout,_Ref,send_request},State=#state{uri=URI,oids=OIDS}) ->
?LOGF("SNMP mgr; get data from host ~p~n", [URI],?DEB),
- snmp_get(URI,
- [?SNMP_CPU_RAW_SYSTEM,
- ?SNMP_CPU_RAW_USER,
- ?SNMP_MEM_AVAIL,
- ?SNMP_CPU_LOAD1],State),
+ snmp_get(URI, OIDS, State),
erlang:start_timer(State#state.interval, self(), send_request ),
{noreply,State};
@@ -215,26 +221,13 @@ analyse_snmp_data([User=#varbind{oid=?SNMP_CPU_RAW_USER}| Tail], Host, Stats, St
%%put this entry at the end, this will be used when SYSTEM match
analyse_snmp_data(Tail ++ [User], Host, Stats, State);
-analyse_snmp_data([#varbind{oid=OID, value=Val}| Tail], Host, Stats, State) ->
- {Type, Name, Value}= oid_to_statname(OID, Host, Val),
+analyse_snmp_data([#varbind{oid=OID, value=Val}| Tail], Host, Stats, State=#state{funs=F}) ->
+ {DataName, Type, Fun} = dict:fetch(OID,F),
+ Value = Fun(Val),
+ Name = {DataName,Host},
?LOGF("Analyse SNMP: ~p:~p:~p ~n", [Type, Name, Value],?DEB),
- analyse_snmp_data(Tail, Host, [{Type, Name, Value}| Stats], State).
+ analyse_snmp_data(Tail, Host, [{Type, Name, Value}| Stats], State).
-%%--------------------------------------------------------------------
-%% Function: oid_to_statname/3
-%%--------------------------------------------------------------------
-oid_to_statname(?SNMP_CPU_RAW_IDLE, Name, Value) ->
- CountName = {cpu_idle, Name},
- ?DebugF("Adding counter value for ~p~n",[CountName]),
- {sample_counter, CountName, Value/(?INTERVAL/1000)}; % FIXME ? Interval ??
-oid_to_statname(?SNMP_MEM_AVAIL, Name, Value)->
- CountName = {freemem, Name},
- ?DebugF("Adding counter value for ~p~n",[CountName]),
- {sample,CountName, Value/1000};
-oid_to_statname(?SNMP_CPU_LOAD1, Name, Value)->
- CountName = {load, Name},
- ?DebugF("Adding counter value for ~p~n",[CountName]),
- {sample,CountName, Value/100}.
%%--------------------------------------------------------------------
%% Function: snmp_get/3
@@ -243,7 +236,7 @@ oid_to_statname(?SNMP_CPU_LOAD1, Name, Value)->
snmp_get(Agent,OIDs,State)->
snmp_get(Agent,OIDs,State,?SNMP_TIMEOUT).
-snmp_get(URI="snmp://"++Host,OIDs,State,TimeOut)->
+snmp_get(URI="snmp://"++Host, OIDs, State, TimeOut)->
?LOGF("Running snmp get ~p ~p~n", [URI,OIDs], ?DEB),
[Agent|_]=string:tokens(Host,":"),
Res = snmpm:sync_get("tsung",URI,OIDs,TimeOut),
View
9 tsung-1.0.dtd
@@ -47,12 +47,19 @@
batch (true | false) "false"
type (snmp | erlang | munin) "erlang">
-<!ELEMENT snmp EMPTY>
+<!ELEMENT snmp (oid)*>
<!ATTLIST snmp
version (v1 | v2) "v1"
community NMTOKEN "public"
port NMTOKEN "161">
+<!ELEMENT oid EMPTY>
+<!ATTLIST oid
+ value NMTOKEN #REQUIRED
+ name NMTOKEN #REQUIRED
+ type NMTOKEN "sample"
+ eval CDATA #IMPLIED>
+
<!ELEMENT munin EMPTY>
<!ATTLIST munin
port NMTOKEN "4949">
Please sign in to comment.
Something went wrong with that request. Please try again.