mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-05 17:22:02 +03:00
Make the alerts number configurable (related to #2558)
This commit is contained in:
parent
c88e310920
commit
8ee0a83d77
@ -396,35 +396,40 @@ port_default_gateway=True
|
||||
disable=False
|
||||
# Only show specific containers (comma separated list of container name or regular expression)
|
||||
# Comment this line to display all containers (default configuration)
|
||||
#show=telegraf
|
||||
; show=telegraf
|
||||
# Hide some containers (comma separated list of container name or regular expression)
|
||||
# Comment this line to display all containers (default configuration)
|
||||
#hide=telegraf
|
||||
; hide=telegraf
|
||||
# Define the maximum docker size name (default is 20 chars)
|
||||
max_name_size=20
|
||||
#cpu_careful=50
|
||||
; cpu_careful=50
|
||||
# Thresholds for CPU and MEM (in %)
|
||||
#cpu_warning=70
|
||||
#cpu_critical=90
|
||||
#mem_careful=20
|
||||
#mem_warning=50
|
||||
#mem_critical=70
|
||||
; cpu_warning=70
|
||||
; cpu_critical=90
|
||||
; mem_careful=20
|
||||
; mem_warning=50
|
||||
; mem_critical=70
|
||||
#
|
||||
# Per container thresholds
|
||||
#containername_cpu_careful=10
|
||||
#containername_cpu_warning=20
|
||||
#containername_cpu_critical=30
|
||||
; containername_cpu_careful=10
|
||||
; containername_cpu_warning=20
|
||||
; containername_cpu_critical=30
|
||||
#
|
||||
# By default, Glances only display running containers
|
||||
# Set the following key to True to display all containers
|
||||
all=False
|
||||
# Define Podman sock
|
||||
#podman_sock=unix:///run/user/1000/podman/podman.sock
|
||||
; podman_sock=unix:///run/user/1000/podman/podman.sock
|
||||
|
||||
[amps]
|
||||
# AMPs configuration are defined in the bottom of this file
|
||||
disable=False
|
||||
|
||||
[alert]
|
||||
disable=True
|
||||
# Maximum number of alerts to display (default is 10)
|
||||
; max_events=10
|
||||
|
||||
##############################################################################
|
||||
# Client/server
|
||||
##############################################################################
|
||||
|
@ -35,14 +35,18 @@ class GlancesEvents(object):
|
||||
"top sort key"]
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, max_events=10):
|
||||
"""Init the events class."""
|
||||
# Maximum size of the events list
|
||||
self.events_max = 10
|
||||
self.set_max_events(max_events)
|
||||
|
||||
# Init the logs list
|
||||
self.events_list = []
|
||||
|
||||
def set_max_events(self, max_events):
|
||||
"""Set the maximum size of the events list."""
|
||||
self.max_events = max_events
|
||||
|
||||
def get(self):
|
||||
"""Return the raw events list."""
|
||||
return self.events_list
|
||||
@ -138,8 +142,8 @@ class GlancesEvents(object):
|
||||
# Add the item to the list
|
||||
self.events_list.insert(0, item)
|
||||
|
||||
# Limit the list to 'events_max' items
|
||||
if self.len() > self.events_max:
|
||||
# Limit the list to 'max_events' items
|
||||
if self.len() > self.max_events:
|
||||
self.events_list.pop()
|
||||
|
||||
return True
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.events import glances_events
|
||||
from glances.thresholds import glances_thresholds
|
||||
|
||||
@ -170,7 +171,9 @@ class PluginModel(GlancesPluginModel):
|
||||
|
||||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(args=args, config=config, stats_init_value=[])
|
||||
super(PluginModel, self).__init__(args=args,
|
||||
config=config,
|
||||
stats_init_value=[])
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
self.display_curse = True
|
||||
@ -178,6 +181,10 @@ class PluginModel(GlancesPluginModel):
|
||||
# Set the message position
|
||||
self.align = 'bottom'
|
||||
|
||||
# Set the maximum number of events to display
|
||||
if config is not None and (config.has_section('alert') or config.has_section('alerts')):
|
||||
glances_events.set_max_events(config.get_int_value('alert', 'max_events'))
|
||||
|
||||
def update(self):
|
||||
"""Nothing to do here. Just return the global glances_log."""
|
||||
# Set the stats to the glances_events
|
||||
|
@ -115,7 +115,10 @@ class PluginModel(GlancesPluginModel):
|
||||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config, items_history_list=items_history_list, fields_description=fields_description
|
||||
args=args,
|
||||
config=config,
|
||||
items_history_list=items_history_list,
|
||||
fields_description=fields_description
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
Loading…
Reference in New Issue
Block a user