<?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>TECH.kulish.com &#187; Linux</title>
	<atom:link href="http://tech.kulish.com/category/os/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.kulish.com</link>
	<description>Technical Goulash</description>
	<lastBuildDate>Thu, 01 Dec 2011 00:39:52 +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>Debian Squeeze 802.3ad</title>
		<link>http://tech.kulish.com/2011/11/30/debian-squeeze-802-3ad/</link>
		<comments>http://tech.kulish.com/2011/11/30/debian-squeeze-802-3ad/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 00:12:38 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[MAC]]></category>
		<category><![CDATA[RR]]></category>
		<category><![CDATA[support]]></category>
		<category><![CDATA[TCP]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=416</guid>
		<description><![CDATA[Debian Lenny and Squeeze 2x Realtek 8169 1x Reaktek 8169, 1x nForce Fisher-Price My First Managed Switch Testing: iptraf cat /proc/net/bonding/bond0 [1] mode=0 (balance-rr) Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance. mode=1 (active-backup) One slave interface is active at [...]]]></description>
			<content:encoded><![CDATA[<p>Debian Lenny and Squeeze<br />
2x Realtek 8169<br />
1x Reaktek 8169, 1x nForce<br />
Fisher-Price <a href="http://www.dlink.com/products/?pid=759">My First Managed Switch</a><BR><BR></p>
<p>Testing:<br />
iptraf<br />
cat /proc/net/bonding/bond0<BR><BR></p>
<p>[1]<br />
mode=0 (balance-rr)<br />
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.<br />
<BR><br />
mode=1 (active-backup)<br />
One slave interface is active at any time. If one interface fails, another interface takes over the MAC address and becomes the active interface. Provides fault tolerance only. Doesn’t require special switch support.<br />
<BR><br />
mode=2 (balance-xor)<br />
Tranmissions are balanced across the slave interfaces based on ((source MAC) XOR (dest MAC)) modula slave count. The same slave is selected for each destination MAC. Provides load balancing and fault tolerance.<br />
<BR><br />
mode=3 (broadcast)<br />
Transmits everything on all slave interfaces. Provides fault tolerance.<br />
<BR><br />
<strong>mode=4 (802.3ad)</strong><br />
This is classic IEEE 802.3ad Dynamic link aggregation. This requires 802.3ad support in the switch and driver support for retrieving the speed and duplex of each slave.<br />
<BR><br />
mode=5 (balance-tlb)<br />
Adaptive Transmit Load Balancing. Incoming traffic is received on the active slave only, outgoing traffic is distributed according to the current load on each slave. Doesn’t require special switch support.<br />
<BR><br />
mode=6 (balance-alb)<br />
Adaptive Load Balancing &#8211; provides both transmit load balancing (TLB) and receive load balancing for IPv4 via ARP negotiation. Doesn’t require special switch support, but does require the ability to change the MAC address of a device while it is open.<br />
<BR><br />
[2]<br />
miimon<br />
Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each slave is inspected for link failures. A value of zero disables MII link monitoring. A value of 100 is a good starting point. The use_carrier option, below, affects how the link state is determined. See the High Availability section for additional information. The default value is 0.<br />
<BR><br />
[3]<br />
bond-downdelay 200 : Set the time, t0 200 milliseconds, to wait before disabling a slave after a link failure has been detected. This option is only valid for the bond-miimon.<br />
<BR><br />
bond-updelay 200 : Set the time, to 200 milliseconds, to wait before enabling a slave after a link recovery has been detected. This option is only valid for the bond-miimon.<br />
<BR><br />
[4]<br />
J.A. Sullivan on the debian-user list writes:</p>
<blockquote><p>There are a couple of issues in bonding which can bite the unsuspecting (as they did me!). Round robin will load balance across multiple<br />
interfaces but can produce serious issues with managing out of order TCP<br />
packets. Thus, the performance gain decreases dramatically with the<br />
number of interfaces. In other words, 2 NICs in RR mode will not give 2x the performance nor 3 NICs 3x performance. I do not recall the exact<br />
numbers off the top of my head but averages are something like:<br />
2 NICs &#8211; 1.6x performance<br />
3 NICs &#8211; 1.9x performance<BR><BR></p>
<p>The other modes (other than failover) eliminate the out of order TCP<br />
problem but do so at a cost. All traffic for a single traffic flow goes<br />
across a single path. The most common way to identify a single traffic<br />
flow is matching source and destination MAC addresses. Some bonding algorithms allow matches on layer 3 or even layer 4 data but, if the switch through which they flow only supports MAC to MAC flow assignments, it will all devolve to matching MAC addresses anyway.<BR><BR></p>
<p>So what is the practical outcome using non-RR bonding? You have only one<br />
combination of source and destination MAC address for each socket, e.g.,<br />
if you are measuring a single FTP connection, there is only one<br />
combination of source and destination MAC address. Thus, no matter how<br />
many NICs you have, all the traffic will flow across one combination of<br />
NICs. You will see no performance improvement.<BR><BR></p>
<p>In fact, depending on how the MAC addresses are advertised from the<br />
systems with multiple NICs, all traffic between two systems may flow<br />
across the same pair of NICs even if there are multiple, different<br />
traffic streams.<BR><BR></p>
<p>On the other hand, if you are using bonding to provide a trunk carrying<br />
traffic from many different source and destination MAC address<br />
combinations, each separate stream will be limited to the maximum of the<br />
individual NICs but the aggregate throughput should increase almost<br />
linearly with the number of NICs. Hope that helps &#8211; John</p></blockquote>
<p><BR><br />
Resources:<br />
[1] http://www.howtoforge.com/nic-bonding-on-debian-lenny<br />
[2] http://www.linuxfoundation.org/collaborate/workgroups/networking/bonding<br />
[3] http://www.cyberciti.biz/tips/debian-ubuntu-teaming-aggregating-multiple-network-connections.html<br />
[4] http://comments.gmane.org/gmane.linux.debian.user/405553</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/11/30/debian-squeeze-802-3ad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache to Nginx Migration</title>
		<link>http://tech.kulish.com/2011/11/19/apache-to-nginx-migration/</link>
		<comments>http://tech.kulish.com/2011/11/19/apache-to-nginx-migration/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 17:20:25 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Daemons]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[kulish]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=352</guid>
		<description><![CDATA[Status update of the web engine migration. All items are pending further testing. Tech.kulish.com Fully functional (including links to other/outside domains) Cars.kulish.com Theme issues but otherwise functional I am currently looking at new themes for this site Fully functional Family.kulish.com Fully functional Gallery.kulish.com Working except HTTPS redirects to HTTP because of this&#8230; setConfig(&#8216;baseUri&#8217;, &#8216;http://gallery.kulish.com/main.php&#8217;) Webmail.kulish.com [...]]]></description>
			<content:encoded><![CDATA[<p><center><br />
<a href="http://wiki.nginx.org"><br />
<img src="http://gallery.kulish.com/main.php?g2_view=core.DownloadItem&#038;g2_itemId=4846&#038;g2_serialNumber=1" title="Apache to Nginx Migration" alt=" Apache to Nginx Migration" /><br />
</a><br />
</center></p>
<p>Status update of the web engine migration.<br />
All items are pending further testing.<br />
<BR></p>
<p><strong><font color=cyan>Tech.kulish.com</font></strong><br />
Fully functional (including links to other/outside domains)</p>
<p><span id="more-352"></span><br />
<strong><font color=cyan>Cars.kulish.com</font></strong><br />
<del datetime="2011-11-22T14:13:39+00:00">Theme issues but otherwise functional<br />
I am currently looking at new themes for this site</del><br />
Fully functional<br />
<BR></p>
<p><strong><font color=cyan>Family.kulish.com</font></strong><br />
Fully functional<br />
<BR></p>
<p><strong><font color=cyan>Gallery.kulish.com</font></strong><br />
Working except HTTPS redirects to HTTP because of this&#8230;</p>
<blockquote><p><font color=red><br />
    <strong>setConfig(&#8216;baseUri&#8217;, &#8216;http://gallery.kulish.com/main.php&#8217;)</strong><br />
</font>
</p></blockquote>
<p><BR></p>
<p><strong><font color=cyan>Webmail.kulish.com</font></strong><br />
Fully functional, permanent HTTPS redirect in place<br />
<BR></p>
<p><strong><font color=cyan>Mediaserv.kulish.com</font></strong><br />
Fully functional<br />
<BR></p>
<p><strong><font color=cyan>Monitoring</font></strong><br />
My monitoring solution is collecting data <del datetime="2011-11-21T23:45:25+00:00">but display is broken</del>.<br />
<del datetime="2011-11-21T23:45:25+00:00">HTTP links do not work, just reloads the overview regardless of URL</del><br />
HTTPS links do not work, throws an error on every click</p>
<blockquote><p><font color=red><br />
 <strong> 400 Bad Request<br />
  The plain HTTP request was sent to HTTPS port</strong><br />
</font>
</p></blockquote>
<p><BR></p>
<p><strong><font color=cyan>Cloud</font></strong><br />
Fully functional, permanent HTTPS redirect in place<br />
<BR></p>
<p><strong><font color=cyan>Benchmarks</font></strong><br />
Benchmarks reflect real world performance but I&#8217;ve ran it locally against both engines.<br />
Command used: ab -n 1000 -c 5 http://tech.kulish.com/index.php<br />
<BR><br />
Short version.<br />
<font color=cyan>APACHE:</font><br />
Time taken for tests:   195.169 seconds<br />
Requests per second:    5.12 [#/sec] (mean)<br />
<BR><br />
Connect:        0    0   2.8      0      90<br />
Processing:   318  973 2219.7    595   27929<br />
Waiting:      318  965 2209.7    591   27929<br />
Total:        319  974 2219.9    595   27929<br />
<BR><br />
<font color=cyan>NGINX:</font><br />
Time taken for tests:   109.310 seconds<br />
Requests per second:    9.15 [#/sec] (mean)<br />
<BR><br />
Connect:        0    0   0.6      0      10<br />
Processing:   280  546  80.1    543    1022<br />
Waiting:      280  546  80.1    543    1022<br />
Total:        280  546  80.0    543    1022<br />
<BR><br />
Long version.<br />
<font color=cyan>APACHE:</font><br />
This is ApacheBench, Version 2.3 <$Revision: 655654 $><br />
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br />
Licensed to The Apache Software Foundation, http://www.apache.org/<br />
<BR><br />
Benchmarking tech.kulish.com (be patient)<br />
Completed 100 requests<br />
Completed 200 requests<br />
Completed 300 requests<br />
Completed 400 requests<br />
Completed 500 requests<br />
Completed 600 requests<br />
Completed 700 requests<br />
Completed 800 requests<br />
Completed 900 requests<br />
Completed 1000 requests<br />
Finished 1000 requests<br />
<BR></p>
<p>Server Software:        Apache/2.2.16<br />
Server Hostname:        tech.kulish.com<br />
Server Port:            80<br />
<BR><br />
Document Path:          /index.php<br />
Document Length:        0 bytes<br />
<BR><br />
Concurrency Level:      5<br />
Time taken for tests:   195.169 seconds<br />
Complete requests:      1000<br />
Failed requests:        0<br />
Write errors:           0<br />
Non-2xx responses:      1000<br />
Total transferred:      474000 bytes<br />
HTML transferred:       0 bytes<br />
Requests per second:    5.12 [#/sec] (mean)<br />
Time per request:       975.847 [ms] (mean)<br />
Time per request:       195.169 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          2.37 [Kbytes/sec] received<br />
<BR><br />
Connection Times (ms)<br />
              min  mean[+/-sd] median   max<br />
Connect:        0    0   2.8      0      90<br />
Processing:   318  973 2219.7    595   27929<br />
Waiting:      318  965 2209.7    591   27929<br />
Total:        319  974 2219.9    595   27929<br />
<BR><br />
Percentage of the requests served within a certain time (ms)<br />
  50%    595<br />
  66%    663<br />
  75%    715<br />
  80%    761<br />
  90%   1014<br />
  95%   1855<br />
  98%   4427<br />
  99%  15662<br />
 100%  27929 (longest request)<br />
<BR><BR><br />
<font color=cyan>NGINX:</font><br />
This is ApacheBench, Version 2.3 <$Revision: 655654 $><br />
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br />
Licensed to The Apache Software Foundation, http://www.apache.org/<br />
<BR><br />
Benchmarking tech.kulish.com (be patient)<br />
Completed 100 requests<br />
Completed 200 requests<br />
Completed 300 requests<br />
Completed 400 requests<br />
Completed 500 requests<br />
Completed 600 requests<br />
Completed 700 requests<br />
Completed 800 requests<br />
Completed 900 requests<br />
Completed 1000 requests<br />
Finished 1000 requests<br />
<BR></p>
<p>Server Software:        nginx/1.0.10<br />
Server Hostname:        tech.kulish.com<br />
Server Port:            80<br />
<BR><br />
Document Path:          /index.php<br />
Document Length:        0 bytes<br />
<BR><br />
Concurrency Level:      5<br />
Time taken for tests:   109.310 seconds<br />
Complete requests:      1000<br />
Failed requests:        0<br />
Write errors:           0<br />
Non-2xx responses:      1000<br />
Total transferred:      411000 bytes<br />
HTML transferred:       0 bytes<br />
Requests per second:    9.15 [#/sec] (mean)<br />
Time per request:       546.548 [ms] (mean)<br />
Time per request:       109.310 [ms] (mean, across all concurrent requests)<br />
Transfer rate:          3.67 [Kbytes/sec] received<br />
<BR><br />
Connection Times (ms)<br />
              min  mean[+/-sd] median   max<br />
Connect:        0    0   0.6      0      10<br />
Processing:   280  546  80.1    543    1022<br />
Waiting:      280  546  80.1    543    1022<br />
Total:        280  546  80.0    543    1022<br />
<BR><br />
Percentage of the requests served within a certain time (ms)<br />
  50%    543<br />
  66%    573<br />
  75%    592<br />
  80%    605<br />
  90%    641<br />
  95%    674<br />
  98%    735<br />
  99%    779<br />
 100%   1022 (longest request)</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/11/19/apache-to-nginx-migration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>irc.diff.05142011.2.txt</title>
		<link>http://tech.kulish.com/2011/05/14/irc-diff-05142011-2-txt/</link>
		<comments>http://tech.kulish.com/2011/05/14/irc-diff-05142011-2-txt/#comments</comments>
		<pubDate>Sun, 15 May 2011 04:57:57 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=319</guid>
		<description><![CDATA[Index: irc.php =================================================================== --- irc.php (revision 2317) +++ irc.php (working copy) @@ -1,10 +1,6 @@ #!/usr/bin/env php -# status -# reboot -# log -# help -# down +# port_info is broken. always reports same values no matter host selected]]></description>
			<content:encoded><![CDATA[<p><code><br />
Index: irc.php<br />
===================================================================<br />
--- irc.php	(revision 2317)<br />
+++ irc.php	(working copy)<br />
@@ -1,10 +1,6 @@<br />
 #!/usr/bin/env php</p>
<p>-# status <dev prt srv><br />
-# reboot<br />
-# log<br />
-# help<br />
-# down<br />
+# port_info is broken.  always reports same values no matter host selected</p>
<p> <?php</p>
<p>@@ -23,14 +19,33 @@<br />
 # Redirect to /dev/null if you aren't using screen to keep tabs<br />
 echo "Observer Bot Starting ...\n";<br />
 echo "\n";<br />
-echo "COMMAND\t\tHOST\t\t\tDEVICE\n";<br />
-echo "-------\t\t----\t\t\t------\n";<br />
+echo "Timestamp         Command\n";<br />
+echo "----------------- ------- \n";</p>
<p> class observiumbot</p>
<p> {</p>
<p>+<br />
 ###<br />
+# Get HELP!<br />
+###<br />
+  function help_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+<br />
+global $config;<br />
+<br />
+$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Commands: !help, !log, !status, !version, !down, !port, !device, !listdevices");<br />
+<br />
+echo date("m-d-y H:i:s ");<br />
+echo "HELP\n";<br />
+<br />
+mysql_close();<br />
+<br />
+  }<br />
+<br />
+<br />
+###<br />
 # Get status on !version<br />
 ###<br />
   function version_info(&#038;$irc, &#038;$data)<br />
@@ -40,6 +55,7 @@</p>
<p> $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Observium Version " . $config['version']);</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "VERSION\t\t". $config['version'] . "\n";</p>
<p> mysql_close();<br />
@@ -47,6 +63,31 @@<br />
   }</p>
<p> ###<br />
+# Get last eventlog entry<br />
+###<br />
+  function log_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+<br />
+global $config;<br />
+<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);<br />
+<br />
+    $device = dbFetchRow("SELECT `event_id`,`host`,`datetime`,`message`,`type` FROM `eventlog` ORDER BY `event_id` DESC LIMIT 1");<br />
+     $host=$device['host'];<br />
+     $hostid = dbFetchRow("SELECT `hostname` FROM `devices` WHERE `device_id` = $host");<br />
+<br />
+$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $device['event_id'] ." ". $hostid['hostname'] ." ". $device['datetime'] ." ". $device['message'] ." ". $device['type']);<br />
+<br />
+echo date("m-d-y H:i:s ");<br />
+echo "LOG\n";<br />
+<br />
+mysql_close();<br />
+<br />
+  }<br />
+<br />
+<br />
+###<br />
 # Get status on !down devices<br />
 ###<br />
   function down_info(&#038;$irc, &#038;$data)<br />
@@ -56,18 +97,16 @@<br />
 mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
 mysql_select_db($config['db_name']);</p>
<p>-    $query = mysql_query("SELECT * FROM `devices` where status=0");<br />
-    unset($message);<br />
-    while($device = mysql_fetch_assoc($query))<br />
+    foreach (dbFetchRows("SELECT * FROM `devices` where status=0") as $device)<br />
     {<br />
       $message .= $sep . $device['hostname'];<br />
       $sep = ", ";<br />
     }<br />
     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);<br />
-    unset($sep);</p>
<p> mysql_close();</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "DOWN\n";</p>
<p>   }<br />
@@ -92,9 +131,10 @@<br />
     if ($device['ignore']) { $status = "*Ignored*"; }<br />
     if ($device['disabled']) { $status = "*Disabled*"; }</p>
<p>-    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, '#'.$device['device_id'] . " " . $device['os'] . " " . $device['version'] . " " .<br />
+    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $device['os'] . " " . $device['version'] . " " .<br />
       $device['features'] . " " . $status);</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "DEVICE\t\t". $device['hostname']."\n";</p>
<p>   }<br />
@@ -122,10 +162,11 @@<br />
     $pps_in = format_bi($port['ifInUcastPkts_rate']);<br />
     $pps_out = format_bi($port['ifOutUcastPkts_rate']);</p>
<p>-    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, '#' . $port['interface_id'] . " " . $port['ifAdminStatus'] . "/" . $port['ifOperStatus'] . " " .<br />
+    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $port['ifAdminStatus'] . "/" . $port['ifOperStatus'] . " " .<br />
       $bps_in. " > bps > " . $bps_out . " | " . $pps_in. "pps > PPS > " . $pps_out ."pps");</p>
<p>-echo "PORT\t\t" . $hostname . "\t". $ifname . "\n";<br />
+echo date("m-d-y H:i:s ");<br />
+echo "PORT\t\t\t" . $hostname . "\t". $ifname . "\n";</p>
<p>   }</p>
<p>@@ -152,9 +193,58 @@<br />
     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);<br />
     unset($sep);</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "LISTDEVICES\n";</p>
<p>   }<br />
+<br />
+<br />
+###<br />
+# !status <dev prt srv> gives overall status<br />
+###<br />
+  function status_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+    $statustype = $data->messageex[1];<br />
+<br />
+global $config;<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);<br />
+<br />
+    if ($statustype == "dev") {<br />
+        $devcount = array_pop(dbFetchRow("SELECT count(*) FROM devices"));<br />
+        $devup = array_pop(dbFetchRow("SELECT count(*) FROM devices  WHERE status = '1' AND `ignore` = '0'"));<br />
+        $devdown = array_pop(dbFetchRow("SELECT count(*) FROM devices WHERE status = '0' AND `ignore` = '0'"));<br />
+        $devign = array_pop(dbFetchRow("SELECT count(*) FROM devices WHERE `ignore` = '1'"));<br />
+        $devdis = array_pop(dbFetchRow("SELECT count(*) FROM devices WHERE `disabled` = '1'"));<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Devices: " .$devcount . " (" .$devup . " up, " .$devdown . " down, " .$devign . " ignored, " .$devdis . " disabled" . ")"); }<br />
+<br />
+    else if ($statustype == "prt") {<br />
+        $prtcount = array_pop(dbFetchRow("SELECT count(*) FROM ports"));<br />
+        $prtup = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D  WHERE I.ifOperStatus = 'up' AND I.ignore = '0' AND I.device_id = D.device_id AND D.ignore = '0'"));<br />
+        $prtdown = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE I.ifOperStatus = 'down' AND I.ifAdminStatus = 'up' AND I.ignore = '0' AND D.device_id = I.device_id AND D.ignore = '0'"));<br />
+        $prtsht = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE I.ifAdminStatus = 'down' AND I.ignore = '0' AND D.device_id = I.device_id AND D.ignore = '0'"));<br />
+        $prtign = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE D.device_id = I.device_id AND (I.ignore = '1' OR D.ignore = '1')"));<br />
+        $prterr = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE D.device_id = I.device_id AND (I.ignore = '0' OR D.ignore = '0') AND (I.ifInErrors_delta > '0' OR I.ifOutErrors_delta > '0')"));<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Ports: " .$prtcount . " (" .$prtup . " up, " .$prtdown . " down, " .$prtign . " ignored, " .$prtsht . " shutdown" . ")");}<br />
+<br />
+    else if ($statustype == "srv") {<br />
+        $srvcount = array_pop(dbFetchRow("SELECT count(service_id) FROM services"));<br />
+        $srvup = array_pop(dbFetchRow("SELECT count(service_id) FROM services  WHERE service_status = '1' AND service_ignore ='0'"));<br />
+        $srvdown = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_status = '0' AND service_ignore = '0'"));<br />
+        $srvign = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_ignore = '1'"));<br />
+        $srvdis = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_disabled = '1'"));<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Services: " .$srvcount . " (" .$srvup . " up, " .$srvdown . " down, " .$srvign . " ignored, " .$srvdis . " disabled" . ")"); }<br />
+<br />
+    else {<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Error: STATUS requires one of the following <dev prt srv>"); }<br />
+<br />
+mysql_close();<br />
+<br />
+echo date("m-d-y H:i:s ");<br />
+echo "STATUS\t\t$statustype\n";<br />
+<br />
+  }<br />
+<br />
 }</p>
<p> $bot = &#038;new observiumbot();<br />
@@ -166,6 +256,9 @@<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!port', $bot, 'port_info');<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!down', $bot, 'down_info');<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!version', $bot, 'version_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!status', $bot, 'status_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!log', $bot, 'log_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!help', $bot, 'help_info');</p>
<p> $irc->connect($config['irc_host'], $config['irc_port']);<br />
 $irc->login($config['irc_nick'], 'Observium Bot', 0, $config['irc_nick']);<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/05/14/irc-diff-05142011-2-txt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>irc.diff.05142011.1.txt</title>
		<link>http://tech.kulish.com/2011/05/14/irc-diff-05142011-1-txt/</link>
		<comments>http://tech.kulish.com/2011/05/14/irc-diff-05142011-1-txt/#comments</comments>
		<pubDate>Sun, 15 May 2011 04:56:47 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=316</guid>
		<description><![CDATA[Index: irc.php =================================================================== --- irc.php (revision 2317) +++ irc.php (working copy) @@ -1,11 +1,5 @@ #!/usr/bin/env php -# status -# reboot -# log -# help -# down -]]></description>
			<content:encoded><![CDATA[<p><code><br />
Index: irc.php<br />
===================================================================<br />
--- irc.php	(revision 2317)<br />
+++ irc.php	(working copy)<br />
@@ -1,11 +1,5 @@<br />
 #!/usr/bin/env php</p>
<p>-# status <dev prt srv><br />
-# reboot<br />
-# log<br />
-# help<br />
-# down<br />
-<br />
 <?php</p>
<p> # Disable annoying messages... well... all messages actually :)<br />
@@ -23,14 +17,33 @@<br />
 # Redirect to /dev/null if you aren't using screen to keep tabs<br />
 echo "Observer Bot Starting ...\n";<br />
 echo "\n";<br />
-echo "COMMAND\t\tHOST\t\t\tDEVICE\n";<br />
-echo "-------\t\t----\t\t\t------\n";<br />
+echo "Timestamp         Command\n";<br />
+echo "----------------- ------- \n";</p>
<p> class observiumbot</p>
<p> {</p>
<p>+<br />
 ###<br />
+# Get HELP!<br />
+###<br />
+  function help_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+<br />
+global $config;<br />
+<br />
+$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Commands: !help, !log, !status, !version, !down, !port, !device, !listdevices");<br />
+<br />
+echo date("m-d-y H:i:s ");<br />
+echo "HELP\n";<br />
+<br />
+mysql_close();<br />
+<br />
+  }<br />
+<br />
+<br />
+###<br />
 # Get status on !version<br />
 ###<br />
   function version_info(&#038;$irc, &#038;$data)<br />
@@ -40,6 +53,7 @@</p>
<p> $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Observium Version " . $config['version']);</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "VERSION\t\t". $config['version'] . "\n";</p>
<p> mysql_close();<br />
@@ -47,6 +61,31 @@<br />
   }</p>
<p> ###<br />
+# Get last eventlog entry<br />
+###<br />
+  function log_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+<br />
+global $config;<br />
+<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);<br />
+<br />
+    $device = dbFetchRow("SELECT `event_id`,`host`,`datetime`,`message`,`type` FROM `eventlog` ORDER BY `event_id` DESC LIMIT 1");<br />
+     $host=$device['host'];<br />
+     $hostid = dbFetchRow("SELECT `hostname` FROM `devices` WHERE `device_id` = $host");<br />
+<br />
+$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $device['event_id'] ." ". $hostid['hostname'] ." ". $device['datetime'] ." ". $device['message'] ." ". $device['type']);<br />
+<br />
+echo date("m-d-y H:i:s ");<br />
+echo "LOG\n";<br />
+<br />
+mysql_close();<br />
+<br />
+  }<br />
+<br />
+<br />
+###<br />
 # Get status on !down devices<br />
 ###<br />
   function down_info(&#038;$irc, &#038;$data)<br />
@@ -56,18 +95,16 @@<br />
 mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
 mysql_select_db($config['db_name']);</p>
<p>-    $query = mysql_query("SELECT * FROM `devices` where status=0");<br />
-    unset($message);<br />
-    while($device = mysql_fetch_assoc($query))<br />
+    foreach (dbFetchRows("SELECT * FROM `devices` where status=0") as $device)<br />
     {<br />
       $message .= $sep . $device['hostname'];<br />
       $sep = ", ";<br />
     }<br />
     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);<br />
-    unset($sep);</p>
<p> mysql_close();</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "DOWN\n";</p>
<p>   }<br />
@@ -92,9 +129,10 @@<br />
     if ($device['ignore']) { $status = "*Ignored*"; }<br />
     if ($device['disabled']) { $status = "*Disabled*"; }</p>
<p>-    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, '#'.$device['device_id'] . " " . $device['os'] . " " . $device['version'] . " " .<br />
+    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $device['os'] . " " . $device['version'] . " " .<br />
       $device['features'] . " " . $status);</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "DEVICE\t\t". $device['hostname']."\n";</p>
<p>   }<br />
@@ -122,10 +160,11 @@<br />
     $pps_in = format_bi($port['ifInUcastPkts_rate']);<br />
     $pps_out = format_bi($port['ifOutUcastPkts_rate']);</p>
