Fix regex matching in collectd_plugin
This commit is contained in:
parent
91ebe44599
commit
4c6d75bb52
|
@ -20,31 +20,31 @@ while True:
|
||||||
# Read values from status file
|
# Read values from status file
|
||||||
if os.path.isfile(FILENAME):
|
if os.path.isfile(FILENAME):
|
||||||
with open(FILENAME, 'r', encoding='utf-8') as f:
|
with open(FILENAME, 'r', encoding='utf-8') as f:
|
||||||
status_str = "".join(f.readlines())
|
status_str = f.readlines()
|
||||||
else:
|
else:
|
||||||
status_str = ""
|
status_str = ""
|
||||||
|
|
||||||
for line in status_str:
|
for line in status_str:
|
||||||
# Try to match SMB status
|
# Try to match SMB status
|
||||||
smb_match = SMB_STATUS_REGEX.match(status_str)
|
smb_match = SMB_STATUS_REGEX.match(line)
|
||||||
if smb_match:
|
if smb_match:
|
||||||
smb_current_files = int(smb_match.group('files'))
|
smb_current_files = int(smb_match.group('files'))
|
||||||
smb_current_users = int(smb_match.group('users'))
|
smb_current_users = int(smb_match.group('users'))
|
||||||
smb_active_users = int(smb_match.group('active'))
|
smb_active_users = int(smb_match.group('active'))
|
||||||
|
|
||||||
# Try to match SMB failure
|
# Try to match SMB failure
|
||||||
smb_noopen_match = SMB_NOOPEN_REGEX.match(status_str)
|
smb_noopen_match = SMB_NOOPEN_REGEX.match(line)
|
||||||
if smb_noopen_match:
|
if smb_noopen_match:
|
||||||
smb_current_files, smb_current_users, smb_active_users = 0, 0, 0
|
smb_current_files, smb_current_users, smb_active_users = 0, 0, 0
|
||||||
|
|
||||||
# Try to match HTTP status
|
# Try to match HTTP status
|
||||||
http_match = HTTP_STATUS_REGEX.match(status_str)
|
http_match = HTTP_STATUS_REGEX.match(line)
|
||||||
if http_match:
|
if http_match:
|
||||||
http_current_transfers = int(http_match.group('transfers'))
|
http_current_transfers = int(http_match.group('transfers'))
|
||||||
http_current_users = int(http_match.group('users'))
|
http_current_users = int(http_match.group('users'))
|
||||||
|
|
||||||
# Try to match HTTP failure
|
# Try to match HTTP failure
|
||||||
http_noopen_match = HTTP_NOOPEN_REGEX.match(status_str)
|
http_noopen_match = HTTP_NOOPEN_REGEX.match(line)
|
||||||
if http_noopen_match:
|
if http_noopen_match:
|
||||||
http_current_transfers, http_current_users = 0, 0
|
http_current_transfers, http_current_users = 0, 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue