<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Altentee &#187; Performance &#38; Test Automation Experts &#187; monitoring</title>
	<atom:link href="http://altentee.com/tag/monitoring/feed/" rel="self" type="application/rss+xml" />
	<link>http://altentee.com</link>
	<description>Performance and Test Automation Experts</description>
	<lastBuildDate>Sat, 12 Jun 2010 00:35:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Roll Your Own SiteScope, a Simple Alternative</title>
		<link>http://altentee.com/2008/roll-your-own-sitescope-a-simple-alternative/</link>
		<comments>http://altentee.com/2008/roll-your-own-sitescope-a-simple-alternative/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:06:34 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2008/roll-your-own-sitescope-a-simple-alternative/</guid>
		<description><![CDATA[<p>In working with SiteScope of late, I&#8217;ve found that it doesn&#8217;t always collect performance metrics the way I want to. More importantly, it can often turn a simple monitoring activity into a complex disaster. Take monitoring via JMX for example. In SiteScope, it has a rather complicated (and sometimes broken) interface when trying to communicate [...]]]></description>
			<content:encoded><![CDATA[<p>In working with SiteScope of late, I&#8217;ve found that it doesn&#8217;t always collect performance metrics the way I want to. More importantly, it can often turn a simple monitoring activity into a complex disaster. Take monitoring via JMX for example. In SiteScope, it has a rather complicated (and sometimes broken) interface when trying to communicate with a busy MBean Server. One can quite easily roll your own JMX monitor using open source tools in about 65 lines of code as I demonstrated <a href="http://90kts.com/blog/2008/monitoring-weblogic-92-with-jmx-and-jruby/">here</a>.</p>
<p>But we still all use tools like LoadRunner in these commercial 9-5 contracts right? Wouldn&#8217;t it be nice, if you could roll your own custom monitors in Ruby, Perl or whatever language you like, store that data in a simple repository, let&#8217;s say a MySQL database, and still be able to hook into those metrics from a LoadRunner Controller during test execution!?</p>
<p>It is possible, with one PHP file and a simple WAMP (or LAMP) installation all wrapped up in a SiteScope-like alternative.<br />
<span id="more-135"></span></p>
<p>First thing, is you will probably want to get data from a variety of sources/platforms/operating systems. Using common scripting languages it is possible to roll your own remote agents.</p>
<p>For example, the following UDP server written in Perl, will listen on port 5151 in a central location, possibly on the same box as your SiteScope alternative.<br />
I&#8217;ve also added some custom formatting templates for the type of remote monitors you might engage (vmstat, sar, iostat etc)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Socket</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sock</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$oldmsg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$msg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hisaddr</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hishost</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$MAXLEN</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$PORTNO</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$MYSQL</span>  <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;D:<span style="color: #000099; font-weight: bold;">\\</span>wamp<span style="color: #000099; font-weight: bold;">\\</span>bin<span style="color: #000099; font-weight: bold;">\\</span>mysql<span style="color: #000099; font-weight: bold;">\\</span>mysql5.0.51a<span style="color: #000099; font-weight: bold;">\\</span>bin<span style="color: #000099; font-weight: bold;">\\</span>mysql -u root -D perf -e &quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$MAXLEN</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$PORTNO</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5151</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$sock</span> <span style="color: #339933;">=</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Socket</span><span style="color: #339933;">::</span><span style="color: #006600;">INET</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span>LocalPort <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$PORTNO</span><span style="color: #339933;">,</span> Proto <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'udp'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;socket: $@&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Awaiting UDP messages on port $PORTNO<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">recv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$msg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$MAXLEN</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$port</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ipaddr</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> sockaddr_in<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">peername</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$hishost</span>    <span style="color: #339933;">=</span> <span style="color: #000066;">gethostbyaddr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$ipaddr</span><span style="color: #339933;">,</span> AF_INET<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$table</span>      <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$msg</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^([\w\_]+):/g</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #0000ff;">$1</span> <span style="color: #339933;">:</span> <span style="color: #000066;">undef</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$msg</span>        <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\w+://g</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Print unformatted message</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$table, $hishost,$msg<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Apply formatting rules</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$table</span>   <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/vmstat/g</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;"># vmstat 60 120 | tee vmstat.$HOSTNAME.csv | ./udpClient.pl monitorHost perf_vmstat</span>
        <span style="color: #0000ff;">$msg</span>    <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\s+//g</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$msg</span>    <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s+/,/g</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$now</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&amp;formatTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cmd</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">$MYSQL</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>INSERT INTO $table VALUES('','$hishost',$now ,$msg)<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`$cmd`</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$msg</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^\d+/g</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$table</span>   <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/iostat/g</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;"># iostat -xnMrTuc 60 120 | tee iostat.$HOSTNAME.csv | ./udpClient.pl monitorHost  perf_iostat</span>
		<span style="color: #0000ff;">$msg</span>    <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/([\d\w]+$)/'$1'/g</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$now</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&amp;formatTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cmd</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">$MYSQL</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>INSERT INTO $table VALUES('','$hishost',$now ,$msg)<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`$cmd`</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$msg</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^\d+\.\d+/g</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$table</span>   <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/sar/g</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;"># sar 60 120 | tee sar.$HOSTNAME.csv | ./udpClient.pl monitorHost perf_sar</span>
		<span style="color: #0000ff;">$msg</span>    <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(^\d+:\d+:\d+)//g</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$msg</span>    <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\s+//g</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$msg</span>    <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s+/,/g</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$now</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&amp;formatTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cmd</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">$MYSQL</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>INSERT INTO $table VALUES('','$hishost',$now ,$msg)<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`$cmd`</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$msg</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/^\d+/g</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">send</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ACK&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;recv: $!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> formatTime
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">use</span> POSIX <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span> strftime <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$year</span>	<span style="color: #339933;">=</span> strftime <span style="color: #ff0000;">&quot;%Y&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">localtime</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$month</span>	<span style="color: #339933;">=</span> strftime <span style="color: #ff0000;">&quot;%m&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">localtime</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$day</span>	    <span style="color: #339933;">=</span> strftime <span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">localtime</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hour</span>	<span style="color: #339933;">=</span> strftime <span style="color: #ff0000;">&quot;%H&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">localtime</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$min</span>	    <span style="color: #339933;">=</span> strftime <span style="color: #ff0000;">&quot;%M&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">localtime</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sec</span>	    <span style="color: #339933;">=</span> strftime <span style="color: #ff0000;">&quot;%S&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">localtime</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$now</span>     <span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;'$year-$month-$day', '$hour:$min:$sec'&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$now</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Given that many Operating Systems are likely to have Perl already installed, a remote UDP client written in Perl will suffice. This significantly lessens the footprint of your remote agents.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Socket</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sock</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$server_host</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$msg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$port</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$ipaddr</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$hishost</span><span style="color: #339933;">,</span>
       <span style="color: #0000ff;">$MAXLEN</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$PORTNO</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$TIMEOUT</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$server_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">||</span> <span style="color: #ff0000;">&quot;monitorHost&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$table</span> 		 <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">||</span> <span style="color: #ff0000;">&quot;undef&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$line</span> <span style="color: #339933;">=</span> <span style="color: #009999;">&lt;stdin&gt;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000066;">chomp</span> <span style="color: #0000ff;">$line</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$line</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/[\w\d]+/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #0000ff;">$MAXLEN</span>  <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$PORTNO</span>  <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5151</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$TIMEOUT</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #0000ff;">$msg</span>         <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;$table:$line&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$sock</span> <span style="color: #339933;">=</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Socket</span><span style="color: #339933;">::</span><span style="color: #006600;">INET</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span>Proto     <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'udp'</span><span style="color: #339933;">,</span>
                                  PeerPort  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$PORTNO</span><span style="color: #339933;">,</span>
                                  PeerAddr  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$server_host</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Creating socket: $!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">send</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$msg</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;send: $!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066;">eval</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">local</span> <span style="color: #0000ff;">$SIG</span><span style="color: #009900;">&#123;</span>ALRM<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;alarm time out&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">alarm</span> <span style="color: #0000ff;">$TIMEOUT</span><span style="color: #339933;">;</span>
        <span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">recv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$msg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$MAXLEN</span><span style="color: #009900;">&#41;</span>      <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;recv: $!&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">alarm</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;"># return value from eval on normalcy</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;recv from $server_host timed out after $TIMEOUT seconds.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>So what we&#8217;ve just achieved there, is a simple UDP client/server, whereby you can pipe in any type of command on the monitored host into your UDP client. Eg:<br />
<code>sar 60 120 | tee sar.$HOSTNAME.csv | ./udpClient.pl monitorHost perf_sar</code></p>
<p>That code will instruct the remote agent to pipe the results of sar into a csv (just in case) and into the udpClient. The extra parameter arguments just tell the script which host has the udpServer running and also which database table the results should be fed into.</p>
<p>Meanwhile, back at the ranch, the udpServer is collecting these results over a UDP connection (nice and light), doing some formatting (you can be creative here) and basically inserting that data straight into a MySQL database. I haven&#8217;t bothered with a DBI interface (as I&#8217;m trying to work with a basic Perl installation), so am just using mysql -e with insert statements from a command line.</p>
<p>This is just one way to get data in. I often have other scripts running such as Ruby, perl, typeperf (perfmon) and so on running in the background whilst feeding data into the database.</p>
<p>So now we have a populated database&#8230; what now?</p>
<p>If you&#8217;re using LoadRunner Controller, you might be interested in getting that information out dynamically during test execution, rather than relying on bulk inserts of data in Analysis. Using my same WAMP box, I wrote a SiteScope alternative or &#8216;faker&#8217;, which reads from the database and presents the relevant XML as SiteScope normally would.</p>
<p>You need to create an alias for SiteScope to wherever you&#8217;ve got the code hosted. Eg:<br />
<code>Alias /SiteScope/ "D:/Sites/SiteScopeFaker/"</p>
<p><directory "D:/Sites/SiteScopeFaker/"><br />
    Options Indexes FollowSymLinks MultiViews<br />
    AllowOverride all<br />
        Order allow,deny<br />
    Allow from all<br />
</directory></code></p>
<p>Then make sure you&#8217;ve got the sub directory path that SiteScope would normally present to the LoadRunner Controller. Eg:<br />
<code>D:\Sites\SiteScopeFaker\cgi\go.exe\</code></p>
<p>Also make sure you edit your .htaccess for your alias to serve up everything as php, even if the extension is missing. Eg:<br />
<code>ForceType application/x-httpd-php</code></p>
<p>And finally, add the php code below to a file called &#8216;SiteScope&#8217; to the go.exe\ subdirectory.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$catalog</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mydb'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Not overly concerned about security here, lock it down as you must ...
</span><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$dbconnect</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost:3306'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Connection failed to the host 'localhost'.&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$catalog</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Cannot connect to database <span style="color: #006699; font-weight: bold;">$catalog</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># create root element
</span><span style="color: #000088;">$doc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DomDocument<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1.0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$root</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PerformanceMonitor'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$root</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$root</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get tables to process
</span><span style="color: #666666; font-style: italic;"># ---------------------
</span><span style="color: #000088;">$dbtables</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;table&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$dbtables</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;table&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$query</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;show tables&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$tables</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbconnect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tables</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$dbtables</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Tables_in_<span style="color: #006699; font-weight: bold;">$catalog</span>&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get date time brackets if available
</span><span style="color: #666666; font-style: italic;"># -----------------------------------
</span><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;df&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$df</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;df&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;dt&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$dt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;dt&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tf&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$tf</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tf&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tt&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$tt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tt&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># process each table
</span><span style="color: #666666; font-style: italic;"># ------------------
</span><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbtables</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;perf_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$table_element</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$table_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;class&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;group&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$table_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$table_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;desc&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$table_element</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$root</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table_element</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;"># set up counters
</span>            <span style="color: #666666; font-style: italic;"># ---------------
</span>            <span style="color: #000088;">$counters</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$query</span>   <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from <span style="color: #006699; font-weight: bold;">$table</span> limit 1&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$fields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbconnect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$fields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fields</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$has_groupid</span> 	    <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$has_subgroupid</span> 	<span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$fields</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$exclusions</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/rowid|^date|^time|groupid|subgroupid/'</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$exclusions</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$counters</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$field</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;groupid&quot;</span><span style="color: #009900;">&#41;</span> 	<span style="color: #000088;">$has_groupid</span> 	<span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;subgroupid&quot;</span><span style="color: #009900;">&#41;</span>  <span style="color: #000088;">$has_subgroupid</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;"># set up filters by groups or subgroups
</span>            <span style="color: #666666; font-style: italic;"># -------------------------------------
</span>            <span style="color: #000088;">$filters</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$has_subgroupid</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$query</span>       <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select groupid, subgroupid from <span style="color: #006699; font-weight: bold;">$table</span> group by groupid, subgroupid&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$groups</span>      <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbconnect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$num_groups</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$groups</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$group</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$groups</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$filters</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>       <span style="color: #339933;">=</span> <span style="color: #000088;">$group</span><span style="color: #009900;">&#91;</span>groupid<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$group</span><span style="color: #009900;">&#91;</span>subgroupid<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$query</span>       <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select groupid from <span style="color: #006699; font-weight: bold;">$table</span> group by groupid&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$groups</span>      <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbconnect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$num_groups</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$groups</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$group</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$groups</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$filters</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>       <span style="color: #339933;">=</span> <span style="color: #000088;">$group</span><span style="color: #009900;">&#91;</span>groupid<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;"># now get data
</span>            <span style="color: #666666; font-style: italic;"># ------------
</span>            <span style="color: #000088;">$query</span>   <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from <span style="color: #006699; font-weight: bold;">$table</span> order by rowid desc limit <span style="color: #006699; font-weight: bold;">$num_groups</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbconnect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$num_results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_results</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$counters</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$counter</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$allowed</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/[^a-z0-9<span style="color: #000099; font-weight: bold;">\\</span>.<span style="color: #000099; font-weight: bold;">\\</span>-<span style="color: #000099; font-weight: bold;">\\</span>_<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>]/i&quot;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$counter_name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$allowed</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$counter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$counter_element</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$counter_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;class&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;monitor&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$counter_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$counter_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$counter_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;desc&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$counter_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$counter_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;type&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;custom&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$counter_element</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$table_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$counter_element</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$filters</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$filter</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$data</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filter</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span>groupid<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span>subgroupid<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$counter</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                            <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filter</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span>groupid<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$counter</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                        <span style="color: #990000;">mysql_data_seek</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                        <span style="color: #666666; font-style: italic;">#array_pop($data)
</span>                        <span style="color: #000088;">$filter</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$allowed</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$value_element</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;counter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$value_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$value_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;desc&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$operation</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;config&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$value_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;val&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$value_element</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$counter_element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value_element</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;No data for returned for query:&lt;br/&gt; <span style="color: #006699; font-weight: bold;">$query</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// get completed xml document</span>
<span style="color: #000088;">$xml_string</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml_string</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>What you end up with is a nicely presented SiteScope alternative within LoadRunner.<br />
<a href='http://90kts.com/blog/wp-content/uploads/2008/04/working003.jpg' title='SiteScope Faker'><img src='http://90kts.com/blog/wp-content/uploads/2008/04/working003.jpg' alt='SiteScope Faker' /></a></p>
<p>As long as your database tables start with the prefix &#8216;perf_&#8217;. Eg.:<br />
<code>perf_sar</code></p>
<p>The SiteScope faker when running will read all the columns from that table and wrap it up as available groups, monitors and counters within a normal &#8216;Add Measurements&#8217; for SiteScope dialog.<br />
<a href='http://90kts.com/blog/wp-content/uploads/2008/04/working004.jpg' title='SiteScope Faker Counter Dialog'><img src='http://90kts.com/blog/wp-content/uploads/2008/04/working004.jpg' alt='SiteScope Faker Counter Dialog' /></a></p>
<p>And finally, when creating your perf_tables, you just need to make sure they follow a certain layout, in that you must have a rowid, date, time, group and optional [subgroup] columns so that the SiteScope faker can correctly organise your counters.<br />
<a href='http://90kts.com/blog/wp-content/uploads/2008/04/working005.jpg' title='SiteScope Faker Columns'><img src='http://90kts.com/blog/wp-content/uploads/2008/04/working005.jpg' alt='SiteScope Faker Columns' /></a></p>
<p>Hope you find that hack useful. <img src='http://altentee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2008/roll-your-own-sitescope-a-simple-alternative/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Another chart API for your performance metrics</title>
		<link>http://altentee.com/2007/another-chart-api-for-your-performance-metrics/</link>
		<comments>http://altentee.com/2007/another-chart-api-for-your-performance-metrics/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 09:59:01 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/another-chart-api-for-your-performance-metrics/</guid>
		<description><![CDATA[<p>Google have got some charting code worth looking at, which basically allows you to create charts by modifying parameters in the query string.</p>
<p>Something as simple as this:
http://chart.apis.google.com/chart?chtt=Tim's%20Beer%20Intake&#038;cht=p3&#038;chd=s:9h&#038;chs=250x100&#038;chco=00ff00&#038;chl=Unemployed&#124;Employed produces this:
</p>
<p>Being on holidays at the moment, I&#8217;m lacking the um, &#8216;project&#8217; on which to apply this technology, but am curious to see how functional it is. They [...]]]></description>
			<content:encoded><![CDATA[<p>Google have <a href="http://code.google.com/apis/chart/">got some charting code</a> worth looking at, which basically allows you to create charts by modifying parameters in the query string.</p>
<p>Something as simple as this:<br />
<code>http://chart.apis.google.com/chart?chtt=Tim's%20Beer%20Intake&#038;cht=p3&#038;chd=s:9h&#038;chs=250x100&#038;chco=00ff00&#038;chl=Unemployed|Employed</code> produces this:<br />
<a href='http://90kts.com/blog/wp-content/uploads/2007/12/chart1.png' title='Timâ€™s beer intake'><img src='http://90kts.com/blog/wp-content/uploads/2007/12/chart1.png' alt='Timâ€™s beer intake' /></a></p>
<p>Being on holidays at the moment, I&#8217;m lacking the um, &#8216;project&#8217; on which to apply this technology, but am curious to see how functional it is. They give some examples on how to serialize datasets, and I think up to 4095 data points can be used. Not bad for those dashboard type applications &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/another-chart-api-for-your-performance-metrics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>By the power of R, statistical computing at your fingertips</title>
		<link>http://altentee.com/2007/by-the-power-of-r-statistical-computing-at-your-fingertips/</link>
		<comments>http://altentee.com/2007/by-the-power-of-r-statistical-computing-at-your-fingertips/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 02:07:18 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/by-the-power-of-r-statistical-computing-at-your-fingertips/</guid>
		<description><![CDATA[<p>I&#8217;ve explored in previous posts the use of tools such as onboard Analytics (LoadRunner), off-the-shelf tools (Excel) and custom web based implementations (JGraph, ChartDirector) used to analyze the nitty gritty of performance metrics.</p>
<p>All of these tool&#8217;s use are governed by some common factors being:</p>
the Expediency factor &#8211; the timeliness of data being analyzed as measured [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve explored in previous posts the use of tools such as onboard Analytics (LoadRunner), off-the-shelf tools (Excel) and custom web based implementations (JGraph, ChartDirector) used to analyze the nitty gritty of performance metrics.</p>
<p>All of these tool&#8217;s use are governed by some common factors being:</p>
<li><strong>the Expediency factor</strong> &#8211; the timeliness of data being analyzed as measured between capturing and analysis of raw data.</li>
<li><strong>the Pimp factor</strong> &#8211; the &#8216;prettiness&#8217; in the presentation of data. Particularly important for benchmarking or external (public) facing documents. Never underestimate the importance in presentation of your results.</li>
<li><strong>the Share-ability factor</strong> &#8211; how portable the analysis needs to be. Particularly important when working with different technology groups such as middleware, storage or network subject matter experts.</li>
<li><strong>the Proprietary factor</strong> &#8211; sometimes you just can&#8217;t escape this. Your heart may lie with support open source, but often your pay check dictates that you must use proprietary formats, templates and the like as already setup by the client. Particularly pertinent with the use of tools like Load Runner, QALoad and the like.</li>
<p><span id="more-97"></span><br />
Enter stage right, the <a href="http://www.r-project.org/">R-Project</a>.</p>
<blockquote><p>R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS.</p></blockquote>
<p>Using R escapes the proprietary factor although some employers may object to you using GPL in their environment. It is a tad weak on the share-ability factor but is very strong on expediency and the subsequent timeliness of your analysis. Oh and the pimp factor, well, that just depends on your imagination. For this demo I&#8217;m sticking with corporate grey on a white background. <img src='http://altentee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>So how do you use it?</strong><br />
Essentially the reason I&#8217;m finding R so powerful, is its ability to quickly analyze and present meaningful statistical information from a raw data source. In my current implementation, I&#8217;m using a sequence of simple MySQL import scripts to import raw data (e.g. iostat, vmstat etc) in a database table. For my demo, the table name is based on the server I am sampling.</p>
<p>Then using a simple R script, that is executed from the R console, I loop through that table (don&#8217;t even need to bother with what the column names are, as it automatically enumerates those) and present the data as a series of line charts with a lowess curve fitted.</p>
<p>The script itself is as simple as this.<br />
<code>library(RMySQL)<br />
MySQL<br />
m <- dbDriver("MySQL")<br />
con <- dbConnect(m, group="DatabaseName")</p>
<p>perfstat <- function(metric, table, dtgFrom, dtgTo) {<br />
    print(metric)<br />
    query<-paste("SELECT ", metric, " result FROM ", table, "<br />
    WHERE dtg BETWEEN ", dtgFrom, " AND ", dtgTo, sep="")<br />
    rs<-dbSendQuery(con, query)<br />
    df<-fetch(rs,n=-1)<br />
    quartz()<br />
    plot(df$result, yaxs ="i", type="l", col="grey", xlab="Elapsed Time",<br />
    ylab=metric, main=paste("Line chart of ",metric), lwd=1)<br />
    lines(lowess(df$result,f=.05,iter=100), col="blue", lwd="0.25")<br />
}</p>
<p>table<-"perfstats_ServerName"<br />
dtgFrom<-"'2007-11-29 19:00:00'"<br />
dtgTo  <-"'2007-11-30 19:00:00'"<br />
fields <- dbListFields(con, table)<br />
for (i in fields) {<br />
if (i == "dtg") print("skipping") else<br />
perfstat(paste("`",i,"`",sep=""),table, dtgFrom, dtgTo) }</p>
<p>dbDisconnect(con)</code></p>
<p>In that example, I'm sampling performance stats from a remote server spanning a 24 hour period, from which data was sampled at a 5 second interval, and presenting that info as follows.<br />
<a href='http://90kts.com/blog/wp-content/uploads/2007/12/r-output.png' title='r sample otuput'><img src='http://90kts.com/blog/wp-content/uploads/2007/12/r-output.thumbnail.png' alt='r sample otuput' /></a></p>
<p>With a slight twist of the code, you can plot result distributions using my favourite representation (boxplot) to help show the distribution of your data. Code like this:<br />
<code>library(RMySQL)<br />
MySQL<br />
m <- dbDriver("MySQL")<br />
con <- dbConnect(m, group="mysql")</p>
<p>perfstat <- function(metric, table, dtgFrom, dtgTo) {<br />
    print(metric)<br />
    query<-paste("SELECT ", metric, " result, device FROM ", table, "<br />
    WHERE dtg BETWEEN ", dtgFrom, " AND ", dtgTo, " ORDER BY device", sep="")<br />
    rs<-dbSendQuery(con, query)<br />
    df<-fetch(rs,n=-1)<br />
    quartz()<br />
	# set plot parameters<br />
	op <- par(las=2, lwd=0.5, omd=c(0,1,0,1), mar=c(5,15,4,2), cex=0.8)</p>
<p>    boxplot(df$result ~ df$device, data = df, col="lightgray", horizontal=TRUE, lwd=0.5, range=0, notch=TRUE,<br />
		xlab=metric, main=paste("Boxplot of ",metric))<br />
}</p>
<p>table<-"_iostat"<br />
dtgFrom<-"'2007-11-13 18:00:00'"<br />
dtgTo  <-"'2007-11-14 18:00:00'"<br />
fields <- dbListFields(con, table)<br />
for (i in fields) {<br />
if (i == "dtg") print("skipping") else<br />
perfstat(paste("`",i,"`",sep=""),table, dtgFrom, dtgTo) }</p>
<p>dbDisconnect(con)</code><br />
Will present very useful boxplots (grouped by device ID) something like this:<br />
<a href='http://90kts.com/blog/wp-content/uploads/2007/12/r-boxplot.png' title='r boxplot'><img src='http://90kts.com/blog/wp-content/uploads/2007/12/r-boxplot.png' alt='r boxplot' /></a></p>
<p>Which makes it very easy to spot performance bottlenecks from a 20,000' level.</p>
<p>I'm a realtive noob with this program, so will be exploring better ways to script and automate with it in future. But for the time being, its ability to quickly analyze data in a meaningful manner makes it one of the sharper tools in your toolbox.</p>
<p>I'm currently using it from my Macbook Pro, but hope to integrate it on some production Windows servers in the near future (using its ability to output straight to png). This a great product, it's free and relatively easy to use. You could use this tool to automate ongoing performance benchmarking aspects of your application development life cycle, or as a simple health check for your key systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/by-the-power-of-r-statistical-computing-at-your-fingertips/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Win32::PerfMon is unable to enum objects with multiple instances</title>
		<link>http://altentee.com/2007/win32perfmon-is-unable-to-enum-objects-with-multiple-instances/</link>
		<comments>http://altentee.com/2007/win32perfmon-is-unable-to-enum-objects-with-multiple-instances/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 00:48:58 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/win32perfmon-is-unable-to-enum-objects-with-multiple-instances/</guid>
		<description><![CDATA[<p>I&#8217;ve been looking for some easy ways to enumerate all of the available performance counters on a Win32 platform programatically.</p>
<p>Rather than trawl through the PerfMon counter GUI, or regress back into the millions of raw counters available via WMI, I was looking for a solution somewhere in between.</p>
<p>The ActiveState version of Perl has a Win32::PerfMon [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for some easy ways to enumerate all of the available performance counters on a Win32 platform programatically.</p>
<p>Rather than trawl through the PerfMon counter GUI, or regress back into the millions of raw counters available via WMI, I was looking for a solution somewhere in between.</p>
<p>The ActiveState version of Perl has a Win32::PerfMon module which lets you enumerate cooked performance counter metrics on a Win32 platform. So I started to write a simple script that would list all Objects->Instances->Counters recursively. Sounds simple right?</p>
<p>Unfortunately I found that the module appears faulty when trying to enum Objects that have multiple instances, such as PhysicalDisk and LogicalDisk. Naturally, these are the counters I&#8217;m most interested in! After <a href="http://www.perlmonks.org/?node_id=439573">googling</a> to the end of the known universe, I couldn&#8217;t find a solution to this problem.</p>
<p>Windows comes with a command line utility called <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_typeperf.mspx?mfr=true">Typeperf</a> which is great for what I ultimately need to script (an unattended batch job that collects performance metrics).</p>
<p>But in order to develop a list of ALL available counters I wrote a mashup in Perl using the Win32::Perfmon module and calls to Typeperf to discover performance counters related to any particular object. That way, I can top and tail the output to my chosen performance counters and not have to worry about the exact typing of these finicky little buggers.<br />
<span id="more-95"></span></p>
<p>To use:<br />
<code>discoverCounters.pl <serverName></code></p>
<p>Output:<br />
<code>.NET CLR Data<br />
.NET CLR Networking<br />
.NET Data Provider for Oracle<br />
.NET Data Provider for SqlServer<br />
.NET CLR Memory<br />
	.NET CLR Memory(_Global_)\# Gen 0 Collections<br />
	.NET CLR Memory(_Global_)\# Gen 1 Collections<br />
	.NET CLR Memory(_Global_)\# Gen 2 Collections<br />
...</code></p>
<p>Code:<br />
<code>use Win32::PerfMon;<br />
my $server      = $ARGV[0]  || "VIRTUAL";<br />
my $PerfObj     = Win32::PerfMon->new("\\\\$server");<br />
my $Objects     = $PerfObj->ListObjects();</p>
<p>foreach $Object (@$Objects)<br />
{</p>
<p>    if($Object=~/\bPaging File\b|\bThread\b|\bProcess\b/){<br />
        # I prefer to skip counters related to the following objects<br />
        #  Paging File<br />
        #  Thread<br />
        #  Process<br />
        print "$Object\n";<br />
    } else {<br />
        # The following is a list of the possible formats:<br />
        # object(parent/instance#index)\counter<br />
        $cmd1="typeperf \"$Object(*\/*#*)\\*\" -sc 1";<br />
        # object(parent/instance)\counter<br />
        $cmd2="typeperf \"$Object(*\/*)\\*\" -sc 1";<br />
        # object(instance#index)\counter<br />
        $cmd3="typeperf \"$Object(*#*)\\*\" -sc 1";<br />
        # object(instance)\counter<br />
        $cmd4="typeperf \"$Object(*)\\*\" -sc 1";<br />
        # object\counter<br />
        $cmd5="typeperf \"$Object\\*\" -sc 1";</p>
<p>        # Using typeperf, enum the possible counters<br />
        undef $val;<br />
        $val=`$cmd1`;<br />
        if($val=~/No valid counters/) { $val=`$cmd2`; }<br />
        if($val=~/No valid counters/) { $val=`$cmd3`; }<br />
        if($val=~/No valid counters/) { $val=`$cmd4`; }<br />
        if($val=~/No valid counters/) { $val=`$cmd5`; }</p>
<p>        # Clean up and print available counters to display<br />
        if($val=~/No valid counters/) {<br />
            print "$Object\n";<br />
    	} elsif ($val=~/$Object/) {<br />
    	    print "$Object\n";<br />
    	    @values = split(',', $val);<br />
    	    foreach $value(@values) {<br />
    	        if($value=~/$Object/) {<br />
    	            $value=~s/"\\\\$server\\//;<br />
    	            $value=~s/"\n.*//;<br />
                    $value=~s/"$//;<br />
    	            print "\t$value\n";<br />
                }<br />
    	    }<br />
    	}<br />
    }<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/win32perfmon-is-unable-to-enum-objects-with-multiple-instances/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use of dashboards for performance tuning</title>
		<link>http://altentee.com/2007/use-of-dashboards-for-performance-tuning/</link>
		<comments>http://altentee.com/2007/use-of-dashboards-for-performance-tuning/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 01:42:17 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/use-of-dashboards-for-performance-tuning/</guid>
		<description><![CDATA[<p>Jason Gorman describes in his article 6 requirements for the practical use of dashboards in performance related testing.</p>
<p>As a performance tester, I find that I often need to provide snapshot summaries of systems performance ala dashboards. The key requirement imposed is normally timeliness and relevance of data being presented.</p>
<p>So sticking with Jason&#8217;s requirements, how do [...]]]></description>
			<content:encoded><![CDATA[<p>Jason Gorman describes in his <a href="http://parlezuml.com/blog/?postid=499/">article</a> 6 requirements for the practical use of dashboards in performance related testing.</p>
<p>As a performance tester, I find that I often need to provide snapshot summaries of systems performance ala dashboards. The key requirement imposed is normally timeliness and relevance of data being presented.</p>
<p>So sticking with Jason&#8217;s requirements, how do you <strong>implement</strong> good dashboard design?<br />
<span id="more-87"></span></p>
<p><em>1. Cognitive Simplicity &#8211; you should be able to digest the meaning of it in a matter of seconds &#8230;</em><br />
I think the key here is to understand your audience. Generally the higher up the management food chain you go, the more simple they like the presentation. For a tech audience, I like to present in something they might relate to, such as transaction distributions represented by a miniature line chart and vertical box plot. Take for example the following graphical representation:<br />
<a href='http://90kts.com/blog/wp-content/uploads/2007/10/boxplotline.png' title='box plot with line chart'><img src='http://90kts.com/blog/wp-content/uploads/2007/10/boxplotline.png' alt='box plot with line chart' /></a><br />
I find that to be a popular format. The line chart gives you an instant snapshot of data over time (in this case asvc_t response time on the active queue) and you can easily see where response times spiked in the sample. More useful IMHO though is the use of box plots. The vertical box plot to the right indicates that the top 25% of transactions measured ranged from 0 &#8211; 60 msecs indicating a problem with 25% of my results. Couple with the use of visual indicators such as colour, where red represents an exceeded threshold, I find these snapshots very useful and popular with other tech peeps.</p>
<p>A bit higher up the food chain, I find people tend to get suckered by corny dashboard widgets as in the following:<br />
<a href='http://90kts.com/blog/wp-content/uploads/2007/10/cpugauge.png' title='cpu gauge'><img src='http://90kts.com/blog/wp-content/uploads/2007/10/cpugauge.thumbnail.png' alt='cpu gauge' /></a></p>
<p><em>2. Timeliness &#8211; the information should, as much as possible, be a reflection of the reality now &#8230;</em><br />
This is actually a difficult requirement to achieve, and normally the limiting factor for me is the size of the data that you need to analyze in order to provide concise, meaningful snapshots of information. Particularly when that data exists on multiple providers/sources, that are separate to your analysis solution. In any case, the best way to achieve timeliness is to automate the processing as much as possible. To that end, I normally collect data via scheduled cron jobs, and facilitate some sort of batch processing into my dashboard solution. Currently I generate data into csv files, then have a web based front end where I can upload that data for further processing. Sometimes I am dealing with 300MB+ size files of raw data, so you may wish to introduce some form of data aggregation or thinning in your solution. An example of the web front end I use is available at <a href="http://numbrcrunchr.com">numbrcrunchr.com</a> but this is really not suitable for Internet use. You need high speed bandwidth to upload (and process) such huge files.</p>
<p><em>3. Actionability &#8211; (yes, that&#8217;s a made-up word) &#8211; you should be able to take some kind of action to correct any problems revealed by the dashboard &#8230;</em><br />
I&#8217;m afraid this is something that my own implementation lacks and I fear it could be quite difficult to provide based on the permutations and combinations of advice you may need to provide for a given scenario. However, more often than not, the use of thresholds in your dashboards can often provide the necessary triggers to instigate corrective action. Whether that be as simple as sending an email or sms, restarting a service or flagging the problem in some sort of log is the start of your action plan. Actually telling people how to resolve it, now that&#8217;s a challenge!</p>
<p><em>4. Constructiveness &#8211; it should point you towards practical improvements, rather than just damning current performance &#8230;</em><br />
I think as a performance tester you always need to be cognizant of this, as being overly negative both in your analysis and presentation of information can relegate you to the too hard basket. I try to remove any personal comments in my analysis as in:<br />
&#8220;the sub system performance of the SAN was very poor and the application could not provide a consistent response time&#8221; &#8211; this only isolates yourself from the production support and application development teams<br />
Try and concentrate on the aspects which you may be able to tune or improve such as:<br />
&#8220;disk io wait was observed to be high, it is recommended that cache hit ratios and network latencies are checked by the ABC support team for the period 03.00-04.00 am&#8221;</p>
<p><em>5. Approachability &#8211; it should not be threatening or put people off seeking feedback &#8230;</em><br />
Once again I think this relates to your intended audience, and being aware of what they expect. One performance measurement I particularly hate is RAG (red amber green traffic lights) but I find it commonplace in most places I work. Over simplification of dashboards can be just as bad as over the top detailed widgets! Imagine people&#8217;s reaction to your assessment of their overall application performance as &#8216;red&#8217;. I think you need to be granular enough in your approach, and descriptive enough that it encourages feedback or more questions. &#8220;Do  you know why response times peaked at 3.00am? Why yes, we run an Oracle backup at that time etc&#8221;</p>
<p><em>6. Practicality &#8211; a dashboard needs to not be a burden on the people who manage and use it &#8230;</em><br />
I find web based tools are the best. At the end of the day it depends on what the company already has in place, try not to re-invent the wheel as there are a lot of great applications out there (SiteScope, OpenView, SAS etc). But if you get the urge, try some of the multitudes of charting APIs available. I personally prefer <a href="http://www.advsofteng.com/download.html">ChartDirector</a> but there are tons of options on offer!</p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/use-of-dashboards-for-performance-tuning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Microsoft&#8217;s log parser to analyse web server traffic</title>
		<link>http://altentee.com/2007/using-microsofts-log-parser-to-analyse-web-server-traffic/</link>
		<comments>http://altentee.com/2007/using-microsofts-log-parser-to-analyse-web-server-traffic/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 00:19:35 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/using-microsofts-log-parser-to-analyse-web-server-traffic/</guid>
		<description><![CDATA[<p>IIS logs if setup properly can be an extremely useful source of information during load testing and for other activities such as capacity planning. Another load tester sings its praise here and provides good justification of why you should use it.</p>
<p>The log parser comes for free with the IIS resource pack but you can also [...]]]></description>
			<content:encoded><![CDATA[<p>IIS logs if setup properly can be an extremely useful source of information during load testing and for other activities such as capacity planning. Another load tester sings its praise <a href="http://www.myloadtest.com/analysing-web-server-logs/">here</a> and provides good justification of why you should use it.</p>
<p>The log parser comes for free with the IIS resource pack but you can also get it individually <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&#038;displaylang=en">here</a>.</p>
<p><span id="more-285"></span><br />
There are some gotchas that you need to be aware, mostly to do with the amount of extended info you are logging. If you hope to get into the nitty gritty and use extended logging info you must make sure these options are selected in the advanced properties for your log files.<br />
<a href='http://90kts.com/blog/wp-content/uploads/2007/08/picture-1.png' title='picture-1.png'><img src='http://90kts.com/blog/wp-content/uploads/2007/08/picture-1.png' alt='picture-1.png' /></a></p>
<p>You probably also want to consolidate your log files into a dedicated partition or volume, for easier administration further down the track. If you&#8217;re operating in a web farm type environment, you may also want to consolidate log files onto a single volume. You can specify these type of locations using UNC paths / shares etc. There&#8217;s a very good <a href="http://blog.crowe.co.nz/archive/2006/05/03/619.aspx">blog</a> post that explains how to control the seemingly random instance naming convention that Microsoft assigns to each additional web server in your farm.</p>
<p>And finally, this tool runs great via cygwin/ssh so you can remotely log in and run queries as required. Here&#8217;s a query to get you started, there are many more out there on the web. I use this to show me how many total Bytes are being transmitted for any given day grouped by file extension, and also the average time taken in milliseconds to serve up each of the file extensions.</p>
<p><code><br />
./LogParser.exe "SELECT EXTRACT_TOKEN (cs-uri-stem, -1, '.') AS Extension, AVG(time-taken) AS AvgTimeMs, SUM(sc-bytes) AS SumBytesTx, SUM(cs-bytes) AS SumBytesRx FROM D:\LOGS\HTTP\w3svc1\ex070719*.log WHERE Extension IN ('php';'html';'swf';'js'; 'jpg';'flv';'xml') GROUP BY Extension"<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/using-microsofts-log-parser-to-analyse-web-server-traffic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using perl to read your win32 event log</title>
		<link>http://altentee.com/2007/using-perl-to-read-your-win32-event-log/</link>
		<comments>http://altentee.com/2007/using-perl-to-read-your-win32-event-log/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 06:16:35 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/using-perl-to-read-your-win32-event-log/</guid>
		<description><![CDATA[<p>I often use a combination of cygwin with ssh to remotely manage windows servers, as I find this to be a quicker (and hopefully safer) method of access to my windows boxes. To that end, I often need to check windows application event logs. Typically you&#8217;d use the mmc, but all I want to do [...]]]></description>
			<content:encoded><![CDATA[<p>I often use a combination of cygwin with ssh to remotely manage windows servers, as I find this to be a quicker (and hopefully safer) method of access to my windows boxes. To that end, I often need to check windows application event logs. Typically you&#8217;d use the mmc, but all I want to do mostly is check the last 10 or 100 entries for things like break in attempts, or application warnings/failures etc.</p>
<p><span id="more-283"></span><br />
To do that through your ssh session, you can use the native Win32::EventLog module that ships with the ActiveState version of Perl. I can&#8217;t remember where I got the majority of this code from, but I have since modified it to work within a Win32 environment along with some simple command line arguments. The version I copied was more in line with *ix systems I believe.</p>
<p>If I can remember where I got the code from I&#8217;ll  acknowledge it, but feel free to use my modified version in the interim <img src='http://altentee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<code><br />
use Win32::EventLog;</p>
<p>$machine  = $ARGV[0] || "DEFAULTSERVERNAME";<br />
$eventlog = $ARGV[1] || "Application";<br />
$limit    = $ARGV[2] || 100;</p>
<p>my ($EventLog, $count, $first, $key);</p>
<p>$first = $count = 0;<br />
my $event={<br />
        'Source'              =>NULL,<br />
        'Computer'            =>NULL,<br />
        'Length'              =>NULL,<br />
        'Category'            =>NULL,<br />
        'RecordNumber'        =>NULL,<br />
        'TimeGenerated'       =>NULL,<br />
        'Timewritten'         =>NULL,<br />
        'EventID'             =>NULL,<br />
        'EventType'           =>NULL,<br />
        'ClosingRecordNumber' =>NULL,<br />
        'Strings'             =>NULL,<br />
        'Data',               =>NULL,<br />
        };</p>
<p>$EventLog = new Win32::EventLog( 'Application' ) || die $!;</p>
<p>$EventLog->GetOldest(\$first) || die $!;<br />
$EventLog->GetNumber(\$count) || die $!;</p>
<p>$EventLog->Read((EVENTLOG_SEEK_READ | EVENTLOG_BACKWARDS_READ),$first+$count,$event);</p>
<p>for $i ($first+$count-$limit+1..$first+$count)<br />
        {<br />
        $EventLog->Read((EVENTLOG_SEQUENTIAL_READ|EVENTLOG_BACKWARDS_READ),0,$event);<br />
        ($sec,$min,$hour,$mday,$mon,$year,$sday,$yday,$isdst) = localtime($event->{'TimeGenerated'});;</p>
<p>        #to get a readable EventId<br />
        $event->{'EventID'} = $event->{'EventID'} &#038; 0xffff;</p>
<p>        #foreach $key ('RecordNumber','Category','Source','Strings')<br />
        #       {<br />
        #       print sprintf( "%15s -> %s\n",$key, $event->{$key} );<br />
        #       }</p>
<p>        print "$mday/",$mon+1,"/",$year+1900,"\t$hour:$min\t".$event->{Strings}."\n";<br />
        }<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/using-perl-to-read-your-win32-event-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring queue statistics in MQ</title>
		<link>http://altentee.com/2007/monitoring-queue-statistics-in-mq/</link>
		<comments>http://altentee.com/2007/monitoring-queue-statistics-in-mq/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 05:55:43 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[MQ]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/monitoring-queue-statistics-in-mq/</guid>
		<description><![CDATA[<p>When load testing MQ you are no doubt going to need to be able to monitor queue statistics in terms of how many messages have been enqueued and dequeued within a given timeframe. You can use native runmqsc commands to query queues in order to find current queue depths but this is just a snapshot [...]]]></description>
			<content:encoded><![CDATA[<p>When load testing MQ you are no doubt going to need to be able to monitor queue statistics in terms of how many messages have been enqueued and dequeued within a given timeframe. You can use native <b>runmqsc</b> commands to query queues in order to find current queue depths but this is just a snapshot in time. In order to be able to monitor how many messages have been or gone, you need to sample the queue over time.  Here is a good <a href="http://www.mqseries.net/phpBB2/viewtopic.php?p=112759">synopsis</a> of options&#8230;</p>
<p>A good way to achieve this is my using the <a href="http://www-1.ibm.com/support/docview.wss?rs=203&#038;uid=swg24000668&#038;loc=en_US&#038;cs=utf-8&#038;lang=en">PCF support package</a> provided by IBM.</p>
<blockquote><p>The WebSphere MQ Programmable Command Formats (PCF) provide the capability to perform administration tasks on a queue manager by sending and receiving WebSphere MQ messages of a special format. PCF request messages are sent to the queue manager&#8217;s command queue, where they are processed by the command server and replies returned to the designated reply-to queue.</p>
<p>This SupportPac contains a set of Java classes representing PCF header structures as well as an agent that can be used to simplify the task of communicating with a target queue manager and thus enable the use of WebSphere MQ Programmable Command Formats for queue manager administration. </p></blockquote>
<p>Using a simple java object as documented in <a href="http://www-304.ibm.com/jct09002c/isv/tech/sample_code/mq/ResetQStats.java">sample</a> code, you can query queue stats of your choice. My implementation simply prints out the queue you are connected to, along with enqueue, dequeue and total queue size stats over an arbitrary time frame (eg. last 2 seconds). This can easily be called from a simple shell script.</p>
<p><span id="more-273"></span><br />
<b>ResetQStats.java</b><br />
<code><br />
/**<br />
* Reset MQ Queue Statistics (ResetQStats)<br />
*<br />
* Compile	: javac -classpath com.ibm.mq.jar:connector.jar:jta.jar:com.ibm.mq.pcf-6.0.jar ResetQStats.java</p>
<p>* Package	: jar cfm ResetQStats.jar ResetQStats.MF *.class<br />
* Execute	: java -cp com.ibm.mq.jar:connector.jar:jta.jar:com.ibm.mq.pcf-6.0.jar:ResetQStats.jar ResetQStats [options]<br />
* Usage		: ResetQStats [options]<br />
* Options	:<br />
		host		MQ hostname eg. 127.0.0.1<br />
		port		      MQ port eg. 1415<br />
		channel		MQ channel eg. CHANNEL_NAME<br />
		queue		MQ queue eg. QUEUE_NAME<br />
*<br />
* Last edited	: 6 Mar 07 14.00<br />
* Author		: Tim Koopmans<br />
**/</p>
<p>import java.io.*;<br />
import com.ibm.mq.*;<br />
import com.ibm.mq.pcf.*;</p>
<p>public class ResetQStats<br />
{<br />
	final public static String copyright =<br />
                  "Copyright (c) IBM Corp. 2005 All rights reserved.";</p>
<p>	public static void main (String [] args)<br />
	{<br />
           PCFAgent 		 agent;<br />
		PCFParameter [] parameters = { new MQCFST (CMQC.MQCA_Q_NAME,args [3]) };<br />
		MQMessage [] 	 responses;<br />
		MQCFH 			 cfh;<br />
		PCFParameter 	 p;</p>
<p>		try<br />
		{<br />
		   	// Connect a PCFAgent to the specified queue manager<br />
			if (args.length == 1)<br />
			{<br />
				agent = new PCFAgent (args [0]);<br />
			}<br />
			else<br />
			{<br />
				agent = new PCFAgent (args [0], Integer.parseInt (args [1]), args [2]);<br />
			}</p>
<p>			// Use the agent to send the request</p>
<p>			responses = agent.send (CMQCFC.MQCMD_RESET_Q_STATS, parameters);<br />
			cfh = new MQCFH (responses [0]);</p>
<p>			if (cfh.reason == 0)<br />
			{<br />
				//System.out.println ("Queue Statistics:");<br />
				for (int i = 0; i < cfh.parameterCount; i++)<br />
				{<br />
					// Walk through the returned attributes<br />
					p = PCFParameter.nextParameter (responses [0]);<br />
					int parm = p.getParameter();<br />
					switch (parm)<br />
					{<br />
						case CMQC.MQCA_Q_NAME:<br />
									        //Queue Name<br />
									        break;<br />
						case CMQC.MQIA_TIME_SINCE_RESET:<br />
									        //TimeSinceReset t(sec)<br />
									        break;<br />
						case CMQC.MQIA_MSG_ENQ_COUNT:<br />
									        //MsgEnqCount ++<br />
										  break;<br />
						case CMQC.MQIA_MSG_DEQ_COUNT:<br />
									        //MsgDeqCount --										  break;<br />
						case CMQC.MQIA_HIGH_Q_DEPTH:<br />
									        //HighQDepth  (total)<br />
										  break;<br />
					}<br />
					System.out.print(" \t" + p.getValue ());<br />
				}<br />
				System.out.print("\n");<br />
			}<br />
			else<br />
			{<br />
				System.out.println ("PCF error:\n" + cfh);<br />
				// Walk through the returned parameters describing the error<br />
				for (int i = 0; i < cfh.parameterCount; i++)<br />
				{<br />
					System.out.println (PCFParameter.nextParameter (responses [0]));<br />
				}<br />
			}</p>
<p>			// Disconnect<br />
			agent.disconnect ();<br />
		}</p>
<p>		catch (ArrayIndexOutOfBoundsException abe)<br />
		{<br />
			System.out.println ("Usage: \n" +<br />
				"\tjava ResetQStats queue-manager\n" +<br />
				"\tjava ResetQStats host port svrconn-channel");<br />
		}</p>
<p>		catch (NumberFormatException nfe)<br />
		{<br />
			System.out.println ("Invalid port: " + args [1]);<br />
			System.out.println ("Usage: \n" +<br />
				"\tjava ResetQStats queue-manager\n" +<br />
				"\tjava ResetQStats host port svrconn-channel");<br />
		}</p>
<p>		catch (MQException mqe)<br />
		{<br />
			System.err.println (mqe);<br />
		}</p>
<p>		catch (IOException ioe)<br />
		{<br />
			System.err.println (ioe);<br />
		}<br />
	}<br />
}<br />
</code></p>
<p><b>Simple Shell Script</b><br />
<code><br />
#~/bin/sh<br />
javac -classpath $HOME/harness/CDE/com.ibm.mq.jar:$HOME/harness/CDE/connector.jar:$HOME/harness/CDE/jta.jar:/home/strata/d281447/harness/CDE/com.ibm.mq.pcf-6.0.jar $HOME/harness/CDE/ResetQStats.java<br />
cd $HOME/harness/CDE<br />
jar cfm ResetQStats.jar ResetQStats.MF *.class<br />
rm $HOME/harness/CDE/*.class</p>
<p>cd $HOME/harness/CDE</p>
<p>printf "\tQueue Name\t\t\t\t\t\t++ \t-- \tdepth \tsecs\n"</p>
<p>duration=$2	#duration in seconds<br />
sampleRate=$3 	#sample every n seconds</p>
<p>i="1"<br />
while [ $i -le $duration ]<br />
do<br />
	java -cp com.ibm.mq.jar:connector.jar:jta.jar:com.ibm.mq.pcf-6.0.jar:ResetQStats.jar ResetQStats 127.0.0.1 1415 CHANNEL $1</p>
<p>	sleep $sampleRate<br />
	i=`expr $i + 1`</p>
<p>done<br />
printf "\n"<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/monitoring-queue-statistics-in-mq/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting busy with statistics</title>
		<link>http://altentee.com/2007/getting-busy-with-statistics/</link>
		<comments>http://altentee.com/2007/getting-busy-with-statistics/#comments</comments>
		<pubDate>Mon, 15 Jan 2007 02:19:05 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/?p=7</guid>
		<description><![CDATA[<p>The screenshot you see is an example of the graphs you can output in my descriptive statistics Excel template without using any macros. I often find moving averages and boxplots / histograms to be extremely useful in analyzing raw data for stress and volume testing &#8230;</p>
<p>So what are my favourite descriptive statistics I like to [...]]]></description>
			<content:encoded><![CDATA[<p>The screenshot you see is an example of the graphs you can output in my <a href='http://90kts.com/blog/wp-content/uploads/2007/05/descriptivestatswinstaticxls.zip' title='Descriptive Stats Excel Template'>descriptive statistics Excel template</a><img src="http://90kts.com/blog/wp-content/uploads/2007/04/picture-1.png" border="0" height="325" width="259" alt="Picture 1.png" align="left"/> without using any macros. I often find moving averages and boxplots / histograms to be extremely useful in analyzing raw data for stress and volume testing &#8230;</p>
<p>So what are my favourite descriptive statistics I like to analyse data with?</p>
<p>1. Box plots and histograms are great for displaying distribution and give you a good insight to characteristics of the data you are analyzing. A standard box-whisker chart plots up to 5 data sets using box-whisker symbols. Variants are box plots without the whiskers. The 5 data sets are sometimes called the maximum, 3rd quartile, median, 1st quartile and minimum, although they can represent any kind of quantities.<br />
2. Trend line charts. A trend line is a straight line that fits a number of data points computed using linear regression (the least square method). This is excellent for predictive analysis of data, especially if you get roped into capacity planning activities. You do however need a signficant empirical baseline from which to draw your results, which usually means you have to execute many test runs in order to establish the data.<br />
3. Good old line charts. A line chart with thinned results (for easier presentation) can give immediate insights to where your transaction response times went wrong. This is good for coarse analysis of rows of data. Some variations of the line chart is the moving average as provided by excel. I&#8217;m not sure on the accuracy of moving averages though. Can be useful when trying to smooth the curve.<br />
4. In a spline charts, the data points are connected together using cardinal spline curves (as opposed to straight lines). The &#8220;tension&#8221; of the curve can normally be configured.</p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/getting-busy-with-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resource utilization script for Solaris</title>
		<link>http://altentee.com/2006/resource-utilization-script-for-solaris/</link>
		<comments>http://altentee.com/2006/resource-utilization-script-for-solaris/#comments</comments>
		<pubDate>Mon, 18 Dec 2006 02:14:09 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/?p=4</guid>
		<description><![CDATA[<p>Recently I found myself in a performance test analyst role on a unix system with no access to customised tools for collecting performance statistics such as Compuware QALoad or Mecury LoadRunner. Not to worry, Solaris 9 comes with a bucket load of native tools that allow you to easily collect statistics. Using a combination of [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I found myself in a performance test analyst role on a unix system with no access to customised tools for collecting performance statistics such as Compuware QALoad or Mecury LoadRunner. Not to worry, Solaris 9 comes with a bucket load of native tools that allow you to easily collect statistics. Using a combination of native tools (sar, netstat, top, vmstat and iostat) I wrote a rough but effective shell script to assist in collecting raw performance statistics to later analyse for server resource utilization characterstics.</p>
<p><span id="more-262"></span><br />
<code>#~/bin/sh<br />
# #########################################################################<br />
# Server Resource Utilization Monitor<br />
#<br />
# Usage		: ./resource.sh [options]<br />
# Options	:<br />
#     t		duration in seconds to monitor server for<br />
#     n		sample rate every n seconds<br />
#     testID	optional testID used for storing in database<br />
#<br />
# Last edited	: 06 Feb 07 14.00<br />
# Author		: Tim Koopmans<br />
# Version		: 1.1<br />
# #########################################################################</p>
<p>duration=$1		#duration in seconds<br />
sampleRate=$2 	#sample every n seconds<br />
testID=$3		#optional test ID<br />
service=$4		#business service</p>
<p># LOG FILE NAMES<br />
DTG=`date +%y%m%d%H%M`<br />
logfileSAR=$HOME/logs/$DTG\_$testID\_SAR.log<br />
logfileTOP=$HOME/logs/$DTG\_$testID\_TOP.log<br />
logfileVMSTAT=$HOME/logs/$DTG\_$testID\_VMSTAT.log<br />
logfileIOSTAT=$HOME/logs/$DTG\_$testID\_IOSTAT.log<br />
logfileNETSTAT=$HOME/logs/$DTG\_$testID\_NETSTAT.log<br />
logfileDISK=$HOME/logs/$DTG\_$testID\_DISK.log</p>
<p># SAR<br />
sar $sampleRate $duration | awk '{<br />
	toady="true";</p>
<p>	if($6~/2007/)<br />
	{<br />
		YY=substr($6,7,4);<br />
		MM=substr($6,0,2);<br />
		dd=substr($6,4,2);<br />
		dateToday=YY MM dd;<br />
		dateYesterday=dateToday-1;<br />
	}</p>
<p>	if($1~/[0-9]*:[0-9]*:[0-9]*/) DTG=$1;</p>
<p>	HH=substr(DTG,0,2);<br />
	if(HH>10) {<br />
		HH=HH-11;<br />
		today="true";<br />
	} else {<br />
		HH=24-(11-HH);<br />
		today="false";<br />
	}<br />
	if(HH<10) HH="0"HH;<br />
	mm=substr(DTG,4,2);<br />
	ss=substr(DTG,7,2);</p>
<p>	if($2~/^[0-9]+/) {<br />
		if(today=="true"){<br />
			print "\t"dateToday"\t"HH":"mm":"ss"\tSAR    \t"$2"\t"$3"\t"$4"\t"$5"\t'$testID'";<br />
		} else {<br />
			print "\t"dateYesterday"\t"HH":"mm":"ss"\tSAR    \t"$2"\t"$3"\t"$4"\t"$5"\t'$testID'";<br />
		}<br />
	}</p>
<p>}' >>$logfileSAR &#038;</p>
<p>#IOSTAT<br />
iostat -xnMTd $sampleRate $duration | egrep 'd71|d72|d73|d74|d75|2007' | awk '<br />
{<br />
	if($5~/2007/){<br />
		YY=$5;MM=$2;dd=$3;dateToday=YY"-"MM"-"dd;timeToday=$4;<br />
	}<br />
	else{<br />
		print "\t"dateToday"\t"timeToday"\tDISK\t"$11"\t"$1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10"\t'$testID'";<br />
	}<br />
}' >>$logfileIOSTAT &#038;</p>
<p># VMSTAT<br />
vmstat $sampleRate $duration | awk ' {<br />
print "\t \t \tCPU\t"$1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$12"\t"$18"\t"$19"\t"$20"\t"$21"\t'$testID'";<br />
}' >>$logfileVMSTAT &#038;</p>
<p>i="1"<br />
while [ $i -le $duration ]<br />
do<br />
	dateNow=`date -u +%Y%m%d`<br />
	timeNow=`date -u +%H:%M:%S`</p>
<p>	# NETSTAT<br />
	printf "\t$dateNow    \t$timeNow    \t">>$logfileNETSTAT<br />
	netstat -k | grep bytes | head -1 |awk '{<br />
		printf "NET\t"$6"\t"$10;<br />
	}' >>$logfileNETSTAT<br />
	printf "\t$testID\n">>$logfileNETSTAT</p>
<p>	# DISK SPACE CAPACITY<br />
	printf "\t$dateNow    \t$timeNow    \t">>$logfileDISK<br />
	df -vh | egrep 'd71|d72|d73|d74|d75' | awk '{printf substr($1,13,3)"\t"$5"\t'$testID'\n";}' >>$logfileDISK</p>
<p>	#printf "."<br />
	sleep $sampleRate<br />
	i=`expr $i + 1`<br />
done<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2006/resource-utilization-script-for-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
