How do I check how many HTTP connections are open currently?

Keep it mind that http is a stateless protocol. Each line can represent one client opening multiple sockets to grab different files (css, images, etc) that will hang out for awhile in a timewait state.

To display only active Internet connections to the server at port 80 and sort the results, allow to recognize many connections coming from one IP

# netstat -an | grep :80 | sort

To display the list of the all IP addresses involved instead of just count.

# netstat -n -p | grep SYN_REC | sort -u

Slow Server

# netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n 

# netstat -nat | grep :80 | grep ESTAB | wc -l

# netstat -nat | grep :80 | gawk '{ print $5; }' | gawk -F: '{ print $1 }' | sort | uniq -c | sort -n

# netstat -an|grep ":80"|awk '/tcp/ {print $6}'|sort -nr| uniq -c | sort -n

# netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1

For Java?

# netstat -nat | grep :1935 | gawk '{ print $5; }' | gawk -F: '{ print $1 }' | sort | uniq -c | sort -n

Need to optimize?

http://httpd.apache.org/docs/2.2/misc/perf-tuning.html
http://blog.monitis.com/2011/07/05/25-apache-performance-tuning-tips/
http://stackoverflow.com/questions/8902103/is-there-an-apache-tuner-script-like-mysqltuner-pl

Adding Additional IP Addresses CentOS

ssh to the server

# cd /etc/sysconfig/network-scripts
# ls -l | grep ifcfg-eth
-rw-r--r-- 1 root root   119 Jan 11 19:16 ifcfg-eth0
-rw-r--r-- 1 root root   119 Jan  3 08:45 ifcfg-eth0.bak
-rw-r--r-- 1 root root   119 Feb 24 04:34 ifcfg-eth1
-rw-r--r-- 1 root root   128 Jan 19 18:20 ifcfg-eth1.bak

If the main adapter is called “eth0” you have to call the next (virtual) adapter in a sequential order like so:

ifcfg-eth0 (primary adapter, physical)
ifcfg-eth0:1 (first virtual adapter to the physical primary adapter)
ifcfg-eth0:2 (second virtual adapter to the physical primary adapter)

Copy our primary adapter configuration file and name it to be the first virtual adapter:


# cp ifcfg-eth0 ifcfg-eth0:1
# ls -l | grep ifcfg-eth
-rw-r--r-- 1 root root   119 Jan 11 19:16 ifcfg-eth0
-rw-r--r-- 1 root root   119 Feb 24 08:53 ifcfg-eth0:1
-rw-r--r-- 1 root root   119 Jan  3 08:45 ifcfg-eth0.bak
-rw-r--r-- 1 root root   119 Feb 24 04:34 ifcfg-eth1
-rw-r--r-- 1 root root   128 Jan 19 18:20 ifcfg-eth1.bak

Configure this virtual adapter to be a static IP, no hardware address (MAC), configure netmask and of course rename the device.


# vim ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.1.1.2
NETMASK=255.255.255.0

There is no need to specify a MAC address – it is a virtual adapter and there is also no need to specify a default gateway as it is already routed through the primary adapter. Basically there are only four things that you will need to change:

File name for the adapter itself
DEVICE= (should correspond with the file name)
IPADDR=
NETMASK=

Restart the networking service:


# service network restart

That’s it; lets check ifconfig to make sure the virtual adapter is there and working:


# ifconfig eth0:1
eth0:1    Link encap:Ethernet  HWaddr 08:00:27:ED:05:B7
inet addr:10.1.1.2  Bcast:10.1.1.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


# ping 10.1.1.2
PING 10.1.1.2 (10.1.1.2) 56(84) bytes of data.
64 bytes from 10.1.1.2: icmp_seq=1 ttl=64 time=0.073 ms
64 bytes from 10.1.1.2: icmp_seq=2 ttl=64 time=0.042 ms
64 bytes from 10.1.1.2: icmp_seq=3 ttl=64 time=0.029 ms
64 bytes from 10.1.1.2: icmp_seq=4 ttl=64 time=0.029 ms
--- 10.1.1.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.029/0.043/0.073/0.018 ms

AB Tool for Benchmark

http://httpd.apache.org/docs/2.2/programs/ab.html

http://www.cyberciti.biz/tips/howto-performance-benchmarks-a-web-server.html


ab -c 50 -n 10000 URL_TO_THE_SITE

-n 10000: ab will send 1000 number of requests to server 202.54.200.1 in order to perform for the benchmarking session
-c 50 : 50 is concurrency number i.e. ab will send 50 number of multiple requests to perform at a time to server 202.54.200.1

Login to Linux/bsd desktop computer and type following command:


$ ab -n 1000 -c 5 http://202.54.200.1/snkpage.html

Where,

-n 1000: ab will send 1000 number of requests to server 202.54.200.1 in order to perform for the benchmarking session
-c 5 : 5 is concurrency number i.e. ab will send 5 number of multiple requests to perform at a time to server 202.54.200.1
For example if you want to send 10 request, type following command:

FTP Passive Mode – Plesk Server

Passive Mode

