Wednesday, March 14, 2012

How to test for packet loss on a broadband connection

— SkyHi @ Wednesday, March 14, 2012
Measuring packet loss from home over a broadband connection can be a difficult task. Packet loss can occur anywhere along the path between your computer and the destination you are trying to reach over the Internet. Packet loss is typically a result of one or more of the following: network congestion, overworked routers and switches, slow roundtrip times, or possibly a result of traffic prioritization schemes used by service providers or the company hosting the site you are trying to access.

Without actively measuring the TCP flows of actual retransmissions (these products are usually too expensive to use for a home broadband connection), it is hard to determine if there are real retransmissions occurring. The mechanisms you mentioned, ping and trace route, are the most readily available tools for at-home users for helping to determine where there is slowness on the Internet. Ping measures the roundtrip time between your computer and the IP address you are pinging. Trace route measures the response times of the routers along the path between your computer and the IP address you are trace routing.

Using Ping

The best way to measure packet loss using ping is to send a large number of pings to an IP address, and then look for failed responses to those pings. For instance, if you ping something 50 times in a rapid fashion, you can measure the number of failed responses and use this as an estimate of "packet loss." Anything over five percent is probably something to be concerned about.

On a Windows machine, this can be accomplished by using the following command at the command prompt:

Ping -n 50 (IP Address or domain name [www.website.com])>
The "–n" tells ping to send a set number of pings, and "50" is the number to send.

Afterwards, you will get a summary of the test that includes the number lost and a percentage:

Ping statistics for 199.181.132.250:
Packets: Sent = 6, Received = 6, Lost = 0 (0%)
Approximate round trip times in milliseconds:
Minimum = 26ms, Maximum = 29ms, Average = 27ms
If you see a very high average roundtrip time (greater then 100ms), this will also cause you to experience slow network downloads.

One way to try to eliminate certain parts of the network that may be the cause of packet loss is to do the ping test along various segments along the path. The first place I normally start testing is the local "default gateway." This is the first router that all your data is transmitted to on the network. If there is high packet loss on this segment, then the problem is localized to your service provider's network.

You can find the IP address of your default router by typing in the "ipconfig" command at your Windows command prompt. This will display the following:

Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix_: domainname.com
IP Address. . . . . . . . . . . . : 192.168.2.189
Subnet Mask . . . . . . . . . . . : 255.255.252.0
Default Gateway . . . . . . . . . : 10.10.0.1
What you are looking for is the default gateway IP address. In the example above, it is 10.10.0.1.

Using Trace route

Trace routes can be run by using the trace route command at the Windows command prompt. On Windows XP this is:

tracert (IP Address or Hostname)
While the output doesn't show you packet loss, it will show you if there are slow-responding routers along the path.

The output will show you the response time of all the routers. The following is an example:

5 ms 2 ms 3 ms malibu.domain.com [10.10.0.1]
10 ms 6 ms 7 ms 10.60.0.6
9 ms 7 ms 7 ms 10.20.0.1
6 ms 7 ms 7 ms x130.cd9e68.sj.concentric.net [205.158.104.130]
7 ms 7 ms 8 ms ge9-0.dcr2.dc-fremont-ca.us.xo.net [205.158.60.169]
7 ms 7 ms 7 ms ge2-0.dcr1.dc-fremont-ca.us.xo.net [65.106.2.205]
10 ms 7 ms 8 ms p5-1-0-2.rar2.sanjose-ca.us.xo.net [65.106.2.153]
10 ms 9 ms 11 ms p1-0.ir1.paloalto-ca.us.xo.net [65.106.5.178]
9 ms 10 ms 15 ms 206.111.12.114.ptr.us.xo.net [206.111.12.114]
9 ms 10 ms 10 ms svl-core-03.inet.qwest.net [205.171.205.29]
29 ms 28 ms 29 ms stl-core-02.inet.qwest.net [205.171.5.85]
30 ms 29 ms 29 ms sea-edge-03.inet.qwest.net [205.171.26.42]
* * * Request timed out.
* * * Request timed out.
28 ms 28 ms 29 ms sam.abcnews.go.com [199.181.132.250]
If you see trace route roundtrip times along the path greater than 100ms (1/10th of a second), this can cause slow transfer times over the network.