<p>-    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, '#' . $port['interface_id'] . " " . $port['ifAdminStatus'] . "/" . $port['ifOperStatus'] . " " .<br />
+    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $port['ifAdminStatus'] . "/" . $port['ifOperStatus'] . " " .<br />
       $bps_in. " > bps > " . $bps_out . " | " . $pps_in. "pps > PPS > " . $pps_out ."pps");</p>
<p>-echo "PORT\t\t" . $hostname . "\t". $ifname . "\n";<br />
+echo date("m-d-y H:i:s ");<br />
+echo "PORT\t\t\t" . $hostname . "\t". $ifname . "\n";</p>
<p>   }</p>
<p>@@ -152,9 +191,58 @@<br />
     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);<br />
     unset($sep);</p>
<p>+echo date("m-d-y H:i:s ");<br />
 echo "LISTDEVICES\n";</p>
<p>   }<br />
+<br />
+<br />
+###<br />
+# !status <dev prt srv> gives overall status<br />
+###<br />
+  function status_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+    $statustype = $data->messageex[1];<br />
+<br />
+global $config;<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);<br />
+<br />
+    if ($statustype == "dev") {<br />
+        $devcount = array_pop(dbFetchRow("SELECT count(*) FROM devices"));<br />
+        $devup = array_pop(dbFetchRow("SELECT count(*) FROM devices  WHERE status = '1' AND `ignore` = '0'"));<br />
+        $devdown = array_pop(dbFetchRow("SELECT count(*) FROM devices WHERE status = '0' AND `ignore` = '0'"));<br />
+        $devign = array_pop(dbFetchRow("SELECT count(*) FROM devices WHERE `ignore` = '1'"));<br />
+        $devdis = array_pop(dbFetchRow("SELECT count(*) FROM devices WHERE `disabled` = '1'"));<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Devices: " .$devcount . " (" .$devup . " up, " .$devdown . " down, " .$devign . " ignored, " .$devdis . " disabled" . ")"); }<br />
+<br />
+    else if ($statustype == "prt") {<br />
+        $prtcount = array_pop(dbFetchRow("SELECT count(*) FROM ports"));<br />
+        $prtup = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D  WHERE I.ifOperStatus = 'up' AND I.ignore = '0' AND I.device_id = D.device_id AND D.ignore = '0'"));<br />
+        $prtdown = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE I.ifOperStatus = 'down' AND I.ifAdminStatus = 'up' AND I.ignore = '0' AND D.device_id = I.device_id AND D.ignore = '0'"));<br />
+        $prtsht = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE I.ifAdminStatus = 'down' AND I.ignore = '0' AND D.device_id = I.device_id AND D.ignore = '0'"));<br />
+        $prtign = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE D.device_id = I.device_id AND (I.ignore = '1' OR D.ignore = '1')"));<br />
+        $prterr = array_pop(dbFetchRow("SELECT count(*) FROM ports AS I, devices AS D WHERE D.device_id = I.device_id AND (I.ignore = '0' OR D.ignore = '0') AND (I.ifInErrors_delta > '0' OR I.ifOutErrors_delta > '0')"));<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Ports: " .$prtcount . " (" .$prtup . " up, " .$prtdown . " down, " .$prtign . " ignored, " .$prtsht . " shutdown" . ")");}<br />
+<br />
+    else if ($statustype == "srv") {<br />
+        $srvcount = array_pop(dbFetchRow("SELECT count(service_id) FROM services"));<br />
+        $srvup = array_pop(dbFetchRow("SELECT count(service_id) FROM services  WHERE service_status = '1' AND service_ignore ='0'"));<br />
+        $srvdown = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_status = '0' AND service_ignore = '0'"));<br />
+        $srvign = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_ignore = '1'"));<br />
+        $srvdis = array_pop(dbFetchRow("SELECT count(service_id) FROM services WHERE service_disabled = '1'"));<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Services: " .$srvcount . " (" .$srvup . " up, " .$srvdown . " down, " .$srvign . " ignored, " .$srvdis . " disabled" . ")"); }<br />
+<br />
+    else {<br />
+        $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Error: STATUS requires one of the following <dev prt srv>"); }<br />
+<br />
+mysql_close();<br />
+<br />
+echo date("m-d-y H:i:s ");<br />
+echo "STATUS\t\t$statustype\n";<br />
+<br />
+  }<br />
+<br />
 }</p>
<p> $bot = &#038;new observiumbot();<br />
@@ -166,6 +254,9 @@<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!port', $bot, 'port_info');<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!down', $bot, 'down_info');<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!version', $bot, 'version_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!status', $bot, 'status_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!log', $bot, 'log_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!help', $bot, 'help_info');</p>
<p> $irc->connect($config['irc_host'], $config['irc_port']);<br />
 $irc->login($config['irc_nick'], 'Observium Bot', 0, $config['irc_nick']);<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/05/14/irc-diff-05142011-1-txt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>irc.diff.05142011.txt</title>
		<link>http://tech.kulish.com/2011/05/14/irc-diff-05142011-txt/</link>
		<comments>http://tech.kulish.com/2011/05/14/irc-diff-05142011-txt/#comments</comments>
		<pubDate>Sun, 15 May 2011 04:55:49 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=312</guid>
		<description><![CDATA[Index: irc.php =================================================================== --- irc.php (revision 2284) +++ irc.php (working copy) @@ -1,37 +1,122 @@ #!/usr/bin/env php + +# status +# reboot +# log +# help +# down +]]></description>
			<content:encoded><![CDATA[<p><code><br />
Index: irc.php<br />
===================================================================<br />
--- irc.php	(revision 2284)<br />
+++ irc.php	(working copy)<br />
@@ -1,37 +1,122 @@<br />
 #!/usr/bin/env php<br />
+<br />
+# status <dev prt srv><br />
+# reboot<br />
+# log<br />
+# help<br />
+# down<br />
+<br />
 <?php</p>
<p>-include("includes/defaults.inc.php");<br />
-include("config.php");<br />
-include("includes/functions.php");<br />
-include("includes/discovery/functions.inc.php");<br />
+# Disable annoying messages... well... all messages actually :)<br />
+error_reporting(0);</p>
<p>+include_once("includes/defaults.inc.php");<br />
+include_once("config.php");<br />
+include_once("includes/functions.php");<br />
+include_once("includes/discovery/functions.inc.php");<br />
+<br />
 include_once('Net/SmartIRC.php');</p>
<p>+mysql_close();<br />
+<br />
+# Redirect to /dev/null if you aren't using screen to keep tabs<br />
+echo "Observer Bot Starting ...\n";<br />
+echo "\n";<br />
+echo "COMMAND\t\tHOST\t\t\tDEVICE\n";<br />
+echo "-------\t\t----\t\t\t------\n";<br />
+<br />
 class observiumbot<br />
+<br />
 {<br />
+<br />
+###<br />
+# Get status on !version<br />
+###<br />
+  function version_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+<br />
+global $config;<br />
+<br />
+$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Observium Version " . $config['version']);<br />
+<br />
+echo "VERSION\t\t". $config['version'] . "\n";<br />
+<br />
+mysql_close();<br />
+<br />
+  }<br />
+<br />
+###<br />
+# Get status on !down devices<br />
+###<br />
+  function down_info(&#038;$irc, &#038;$data)<br />
+  {<br />
+<br />
+global $config;<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);<br />
+<br />
+    $query = mysql_query("SELECT * FROM `devices` where status=0");<br />
+    unset($message);<br />
+    while($device = mysql_fetch_assoc($query))<br />
+    {<br />
+      $message .= $sep . $device['hostname'];<br />
+      $sep = ", ";<br />
+    }<br />
+    $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);<br />
+    unset($sep);<br />
+<br />
+mysql_close();<br />
+<br />
+echo "DOWN\n";<br />
+<br />
+  }<br />
+<br />
+###<br />
+# Get status on !device <hostname><br />
+###<br />
   function device_info(&#038;$irc, &#038;$data)<br />
   {<br />
+<br />
     $hostname = $data->messageex[1];</p>
<p>-    $device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'"));<br />
+global $config;<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);</p>
<p>+    $device = dbFetchRow("SELECT * FROM `devices` WHERE `hostname` = ?",array($hostname));<br />
+<br />
+mysql_close();<br />
+<br />
     if ($device['status'] == 1) { $status = "Up " . formatUptime($device['uptime'] . " "); } else { $status = "Down "; }<br />
     if ($device['ignore']) { $status = "*Ignored*"; }<br />
     if ($device['disabled']) { $status = "*Disabled*"; }</p>
<p>     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, '#'.$device['device_id'] . " " . $device['os'] . " " . $device['version'] . " " .<br />
       $device['features'] . " " . $status);<br />
+<br />
+echo "DEVICE\t\t". $device['hostname']."\n";<br />
+<br />
   }</p>
<p>+<br />
+###<br />
+# Get status on !port <hostname port><br />
+###<br />
   function port_info(&#038;$irc, &#038;$data)<br />
   {<br />
     $hostname = $data->messageex[1];<br />
     $ifname = $data->messageex[2];</p>
<p>-    $device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'"));<br />
-    $port   = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE `ifName` = '".mres($ifname)."' OR `ifDescr` = '".mres($ifname)."' AND device_id = '".$device['device_id']."'"));<br />
+global $config;<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);</p>
<p>+    $device = dbFetchRow("SELECT * FROM `devices` WHERE `hostname` = ?",array($device));<br />
+    $port   = dbFetchRow("SELECT * FROM `ports` WHERE `ifName` = ? OR `ifDescr` = ? AND device_id = ?", array($ifname, $ifname, $device['device_id']));<br />
+<br />
+mysql_close();<br />
+<br />
     $bps_in = formatRates($port['ifInOctets_rate']);<br />
     $bps_out = formatRates($port['ifOutOctets_rate']);<br />
     $pps_in = format_bi($port['ifInUcastPkts_rate']);<br />
@@ -39,19 +124,36 @@</p>
<p>     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, '#' . $port['interface_id'] . " " . $port['ifAdminStatus'] . "/" . $port['ifOperStatus'] . " " .<br />
       $bps_in. " > bps > " . $bps_out . " | " . $pps_in. "pps > PPS > " . $pps_out ."pps");<br />
+<br />
+echo "PORT\t\t" . $hostname . "\t". $ifname . "\n";<br />
+<br />
   }</p>
<p>+<br />
+###<br />
+# !listdevices lists all devices<br />
+###<br />
   function list_devices(&#038;$irc, &#038;$data)<br />
   {<br />
-    $query = mysql_query("SELECT * FROM `devices`");<br />
-    unset($message);<br />
-    while($device = mysql_fetch_assoc($query))<br />
+    unset ($message);<br />
+<br />
+global $config;<br />
+mysql_connect($config['db_host'],$config['db_user'],$config['db_pass']);<br />
+mysql_select_db($config['db_name']);<br />
+<br />
+    foreach (dbFetchRows("SELECT `hostname` FROM `devices`") as $device)<br />
     {<br />
       $message .= $sep . $device['hostname'];<br />
       $sep = ", ";<br />
     }<br />
+<br />
+mysql_close();<br />
+<br />
     $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);<br />
     unset($sep);<br />
+<br />
+echo "LISTDEVICES\n";<br />
+<br />
   }<br />
 }</p>
<p>@@ -62,6 +164,8 @@<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!listdevices', $bot, 'list_devices');<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!device', $bot, 'device_info');<br />
 $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!port', $bot, 'port_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!down', $bot, 'down_info');<br />
