メイン プロセス (gwd) のメモリは vc_process_monitor によって監視されます。これにより、使用可能なメモリの 75% を超えてメモリが消費されるのを防ぎます。その結果、システム メモリ全体の監視は、警告しきい値 80% およびクリティカルしきい値 90% で実行されます。
サービスに影響を与える前に、潜在的な問題を示す警告または重大な状態を提供するしきい値を持つ Gateway を監視できます。次の表に、しきい値と推奨アクションを示します。
| しきい値の状態 | しきい値 | 推奨される修正アクション |
|---|---|---|
| 警告 | 80% | メモリが警告しきい値を超えた場合:
引き続きアクティブに監視し、使用量の増加を確認します。 |
| 重大 | 90% | メモリが重大しきい値を超えた場合:
問題が再び発生した場合:
注: Gateway を再分配する前に、キャパシティ メトリックが推奨制限内であることを確認します。キャパシティ メトリックの詳細については、
Gateway コンポーネントのキャパシティを参照してください。
|
メモリ使用量を監視する Python スクリプトの例を次に示します。
注: Telegraf を使用してメモリ使用量を監視することもできます。詳細については、
Telegraf を使用した Gateway の監視を参照してください。
#!/usr/bin/env python
from optparse import OptionParser
import sys
# Parse commandline options:
parser = OptionParser(usage="%prog -w <warning threshold>% -c <critical threshold>% [ -h ]")
parser.add_option("-w", "--warning",
action="store", type="string", dest="warn_threshold", help="Warning threshold in absolute(MB) or percentage")
parser.add_option("-c", "--critical",
action="store", type="string", dest="crit_threshold", help="Critical threshold in ansolute(MB) or percentage")
(options, args) = parser.parse_args()
def read_meminfo():
meminfo = {}
for line in open('/proc/meminfo'):
if not line: continue
(name, value) = line.split()[0:2]
meminfo[name.strip().rstrip(':')] = int(value)
return meminfo
if __name__ == '__main__':
if not options.crit_threshold:
print "UNKNOWN: Missing critical threshold value."
sys.exit(3)
if not options.warn_threshold:
print "UNKNOWN: Missing warning threshold value."
sys.exit(3)
is_warn_pct = options.warn_threshold.endswith('%')
if is_warn_pct:
warn_threshold = int(options.warn_threshold[0:-1])
else:
warn_threshold = int(options.warn_threshold)
is_crit_pct = options.crit_threshold.endswith('%')
if is_crit_pct:
crit_threshold = int(options.crit_threshold[0:-1])
else:
crit_threshold = int(options.crit_threshold)
if crit_threshold >= warn_threshold:
print "UNKNOWN: Critical percentage can't be equal to or bigger than warning percentage."
sys.exit(3)
meminfo = read_meminfo()
memTotal = meminfo["MemTotal"]
memFree = meminfo["MemFree"] + meminfo["Buffers"] + meminfo["Cached"]
memFreePct = 100.0*memFree/memTotal
if (is_crit_pct and memFreePct <= crit_threshold) or (not is_crit_pct and memFree/1024<=crit_threshold):
print "CRITICAL: Free memory is at %2.0f %% ( %d MB free our of %d MB total)" % (memFreePct, memFree/1024, memTotal/1024)
sys.exit(2)
if (is_warn_pct and memFreePct <= warn_threshold) or (not is_warn_pct and memFree/1024<=warn_threshold):
print "WARNING: Free memory is at %2.0f %% ( %d MB free our of %d MB total)" % (memFreePct, memFree/1024, memTotal/1024)
sys.exit(1)
else:
print "OK: Free memory is at %2.0f %% ( %d MB free our of %d MB total)" % (memFreePct, memFree/1024, memTotal/1024)
sys.exit(0)