LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-03-2018, 09:26 PM   #1
sampy12345
LQ Newbie
 
Registered: Jul 2017
Posts: 4

Rep: Reputation: Disabled
Linux Open file count


Hi Team,

can anyone help me with a script which helps to send a mail if the open file count increases a count.

And also help me with a alternate command for lsof|wc -l for calculating the openfile count .

As per my linux team they are saying not to use lsof command . So please suggest an alternate command
 
Old 02-04-2018, 09:12 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 2,948

Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
echo /proc/*/fd/* |wc -w

Last edited by smallpond; 02-04-2018 at 01:16 PM.
 
Old 02-04-2018, 03:37 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,348

Rep: Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228
google lsof linux
https://www.cyberciti.biz/tips/linux...scriptors.html

Code:
userx@slackwhere:~
$ lsof | wc -l
112107
userx@slackwhere:~
$ countis="$(echo /proc/*/fd/* |wc -w)"
userx@slackwhere:~
$ echo ${countis}
1303

Last edited by BW-userx; 02-04-2018 at 03:38 PM.
 
Old 02-05-2018, 01:37 AM   #4
sampy12345
LQ Newbie
 
Registered: Jul 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
google lsof linux
https://www.cyberciti.biz/tips/linux...scriptors.html

Code:
userx@slackwhere:~
$ lsof | wc -l
112107
userx@slackwhere:~
$ countis="$(echo /proc/*/fd/* |wc -w)"
userx@slackwhere:~
$ echo ${countis}
1303



HI I have used the given commands by you but there is major difference

[appuser@HYD-VNOC-Training-Lnx01 ~]$ echo /proc/*/fd/* |wc -w
22
[appuser@HYD-VNOC-Training-Lnx01 ~]$ lsof | wc -l
763
[appuser@HYD-VNOC-Training-Lnx01 ~]$


for lsof i am getting different count and for echo /proc/*/fd/* |wc -w I am getting different count.

Please help me in given a correct command
 
Old 02-05-2018, 07:22 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,348

Rep: Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228Reputation: 1228
So I think the term "files" maybe needed to be defined. When I first read this I immediately thought files as in Document files users would have open.

Now looking up "linux file definition" I get this,
http://www.linfo.org/file.html

So it seems more refining of what type of 'files opened' needs to be set in order to get the correct information in which you are seeking.
 
Old 02-06-2018, 10:26 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,513

Rep: Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415Reputation: 2415
Depending on exactly what 'files' you want to know about, you may even want to look at https://linux.die.net/man/1/fuser.
Fundamentally, remember that almost everything is 'file' (hence the diff counts above) under *nix, so you may want to find out exactly what information you are being asked to gather.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to count the number of open network connections on Linux LXer Syndicated Linux News 0 09-13-2013 10:41 AM
Parse file from remote server to caculate count of string existence in that file saurabhmehan Linux - Newbie 2 08-30-2010 12:30 AM
Open file with a link count of less than 1 ? budword Linux - Security 1 03-23-2007 06:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration