openfiles: module to report open file handle count
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.
This commit is contained in:
parent
4611295475
commit
d1de6c5fa3
30
i3pystatus/openfiles.py
Normal file
30
i3pystatus/openfiles.py
Normal file
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user