Wednesday, November 25, 2020

Apache get concurrent connection

Reference: https://www.cloudtechtiq.com/blog/check-apache-concurrent-connections-using-netstat-command


To Count Apache concurrent connection's, use any of the below commands.

netstat -nt | grep :80 | wc -l    
netstat -plan|grep :80 | wc -l    
netstat -an | grep 'EST' | wc -l    
netstat -ant | grep ESTABLISHED | grep :80 | wc -l    
ps -A | grep httpd | wc -l    
ps -ef | grep http | wc -l    
ps aux | grep httpd | wc -l    
ps aux | grep http | grep -v "\(root\|grep\)" | wc -l

To print the active Internet connections to the server at port 80 and sort the results, use the below commands.

netstat -an | grep :80 | sort 
netstat -plan | grep :80 
netstat -anp | grep :80

To calculate and count, number of connection currently established from each IP address with server.

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

To calculate and count, number of connection currently established from each IP address through TCP or UDP protocol with server.

netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

To Print ESTABLISHED connections instead of all connections, and displays the connections count for each IP

netstat -ntu | grep ESTAB | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr

To print the list of IP address and its connection count, that connect to port 80 on the server.

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

To print all the apache httpd actual processes in Linux, use the below commands.

ps -aux | grep httpd  or  ps -ef | grep httpd

Sunday, August 30, 2020

mysqldump comparison using compress option with bzip2 and gzip performance and the output size

[root@server2 vagrant]# time mysqldump --compress myportal | gzip  > test.gz

real 0m14.675s
user 0m7.426s
sys 0m0.618s
[root@server2 vagrant]# time mysqldump  myportal | gzip  > test.gz

real 0m9.455s
user 0m6.343s
sys 0m0.646s
[root@server2 vagrant]# time mysqldump --compress myportal | gzip  > test-compress-gzip.gz

real 0m14.603s
user 0m7.371s
sys 0m0.580s
[root@server2 vagrant]# time mysqldump  myportal | gzip  > test--gzip.gz

real 0m9.357s
user 0m6.314s
sys 0m0.668s
[root@server2 vagrant]# time mysqldump  myportal | bzip2  > test--bzip.bz2

real 1m10.520s
user 1m7.152s
sys 0m0.739s
[root@server2 vagrant]# time mysqldump --compress  myportal | bzip2  > test-compress-bzip.bz2

real 1m15.358s
user 1m7.156s
sys 0m0.773s

[root@server2 vagrant]# du -h test-*
6.7M test--bzip.bz2
13M test--gzip.gz
6.7M test-compress-bzip.bz2
13M test-compress-gzip.gz

[root@server2 vagrant]# du  test-*
6808 test--bzip.bz2
12376 test--gzip.gz
6808 test-compress-bzip.bz2
12376 test-compress-gzip.gz

bzip2 compress more than gzip but the process time is longer than gzip. 

So please choose between speed and compression ratio, which suite ur needs.

Tuesday, December 3, 2019

Show hidden files and sub directories in root directory

By default the root directory will not show you the directories like /usr/bin/etc etc. To make them visible you need to show the hidden files.

Open terminal and type the following command and hit return.

defaults write com.apple.finder AppleShowAllFiles -bool TRUE;killall Finder

Reference: https://themacbeginner.com/view-content-root-directory-mac-os-x/

Saturday, December 29, 2018

Mysql On delete cascade reference information

Tips to find tables affected by MySQL ON DELETE CASCADE action

Sometimes, it is useful to know which table is affected by the MySQL ON DELETE CASCADE  referential action when you delete data from a table. You can query this data from the referential_constraints in the information_schema  database as follows:

1
2
3
4
5
6
7
8
9
10
USE information_schema;
 
SELECT
    table_name
FROM
    referential_constraints
WHERE
    constraint_schema = 'database_name'
        AND referenced_table_name = 'parent_table'
        AND delete_rule = 'CASCADE'


Thursday, November 29, 2018

Wednesday, June 27, 2018

Tuesday, June 26, 2018

PHP / CentOS 7Connect DATABASE Error TYPE: 2002: Permission denied


9
down voteaccepted

I had the same issue after getting a new CentOS 7 box, running SELinux. I could connect to my remote MySQL DB server from the command line, but Drupal (and test PHP scripts) could not.

The issue turned out to be the SELinux security policies.

By default, the policy httpd_can_network_connect_db is disabled (meaning that your web server cannot contact a remote DB.)

Check this via:

getsebool -a | grep httpd

If httpd_can_network_connect_db is Off, enable it via:

setsebool -P httpd_can_network_connect_db 1

(The -P flag makes the change permanent, so the setting survives a reboot.)



Nginx php html permission denied

After searching , I found it.It's all deals with SELINUX which is a security feature. when using ls -Z

drwxrwxrwx. ec2-user root system_u:object_r:httpd_sys_content_t:s0 www

change this to

drwxrwxrwx. ec2-user root system_u:object_r:httpd_sys_rw_content_t:s0 www

using cmd

chcon -R -t httpd_sys_rw_content_t /var/www


Proxmox installation display out of range

Reference:  https://forum.proxmox.com/threads/proxmox-ve-screen-out-of-range.131297/