siremis:install33x:charts

Siremis v3.3.x - Charts Panel

SIREMIS is able to create and display charts using Open Flash Chart library (GPL-licensed) – the library is included in SIREMIS distribution, you do not need to do anything else. Your web browser needs to have a flash player plug-in.

The data to create the charts is taken from tables residing in Kamailio database. There are no such tables by default – the installation wizard of Siremis creates a table statistics with some predefined metrics, you can extend it if you need or create another one following the same kind of structure.

The table has to include a column that stores the time stamp. These values are used for X-axis. The other columns have to store integer values representing time-dependency of a particular attribute.

Besides the dynamic charts, the Charts Pannel includes views for charts or summaries generated from other Kamailio tables, such as location or acc. For these ones, there is no need to do anything, just load the appropriate modules in Kamailio and configure them with database storage support.

Kamailio Config

There are two ways to get data from Kamailio and populate tables to be used for charts:

  • use a cron job to fetch statistics (or other data) from Kamailio and write in the table. This document does not present how to do it, it is expected you know how to deal with cron job and shell tools to parse the output of MI commands. If not, use the next method.
  • use rtimer module to run periodically a route. In that route you insert the values in database. Next are presented the steps to get working the three charts shipped by default with SIREMIS

An example of SIP Proxy configuration snippets for the statistics printed by default Siremis charts:

  • some of the statistics are taken directly from internal Kamailio statistics
  • other statistics are built by config operations, using htable to store them in memory
loadmodule "rtimer.so"
loadmodule "sqlops.so"
loadmodule "htable.so"
 
...
 
modparam("rtimer", "timer", "name=tst;interval=300;mode=1;")
modparam("rtimer", "exec", "timer=tst;route=STATS")
 
modparam("sqlops","sqlcon",
         "ca=>mysql://openser:openserrw@localhost/openser")
 
modparam("htable", "htable", "a=>size=6;")
 
...
route[STATS] {
 
	# clean very old records
	$var(tmc) = $var(tmc) + 1;
	$var(x) = $var(tmc) mod 144;
	if($var(x) == 0)
	    sql_query("ca",
			"delete from statistics where time_stamp<$Ts - 864000",
			"ra");
 
	# insert values for Kamailio internal statistics
	sql_query("ca",
		"insert into statistics (time_stamp,shm_used_size,"
		"shm_real_used_size,shm_max_used_size,shm_free_used_size,"
		"ul_users,ul_contacts) values ($Ts,$stat(used_size),"
		"$stat(real_used_size),$stat(max_used_size),$stat(free_size),"
		"$stat(location-users),$stat(location-contacts))",
		"ra");
 
	# init the values for first execution, compute the diff for the rest
	if($var(tmc)==1)
	{
		$var(rcv_req_diff) = $stat(rcv_requests);
		$var(fwd_req_diff) = $stat(fwd_requests);
		$var(2xx_trans_diff) = $stat(2xx_transactions);
	} else {
		$var(rcv_req_diff) = $stat(rcv_requests) - $sht(a=>last_rcv_req);
		$var(fwd_req_diff) = $stat(fwd_requests) - $sht(a=>last_fwd_req);
		$var(2xx_trans_diff) = $stat(2xx_transactions) 
									- $sht(a=>last_2xx_trans);
	}
	# update the values for stats stored in cache (htable)
	$sht(a=>last_rcv_req) = $stat(rcv_requests);
	$sht(a=>last_fwd_req) = $stat(fwd_requests);
	$sht(a=>last_2xx_trans) = $stat(2xx_transactions);
 
	# insert values for stats computed in config
	sql_query("ca",
		"update statistics set tm_active=$stat(inuse_transactions),"
		"rcv_req_diff=$var(rcv_req_diff),fwd_req_diff=$var(fwd_req_diff),"
		"2xx_trans_diff=$var(2xx_trans_diff) where time_stamp=$Ts",
		"ra");
}

Database

Kamailio statistics table was created by Siremis Web Installation Wizard by checking “Update SIP Database” option in Step 2. You will see a new table named 'statistics'.

Now all is ready for Kamailio, you can restart it.

Siremis Config

The configuration file for charts panel is located at:

    siremis/modules/ser/service/siremisCharts.xml

The content of the file looks like:

