<?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>NoUseFor.net</title>
	<atom:link href="http://nousefor.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://nousefor.net</link>
	<description>Just a few useless thoughts and projects</description>
	<lastBuildDate>Thu, 19 Apr 2012 11:31:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ganglia IOStat Disk Metrics</title>
		<link>http://nousefor.net/79/2012/04/php/ganglia-iostat-disk-metrics/</link>
		<comments>http://nousefor.net/79/2012/04/php/ganglia-iostat-disk-metrics/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 11:31:00 +0000</pubDate>
		<dc:creator>Spoom</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[gangila]]></category>
		<category><![CDATA[gmetric]]></category>
		<category><![CDATA[iostat]]></category>
		<category><![CDATA[metric]]></category>

		<guid isPermaLink="false">http://nousefor.net/?p=79</guid>
		<description><![CDATA[<p>When using Ganglia to monitor your cluster you might miss the possibility to measure disk metrics. Luckily Ganglia allows to measure user defined metrics with the command line tool gmetric. Combined with the disk monitor tool iostat, gmetric allows to measure disk metrics. So i wrote I small PHP script which puts the iostat data [...]</p>
 ]]></description>
			<content:encoded><![CDATA[<p>When using <a href="http://ganglia.info/" target="_blank">Ganglia</a> to monitor your cluster you might miss the possibility to measure disk metrics.<br />
Luckily <a href="http://ganglia.info/" target="_blank">Ganglia</a> allows to measure user defined metrics with the command line tool gmetric.</p><pre class="crayon-plain-tag">gmetric -c /etc/gmond.conf --name=&quot;My Metric&quot; --value=&quot;My Value&quot; --type=&quot;float&quot; --units=&quot;My Unit&quot;</pre><p>Combined with the disk monitor tool iostat, gmetric allows to measure disk metrics.</p><pre class="crayon-plain-tag">Linux 2.6.18-274.17.1.el5xen       04/19/2012

Device:         rrqm/s   wrqm/s   r/s   w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
xvda              2.28    32.11 26.13 14.69   812.28   187.20    48.97     0.96   23.58   2.80  11.42
xvda1             0.00     0.00  0.00  0.00     0.00     0.00     7.82     0.00   45.52  30.23   0.00
xvda2             0.37     6.46  5.22  4.91   127.79    45.47    34.22     0.24   24.13   4.06   4.11
xvda3             1.38     7.29 15.68  3.96   490.93    45.01    54.56     0.33   16.84   3.30   6.47
xvda4             0.53    18.36  5.24  5.81   193.56    96.72    52.54     0.39   35.07   2.04   2.25
xvdb              0.87    15.35 11.04  8.91   316.92    97.04    41.50     0.49   24.52   3.10   6.18
xvdb1             0.87    15.35 11.04  8.91   316.92    97.04    41.50     0.49   24.52   3.10   6.18
dm-0              0.00     0.00 40.33 71.06  1129.20   284.24    25.38     0.73    6.51   1.50  16.66
dm-1              0.00     0.00  0.00  0.00     0.00     0.00     8.00     0.00   16.82   1.54   0.00</pre><p>So i wrote I small PHP script which puts the iostat data to gmetric and is called periodically by a cronjob.</p><pre class="crayon-plain-tag">exec('iostat -d -x -k 10 2', $out);

	$out = array_slice($out, ceil(count($out)/2));

	//var_dump($out);
	$header = array();
	$data = array();

	foreach($out as $line)
	{
		$line= preg_replace('/\s+/', ' ',$line);
		$cols = explode(&quot; &quot;, $line);

		if($cols[0] == &quot;Device:&quot;){
			$header = $cols;
		}elseif(count($header) &amp;gt; 0 &amp;amp;&amp;amp; count($cols) &amp;gt; 1){
			$data[] = $cols;
		}

	}

	$units = array();
	$units['rrqm_s'] = 'Queued Requests/s';
	$units['wrqm_s'] = 'Queued Requests/s';
	$units['r_s'] =  'Requests/s';
	$units['w_s'] =  'Requests/s';
	$units['rkB_s'] = 'kB/s';
	$units['wkB_s'] = 'kB/s';
	$units['avgrq-sz'] = 'Sectors';
	$units['avgqu-sz'] =  'Sectors';
	$units['await'] =  'ms';
	$units['svctm'] =  'ms';
	$units['util'] =  '%';

	//clean
	for($col=0;$col&amp;lt;count($header);$col++)
	{
		$header[$col] = str_replace(&quot;/&quot;, &quot;_&quot;, $header[$col]);
		$header[$col] = str_replace(&quot;%&quot;, &quot;&quot;, $header[$col]);
	}

	for($row=0;$row&amp;lt;count($data);$row++)
	{
		for($col=1;$col&amp;lt;count($header);$col++)
		{
			if($col != 5 &amp;amp;&amp;amp; $col != 6 &amp;amp;&amp;amp; $col != 11)
			continue;

			if($header[$col]=='')
			continue;

			if(!isset($data[$row][$col]))
			continue;

			$caption = &quot;disk_&quot;.$data[$row][0].&quot;-&quot;.$header[$col];
			$value = $data[$row][$col];
			$unit = $units[$header[$col]];

			//echo $caption.&quot;-&amp;gt;&quot;.$value.&quot;\n&quot;;

			exec('gmetric -c /etc/gmond.conf --name=&quot;'.$caption.'&quot; --value=&quot;'.$value.'&quot; --type=&quot;float&quot; --units=&quot;'.$unit.'&quot;');
		}
	}</pre><p>Using <a href="http://sourceforge.net/apps/trac/ganglia/wiki/ganglia-web-2" target="_blank">Ganglia Web 2</a> the outcome is pretty candy</p>
<p><a href="http://nousefor.net/79/2012/04/php/ganglia-iostat-disk-metrics/attachment/disk/" rel="attachment wp-att-86"><img class="alignnone size-medium wp-image-86" title="Ganglia Disk Reads" src="http://nousefor.net/blog/wp-content/uploads/disk-300x215.png" alt="" width="300" height="215" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://nousefor.net/79/2012/04/php/ganglia-iostat-disk-metrics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Curl Proxy</title>
		<link>http://nousefor.net/71/2012/03/php/php-curl-proxy/</link>
		<comments>http://nousefor.net/71/2012/03/php/php-curl-proxy/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 11:58:14 +0000</pubDate>
		<dc:creator>Spoom</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[anonymous]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://nousefor.net/?p=71</guid>
		<description><![CDATA[<p>If you want to use random anonymous proxies for your curl connections, but TOR is not available use the PHP function below. It uses the CURL proxy option with a random chosen proxy from proxylist.net. Simple but very effective and it also supports POST data, cookies and retries.</p>
 ]]></description>
			<content:encoded><![CDATA[<p>If you want to use random anonymous proxies for your curl connections, but TOR is not available use the PHP function below.<br />
It uses the CURL proxy option with a random chosen proxy from proxylist.net.<br />
Simple but very effective and it also supports POST data, cookies and retries.</p>
<p></p><pre class="crayon-plain-tag">function curl($URLServer,$postdata=&quot;&quot;, $cookieFile=null, $proxy=true, $proxyRetry=0)
{
		global $proxyCache;
		//sleep(20);
		$agent = &quot;Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.10 (maverick) Firefox/3.6.12&quot;;
		$cURL_Session = curl_init();
		 
		curl_setopt($cURL_Session, CURLOPT_URL,$URLServer);
		curl_setopt($cURL_Session, CURLOPT_USERAGENT, $agent);
		if($postdata != &quot;&quot;)
		{
		curl_setopt($cURL_Session, CURLOPT_POST, 1);
		curl_setopt($cURL_Session, CURLOPT_POSTFIELDS,$postdata);
		}
		curl_setopt($cURL_Session, CURLOPT_RETURNTRANSFER, 1);
		//curl_setopt($cURL_Session, CURLOPT_FOLLOWLOCATION, 1);
		if($cookieFile != null){
		curl_setopt($cURL_Session,CURLOPT_COOKIEJAR, $cookieFile);
		curl_setopt($cURL_Session,CURLOPT_COOKIEFILE, $cookieFile);  
		}
		
		if($proxy == true)
		{
			if($proxyCache == &quot;&quot;)
			{
			$c = curl(&quot;http://www.proxylist.net/&quot;, &quot;&quot;, null, false);
			preg_match_all(&quot;/([0-9]*).([0-9]*).([0-9]*).([0-9]*):([0-9]*)/&quot;, $c, $matches);
			$matches = $matches[0];
			$proxyCache = $matches[rand(0, (count($matches)-1))];
			}
			
			echo &quot;proxy:$proxyCache&lt;br&gt;&quot;;
			
						
			list($proxy_ip, $proxy_port) = explode(&quot;:&quot;, $proxyCache);

			curl_setopt($cURL_Session, CURLOPT_PROXYPORT, $proxy_port);
			curl_setopt($cURL_Session, CURLOPT_PROXYTYPE, 'HTTP');
			curl_setopt($cURL_Session, CURLOPT_PROXY, $proxy_ip);		
		}
		
		$result = curl_exec ($cURL_Session);
		
		if($result === false)
		{
    	echo 'Curl error: ' . curl_error($cURL_Session).&quot;&lt;br&gt;&quot;;
    	
    	if($proxy == true &amp;&amp; $proxyRetry &lt;= 5)
    		curl($URLServer,$postdata=&quot;&quot;, $cookieFile, $proxy, $proxyRetry++);
		}
		curl_close ($cURL_Session);
		 
		return $result;
}</pre><p></p>
]]></content:encoded>
			<wfw:commentRss>http://nousefor.net/71/2012/03/php/php-curl-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HBase and Hive Thrift PHP Client</title>
		<link>http://nousefor.net/55/2011/12/php/hbase-and-hive-thrift-php-client/</link>
		<comments>http://nousefor.net/55/2011/12/php/hbase-and-hive-thrift-php-client/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 13:45:37 +0000</pubDate>
		<dc:creator>Spoom</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[Hadoop]]></category>
		<category><![CDATA[HBase]]></category>
		<category><![CDATA[Hive]]></category>
		<category><![CDATA[RPC]]></category>
		<category><![CDATA[Thrift]]></category>

		<guid isPermaLink="false">http://nousefor.net/?p=55</guid>
		<description><![CDATA[<p>Due to my newest project I built a php client to access the HBase and Hive services within a hadoop cluster. Those services are accessible via thrift a high performance protocol for back end services. As building a client with thrift is not that easy I decided to put my HBase and Hive php thrift [...]</p>
 ]]></description>
			<content:encoded><![CDATA[<p>Due to my newest project I built a php client to access the HBase and Hive services within a hadoop cluster.</p>
<p>Those services are accessible via thrift a high performance protocol for back end services.</p>
<p>As building a client with thrift is not that easy I decided to put my HBase and Hive php thrift client packages online for others.</p>
<p>Links:<a href="http://hadoop.apache.org/"><br />
Hadoop</a><br />
<a href="http://hive.apache.org/">Hive</a><br />
<a href="http://hbase.apache.org/">HBase</a><br />
<a href="http://thrift.apache.org/">Thrift</a></p>
<p><strong>How it works</strong></p>
<p>Start the HBase and Hive Thrift server via shell:</p><pre class="crayon-plain-tag">hive --service hiveserver
/usr/lib/hbase/bin/hbase-daemon.sh start thrift</pre><p></p>
<p>&nbsp;</p>
<p><a href="/download/hbase_hive_thrift_php.zip">Download HBase and Thrift php client package</a> and write your own client:</p><pre class="crayon-plain-tag">//thrift php
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__).'/thrift/src';
require_once( $GLOBALS['THRIFT_ROOT'].'/Thrift.php' );
require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php' );
require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php' );
require_once( $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php' );

//hbase thrift
require_once dirname(__FILE__).'/thrift/Hbase.php';

//hive thrift
require_once dirname(__FILE__).'/thrift/ThriftHive.php';

/*
HBase php thrift client
*/

//open connection
$socket = new TSocket( 'localhost', 9090 );
$transport = new TBufferedTransport( $socket );
$protocol = new TBinaryProtocol( $transport );
$client = new HbaseClient( $protocol );
$transport-&gt;open();

//show all tables
$tables = $client-&gt;getTableNames();
foreach ( $tables as $name ) {
echo( &quot;  found: {$name}\n&quot; );
}

//Create a table
try {
$columns = array(new ColumnDescriptor( array(
'name' =&gt;; 'colFamily:',
'maxVersions' =&gt; 10) ));

$client-&gt;createTable(&quot;tableName&quot;, $columns );
} catch ( AlreadyExists $ae ) {
echo( &quot;WARN: {$ae-&gt;;message}\n&quot; );
}

//insert data to table
$mutations = array(
new Mutation( array(
'column' =&gt; 'colFamily:Col',
'value' =&gt; 'value123'
) ),
);
$client-&gt;mutateRow( &quot;tableName&quot;, &quot;ID_1237846634624&quot;, $mutations );

//get table data
$row = $client-&gt;getRow(&quot;tableName&quot;, &quot;ID_1237846634624&quot;);

/*
Hive php thrift client
*/

//open connection
$transport = new TSocket(&quot;localhost&quot;, 10000);
$protocol = new TBinaryProtocol($transport);
$client = new ThriftHiveClient($protocol);
$transport-&gt;open();

//show tables
$client-&gt;execute('SHOW TABLES');
$tables = $client-&gt;fetchAll();
foreach ($tables as $name){
echo( &quot; found: {$name}\n&quot; );
}

//Create Hive table with Hbase table mapping
$mapping = 'CREATE EXTERNAL TABLE tableName(Col String, Col1 String)

STORED BY \'org.apache.hadoop.hive.hbase.HBaseStorageHandler\'
WITH SERDEPROPERTIES (&quot;hbase.columns.mapping&quot; = &quot;colFamily:Col, colFamily:Col&quot;)
TBLPROPERTIES(&quot;hbase.table.name&quot; = &quot;tableName&quot;)';

$client-&gt;execute($mapping);

//Query table
$client-&gt;execute('SELECT * FROM tableName Limit 10');
var_dump($client-&gt;fetchAll());</pre><p></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://nousefor.net/55/2011/12/php/hbase-and-hive-thrift-php-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iSearch &#8211; Meta Search Engine</title>
		<link>http://nousefor.net/44/2011/12/php/isearch-meta-search-engine/</link>
		<comments>http://nousefor.net/44/2011/12/php/isearch-meta-search-engine/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 12:12:42 +0000</pubDate>
		<dc:creator>Spoom</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[extract]]></category>
		<category><![CDATA[iSearch]]></category>
		<category><![CDATA[meta search]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[search engine]]></category>

		<guid isPermaLink="false">http://nousefor.net/?p=44</guid>
		<description><![CDATA[<p>Regular expression pattern based meta search with  an editor that is able to auto create patterns based on html code. Download source code</p>
 ]]></description>
			<content:encoded><![CDATA[<p><strong>Regular expression <a href="http://www.isearch.netii.net/showPatterns.php">pattern</a> based </strong><a href="http://www.isearch.netii.net/"><strong>meta search</strong></a> with  an <a href="http://www.isearch.netii.net/patternCreator.php">editor</a> that is able to auto create patterns based on html code.</p>
<p><a href="/download/iSearch.zip">Download source code</a></p>
<p><a href="http://www.isearch.netii.net/"><br />
</a>
<a href='http://nousefor.net/44/2011/12/php/isearch-meta-search-engine/attachment/index/' title='index'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/index-150x150.png" class="attachment-thumbnail" alt="index" title="index" /></a>
<a href='http://nousefor.net/44/2011/12/php/isearch-meta-search-engine/attachment/pattern-creator-2/' title='pattern creator'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/pattern-creator1-150x150.png" class="attachment-thumbnail" alt="pattern creator" title="pattern creator" /></a>
<a href='http://nousefor.net/44/2011/12/php/isearch-meta-search-engine/attachment/patterns-2/' title='patterns'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/patterns1-150x150.png" class="attachment-thumbnail" alt="patterns" title="patterns" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://nousefor.net/44/2011/12/php/isearch-meta-search-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>K9 Surveillance Robot</title>
		<link>http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/</link>
		<comments>http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 09:04:49 +0000</pubDate>
		<dc:creator>Spoom</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[barcode]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[face detection]]></category>
		<category><![CDATA[lego]]></category>
		<category><![CDATA[lejos]]></category>
		<category><![CDATA[mindstorm]]></category>
		<category><![CDATA[NXT]]></category>
		<category><![CDATA[QR-Code]]></category>
		<category><![CDATA[text2speech]]></category>
		<category><![CDATA[web interface]]></category>

		<guid isPermaLink="false">http://nousefor.net/blog/?p=13</guid>
		<description><![CDATA[<p>K9 surveillance robot is a lejos and android implementation running on Lego mindstorm hardware with the following features: Explores it’s environment while avoiding obstacles with an ultra sonar scanner and detects collisions with a bump sensor. Creates a map from cruising data and detected obstacles. Connects to bluetooth devices to exchange control data and commands. [...]</p>
 ]]></description>
			<content:encoded><![CDATA[<p>K9 surveillance robot is a lejos and android implementation running on Lego mindstorm hardware with the following features:</p>
<ul>
<li>Explores it’s environment while avoiding obstacles with an ultra sonar scanner and detects collisions with a bump sensor.</li>
<li>Creates a map from cruising data and detected obstacles.</li>
<li>Connects to bluetooth devices to exchange control data and commands.</li>
<li>Is monitoring the surrounding area by decoding video data processing it with face detection<br />
and draw detected faces into the map</li>
<li>Detects QR codes to receive commands and authentications.</li>
<li>Uses text to speech.</li>
<li>Serves a telnet interface for an interactive speech output.</li>
<li>Implements a web interface for live image streams, log output and a real time map</li>
</ul>
<p><a href="http://nousefor.net/download/k9.zip" target="_blank">Download</a></p>

<a href='http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/attachment/bruno/' title='bruno'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/2011/11/bruno-150x150.jpg" class="attachment-thumbnail" alt="bruno" title="bruno" /></a>
<a href='http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/attachment/map/' title='map'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/2011/11/map-150x150.png" class="attachment-thumbnail" alt="map" title="map" /></a>
<a href='http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/attachment/overview/' title='overview'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/2011/11/overview-150x150.png" class="attachment-thumbnail" alt="overview" title="overview" /></a>
<a href='http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/attachment/processing/' title='processing'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/2011/11/processing-150x150.png" class="attachment-thumbnail" alt="processing" title="processing" /></a>
<a href='http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/attachment/webinterface/' title='webinterface'><img width="150" height="150" src="http://nousefor.net/blog/wp-content/uploads/2011/11/webinterface-150x150.png" class="attachment-thumbnail" alt="webinterface" title="webinterface" /></a>

]]></content:encoded>
			<wfw:commentRss>http://nousefor.net/13/2011/11/java/android-java/k9-surveillance-robot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

