SD-WAN 网关 可处理突发流量,预计会产生较高的突发 CPU 使用率。应监控网关以了解使用率达到 100% 的 CPU 内核。但是,出于性能考虑,DPDK 内核在轮询模式下运行,因为这些内核预期会在高吞吐量高时占用近 100% CPU。
您可以使用阈值监控网关,这些阈值提供警告或严重状态,以便在潜在问题影响服务之前指示这些问题。下表列出了阈值和建议的措施。
阈值状态 | 阈值 | 建议的纠正措施 | |
---|---|---|---|
DP 内核 | 非 DP 内核 | ||
警告 | 95% | 80% | 如果在 5 分钟内持续超过阈值:
如果在 5 分钟内持续超过阈值:
|
严重 | 98% | 90% | 如果在 5 分钟内持续超过阈值:
如果在一小时内持续观察到该问题:
|
以下是用于监控 CPU 使用情况的示例 Python 脚本:
注: 您还可以使用 Telegraf 监控 CPU 使用情况。有关更多信息,请参阅
使用 Telegraf 监控网关。
#! /usr/bin/env python """ Check for CPUs spinning at 100% """ import re import collections import time import sys import json import os import subprocess re_cpu = re.compile(r"^cpu\d+\s") CPUStat = collections.namedtuple('CPUStat', ['user', 'nice', 'sys', 'idle']) def get_stats(): stats = open("/proc/stat").readlines() ret = {} for s in stats: if not re_cpu.search(s): continue s = s.split() ret[s[0]] = CPUStat(*[ int(v) for v in s[1:5]]) return ret def verify_dpdk_support(): if os.path.isfile('/opt/vc/etc/dpdk.json'): with open("/opt/vc/etc/dpdk.json") as data: d=json.loads((data.read())) if "status" in d.keys(): return True if d['status'] is "Supported" else False else: return False def another_verify_dpdk_support(): if os.path.isfile('/opt/vc/bin/debug.py'): f=subprocess.check_output(["/opt/vc/bin/debug.py","--dpdk_ports_dump"]) x=[r.split() for r in f.split('\n')] if len(x) <= 1: return False else: return True else: return False dpdk_status=verify_dpdk_support() or another_verify_dpdk_support() if __name__ == "__main__": try: stat1 = get_stats() time.sleep(3) stat2 = get_stats() except: print "UKNOWN - failed to get CPU stat: %s" % str(sys.exc_info()[1]) sys.exit(3) busy_cpu_set = [ cpu for cpu in stat1 if (stat2[cpu].idle - stat1[cpu].idle)==0 ] if not busy_cpu_set: print "OK - no spinning CPUs" sys.exit(0) if dpdk_status == True: if "cpu1" in busy_cpu_set and len(busy_cpu_set) == 1: print "OK - no spinning CPUs" sys.exit(0) elif "cpu1" in busy_cpu_set: busy_cpu_set.remove('cpu1') print "CRITICAL - %s is at 100%%" % (",".join(busy_cpu_set)) sys.exit(2) else: print busy_cpu_set,1 print "CRITICAL - %s is at 100%%" % (",".join(busy_cpu_set)) sys.exit(2) else: print "CRITICAL - %s is at 100%%" % (",".join(busy_cpu_set)) sys.exit(2)