Monday, 20 November 2017

How to get total number of active connections in linux?


Solution

netstat -n | grep [:portnumber] | grep ESTABLISHED | wc -l

Example

netstat -n | grep :8080 | grep ESTABLISHED | wc -l

Explanation 

netstat
(network statistics) command displays network connections (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics.

-n: Show numerical addresses instead of trying to determine symbolic host, port or user names

grep (global regular expression print) command processes text line by line and prints any lines which match a specified pattern.

wc (word count) command prints a count of newlines, words, and bytes for each input file. 

-l: print the newline counts.

No comments:

Post a Comment

The total number of locks exceeds the lock table size

 SHOW VARIABLES LIKE 'innodb_buffer_pool_size'; SET GLOBAL innodb_buffer_pool_size = 2147483648;  -- 2GB Note: The value is in byte...