mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-24 05:15:47 +03:00
Merge branch 'issue1491' into develop
This commit is contained in:
commit
f8e036ee25
1
NEWS
1
NEWS
@ -12,6 +12,7 @@ Enhancements and new features:
|
||||
* Add authprovider for cassandra export (thanks to @EmilienMottet) #1395
|
||||
* Curses's browser server list sorting added (thanks to @limfreee) #1396
|
||||
* ElasticSearch: add date to index, unbreak object push (thanks to @genevera) # 1438
|
||||
* Performance issue with large folder #1491
|
||||
|
||||
Bugs corrected:
|
||||
|
||||
|
@ -174,10 +174,12 @@ critical=90
|
||||
# * careful: optional careful threshold (in MB)
|
||||
# * warning: optional warning threshold (in MB)
|
||||
# * critical: optional critical threshold (in MB)
|
||||
# * refresh: interval in second between two refreshs
|
||||
#folder_1_path=/tmp
|
||||
#folder_1_careful=2500
|
||||
#folder_1_warning=3000
|
||||
#folder_1_critical=3500
|
||||
#folder_1_refresh=60
|
||||
#folder_2_path=/home/nicolargo/Videos
|
||||
#folder_2_warning=17000
|
||||
#folder_2_critical=20000
|
||||
|
@ -17,11 +17,12 @@ Each item is defined by:
|
||||
- ``careful``: optional careful threshold (in MB)
|
||||
- ``warning``: optional warning threshold (in MB)
|
||||
- ``critical``: optional critical threshold (in MB)
|
||||
- ``refresh``: interval in second between two refresh (default is 30 seconds)
|
||||
|
||||
Up to ``10`` items can be defined.
|
||||
|
||||
For example, if you want to monitor the ``/tmp`` folder, the following
|
||||
definition should do the job:
|
||||
For example, if you want to monitor the ``/tmp`` folder every minute,
|
||||
the following definition should do the job:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
@ -30,8 +31,10 @@ definition should do the job:
|
||||
folder_1_careful=2500
|
||||
folder_1_warning=3000
|
||||
folder_1_critical=3500
|
||||
folder_1_refresh=60
|
||||
|
||||
In client/server mode, the list is defined on the ``server`` side.
|
||||
|
||||
.. warning::
|
||||
Do **NOT** define folders containing lot of files and subfolders.
|
||||
Do **NOT** define folders containing lot of files and subfolders or use an
|
||||
huge refresh time...
|
||||
|
@ -1,6 +1,6 @@
|
||||
.\" Man page generated from reStructuredText.
|
||||
.
|
||||
.TH "GLANCES" "1" "Apr 18, 2019" "3.1.1b0" "Glances"
|
||||
.TH "GLANCES" "1" "Jun 12, 2019" "3.1.1b0" "Glances"
|
||||
.SH NAME
|
||||
glances \- An eye on your system
|
||||
.
|
||||
|
@ -22,6 +22,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from glances.timer import Timer
|
||||
from glances.compat import range, nativestr
|
||||
from glances.logger import logger
|
||||
|
||||
@ -57,11 +58,19 @@ class FolderList(object):
|
||||
__folder_list_max_size = 10
|
||||
# The folder list
|
||||
__folder_list = []
|
||||
# Default refresh time is 30 seconds for this plugins
|
||||
__default_refresh = 30
|
||||
|
||||
def __init__(self, config):
|
||||
"""Init the folder list from the configuration file, if it exists."""
|
||||
self.config = config
|
||||
|
||||
# A list of Timer
|
||||
# One timer per folder
|
||||
# default timer is __default_refresh, can be overwrite by folder_1_refresh=600
|
||||
self.timer_folders = []
|
||||
self.first_grab = True
|
||||
|
||||
if self.config is not None and self.config.has_section('folders'):
|
||||
if scandir_tag:
|
||||
# Process monitoring list
|
||||
@ -90,6 +99,12 @@ class FolderList(object):
|
||||
value['path'] = nativestr(value['path'])
|
||||
|
||||
# Optional conf keys
|
||||
# Refresh time
|
||||
value['refresh'] = int(self.config.get_value(section,
|
||||
key + 'refresh',
|
||||
default=self.__default_refresh))
|
||||
self.timer_folders.append(Timer(value['refresh']))
|
||||
# Thesholds
|
||||
for i in ['careful', 'warning', 'critical']:
|
||||
# Read threshold
|
||||
value[i] = self.config.get_value(section, key + i)
|
||||
@ -155,6 +170,9 @@ class FolderList(object):
|
||||
# Iter upon the folder list
|
||||
for i in range(len(self.get())):
|
||||
# Update folder size
|
||||
if not self.first_grab and not self.timer_folders[i].finished():
|
||||
continue
|
||||
# Get folder size
|
||||
try:
|
||||
self.__folder_list[i]['size'] = self.__folder_size(self.path(i))
|
||||
except OSError as e:
|
||||
@ -164,6 +182,11 @@ class FolderList(object):
|
||||
self.__folder_list[i]['size'] = '!'
|
||||
else:
|
||||
self.__folder_list[i]['size'] = '?'
|
||||
# Reset the timer
|
||||
self.timer_folders[i].reset()
|
||||
|
||||
# It is no more the first time...
|
||||
self.first_grab = False
|
||||
|
||||
return self.__folder_list
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user