From the above, you can see that data travels along lots of different networks (XO, Qwest, ABC). This is part of the beauty of the Internet. The downside is that it places the ability to resolve slow response times out of the hands of individual users. The best place to start is to make sure that there is not packet loss between yourself and your service provider.



Measuring packet loss

n continuing on with my commitment to describe my favorite network utilities, I bring to you mtr:
$ mtr -r -c 10 mail.prefetch.net
HOST: me                           Loss%   Snt   Last   Avg  Best  Wrst StDev
  1. 10.238.4.1                    0.0%    10    9.2   8.2   5.4  12.6   2.1
  2. 68.86.108.13                  0.0%    10    9.2   9.4   6.3  14.9   2.8
  3. 68.86.106.45                  0.0%    10   15.1  10.1   6.9  17.5   3.5
  4. 68.86.106.13                  0.0%    10   14.0  11.0   5.7  22.1   4.8
  5. 68.86.106.9                   0.0%    10   14.6  11.4   7.2  18.5   3.6
  6. 12.118.120.89                 0.0%    10   10.2  10.3   8.2  14.6   2.2
  7. tbr1-p012201.attga.ip.att.ne  0.0%    10   23.8  25.8  21.8  33.9   3.6
  8. tbr2-cl1.wswdc.ip.att.net     0.0%    10   27.3  26.9  23.7  33.4   3.0
  9. ggr2-p390.wswdc.ip.att.net    0.0%    10   23.0  27.6  22.6  41.0   5.6
 10. so6-3-0-2488M.ar1.DCA3.gblx.  0.0%    10   26.0  30.4  23.9  43.3   6.3
 11. so0-0-0-622M.ar2.CLE1.gblx.n  0.0%    10  130.3  49.8  37.7 130.3  28.4
 12. Enet-Inc-Internet.so-0-3-3.a  0.0%    10   51.2  45.9  42.5  54.9   4.0
 13. extreme.xlhost.com            0.0%    10   44.2  67.1  41.4 261.4  68.3
 14. mail.prefetch.net            0.0%    10   48.3  56.6  41.5 172.9  40.9
mtr allows you to view hop-by-hop latency metrics, and is invaluable for finding busy devices between two endpoints. Some routers will place low QOS priorities on ICMP traffic, so it is important to capture traffic at various intervals to see if a device is truly overloaded.


REFERENCES
http://searchnetworking.techtarget.com/answer/How-to-test-for-packet-loss-on-a-broadband-connection
http://nixcraft.com/centos-rhel-fedora/15483-showing-packet-loss-interface.html
http://prefetch.net/blog/index.php/2005/08/29/measuring-packet-loss/

Supercharge WordPress, Part 1

— SkyHi @ Wednesday, March 14, 2012


Here are a few example configuration settings for servers of different memory sizes running both MySQL and a web server on the same machine. These are not perfect, but they are good starting points.
For servers with 512MB RAM:
thread_cache_size=50
key_buffer=40M
table_cache=384
sort_buffer_size=768K
read_buffer_size=512K
read_rnd_buffer_size=512K
query_cache_limit=2M
query_cache_size=16M
query_cache_type=1
thread_concurrency=2*CPU
skip-innodb
For servers with 1GB RAM:
thread_cache_size=80
key_buffer=150M
table_cache=512
sort_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=768K
query_cache_limit=4M
query_cache_size=32M
query_cache_type=1
thread_concurrency=2*CPU
skip-innodb
For servers with 2GB RAM:
thread_cache_size=80
key_buffer=350M
table_cache=1024
sort_buffer_size=2M
read_buffer_size=2M
read_rnd_buffer_size=768K
query_cache_limit=4M
query_cache_size=64M
query_cache_type=1
thread_concurrency=2*CPU
skip-innodb
Once WordPress has been up and running for some time you can tweak your settings by running MySQLTuner, a Perl script that analyzes your MySQL performance and, based on the statistics it gathers, gives recommendations about which variables you should adjust to increase performance. With MySQLTuner, you can tune your my.cnf file to tease out the last bit of performance from your MySQL server and make it work more efficiently.

