Skip to content

Commit 0eb16b8

Browse files
committed
CP-12640: Generate alert when log partition is full
Signed-off-by: Sharad Yadav <[email protected]>
1 parent 2efaa54 commit 0eb16b8

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

scripts/perfmon

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,32 @@ class RRDUpdates:
345345

346346

347347
# Consolidation functions:
348-
supported_consolidation_functions = [ 'sum', 'average', 'max', 'get_percent_fs_usage', 'get_percent_mem_usage' ]
348+
supported_consolidation_functions = [ 'sum', 'average', 'max', 'get_percent_fs_usage', 'get_percent_log_fs_usage', 'get_percent_mem_usage' ]
349349

350350
def average(mylist):
351351
return sum(mylist)/float(len(mylist))
352352

353+
def get_percent_log_fs_usage(ignored):
354+
"Get the percent usage of the host filesystem for logs partition. Input list is ignored and should be empty"
355+
fs_output = commands.getoutput('df /etc/passwd')
356+
log_fs_output = commands.getoutput('df /var/log')
357+
fs_output = ' '.join(fs_output.splitlines()[1:])
358+
log_fs_output = ' '.join(log_fs_output.splitlines()[1:])
359+
# Get the percent usage only when there is a separate logs partition
360+
if (fs_output.split()[0] != log_fs_output.split()[0]):
361+
percentage = log_fs_output.split()[4]
362+
# remove % character and convert to float
363+
return float(percentage[0:-1])/100.0
364+
else:
365+
return float('NaN')
366+
353367
def get_percent_fs_usage(ignored):
354368
"Get the percent usage of the host filesystem. Input list is ignored and should be empty"
355369
# this file is on the filesystem of interest in both OEM and Retail
356370
output = commands.getoutput('df /etc/passwd')
357371
output = ' '.join(output.splitlines()[1:]) # remove header line and rewrap on single line
358372
percentage = output.split()[4]
359-
# strip of % character and convert to float
373+
# remove % character and convert to float
360374
return float(percentage[0:-1])/100.0
361375

362376
def get_percent_mem_usage(ignored):
@@ -643,7 +657,7 @@ class VMMonitor(ObjectMonitor):
643657
* alarm_trigger_period: num seconds of 'bad' values before an alarm is sent (default '60')
644658
* alarm_auto_inhibit_period: num seconds this alarm disabled after an alarm is sent (default '3600')
645659
* consolidation_fn: how to combine variables from rrd_updates into one value
646-
(default is 'average' for 'cpu_usage', 'get_percent_fs_usage' for 'fs_usage', 'get_percent_mem_usage' for 'mem_usage', & 'sum' for everything else)
660+
(default is 'average' for 'cpu_usage', 'get_percent_fs_usage' for 'fs_usage', 'get_percent_log_fs_usage' for 'log_fs_usage', 'get_percent_mem_usage' for 'mem_usage', & 'sum' for everything else)
647661
* rrd_regex matches the names of variables from (xe vm-data-sources-list uuid=$vmuuid) used to compute value
648662
(only has defaults for "cpu_usage", "network_usage", and "disk_usage")
649663
"""
@@ -657,19 +671,22 @@ class VMMonitor(ObjectMonitor):
657671
if config_tag == 'consolidation_fn':
658672
if variable_name == "cpu_usage": return 'average'
659673
elif variable_name == "fs_usage": return 'get_percent_fs_usage'
674+
elif variable_name == "log_fs_usage": return 'get_percent_log_fs_usage'
660675
elif variable_name == "mem_usage": return 'get_percent_mem_usage'
661676
else: return 'sum'
662677
elif config_tag == 'rrd_regex':
663678
if variable_name == "cpu_usage": return "cpu[0-9]+"
664679
elif variable_name == "network_usage": return "vif_[0-9]+_[rt]x"
665680
elif variable_name == "disk_usage": return "vbd_(xvd|hd)[a-z]+_(read|write)"
666681
elif variable_name == "fs_usage": return "_$_DUMMY__" # match nothing
682+
elif variable_name == "log_fs_usage": return "_$_DUMMY__" # match nothing
667683
elif variable_name == "mem_usage": return "_$_DUMMY__" # match nothing
668684
else: raise XmlConfigException, "variable %s: no default rrd_regex - please specify one" % variable_name
669685
elif config_tag == 'alarm_trigger_period': return '60' # 1 minute
670686
elif config_tag == 'alarm_auto_inhibit_period': return '3600' # 1 hour
671687
elif config_tag == 'alarm_trigger_level':
672688
if variable_name == "fs_usage": return '0.9' # trigger when 90% full
689+
elif variable_name == "log_fs_usage": return '0.9' # trigger when 90% full
673690
elif variable_name == "mem_usage": return '0.95' # tigger when mem demanded is close to phy_mem
674691
else: raise XmlConfigException, "variable %s: no default alarm_trigger_level - please specify one" % variable_name
675692
elif config_tag == 'alarm_trigger_sense': return 'high' # trigger if *above*

0 commit comments

Comments
 (0)