To enable FTP Passive Mode on Plesk systems, you will need to first edit the proftpd.conf file in /etc/

nano /etc/proftpd.conf

Then find the following lines

# delay on login off (are included on newest Plesk) 
IdentLookups off
UseReverseDNS off

Under the lines above, add the following and save the file.

# Custom directives
PassivePorts 60000 65000

Now restart xinetd

service xinetd restart

Once xinetd is restarted, you need to add the port range to the Plesk Firewall. Modules > Firewall > Edit Firewall Configuration > Add Custom Rule
Select Incoming, Allow, then add the port range 60000-65000, TCP and OK.

WHM/ cPanel

nano /etc/pure-ftp.conf

PassivePortRange 60000 65000

service pure-ftp restart

Now, log into WHM and edit the firewall:

ConfigServer Security & Firewall > Firewall Configuration. Add port range 60000:65000 to the TCP_IN rules and save!

Update: Configuring the Passive FTP Mode on a Microsoft Azure Instance
See this article: https://docs.plesk.com/en-US/onyx/deployment-guide/plesk-installation-and-upgrade-on-public-cloud-services/installing-plesk-on-microsoft-azure/configuring-the-passive-ftp-mode-on-a-microsoft-azure-instance.79079/

PHP Session write error

php Sessions write error suddenly on website

http://kb.parallels.com/en/115704

Step 1

 cd /var/lib/php/
[root@austin php]# ls -la
total 12
drwxr-xr-x  3 root root 4096 Apr  9 19:54 .
drwxr-xr-x 37 root root 4096 Apr 24 23:41 ..
drwx-wx-wt  2 apache apache 4096 Aug  5 20:01 session

Change the permissions and ownership


chmod 1733 /var/lib/php/session
chown root:root /var/lib/php/session

Step 2

Check the yum update log for php updates as this is usually the cause of the permissions change.


[root@austin log]# grep php /var/log/yum.log
Apr 09 19:54:09 Installed: php-5.3.3-27.el6_5.x86_64

This will give you the date and time of the last php update!

Install Liveperson

Open the Ubuntu Software center

Screenshot from 2014-08-07 10:42:06

http://www.liveperson.com

Linux

http://solutions.liveperson.com/agent-console/launch/lpac_frame.html
Windows

http://agent.liveperson.net/LPAC/INSTALLER/GA/LPAC_WIN.exe
Mac

http://agent.liveperson.net/LPAC/INSTALLER/GAEA/LPAC_OSX.dmg

(Complete the form with your login credentials & Log in)

My Liveperson Agent Console Download


cd ~/Downloads

javaws LPAC-GA.jnlp


Cisco VPN on Ubuntu 14.04

To get started, search for and install network-manager-vpnc package from Ubuntu Software Center. Or, do a:

sudo apt-get install network-manager-vpnc

Once installed, you can follow below steps to setup Cisco VPN for Ubuntu:

1.) Move your cursor to right-top corner system tray area, click on Network Manager icon and choose VPN Connections -> Configure VPN

2.) In next window, click on Add button to add a new connection and then choose Cisco Compatible VPN (vpnc) from the drop-down menu.

3.) Click on Create and you’re able to type in your Cisco VPN details in next window. After all, check off “Use this connection only for resources on its network” otherwise your traffic significantly slowed down

Have a PCF File?


cd /etc/vpnc
mv default.conf default.conf.bk

Now convert the pcf file:


pcf2vpnc namofpcffile.pcf default.conf

Then to run it, you simply do


sudo vpnc /path/to/new.conf

How to chown/chmod all files in current directory?

So – you migrated some file to a plesk/cpanel server and the ownership is wrong. Here is how to change it.
Plesk

[root@austin httpdocs]# cd /var/www/vhosts/domain.com/httpdocs/
[root@austin httpdocs]# chown -R  user:group *

cPanel

[root@austin httpdocs]# cd /home/user/public_html/
[root@austin httpdocs]# chown -R  user:group *

Or

Plesk

[root@austin httpdocs]# chown -R  user:group /var/www/vhosts/domain.com/httpdocs/*

cPanel

[root@austin httpdocs]# chown -R  user:group /home/user/public_html/*

Move a site from one plesk domain to another

How do you move a site from one plesk domian to another on the same server?

The ftp and export method.

Get your data.

1. Ftp to the old site and download the files to your local computer.
2. Login to the plesk panel and go to Manage Hosting for the old domain. Go to Websites and Domains. Go to databases. Click on the database name. Click Webadmin. Click Export Tab. Click Custom. make sure all the databases tables are selected (blue). Click Go. This should produce a popup so you can save the file locally.

New Domain.

1. Login to pelsk and click subscriptions. Click Add New Subscription. Fill out the details (make note of the new username and password) and and click okay.
2. ftp to the new domain and upload the files from the old domain.
3. Go to Manage Hosting for the new domain. Go to Websites and Domains. Go to databases. Click add new database. Click on the database name after creation and add a new database user. Click on Webadmin and go to the import tab. Locate the file for the database download and upload. You should see all the tables at this point.
4. Locate the database config file in the new database and edit it with the new database name, user and password.