REFERENCES
http://linuxaria.com/?p=3293?lang=en 
http://linuxaria.com/article/supercharge-wordpress-part-2?lang=en 

http://linuxaria.com/article/supercharge-wordpress-part-3?lang=en

10 lsof Command Examples

— SkyHi @ Wednesday, March 14, 2012
The lsof command or “list open files” command in Linux is a powerful tool. In Linux and Unix everything behind the scenes are just files. This includes IP sockets, pipes, unix sockets, directories, devices, even inodes are just files. This means that lsof can actually tell you a lot of information of what is going on on your system.

Synopsis

lsof [ -?abChlnNOPRstUvVX ] [ -A A ] [ -c c ] [ +|-d d ] [ +|-D D ] [ +|-f [cfgGn] ] [ -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k ] [ +|-L [l] ] [ -m m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r [t] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -- ] [names]

Example 1: Show all opened files

Type the following command
lsof | more
Sample outputs
COMMAND     PID      USER   FD      TYPE     DEVICE      SIZE       NODE NAME
init          1      root  cwd       DIR      253,4      4096          2 /
init          1      root  rtd       DIR      253,4      4096          2 /
init          1      root  txt       REG      253,4     38652   41746599 /sbin/init
init          1      root  mem       REG      253,4    129900   16252964 /lib/ld-2.5.so
init          1      root  mem       REG      253,4   1693812   16252965 /lib/libc-2.5.so
init          1      root  mem       REG      253,4     20668   16253168 /lib/libdl-2.5.so
init          1      root  mem       REG      253,4    245376   16253222 /lib/libsepol.so.1
init          1      root  mem       REG      253,4     93508   16253815 /lib/libselinux.so.1
init          1      root   10u     FIFO       0,17                 1277 /dev/initctl
...

Example 2: Show all opened internet sockets

Using the -i flag lsof will list the internet sockets currently opened
lsof -i
Sample outputs
COMMAND     PID   USER   FD   TYPE   DEVICE SIZE NODE NAME
sshd       2537   root    3u  IPv6     5348       TCP *:rockwell-csp2 (LISTEN)
mysqld     2625  mysql   11u  IPv4     5463       TCP *:mysql (LISTEN)
httpd      2731 apache    3u  IPv6 30048993       TCP *:http (LISTEN)
...

Example 3: Shows all networking related to a given port 80

lsof -i :80
Sample outputs
COMMAND   PID   USER   FD   TYPE   DEVICE SIZE NODE NAME
httpd    2731 apache    3u  IPv6 30048993       TCP *:http (LISTEN)
httpd    2731 apache   58u  IPv6 39448263       TCP server.com:http->adsl-dynamic-pool-xxx.hcm.fpt.vn:23527 (ESTABLISHED)
httpd    2731 apache   60u  IPv6 39448302       TCP server.com:http->crawl-66-249-69-83.googlebot.com:35190 (ESTABLISHED)
httpd    2731 apache   61u  IPv6 39448336       TCP server.com:http->v16-13.opera-mini.net:37548 (ESTABLISHED)
httpd    2731 apache   62u  IPv6 39448388       TCP server.com:http->v16-13.opera-mini.net:37561 (ESTABLISHED)
httpd    2731 apache   64u  IPv6 39447543       TCP server.com:http->adsl.viettel.vn:13636 (FIN_WAIT2)

Example 4: Show all TCP/UDP connections

