Tech
Linux IO: Part 1 – Disk and Network
by alowe on Jul.07, 2010, under System Admin
Linux IO is a pretty big topic, and this is just a quick entry with some links and notes about tools I have found, I hope to do a more in depth look later.
First up Network IO:
The command ifstat gives you a pretty decent look at current bandwidth usage. ifstat -l will also show loopback devices
Next Up Disk IO, this is a pretty big one, as this is probably a big cause of system load in my environments.
The command iostat gives a basic run down of the disk usage.
Using the eXtended option iostat -x gives you a more detailed look, and is much more useful in finding issues.
Running with an interval at the end will re-run the stats using live data, which again is more useful, and will refresh the display: iostat -x 1 will refresh the data every 1 second.
- r/s and w/s are the requests by a process to read and write to the device
- rsec/s and wsec/s sectors per second.
- avgrq-sz is the average sectors per request (both read an write). Divide by 2 to get bytes.
- avgqu-sz is the average queue length
- await is the average wait time for a request, includes the queue time and the service time
- svctm is the average time spent servicing requests, the actual read/write time
- %util is the utilisation percentage, not quite accurate on shared storage/multiple disk raid
To calculate the queue time, take the svctm from await.
If the queue time is greater then the service time, then the device is probably overloaded. Ideally the await should be pretty much equal to the svctm figure, as then there are not many requests being queued.
Some good references:
Quick Reference about iostat
http://www.pythian.com/news/247/basic-io-monitoring-on-linux/
and a detailed blog entry on iostat, and linux disk IO in general…
http://blog.serverfault.com/post/777852755/interpreting-iostat-output
As a final note, for VMWare ESX, have a look at esxtop, and use the d and v and u keys to display various disk related stats, see man esxtop for more, and I hope to cover more later…
VSphere 4 Essentials Plus – Adding Hosts
by alowe on Feb.05, 2010, under Tech
VSphere 4 Essentials Plus is a cheaper option giving you 3 ESX hosts and a Management Server (VirutalCenter)
When adding hosts that have ISCSI storage you may get an error indicating that you need a VMotion License, and to upgrade your host.
Essentials Plus licences do not include VMotion.
You need to edit the ESX Host Storage Network adaptor, and untick the “Enable VMotion” box. This option is causing the error message.
Using SOAP with PHP 5.2 Object References and .Net
by alowe on Nov.02, 2009, under Programming
PHP 5 introduces object references, where objects are assigned by reference (when you do $b=$a) they both point to the same object. This causes problems when using references with the SOAP server functions.
With earlier version of the SOAP library (5.1, etc) the soap server translated these into the full object (very pseudo code):
As of PHP 5.2, the SOAP code, translates this to use references:
This causes problems with .Net clients and servers, which don’t respect the href options.
The solution, use clone: $b=clone $a.
For more detail where Thijs Feryn has a great article on the topic …
http://blog.feryn.eu/2009/01/warning-object-references-affect-xml-serialization/
Soap Client Max Message Size
by alowe on Oct.28, 2009, under Programming
Just found a solution to the max message size exceeded exception that is generated on large soap messages:
http://craigrandall.net/archives/2009/04/maxreceivedmessagesize/
Quick summary: update the values in the binding in the app.config file.
Force UNC Path
by alowe on Oct.08, 2009, under Programming
Some applications I have written have data files that are required to be opened by multiple users on different computers.  These data files are, of course, stored on a common file server.
Usually the user doing the data-entry will have the path mapped as a network drive such as “u:\”. The people who need to look at the data files may not have the drive mapped, or may have it mapped as a different drive letter. The solution is to store the path as a Uniform Naming Convention (UNC) path, such as: “\\myserver\datafiles\”
The quick solution, is when they type the path, just check the string starts with “\\\\” (we check that there are two backslash characters: “\”, however because this is a special character we need to escape it with a backslash).  This way we know it will be a network path.
Usually a user will want to browse to the directory or file, and you would use the standard .Net widgets for these tasks.  The data-entry user will usually have the path mapped as a network drive and try to browse to that, and you checks will detect that the string stored does not start with “\\\\”, but rather “u:\” and display an error to the user.  This is not very productive to the user, who will have to work out how to fix the problem, if they even understand the problem.
What we need is a method to re-map the mapped network drive to the full UNC path, and this is provided bellow:
public string getUNCPath(string sFilePath)
{
if (sFilePath == string.Empty || sFilePath.StartsWith("\\\\"))
return sFilePath;
System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher("SELECT RemoteName FROM win32_NetworkConnection WHERE LocalName = '" + sFilePath.Substring(0, 2) + "'");
foreach (System.Management.ManagementObject managementObject in searcher.Get())
{
string sRemoteName = managementObject["RemoteName"] as string;
sRemoteName += sFilePath.Substring(2);
return sRemoteName;
}
return sFilePath;
}
After this, a simple check to make sure the string starts with “\\\\” is sufficient to verify that you are storing a UNC path.