rueckstiess / mtools

A collection of scripts to set up MongoDB test environments and parse and visualize MongoDB log files.
Apache License 2.0
1.89k stars 404 forks source link

mloginfo reports host name as unknown for 3.6 logs #819

Closed niccottrell closed 4 years ago

niccottrell commented 4 years ago

Expected behavior

mloginfo should report the host name extracted from the logs

Actual/current behavior

Steps to reproduce the actual/current behavior

Run on a log file starting with:

2020-09-07T19:00:36.263+0100 I CONTROL  [conn71088] pid=55156 port=27120 64-bit host=xyz10498n01

output starts with:

(base) [nic:~/Downloads/xyz]$ mloginfo --clients xyz/*                     
     source: xyz/server_mongosd.log.2020-09-06T08-00-40
       host: unknown
      start: 2020 Sep 05 09:00:17.976
        end: 2020 Sep 06 09:00:40.003
date format: iso8601-local

Environment

Software Version
mtools mtools version 1.6.4
Python Python 3.7.6 (default, Jan 8 2020, 13:42:34) [Clang 4.0.1 (tags/RELEASE_401/final)]
MongoDB server db version v3.6.16
Operating system macOS
niccottrell commented 4 years ago

I think it's this line:

https://github.com/rueckstiess/mtools/blob/59b0233fe93b1183dfa51aad4f408aec21fe9f4d/mtools/util/logfile.py#L348

There's no "starting" in the 3.6 logs. How about


            if ln == 0 or "starting :" in line or "starting:" in line:
``
stennie commented 4 years ago

There's no "starting" in the 3.6 logs.

@niccottrell The "starting" match is looking for known restarts, which is still correct for 3.6 (normally from an initandlisten thread).

However, the alternative example you found works as a fall back for finding the host and port details from another thread.

The current match checks even if the hostname is already set, but since only one hostname is reported I'll only check if hostname isn't already set.

Cheers, Stennie