+$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!version', $bot, 'version_info');</p>
<p> $irc->connect($config['irc_host'], $config['irc_port']);<br />
 $irc->login($config['irc_nick'], 'Observium Bot', 0, $config['irc_nick']);<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/05/14/irc-diff-05142011-txt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Seagate ST32000542AS 2TB Setup</title>
		<link>http://tech.kulish.com/2011/03/05/seagate-st32000542as-2tb-setup/</link>
		<comments>http://tech.kulish.com/2011/03/05/seagate-st32000542as-2tb-setup/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 20:55:09 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Hard Drives]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[HPA]]></category>
		<category><![CDATA[linux lvm]]></category>
		<category><![CDATA[nas]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=266</guid>
		<description><![CDATA[A lot of ST32000542AS drives come with the CC34 firmware. Apparently it has various known problems, one of which is an annoying click (click of death). The first thing you&#8217;ll want to do is upgrade the firmware to CC35. A Link to the instructions is in the references section below. Once that is done, the [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of ST32000542AS drives come with the CC34 firmware.  Apparently it has various known problems, one of which is an annoying click (click of death).  The first thing you&#8217;ll want to do is upgrade the firmware to CC35.  A Link to the instructions is in the references section below.</p>
<p>Once that is done, the next step, if it exists, is removing HPA from the drive.<br />
You&#8217;ll know it has HPA enabled by running hparm.  HPA results in less capacity and so it&#8217;s not a good thing in an array.</p>
<p>We&#8217;ll be using Debian 6.0 (squeeze).</p>
<p><em><strong>hparm -N /dev/sdb</strong></em></p>
<p>You should see a difference in the numbers here.  I chose to take the highest number.  This completely disables HPA.</p>
<p><em><strong>hdparm -N p3907029168 /dev/sdb</strong></em></p>
<p>Finally, we should end up with full usability of the drive.</p>
<p><em><strong>fdisk -l /dev/sdb</strong></em></p>
<blockquote><p>
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes<br />
255 heads, 63 sectors/track, 243201 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0&#215;00000000</p>
<p>Disk /dev/sdb doesn&#8217;t contain a valid partition table
</p></blockquote>
<p>Power cycle (not reboot) to confirm settings survive.</p>
<p>References:<br />
Updating the firmware on the drives:<br />
<a href="http://niallbest.com/seagate-2tb-st32000542as-cc35-firmware-upgrade/"> Seagate 2TB ST32000542AS CC35 Firmware upgrade</a></p>
<p>Disabling HPA using hdparm:<br />
<a href="http://lime-technology.com/forum/index.php?topic=4194.msg37010#msg37010"> unRAID Server Community parity</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/03/05/seagate-st32000542as-2tb-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian Squeeze iscsitarget</title>
		<link>http://tech.kulish.com/2011/03/04/debian-squeeze-iscsitarget/</link>
		<comments>http://tech.kulish.com/2011/03/04/debian-squeeze-iscsitarget/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 01:25:20 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[iscsi]]></category>
		<category><![CDATA[nas]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=262</guid>
		<description><![CDATA[Since Debian squeeze doesn&#8217;t appear to include pre-built iscsitarget kernel modules, the iscsitartget-dkms must be installed. This is a source package and will install gcc etc to compile. It should compile automatically. apt-get install iscsitarget-dkms Here is a list of iscsi related packages I installed on my secondary NAS: iscsitarget 1.4.20.2-1 iSCSI Enterprise Target userland [...]]]></description>
			<content:encoded><![CDATA[<p>Since Debian squeeze doesn&#8217;t appear to include pre-built iscsitarget kernel modules, the iscsitartget-dkms must be installed.  This is a source package and will install gcc etc to compile.  It should compile automatically.</p>
<p>apt-get install iscsitarget-dkms</p>
<p>Here is a list of iscsi related packages I installed on my secondary NAS:<br />
iscsitarget             1.4.20.2-1                   iSCSI Enterprise Target userland tools<br />
iscsitarget-dkms     1.4.20.2-1                   iSCSI Enterprise Target kernel module source &#8211; dkms version<br />
open-iscsi             2.0.871.3-2squeeze1     High performance, transport independent iSCSI implementation</p>
<p>I found this info in a bug report through google after I received a module not found error when issuing a /etc/init.d/iscsitarget restart</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/03/04/debian-squeeze-iscsitarget/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Email Cleanup</title>
		<link>http://tech.kulish.com/2011/02/19/email-cleanup/</link>
		<comments>http://tech.kulish.com/2011/02/19/email-cleanup/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 14:08:17 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Daemons]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[postfix]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=259</guid>
		<description><![CDATA[Our email server directories will be cleaned out February 28th. What this means&#8230; All ham and spam folders will be completely wiped cleaned. If you have email in either folder on your account, move it to your inbox or create a new folder to store it. Thanks. The Administration]]></description>
			<content:encoded><![CDATA[<p>Our email server directories will be cleaned out February 28th.</p>
<p>What this means&#8230;</p>
<p>All ham and spam folders will be completely wiped cleaned.<br />
If you have email in either folder on your account, move it to your inbox or create a new folder to store it.</p>
<p>Thanks.<br />
The Administration</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/02/19/email-cleanup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTTPS Redirects</title>
		<link>http://tech.kulish.com/2011/02/18/https-redirects/</link>
		<comments>http://tech.kulish.com/2011/02/18/https-redirects/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 17:17:44 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Daemons]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=248</guid>
		<description><![CDATA[Redirecting HTTP to HTTPS for a whole site using virtual hosts: #Basics snipped for brevity.... RewriteEngine on #RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] RedirectPermanent / https://www.foo.com/]]></description>
			<content:encoded><![CDATA[<p>Redirecting HTTP to HTTPS for a whole site using virtual hosts:</p>
<blockquote>
<pre><code>

<VirtualHost>

#Basics snipped for brevity....

<Directory /var/www/foo/html>
   RewriteEngine on
   #RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

RedirectPermanent / https://www.foo.com/
</VirtualHost>
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/02/18/https-redirects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CTRL-ALT-DEL: Debian on Desktop</title>
		<link>http://tech.kulish.com/2011/01/25/ctrl-alt-del-debian-on-desktop/</link>
		<comments>http://tech.kulish.com/2011/01/25/ctrl-alt-del-debian-on-desktop/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 19:17:49 +0000</pubDate>
		<dc:creator>Null</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[VM]]></category>

		<guid isPermaLink="false">http://tech.kulish.com/?p=237</guid>
		<description><![CDATA[I run debian+gnome on a VMware desktop. One of the annoying things is when I press CTRL-ALT-DEL to lock Windows (the hosting OS), the guest OS picks it up and I come back to a powered down VM. Google results will tell you that disabling it in /etc/inittab or gconf-edit will do the trick. That&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I run debian+gnome on a VMware desktop.  One of the annoying things is when I press CTRL-ALT-DEL to lock Windows (the hosting OS), the guest OS picks it up and I come back to a powered down VM.</p>
<p>Google results will tell you that disabling it in /etc/inittab or gconf-edit will do the trick.  That&#8217;s just not the case.</p>
<p>You need to go to system > preferences > keyboard shortcuts and disable it there.</p>
<p>This completely disables it.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.kulish.com/2011/01/25/ctrl-alt-del-debian-on-desktop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: kulish.com @ 2012-02-07 17:43:24 by W3 Total Cache -->