lsof -i TCP
Sample outputs
sshd       2537   root    3u  IPv6     5348       TCP *:rockwell-csp2 (LISTEN)
mysqld     2625  mysql   11u  IPv4     5463       TCP *:mysql (LISTEN)
httpd      2731 apache    3u  IPv6 30048993       TCP *:http (LISTEN)
...

Example 5: List open files associated with process ID

The flag +p will display all open files associated with specific process ID, example with process ID is 2625
lsof +p 2625
Sample outputs
COMMAND  PID  USER   FD   TYPE     DEVICE      SIZE     NODE NAME
mysqld  2625 mysql  cwd    DIR      253,4      4096 21495811 /var/lib/mysql
mysqld  2625 mysql  rtd    DIR      253,4      4096        2 /
mysqld  2625 mysql  txt    REG      253,4   7020300 50999198 /usr/libexec/mysqld
mysqld  2625 mysql  DEL    REG      253,4           16253135 /lib/libcrypto.so.0.9.8e.#prelink#.64u8kX
mysqld  2625 mysql  mem    REG      253,4           16252984 /lib/libm-2.5.so (path inode=16253122)
mysqld  2625 mysql  DEL    REG      253,4           50996047 /usr/lib/libgssapi_krb5.so.2.2.#prelink#.YYIHuy
mysqld  2625 mysql  mem    REG      253,4           16252990 /lib/libselinux.so.1 (path inode=16253815)
mysqld  2625 mysql  mem    REG      253,4           16256252 /lib/libsepol.so.1 (path inode=16253222)
mysqld  2625 mysql  mem    REG      253,4     50848 16253138 /lib/libnss_files-2.5.so
mysqld  2625 mysql  mem    REG      253,4           16253825 /lib/librt-2.5.so (path inode=16253220)
mysqld  2625 mysql  mem    REG      253,4           16252942 /lib/ld-2.5.so (path inode=16252964)
mysqld  2625 mysql  mem    REG      253,4           50996107 /usr/lib/libstdc++.so.6.0.8 (path inode=50989584)
mysqld  2625 mysql  mem    REG      253,4           50996061 /usr/lib/libkrb5.so.3.3 (path inode=50999803)
mysqld  2625 mysql  mem    REG      253,4           16252980 /lib/libdl-2.5.so (path inode=16253168)
...

Example 6: Show what a given user has open

The flag -u will show what a given user has open
lsof -u apache
Sample outputs
COMMAND   PID   USER   FD   TYPE     DEVICE      SIZE     NODE NAME
httpd    2731 apache  cwd    DIR      253,4      4096        2 /
httpd    2731 apache  rtd    DIR      253,4      4096        2 /
httpd    2731 apache  txt    REG      253,4   3120954 51157630 /usr/local/apache/bin/httpd
httpd    2731 apache  mem    REG      253,4    375710 51157607 /usr/local/apache/lib/libaprutil-1.so.0.3.10
httpd    2731 apache  mem    REG      253,4     45432 16253184 /lib/libcrypt-2.5.so
httpd    2731 apache  mem    REG      253,4      7748 16253849 /lib/libcom_err.so.2.1
httpd    2731 apache  mem    REG      253,4      7880 16253845 /lib/libkeyutils-1.2.so
httpd    2731 apache  mem    REG      253,4    937178 51157689 /usr/local/apache/modules/mod_security2.so
httpd    2731 apache  mem    REG      253,4    129208 16253851 /lib/libpcre.so.0.0.1
...

Example 7: Pointing to a file shows what’s interacting with that file

Example, type the following command
lsof /var/log/messages
Sample outputs
COMMAND   PID USER   FD   TYPE DEVICE    SIZE     NODE NAME
syslogd  2424 root    2w   REG  253,4 1437387 21463252 /var/log/messages
lfd     20823 root    6r   REG  253,4 1437387 21463252 /var/log/messages

Example 8: Display who is accessing a device

