I am counting current open files by a process pid by :- cmd1:-
ls /proc/$pid/fd/* | wc -l
and then I am calculating percentage by fetching Max open Files limits. cmd2:-
$ cat /proc/$pid/limits
Limit Soft Limit Hard Limit Units
Max resident set unlimited unlimited bytes
Max processes 30425 30425 processes
Max open files 4096 4096 files
Max locked memory 65536 65536 bytes
Only pasting part of output.
I am calculating percentage :-
cmd1/cmd2*100
i.e if ls /proc/$pid/fd/* | wc -l gives 1000.
then percentage will be :-
1000/4096*100= approx 25%
sometimes I am getting this percentage as 220.
scenario is reproducible now,it happened in one server and I found that in
/proc/pid/fd/29: there are 5000 log files opened by a process.
It means process pid is crossing the Max open file limits(4096 ) .