<?xml version="1.0" standalone="no"?>
<PluginService Name="siremisCharts" Package="asipto" Class="siremisCharts">
  <ChartGroup name="tm">
	  <Chart name="tm" table="statistics" title="TM Stats" bgcolor="#FFF8C6"
			order="reverse" orderby="ORDER BY id DESC" limit="LIMIT 120">
		<XAxis>
			<Item name="time_stamp" data="time_stamp" title="timestamp" type="timestamp"/>
		</XAxis>
		<YAxis>
			<Item name="tm_active" data="tm_active" title="Active Transactions" type="dataset"/>
		</YAxis>
    </Chart>
	  <Chart name="tm200okload" table="statistics" title="TM 2xx Trans Load" bgcolor="#C3FDB8"
			order="reverse" orderby="ORDER BY id DESC" limit="LIMIT 120">
		<XAxis>
			<Item name="time_stamp" data="time_stamp" title="timestamp" type="timestamp"/>
		</XAxis>
		<YAxis>
			<Item name="2xx_trans_diff" data="2xx_trans_diff" title="2xx trans" type="dataset" color="#FBB917" />
		</YAxis>
    </Chart>
  </ChartGroup>
  <ChartGroup name="shm">
	  <Chart name="shm" table="statistics" title="Shared Memory" bgcolor="#40E046" type="area"
			order="reverse" orderby="ORDER BY id DESC" limit="LIMIT 120">
		<XAxis>
			<Item name="time_stamp" data="time_stamp" title="timestamp" type="timestamp"/>
		</XAxis>
		<YAxis>
			<Item name="shm_used_size" data="shm_used_size" title="Used Size" type="dataset" color="#DFC329"/>
			<Item name="shm_real_used_size" data="shm_real_used_size" title="Real Used Size" type="dataset" color="#5E4785"/>
		</YAxis>
    </Chart>
	<Chart name="shmused" table="statistics" title="Used Shared Memory" bgcolor="#B0E0E6" type="area"
			order="reverse" orderby="ORDER BY id DESC" limit="LIMIT 120">
		<XAxis>
			<Item name="time_stamp" data="time_stamp" title="timestamp" type="timestamp"/>
		</XAxis>
		<YAxis>
			<Item name="shm_max_used_size" data="shm_max_used_size" title="Max Used Size" type="dataset" color="#6363AC"/>
		</YAxis>
    </Chart>
  </ChartGroup>
  <ChartGroup name="usrloc">
	  <Chart name="usrloc" table="statistics" title="Location" type="area" order="reverse"
			orderby="ORDER BY id DESC" limit="LIMIT 120">
		<XAxis>
			<Item name="time_stamp" data="time_stamp" title="timestamp" type="timestamp"/>
		</XAxis>
		<YAxis>
			<Item name="ul_users" data="ul_users" title="users" type="dataset" color="#D02020"/>
			<Item name="ul_contacts" data="ul_contacts" title="contacts" type="dataset" color="#DFC329"/>
		</YAxis>
    </Chart>
  </ChartGroup>
  <ChartGroup name="load">
	  <Chart name="rreqload" table="statistics" title="Rcv Reqs" type="area" bgcolor="#FFFFCC"
			order="reverse" orderby="ORDER BY id DESC" limit="LIMIT 120">
		<XAxis>
			<Item name="time_stamp" data="time_stamp" title="timestamp" type="timestamp"/>
		</XAxis>
		<YAxis>
			<Item name="rcv_req_diff" data="rcv_req_diff" title="Rcv Reqs Load" type="dataset" color="#990000" />
		</YAxis>
    </Chart>
	  <Chart name="freqload" table="statistics" title="Rcv Reqs" bgcolor="#66CC99"
			order="reverse" orderby="ORDER BY id DESC" limit="LIMIT 120">
		<XAxis>
			<Item name="time_stamp" data="time_stamp" title="timestamp" type="timestamp"/>
		</XAxis>
		<YAxis>
			<Item name="fwd_req_diff" data="fwd_req_diff" title="Fwd Reqs Load" type="dataset" color="#330099" />
		</YAxis>
    </Chart>
  </ChartGroup>
</PluginService>

There are couple of relevant XML nodes in the configuration file

  • ChartGroup – defines the charts to be displayed in one SIREMIS page
  • Chart – defines a chart – there can be many per ChartGroup
  • XAxis – column and data type for X-axis of the chart
  • YAxis – column and data type for Y-axis of the chart – there can be many per chart

The attributes for each XML node are pretty self-suggestive. The ‘name’ has to be unique and ‘data’ in the ‘Item’ node represents the column name in the table from where to fetch the values.

To add new chart page in SIREMIS you have add a new file in directory:

siremis/modules/ser/view/

Say it is named ChartsCgnameView.xml, its content has to be:

<?xml version="1.0" standalone="no"?>
<EasyView Name="ChartsCgnameView" Description="Charts" class="EasyView" Tab="" TemplateEngine="Smarty" TemplateFile="view.tpl">
    <FormReferences>
        <Reference Name="ser.cms.form.ChartsForm"/>
    </FormReferences>
</EasyView>

Then, to add it to menu, update the file:

    siremis/modules/ser/mod.xml

Find the XML node:

<MenuItem Name="System.Ser.Charts" Title="Chart Services" Parent="System.Ser" ...>

and add a new subnode.

The URL for View node has to be “/siremis/ser/charts_cgname/cg=cgname”, where cgname is the value of name attribute for a ChartGroup.

Then, in Siremis web interface, go to Administration panel and reload module ser (under tab Modules).


100%


Copyright 2010-2020 Asipto.com