Skip to content

Commit

Permalink
openfiles: module to report open file handle count
Browse files Browse the repository at this point in the history
This module will display the current open file handles and the kernel
setting for max open file handles.  This is particularly useful when
running applications that like to grab a lot of file handles to help
monitor if/when your system may run out of available file handles.
  • Loading branch information
drwahl committed May 6, 2016
1 parent 4611295 commit d1de6c5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions i3pystatus/openfiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from i3pystatus import IntervalModule


class Openfiles(IntervalModule):
"""
Displays the current/max open files.
"""

settings = (
("filenr_path", "Location to file-nr (usually /proc/sys/fs/file-nr"),
"color",
"format"
)
color = 'FFFFFF'
interval = 30
filenr_path = '/proc/sys/fs/file-nr'
format = "open/max: {openfiles}/{maxfiles}"

def run(self):

cur_filenr = open(self.filenr_path, 'r').readlines()
openfiles, unused, maxfiles = cur_filenr[0].split()

cdict = {'openfiles': openfiles,
'maxfiles': maxfiles}

self.output = {
"full_text": self.format.format(**cdict),
"color": self.color
}

0 comments on commit d1de6c5

Please sign in to comment.