未验证 提交 73283db4 编写于 作者: R Rongfeng Fu 提交者: GitHub

1.0.2 (#17)

* memory and disk check

* 1.0.2
上级 9664cb9c
......@@ -35,7 +35,7 @@ from tool import DirectoryUtil, FileUtil
ROOT_IO = IO(1)
VERSION = '1.0.1'
VERSION = '1.0.2'
REVISION = '<CID>'
BUILD_BRANCH = '<B_BRANCH>'
BUILD_TIME = '<B_TIME>'
......
Name: ob-deploy
Version: 1.0.1
Version: 1.0.2
Release: 1%{?dist}
# if you want use the parameter of rpm_create on build time,
# uncomment below
......@@ -105,4 +105,6 @@ echo -e 'Installation of obd finished successfully\nPlease source /etc/profile.d
- new features: obd update
- cancel the timeout limit for waiting for the cluster to initialize
- new configuration item for store log
- support SUSE, Ubuntu etc.
\ No newline at end of file
- support SUSE, Ubuntu etc.
* Mon Jun 28 2021 obd 1.0.2
- fix memory and disk check bug
\ No newline at end of file
......@@ -31,7 +31,7 @@ def parse_size(size):
_bytes = int(size)
else:
units = {"B": 1, "K": 1<<10, "M": 1<<20, "G": 1<<30, "T": 1<<40}
match = re.match(r'([1-9][0-9]*)([B,K,M,G,T])', size)
match = re.match(r'([1-9][0-9]*)\s*([B,K,M,G,T])', size.upper())
_bytes = int(match.group(1)) * units[match.group(2)]
return _bytes
......
......@@ -20,6 +20,7 @@
from __future__ import absolute_import, division, print_function
import os
import re
......@@ -27,17 +28,6 @@ stdio = None
success = True
def parse_size(size):
_bytes = 0
if not isinstance(size, str) or size.isdigit():
_bytes = int(size)
else:
units = {"B": 1, "K": 1<<10, "M": 1<<20, "G": 1<<30, "T": 1<<40}
match = re.match(r'([1-9][0-9]*)([B,K,M,G,T])', size)
_bytes = int(match.group(1)) * units[match.group(2)]
return _bytes
def get_port_socket_inode(client, port):
port = hex(port)[2:].zfill(4).upper()
cmd = "bash -c 'cat /proc/net/{tcp,udp}' | awk -F' ' '{print $2,$10}' | grep '00000000:%s' | awk -F' ' '{print $2}' | uniq" % port
......@@ -54,7 +44,7 @@ def parse_size(size):
_bytes = int(size)
else:
units = {"B": 1, "K": 1<<10, "M": 1<<20, "G": 1<<30, "T": 1<<40}
match = re.match(r'([1-9][0-9]*)([B,K,M,G,T])', size)
match = re.match(r'([1-9][0-9]*)\s*([B,K,M,G,T])', size.upper())
_bytes = int(match.group(1)) * units[match.group(2)]
return _bytes
......@@ -127,7 +117,7 @@ def start_check(plugin_context, strict_check=False, *args, **kwargs):
memory['percentage'] += int(parse_size(server_config['memory_limit_percentage']))
else:
memory['percentage'] += 80
data_path = server_config['data_dir'] if 'data_dir' in server_config else server_config['home_path']
data_path = server_config['data_dir'] if 'data_dir' in server_config else os.path.join(server_config['home_path'], 'store')
if not client.execute_command('ls %s/sstable/block_file' % data_path):
if data_path in disk:
critical('Same Path: %s in %s and %s' % (data_path, server, disk[data_path]['server']))
......@@ -171,11 +161,15 @@ def start_check(plugin_context, strict_check=False, *args, **kwargs):
alert('(%s) The recommended number of open files is 655350 (Current value: %s)' % (ip, max_of))
# memory
ret = client.execute_command("free -b | grep Mem | awk -F' ' '{print $2, $4}'")
ret = client.execute_command('cat /proc/meminfo')
if ret:
total_memory, free_memory = ret.stdout.split(' ')
total_memory = int(total_memory)
free_memory = int(free_memory)
total_memory = 0
free_memory = 0
for k, v in re.findall('(\w+)\s*:\s*(\d+\s*\w+)', ret.stdout):
if k == 'MemTotal':
total_memory = parse_size(str(v))
elif k == 'MemAvailable':
free_memory = parse_size(str(v))
total_use = servers_memory[ip]['percentage'] * total_memory / 100 + servers_memory[ip]['num']
if total_use > free_memory:
critical('(%s) not enough memory. (Free: %s, Need: %s)' % (ip, formate_size(free_memory), formate_size(total_use)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册