<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss 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" version="2.0">

<channel>
	<title>Trendics Blog</title>
	
	<link>http://blog.trendics.com</link>
	<description />
	<pubDate>Mon, 11 Aug 2008 14:59:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/trendics" type="application/rss+xml" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">2177151</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://www.feedburner.com</feedburner:feedburnerHostname><item>
		<title>6 Essential Javascript String Functions</title>
		<link>http://blog.trendics.com/development/javascript/6-essential-javascript-string-functions/</link>
		<comments>http://blog.trendics.com/development/javascript/6-essential-javascript-string-functions/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 14:00:25 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=128</guid>
		<description><![CDATA[Here are six essential string functions to extend the functions for strings in javascript.  If you are already using a major javascript framework like MooTools or Prototype, you may find many of these redundant with your javascript framework.  In our case, we used YUI to develop our Trendics Control Panel and YUI didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Here are six essential string functions to extend the functions for strings in javascript.  If you are already using a major javascript framework like MooTools or Prototype, you may find many of these redundant with your javascript framework.  In our case, we used <a href="http://developer.yahoo.com/yui">YUI</a> to develop our <a href="https://cp.trendics.com/register">Trendics Control Panel</a> and YUI didn&#8217;t include these type of string prototype functions (similar functions are available in YAHOO.lang but these are not as convenient to call)&#8230;</p>
<pre style="padding-left: 30px;">// Returns the string with all the beginning
// and ending whitespace removed
String.prototype.trim = function() {
  return this.replace(/^\s+/, '').replace(/\s+$/, '');
};

// Returns the left x characters of the string
String.prototype.left = function(count) {
  if (this.length&gt;count) {
    return this.substring(0, count);
  }
  else {
    return this;
  }
}

// Returns the right x characters of the string
String.prototype.right = function(count) {
  if (this.length&gt;count) {
    return this.substring(this.length-count, this.length);
  }
  else {
    return this;
  }
}

// Returns true if the string begins with value
String.prototype.startsWith = function(value) {
  if (this.length&lt;value.length) {
    return false;
  }
  else {
    return this.substring(0, value.length)===value;
  }
}

// Returns true if the string ends with value
String.prototype.endsWith = function(value) {
   if (this.length&lt;value.length) {
    return false;
  }
  else {
    return this.substring(this.length-value.length, this.length)===value;
  }
}

// Returns a shortened version of the string
// suffixed with "..." if characters are truncated
// from the original string
String.prototype.shorten = function(maxLength) {
  if (!this) {
    result = null;
  }
  else if (this.length&gt;maxLength) {
    preferredSize = maxLength-'...'.length;
    if (preferredSize&gt;0) {
      result = this.left(preferredSize) + '...';
    }
    else {
      result = this.left(maxLength);
    }
  }
  else {
    result = this;
  }
  return result;
}</pre>
<p>The functions above can be invoked on any javascript string like this&#8230;</p>
<p style="padding-left: 30px;"><code>alert("   Hello  ".trim());</code></p>
<p style="padding-left: 30px;"><code>var message = "This is a longer sentence.";<br />
alert(message.shorten(10));</code></p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/development/javascript/6-essential-javascript-string-functions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Launched Status Badges</title>
		<link>http://blog.trendics.com/trendics/launched-status-badges/</link>
		<comments>http://blog.trendics.com/trendics/launched-status-badges/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 23:15:15 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[trendics]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=125</guid>
		<description><![CDATA[We&#8217;ve launched status badges that allow you to display the status of any alert rule on your own website.  So, you might create this display on your own website&#8230;



Server
HTTP
POP3
FTP


Jupiter





Saturn





Venus






To embed the alert rule statuses in your pages, you can get the Status Badge HTML simply by&#8230;

Logging in at https://cp.trendics.com
Clicking Devices in the top navigation [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve launched status badges that allow you to display the status of any alert rule on your own website.  So, you might create this display on your own website&#8230;</p>
<table id="status-table" border="0">
<tbody>
<tr>
<th style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px">Server</th>
<th style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px">HTTP</th>
<th style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px">POP3</th>
<th style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px">FTP</th>
</tr>
<tr>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px">Jupiter</td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-clear-1.gif" alt="" /></td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-clear-1.gif" alt="" /></td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-clear-1.gif" alt="" /></td>
</tr>
<tr>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px">Saturn</td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-clear-1.gif" alt="" /></td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-clear-1.gif" alt="" /></td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-clear-1.gif" alt="" /></td>
</tr>
<tr>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px">Venus</td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-clear-1.gif" alt="" /></td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-alert-1.gif" alt="" /></td>
<td style="border: 1px solid #D0D0D0; margin: 0px; padding: 8px"><img style="border:none" src="http://api.trendics.com/img/alert-def-status-alert-1.gif" alt="" /></td>
</tr>
</tbody>
</table>
<p>To embed the alert rule statuses in your pages, you can get the <em>Status Badge HTML</em> simply by&#8230;</p>
<ol>
<li>Logging in at <a href="https://cp.trendics.com">https://cp.trendics.com</a></li>
<li>Clicking <em>Devices</em> in the top navigation bar</li>
<li>Clicking on <em>Manage Status Badge</em></li>
<li>Copying the displayed <em>Badge HTML</em></li>
</ol>
<p>You can also customize the images used for the status on the same <em>Manage Status Badge</em> form.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/trendics/launched-status-badges/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL Stored Procedure Not Working as Expected Puzzler</title>
		<link>http://blog.trendics.com/development/mysql/mysql-stored-procedure-not-working-as-expected-puzzler/</link>
		<comments>http://blog.trendics.com/development/mysql/mysql-stored-procedure-not-working-as-expected-puzzler/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 17:26:53 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[mysql]]></category>

		<category><![CDATA[parameter names]]></category>

		<category><![CDATA[stored procedures]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=120</guid>
		<description><![CDATA[I recently spent 3 hours pulling my hair out trying to fix a MySQL stored procedure that wasn&#8217;t working as expected.  I&#8217;ve boiled the ultimate problem down to a simple example below.  Can you spot the problem?
# First, let's create some sample data
CREATE TABLE TrendicsTest (
DateTime DATETIME NOT NULL,
Value INT NOT NULL,
UNIQUE KEY [...]]]></description>
			<content:encoded><![CDATA[<p>I recently spent 3 hours pulling my hair out trying to fix a MySQL stored procedure that wasn&#8217;t working as expected.  I&#8217;ve boiled the ultimate problem down to a simple example below.  Can you spot the problem?</p>
<p style="padding-left: 30px;"><code># First, let's create some sample data<br />
CREATE TABLE TrendicsTest (<br />
DateTime DATETIME NOT NULL,<br />
Value INT NOT NULL,<br />
UNIQUE KEY DateTime (DateTime)<br />
);<br />
INSERT INTO TrendicsTest VALUES ('2008-01-01 01:00', 1);<br />
INSERT INTO TrendicsTest VALUES ('2008-01-01 02:00', 2);</p>
<p style="padding-left: 30px;"><code># Next, lets' define a stored procedure to query the sample data<br />
DELIMITER |<br />
DROP PROCEDURE IF EXISTS summarizeTrendicsTest|<br />
CREATE PROCEDURE summarizeTrendicsTest(dateTime DATETIME)<br />
BEGIN<br />
SELECT @endDateTime := DATE_ADD(dateTime, INTERVAL 1 HOUR);<br />
SELECT * FROM TrendicsTest WHERE DateTime=@endDateTime;<br />
END;<br />
|<br />
DELIMITER ;</p>
<p style="padding-left: 30px;"><code># Now, let's call the stored procedure and expect<br />
# to get back the first row of data<br />
call summarizeTrendicsTest('2008-01-01 00:00');</p>
<p>What the hell?  The first SELECT that sets @endDateTime variable echoes a result but the main SELECT returns an empty set.  Just to check our query, let's make sure the query runs ok...</p>
<p style="padding-left: 30px;"><code># Add one hour to the time just like the stored procedure<br />
SELECT * FROM TrendicsTest WHERE DateTime='2008-01-01 01:00';</p>
<p>Yes, running the query returns data so why doesn't the stored procedure return any data that appears to be running the same SELECT?  Evidently, using "dateTime" for the stored procedure param and using "DateTime" for the field in the WHERE clause confuses MySQL.  The stored procedure can be fixed by renaming the param name to something else...</p>
<p style="padding-left: 30px;"><code>DELIMITER |<br />
DROP PROCEDURE IF EXISTS summarizeTrendicsTest|<br />
CREATE PROCEDURE summarizeTrendicsTest(dateTimeXyz DATETIME)<br />
BEGIN<br />
SELECT @endDateTime := DATE_ADD(dateTimeXyz, INTERVAL 1 HOUR);<br />
SELECT * FROM TrendicsTest WHERE DateTime=@endDateTime;<br />
END;<br />
|<br />
DELIMITER ;</p>
<p style="padding-left: 30px;"><code># Now, let's call the stored procedure and expect<br />
# to get back the second row of data<br />
call summarizeTrendicsTest('2008-01-01 00:00');</p>
<p>Bah, in a complex stored procedure that is really not so easy to figure out.  So, <strong>be careful with your choice of stored procedure parameter names &#8212; avoid using a parameter name that is the same as a field name in your tables</strong>.  Seems like the MySQL stored procedure compiler should at least warn you when this happens if not throw an error.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/development/mysql/mysql-stored-procedure-not-working-as-expected-puzzler/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Launched Live Chat Provider and Shopping Cart Provider Stats</title>
		<link>http://blog.trendics.com/trendics/launched-live-chat-provider-and-shopping-cart-provider-stats/</link>
		<comments>http://blog.trendics.com/trendics/launched-live-chat-provider-and-shopping-cart-provider-stats/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 18:12:28 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[trendics]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=116</guid>
		<description><![CDATA[We&#8217;ve launched a Live Chat Provider Uptime and Latency section and a Shopping Cart Provider Uptime and Latency section at http://tools.trendics.com today.
Both sections have limited data initially but we&#8217;ll continue to gather data on major live chat providers and major shopping cart providers to compare their uptimes and latencies over longer and longer periods of [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve launched a <a href="http://tools.trendics.com/live-chat">Live Chat Provider Uptime and Latency</a> section and a <a href="http://tools.trendics.com/shopping-cart">Shopping Cart Provider Uptime and Latency</a> section at <a href="http://tools.trendics.com/">http://tools.trendics.com</a> today.</p>
<p>Both sections have limited data initially but we&#8217;ll continue to gather data on major live chat providers and major shopping cart providers to compare their uptimes and latencies over longer and longer periods of time.</p>
<p>In addition, we decided to split out email hosting from web hosting at <a href="http://tools.trendics.com/">http://tools.trendics.com</a>.</p>
<p>Let us know if there are other categories of online service providers you would like to see us launch.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/trendics/launched-live-chat-provider-and-shopping-cart-provider-stats/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using YUI to provide help for web forms</title>
		<link>http://blog.trendics.com/development/yui/using-yui-to-provide-help-for-web-forms/</link>
		<comments>http://blog.trendics.com/development/yui/using-yui-to-provide-help-for-web-forms/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 20:17:41 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=109</guid>
		<description><![CDATA[Users are more likely to complete your web forms if you provide a simple help system to answer common questions to complete each input.  There are a couple of common techniques to provide help for individual form inputs&#8230;

Help text under the form inputs - often too limited in space and/or clutters the form too [...]]]></description>
			<content:encoded><![CDATA[<p>Users are more likely to complete your web forms if you provide a simple help system to answer common questions to complete each input.  There are a couple of common techniques to provide help for individual form inputs&#8230;</p>
<ul>
<li>Help text under the form inputs - often too limited in space and/or clutters the form too much to provide detailed help</li>
<li>Clickable help icons next to the form elements - can either show the help when moused over or when clicked but either way require an additional action from the user to see the help</li>
</ul>
<p>I prefer to show a help tooltip automatically to the right of the input when an input gains the focus.  Unlike normal tooltips, the tooltip remains visible as long as the input has the focus allowing the user to refer back to the tooltip as needed while entering the input.  Tab through each field in the form below to see this in action&#8230;</p>
<p><iframe src="http://blog.trendics.com/wp-content/uploads/2008/08/yformtip-example.html" width="500" height="400"></iframe></p>
<p>The tooltips in the form above are implemented using <a href="http://developer.yahoo.com/yui/">YUI</a> in a Javascript class call YFormTip.  Both the <a href="http://blog.trendics.com/wp-content/uploads/2008/08/yformtip-example.html">formtip-example.html</a> and the <a href="http://blog.trendics.com/wp-content/uploads/2008/08/yformtip.js">yformtip.js</a> are available to download free of course.</p>
<p>None of this is rocket science but it is my $0.02 on providing context sensitive help for web forms.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/development/yui/using-yui-to-provide-help-for-web-forms/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Launched Auto-Trace Route Feature</title>
		<link>http://blog.trendics.com/trendics/launched-auto-trace-route-feature/</link>
		<comments>http://blog.trendics.com/trendics/launched-auto-trace-route-feature/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 23:02:32 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[trendics]]></category>

		<category><![CDATA[auto trace route]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=106</guid>
		<description><![CDATA[Today, we launched a couple of new features designed to help troubleshoot intermittent connectivity problems&#8230;

The new Auto Trace Route feature will automatically perform a trace route after a ping test fails.  The trace route output can be reviewed within the Alert History section of the Trendics Control Panel.
The new Selectable Monitor Aggregation feature allows choosing [...]]]></description>
			<content:encoded><![CDATA[<p>Today, we launched a couple of new features designed to help troubleshoot intermittent connectivity problems&#8230;</p>
<ul>
<li>The new <strong>Auto Trace Route</strong> feature will automatically perform a trace route after a ping test fails.  The trace route output can be reviewed within the <em>Alert History</em> section of the <a href="https://cp.trendics.com">Trendics Control Panel</a>.</li>
<li>The new <strong>Selectable Monitor Aggregation</strong> feature allows choosing within an <em>Alert Rule</em> how all the monitor results are summarized to compare to the alert trigger.  Users can now choose to perform a Median, Average, All, or Any calculation across the monitor results within the <em>Alert Rule</em>.  The <em>Any</em> calculation is the most sensitive triggering alerts when any failure is detected from any monitoring location and the <em>All</em> calculation forces all monitors to report a problem before an alert is triggered.  In most cases the <em>Median</em> calculation is the best compromise as this effectively requires at least 50% of the monitors to detect a problem before an alert is triggered.</li>
</ul>
<p>In a follow-up post, we&#8217;ll discuss how to combine these features to troubleshoot intermittent connectivity problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/trendics/launched-auto-trace-route-feature/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Launched DNS Tests and FTP Connection Tests</title>
		<link>http://blog.trendics.com/trendics/launched-dns-tests-and-ftp-connection-tests/</link>
		<comments>http://blog.trendics.com/trendics/launched-dns-tests-and-ftp-connection-tests/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 21:20:04 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[trendics]]></category>

		<category><![CDATA[dns ftp]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=101</guid>
		<description><![CDATA[Today, we launched DNS and FTP Connection tests.  Within the Devices section of the Trendics Control Panel, you can now choose Add DNS Test or Add FTP Connection Test in the device action menus.
The DNS Test allows specifying a name server to be tested, a query to execute, and an answer to verify the result.  [...]]]></description>
			<content:encoded><![CDATA[<p>Today, we launched DNS and FTP Connection tests.  Within the <em>Devices</em> section of the <a href="https://cp.trendics.com/device">Trendics Control Panel</a>, you can now choose <em>Add DNS Test</em> or <em>Add FTP Connection Test</em> in the device action menus.</p>
<p>The <em>DNS Test</em> allows specifying a name server to be tested, a query to execute, and an answer to verify the result.  This DNS Test can check if a DNS server is responding and can also confirm that a domain continues to resolve correctly.</p>
<p>The <em>FTP Connection Test</em> allows specifying a host, a port, and receive text to confirm an FTP server is responding properly to connection requests.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/trendics/launched-dns-tests-and-ftp-connection-tests/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mass Find and Replace from Linux Shell</title>
		<link>http://blog.trendics.com/linux/mass-find-and-replace-from-linux-shell/</link>
		<comments>http://blog.trendics.com/linux/mass-find-and-replace-from-linux-shell/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 15:24:45 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=99</guid>
		<description><![CDATA[You can do a find and replace on files from the Linux shell using the find and sed commands.  The first example below shows doing a find and replace only in the current directory while the second example below shows doing a find and replace recursing into subdirectories&#8230;

Replace &#8220;www.trendics.com&#8221; with &#8220;tools.trendics.com&#8221; in all html [...]]]></description>
			<content:encoded><![CDATA[<p>You can do a find and replace on files from the Linux shell using the <code>find</code> and <code>sed</code> commands.  The first example below shows doing a find and replace only in the current directory while the second example below shows doing a find and replace recursing into subdirectories&#8230;</p>
<ol>
<li>Replace &#8220;www.trendics.com&#8221; with &#8220;tools.trendics.com&#8221; in all html files in the current directory&#8230;</li>
<p><code>find . </code><code> -maxdepth 1 </code><code>-name "*.html" -type f -exec sed -i 's/www.trendics.com/tools.trendics.com/' {} \;</code></p>
<li>Replace &#8220;www.trendics.com&#8221; with &#8220;tools.trendics.com&#8221; in all text files and all subdirectories&#8230;</li>
<p><code>find . -name "*.txt" -type f -exec sed -i 's/www.trendics.com/tools.trendics.com/' {} \;</code></ol>
<p>Here is how this works&#8230;</p>
<ul>
<li> The dot after the find command specifies to start in the current directory</li>
<li>The <code>-maxdepth 1</code> specifies to only include the current directory</li>
<li>The <code>-name "*.txt"</code> switch specifies to only find txt files</li>
<li>The <code>-type f</code> specifies to only match files</li>
<li>The <code>-exec xyz {} \;</code> specifies to execute xyz for each file where xyz is a sed command specifying to substitute &#8220;tools.trendics.com&#8221; for &#8220;www.trendics.com&#8221;</li>
</ul>
<p>Refer to the documentation on the <a href="http://linux.die.net/man/1/find">find</a> and <a href="http://linux.die.net/man/1/sed">sed</a> for additional options.</p>
<p>Before you run this on your important files, I&#8217;d recommend backing up your important files and I&#8217;d recommend testing your modified find command in a subdirectory with test files to ensure your find command is working as expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/linux/mass-find-and-replace-from-linux-shell/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Four Commands to Analyze Connection Usage under Linux</title>
		<link>http://blog.trendics.com/linux/four-commands-to-analyze-connection-usage-under-linux/</link>
		<comments>http://blog.trendics.com/linux/four-commands-to-analyze-connection-usage-under-linux/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 16:11:28 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=86</guid>
		<description><![CDATA[Is someone establishing an excessive number of connections to your Linux server? Here are the commands I like to run to analyze connection usage.
First, let&#8217;s just store off the netstat output so we don&#8217;t have to retrieve it repeatedly&#8230;
echo "Saving current connections..."
netstat -nta &#62; /tmp/netstat.txt
Next, let&#8217;s see the number of connections per IP address by [...]]]></description>
			<content:encoded><![CDATA[<p>Is someone establishing an excessive number of connections to your Linux server? Here are the commands I like to run to analyze connection usage.</p>
<p>First, let&#8217;s just store off the netstat output so we don&#8217;t have to retrieve it repeatedly&#8230;</p>
<blockquote><p><code>echo "Saving current connections..."<br />
netstat -nta &gt; /tmp/netstat.txt</code></p></blockquote>
<p>Next, let&#8217;s see the number of connections per IP address by extracting the IP address from the netstat output, counting the number of times each IP address was listed in the netstat output, and printing the top 10 (adjust <code>head -10</code> appropriately if you&#8217;d like to see more than the top 10)&#8230;</p>
<blockquote><p><code>echo "Number of connections per IP..."<br />
cut -b 49-75 /tmp/netstat.txt | grep -o -P "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b" | sort | uniq -c | sort -n -r -k 1,7 | head -10</code></p></blockquote>
<p>If there is an excessive number of connections from a single IP, you may want to take action to block this IP.</p>
<p>Next, let&#8217;s see the number of connections in different states by extracting the state from the netstat output, and counting the number of times each state was listed in the netstat output&#8230;</p>
<blockquote><p><code>echo "States of connections..."<br />
cut -b 77-90 /tmp/netstat.txt | sort | uniq -c</code></p></blockquote>
<p>The key reason to run this is to understand if you might be under a syn-flood attack. If you see an excessive number of connections in the SYN_RECV state, you may be under a syn-flood attack. It is normally unusual to see a high percentage of connections in a SYN_RECV state.</p>
<p>Next, let&#8217;s see the IP addresses generating connections currently in the SYN_RECV state by grepping the netstat output appropriately, counting the number of times each IP address was listed in the netstat output, and printing the top 10 (adjust <code>head -10</code> appropriately if you&#8217;d like to see more than the top 10)&#8230;</p>
<blockquote><p><code>echo "Number of SYN_RECV connections per IP..."<br />
fgrep "SYN_RECV" /tmp/netstat.txt | cut -b 49-75 | cut -d ':' -f1 | sort | uniq -c | sort -n -r -k 1,7 | head -10</code></p></blockquote>
<p>If the above command does not return any output, you simply do not have any connections in the SYN_RECV state which is good.</p>
<p>With all the above commands, we&#8217;ve analyzed the current connections to the server; however, this is not enough as you may not see IP addresses establishing lots of short connections. To analyze the number of <strong>new</strong> connections established to your server, you can execute this&#8230;</p>
<blockquote><p><code>echo "Count number of new connection requests over the next 100 packets..."<br />
time tcpdump -ns 200 -c 100 &#039;(dst port http or dst port https) and tcp[13] &amp; 2!=0&#039; | grep -o -P &#039;\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,5}\s\>&#039; | cut -d &#039;.&#039; -f 1-4 | sort | uniq -c | sort -n -r -k 1,7 | head -25</code></p></blockquote>
<p>For this command, the -c parameter specified how many packets to analyze. Generally, I like to have this command run for about 30 seconds and I adjust the -c parameter to make it run over 30 seconds (very busy servers will need a much larger -c value and very light servers will need a much smaller -c value).</p>
<p>If the above command doesn&#8217;t ever return data, you have the -c parameter too high &#8212; basically the command blocks until the number of specified packets is received and your server has not yet received that number of packets.</p>
<p>In addition, the command above is only analyzing http/https connections; however, you can change the <code>dst port http or dst port https</code> to check other types of connections (consult the <a href="http://linux.die.net/man/8/tcpdump">tcpdump documentation</a>).</p>
<p>Also, it is useful to run all the commands above under normal conditions so you have a baseline to compare against when something abnormal occurs.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/linux/four-commands-to-analyze-connection-usage-under-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Argument List Too Long Message in Linux</title>
		<link>http://blog.trendics.com/linux/argument-list-too-long-message-in-linux/</link>
		<comments>http://blog.trendics.com/linux/argument-list-too-long-message-in-linux/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 18:30:44 +0000</pubDate>
		<dc:creator>kent</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[linux tip howto delete files]]></category>

		<guid isPermaLink="false">http://blog.trendics.com/?p=82</guid>
		<description><![CDATA[So, you&#8217;ve filled up a directory with so many files that executing a rm -f * tells you Argument list too long.  Now what?  You can run this to remove the files in a directory too full to use rm -f *&#8230;
# Don't forget to execute this in the right directory!
cd /the-right-directory
# Let's [...]]]></description>
			<content:encoded><![CDATA[<p>So, you&#8217;ve filled up a directory with so many files that executing a <code>rm -f *</code> tells you <code>Argument list too long</code>.  Now what?  You can run this to remove the files in a directory too full to use <code>rm -f *</code>&#8230;</p>
<blockquote><p><code># Don't forget to execute this in the right directory!<br />
cd /the-right-directory</code></p>
<p><code># Let's preview what will get deleted just to be sure</code><br />
<code>find . -maxdepth 1 -name "*" -type f -exec echo {} \;<br />
</code><br />
<code># OK, let's do this<br />
</code><code>find . -maxdepth 1 -name "*" -type f -exec rm -v {} \;</code></p></blockquote>
<p>What is this last find doing?  The dot after find says to do this in the current directory, the <code>-maxdepth 1</code> parameter says not to recurse into subdirectories, the <code>-name "*"</code> parameter says to match any file, the <code>-type f</code> parameter says to do this only on files, and the <code>-exec xyz \;</code> says to execute xyz for each file where xyz is a <code>rm -v</code> command with <code>{}</code> being the name of the current file.</p>
<p><strong>Important:</strong> This is doing a permanent wildcard delete in a directory.  Double check you understand what you are doing before you execute this command.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trendics.com/linux/argument-list-too-long-message-in-linux/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