lsof /dev/tty1
Sample outputs
COMMAND   PID USER   FD   TYPE DEVICE SIZE NODE NAME
mingetty 3032 root    0u   CHR    4,1       854 /dev/tty1
mingetty 3032 root    1u   CHR    4,1       854 /dev/tty1
mingetty 3032 root    2u   CHR    4,1       854 /dev/tty1

Example 9: What files and network connections a command

The flag -c to display files and network connections a command, example display files and network connections syslog command
lsof -c syslog
Sample outputs
COMMAND  PID USER   FD   TYPE     DEVICE    SIZE     NODE NAME
syslogd 2424 root  cwd    DIR      253,4    4096        2 /
syslogd 2424 root  rtd    DIR      253,4    4096        2 /
syslogd 2424 root  txt    REG      253,4   35832 41746614 /sbin/syslogd
syslogd 2424 root  mem    REG      253,4         16252949 /lib/libc-2.5.so (path inode=16252965)
syslogd 2424 root  mem    REG      253,4   50848 16253138 /lib/libnss_files-2.5.so
syslogd 2424 root  mem    REG      253,4         16252942 /lib/ld-2.5.so (path inode=16252964)
syslogd 2424 root    0u  unix 0xf7804040             5125 /dev/log
syslogd 2424 root    2w   REG      253,4 1439314 21463252 /var/log/messages
syslogd 2424 root    3w   REG      253,4   46447 21463260 /var/log/secure
syslogd 2424 root    4w   REG      253,4 3725001 21463266 /var/log/maillog
syslogd 2424 root    5w   REG      253,4  582424 21463282 /var/log/cron
syslogd 2424 root    6w   REG      253,4       0 21463270 /var/log/spooler
syslogd 2424 root    7w   REG      253,4       0 21463275 /var/log/boot.log

Example 10: Show all processes opening files in a directory

lsof +D /usr/bin/
Sample outputs
COMMAND     PID USER   FD   TYPE DEVICE  SIZE     NODE NAME
mysqld_sa  2574 root  255r   REG  253,4 13073 50999014 /usr/bin/mysqld_safe
munin-nod  2968 root  txt    REG  253,4 14984 50993003 /usr/bin/perl
lfd       20823 root  txt    REG  253,4 14984 50993003 /usr/bin/perl

References

The lsof man page



REFERENCES
http://www.lifelinux.com/10-lsof-command-examples/

Monday, March 12, 2012

Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple Content-Disposition headers received

— SkyHi @ Monday, March 12, 2012
I've just been looking at the similar issue.  After spending the best part of a day and a half stripping back our app.  It finally turned out to be an issue with us setting  "Content-Disposition" in the response header.  I had originally used a sample provided by someone else which had a comma instead of a semi colon between type and file name.  For Example: 

Incorrect Header: Response.AddHeader("Content-Disposition", "attachment, filename=\"" + filename + "\""); 
Correct Header: Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); 

This caused two issues for us.  Using a jQueryFileUpload it would not display a list of existing file and the issue you explained.  This only seems to have happened since 16.0.912.63 as I reverted back to an offline version I had downloaded some time back and it did not exhibit the same errors.  IE and Firefox are not affected ans seem to handle this.




Ah, very nice - The patch fixed the problem. It was using a semicolon already, but there was a comma used in the filename and it was unquoted. 

Orginal: 
header("Content-Disposition: inline; filename=vCard_".$this->last_name.",".$this->first_name.".vcf"); 

Fixed: 
header("Content-Disposition: inline; filename=\"vCard_".$this->last_name.",".$this->first_name.".vcf\"");



REFERENCES
http://groups.google.com/a/googleproductforums.com/forum/#!category-topic/chrome/report-a-problem-and-get-troubleshooting-help/hhZh_kpei8U
http://www.altitudesolutions.co.uk/Blog/post/2011/12/28/Chrome-16-breaking-use-of-ASP-NET-AddHeader-Method.aspx

Friday, March 9, 2012

Configure Xinetd

— SkyHi @ Friday, March 09, 2012

