This project has been done by these contributors, be sure to check them out!:
The main purpose of this project is to develop a Script that shows features about Open Files in a Linux System.
- Script should be executed in CentOS (Preferably in CentOS 6.10)
-
Clone the Repository.
-
Script should have execution permission. If the Script haven't got execution permission, be sure to add it writing in a bash located in the Repository Directory on your computer:
chmod a+x ./open_files_stats.sh
-
There are two ways of using the Script.
- Show ALL Open File Stats:
./open_files_stats.sh
- Show Open File Stats from SPECIFIC USERS separated by commas without spaces:
./open_files_stats.sh -u user1,user2,user3
- Show ALL Open File Stats:
-
After a short loading, Bash Output should be printed.
Script follows this trace:
- First, it reads users introduced by parameter (-u option) if it's needed and check if they exist.
- Then, it searches in /proc/$pid/fd file's descriptors. By checking their permissions, Script studies if the file is being opened to be read or to be written. Script saves all this information (with file's owner too) in an associative array in order to go through /proc only once.
- Finally, it prints the content of that array like it's shown in Output Results
Output Results should be something like this if nothing goes wrong:
[Realizando recorrido del /proc...] <= Script starting...
[Recorrido Finalizado] <= Loading Process ended
=========================[Fichero Número: 1]========================= <= File Number
Fichero=/root/.local/share/gvfs-metadata/home <= File Name
NºLecturas=2 <= Number of times that file is being opened to be read by processes
NºEscrituras=0 <= Number of times that file is being opened to be written by processes
Usuario=root <= File Owner's Name
=========================[Fichero Número: 2]=========================
Fichero=/var/log/wpa_supplicant.log
NºLecturas=0
NºEscrituras=1
Usuario=root
=========================[Fichero Número: 3]=========================
Fichero=/dev/cpu_dma_latency
NºLecturas=0
NºEscrituras=1
Usuario=root
[Etc]