Number of open files or file descriptors associated with a process

Since in *nix every thing is a file, When you try to find open files or file descriptor associated with a process you will see Actual file log, Unix Sockets, Library files, Network Sockets,  /dev files and others.

lsof is a command to list all open files.

To list all open files or file descriptors by a process:

$ lsof -p PID

or

$ lsof -a -p PID

or

$ ls /proc/PID/fd

where PID is a process ID of any process that is running.

To count all open files by a process:

$ lsof -p PID | wc -l

or

$ ls /proc/PID/fd | wc -l

To list all open files:

$ lsof 

To count all open files:

$ lsof | wc -l
Advertisements

How to install goaccess in Centos/Fedora/Ubuntu

GoAccess is an interactive command line tool to analyse apache2/apache-httpd/ngnix logs.

It provides realtime HTTP statistics for website administrators.

GoAccess will provide following statistics:

  •  Unique visitors per day – Including spiders
  •  Requested files (Pages-URL)
  • Requested static files – (Static content: png,js,etc)
  • Referrers URLs
  •  HTTP 404 Not Found response code
  •  Operating Systems
  • Browsers
  • Hosts
  • HTTP Status Codes
  • Top Referring Sites
  • Top Keyphrases used on Google’s search engine

Install GoAccess in Ubuntu/Debian based operating systems:

$ apt-get install goaccess

Install GoAccess in RHEL/Fedora/Centos base operating systems:

In RHEL/Fedora/Centos base operating systems there is no single command available to install GoAccess. We need to install it from source code.

First install dependency packages with following command:

$ yum install glib2 glib2-devel glibc make geoip ncurses-devel

Download GoAccess source code:

$ wget http://sourceforge.net/projects/goaccess/files/0.4.2/goaccess-0.4.2.tar.gz

Uncompress source code:

$ tar xzf goaccess-0.4.2.tar.gz

Now install it by running following commands:

$ cd goaccess-0.4.2

$ ./configure

$ make; make install

Following are options available with goaccess command:

Usage: goaccess [ -b ][ -s ][ -e IP_ADDRESS][ – a ]< -f log_file >

The following options can also be supplied to the command:

-f <argument> – Path to input log file.
-b – Enable total bandwidth consumption.
For faster parsing, don’t enable this flag.
-s – Enable HTTP status codes report.
For faster parsing, don’t enable this flag.
-a – Enable a List of User-Agents by host.
For faster parsing, don’t enable this flag.
-e <argument> – Exclude an IP from being counted under the
HOST module. Disabled by default.

Example commands:

$ goaccess -f /var/log/httpd/access_log

$ goaccess -s -b -e 192.168.*.*  -f /var/log/httpd/access_log

-Sany