Step 3:  Configure Xinetd

Since the POP3 server runs from xinetd, you will need to make some configuration changes and then restart/start xinetd. First, we will need to edit the pop3sconfiguration file:
[root@zip root]# cd /etc/xinetd.d
[root@zip xinetd.d]# ls -l *pop3*
-rw-r--r--    1 root     root          359 Jan 25  2003 ipop3
-rw-r--r--    1 root     root          335 Jan 25  2003 pop3s

[root@zip xinetd.d]# vi pop3s
Edit the /etc/xinetd.d/pop3s config file until it looks like this:
# default: off
# description: The POP3S service allows remote users to access their mail \
#              using an POP3 client with SSL support such as fetchmail.
service pop3s
{
        socket_type             = stream
        wait                    = no
        user                    = root
        server                  = /usr/sbin/ipop3d
        log_on_success  += HOST DURATION
        log_on_failure  += HOST
        instances               = 150
        cps                     = 70 30
        disable                 = no
}
The extra settings for "instances" and "cps" are performance limits. I raised them from the defaults, but these can be tweaked as you see fit. See man xinetd.conf for details. Defaults are located in the /etc/xinetd.conf config file.
Now start (or restart) xinetd:
[root@zip xinetd.d]# /etc/init.d/xinetd restart
Stopping xinetd:                                           [FAILED]
Starting xinetd:                                           [  OK  ]



REFERENCES

Thursday, March 8, 2012

Table mysql.servers doesn’t exist: Problem adding a database user in plesk Or restarting mysql

— SkyHi @ Thursday, March 08, 2012
Update: If “mysql_fix_privilege_tables” command does not exist, look at Section 2.
You may receive a “Table ‘mysql.servers’ doesn’t exist” error message while adding a database user in Plesk OR while restarting the Mysql service. The complete error message look like:
Error: Connection to the database server has failed: 
Table 'mysql.servers' doesn't exist
OR
Can't open and lock privilege tables: 
Table 'mysql.servers' doesn't exist
The problem mostly occurs when Mysql is upgraded which introduce newer version of tables and the default Mysql database is not aware of these changes. The “mysql_fix_privilege_tables” command is use to update the Mysql database with the latest contents of the newer version and to fix the privileges of the database users as well.
Section 1:
To fix the issue, SSH to your server and execute:
On a plain Linux OR Linux/cPanel server:
# mysql_fix_privilege_tables --user=root\
 --password=mysqlpasswordhere --verbose
On a Linux/Plesk server:
# mysql_fix_privilege_tables --user=admin\
 --password=`cat /etc/psa/.psa.shadow` --verbose
where, –verbose will display the detailed output.
Section 2:
mysql_upgrade command have superseded mysql_fix_privilege_tables. mysql_fix_privilege_tables is an older script that previously was used to upgrade the system tables in the Mysql database .
To fix the issue, you need to replace mysql_fix_privilege_tables with mysql_upgradein the above stated commands, i.e.
On a plain Linux OR Linux/cPanel server:
# mysql_upgrade --user=root --password=mysqlpasswordhere --verbose
On a Linux/Plesk server:
# mysql_upgrade --user=admin\
  --password=`cat /etc/psa/.psa.shadow` --verbose




REFERENCES
http://linuxhostingsupport.net/blog/problem-adding-a-database-user-in-plesk-or-restarting-mysql-table-mysql-servers-doesnt-exist
http://myeasylinux.wordpress.com/2010/07/20/table-mysql-servers/
http://stackoverflow.com/questions/3653021/error-table-mysql-servers-doesnt-exist

Wednesday, March 7, 2012

Kernel panics

— SkyHi @ Wednesday, March 07, 2012
start_kernel+0x379/0x380


Kernel panics are almost always hardware related:

- Flaky hardware (especially RAM)
- Motherboard/RAM mismatch (i.e. the wrong kind of RAM is installed)
- Overheating
- Immature driver support