Skip to content

Commit 46e9f02

Browse files
committed
[tailer] add a python version of the tailer
Related to #1601
1 parent b165cab commit 46e9f02

File tree

16 files changed

+843
-35
lines changed

16 files changed

+843
-35
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ Features:
2121
the default for a particular file. Files with
2222
content that lie completely outside of the cutoff
2323
will be closed to reduce resource usage.
24+
* Broadened support for viewing files on remote hosts.
25+
The "tailer" program that is transferred to the
26+
remote host to monitor files and perform other tasks
27+
has been translated to Python3. If the remote host
28+
does not have Python, lnav will fall back to the APE
29+
binary.
2430
* The "Files" panel now shows a progress bar for each
2531
file as it is being indexed and finishes with a
2632
check-mark if indexing was successful, a warning

docs/source/usage.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,22 @@ file.
108108
109109
.. note::
110110

111-
Remote file access is implemented by transferring an
112-
`αcτµαlly pδrταblε εxεcµταblε <https://justine.lol/ape.html>`_ to the
113-
destination and invoking it. An APE binary can run on most any x86_64
114-
machine and OS (i.e. MacOS, Linux, FreeBSD, Windows). The binary is
115-
baked into the lnav executable itself, so there is no extra setup that
111+
Remote file access is implemented through a "tailer" executable that is
112+
transferred to the host. The tailer handles requests from lnav for
113+
synchronizing file blocks, completing path names, previewing files,
114+
and so on.
115+
116+
There are two implementations of the tailer: Python3 and an
117+
`αcτµαlly pδrταblε εxεcµταblε <https://justine.lol/ape.html>`_.
118+
If the target host does not have Python3 installed, the APE binary will
119+
be used. An APE binary can run on most any x86_64 machine and OS
120+
(i.e. MacOS, Linux, FreeBSD, Windows). The implementations are baked
121+
into the lnav executable itself. So, there is no extra setup that
116122
needs to be done on the remote machine.
117123

118-
The binary file is named ``tailer.bin.XXXXXX`` where *XXXXXX* is 6 random digits.
119-
The file is, under normal circumstancies, deleted immediately.
124+
The tailer is copied to the user's home directory and is named
125+
``tailer.bin.XXXXXX`` where *XXXXXX* is 6 random digits.
126+
Under normal circumstances, the file should be deleted immediately.
120127

121128
Command Output
122129
^^^^^^^^^^^^^^

src/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ add_subdirectory(yajl)
2929
add_subdirectory(yajlpp)
3030

3131
add_executable(bin2c bin2c.hh ../tools/bin2c.c)
32+
target_include_directories(bin2c PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3233
target_link_libraries(bin2c ZLIB::ZLIB)
3334

3435
add_executable(ptimec ptimec.hh ptimec.cc)
3536

37+
3638
set(TIME_FORMATS
3739
"@%@"
3840
"%Y-%m-%d %H:%M:%S.%f%z"
@@ -146,7 +148,10 @@ add_custom_command(
146148
COMMAND ptimec ${TIME_FORMATS} > time_fmts.cc)
147149

148150
add_library(lnavdt STATIC config.h.in ptimec.hh ptimec_spec.hh ptimec_rt.cc time_fmts.cc)
149-
target_include_directories(lnavdt PUBLIC . ${CMAKE_CURRENT_BINARY_DIR} third-party/date/include)
151+
target_include_directories(lnavdt PUBLIC
152+
${CMAKE_CURRENT_SOURCE_DIR}
153+
${CMAKE_CURRENT_BINARY_DIR}
154+
third-party/date/include)
150155

151156
function(bin2c)
152157
cmake_parse_arguments(BIN2C_ "" "VARNAME" "" ${ARGN})
@@ -221,7 +226,6 @@ set(FORMAT_FILES
221226
formats/snaplogic_log.json
222227
formats/sssd_log.json
223228
formats/strace_log.json
224-
formats/sudo_log.json
225229
formats/syslog_log.json
226230
formats/s3_log.json
227231
formats/tcf_log.json

src/base/date_time_scanner.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <sys/types.h>
3939

4040
#include "date/tz.h"
41+
#include "intern_string.hh"
4142
#include "time_util.hh"
4243

4344
/**

src/base/time_util.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "config.h"
4444
#include "date/date.h"
4545
#include "date/tz.h"
46-
#include "humanize.time.hh"
4746

4847
inline std::chrono::microseconds
4948
to_us(const timeval& tv)

src/cmds.io.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "base/fs_util.hh"
3636
#include "base/humanize.hh"
3737
#include "base/humanize.network.hh"
38+
#include "base/humanize.time.hh"
3839
#include "base/itertools.enumerate.hh"
3940
#include "base/itertools.hh"
4041
#include "base/paths.hh"

src/formats/esx_syslog_log.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"description": "Format specific to the ESXi syslog",
66
"regex": {
77
"std": {
8-
"pattern": "^(?<timestamp>(?:\\S{3,8}\\s+\\d{1,2} \\d{2}:\\d{2}:\\d{2}|\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z))\\s+(?<level>\\w+\\((?<syslog_pri>\\d+)\\))(?:\\[\\+\\]|\\+)?(?:(?: (?<log_syslog_tag>(?<log_procname>(?:[^\\[:]+|[^:]+))(?:\\[(?<log_pid>\\d+)\\])?):\\s*(?:(?:(?:debug|info|warning|error) )?\\[(?<logger>[^ ]+)(?: sub=(?<sub>[@\\.\\-\\w\\(\\)\\[\\]]+))?(?: op[iI][dD]=(?<opid>[^ \\]]+))?(?: update=(?<update_num>\\d+))?(?: sid=(?<sid>\\w+))?(?: user=(?<user>(?:[^\\]]|<[^>]+>)+))?(?: reason=(?<reason>[^\\]]+))?\\]\\s*)?(?<body>.*))$|:?(?:(?: ---)? last message repeated \\d+ times?(?: ---)?))"
8+
"pattern": "^(?<timestamp>(?:\\S{3,8}\\s+\\d{1,2} \\d{2}:\\d{2}:\\d{2}|\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?)Z)\\s+(?<level>\\w+\\((?<syslog_pri>\\d+)\\))(?:\\[\\+\\]|\\+)?(?:(?: (?<log_syslog_tag>(?<log_procname>(?:[^\\[:]+|[^:]+))(?:\\[(?<log_pid>\\d+)\\])?):\\s*(?:(?:(?:debug|info|warning|error) )?\\[(?<logger>[^ ]+)(?: sub=(?<sub>[@\\.\\-\\w\\(\\)\\[\\]]+))?(?: op[iI][dD]=(?<opid>[^ \\]]+))?(?: update=(?<update_num>\\d+))?(?: sid=(?<sid>\\w+))?(?: user=(?<user>(?:[^\\]]|<[^>]+>)+))?(?: reason=(?<reason>[^\\]]+))?\\]\\s*)?(?<body>.*))$|:?(?:(?: ---)? last message repeated \\d+ times?(?: ---)?))"
99
},
1010
"host": {
11-
"pattern": "^(?<timestamp>(?:\\S{3,8}\\s+\\d{1,2} \\d{2}:\\d{2}:\\d{2}|\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z))\\s+(?<level>\\w+\\((?<syslog_pri>\\d+)\\))(?:\\[\\+\\]|\\+)?(?:(?: (?<log_syslog_tag>(?:host-(?<log_pid>\\d+))?)\\s+(?<body>.*))$|:?(?:(?: ---)? last message repeated \\d+ times?(?: ---)?))"
11+
"pattern": "^(?<timestamp>(?:\\S{3,8}\\s+\\d{1,2} \\d{2}:\\d{2}:\\d{2}|\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?)Z)\\s+(?<level>\\w+\\((?<syslog_pri>\\d+)\\))(?:\\[\\+\\]|\\+)?(?:(?: (?<log_syslog_tag>(?:host-(?<log_pid>\\d+))?)\\s+(?<body>.*))$|:?(?:(?: ---)? last message repeated \\d+ times?(?: ---)?))"
1212
},
1313
"notime": {
1414
"pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2})\\s+(?<level>\\w+\\((?<syslog_pri>\\d+)\\))\\s+(?<log_procname>[^\\[]+)\\[(?<log_pid>\\d+)\\]:\\s(?<new_time>\\d{2}:\\d{2}:\\d{2}\\.\\d+)\\s+(?<body>.*)"

src/line_buffer.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#include "base/auto_fd.hh"
4646
#include "base/auto_mem.hh"
47+
#include "base/enum_util.hh"
4748
#include "base/file_range.hh"
4849
#include "base/is_utf8.hh"
4950
#include "base/lnav.gzip.hh"

src/lnav.prompt.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,8 @@ prompt::get_cmd_parameter_completion(textview_curses& tc,
10671067
= poss_paths | lnav::itertools::similar_to(str, 10)
10681068
| lnav::itertools::map([&str](const std::string& path_str) {
10691069
auto escaped_path = shlex::escape(path_str);
1070-
if (path_str.find_last_of("/\\") == std::string::npos
1070+
if ((path_str.find_last_of("/\\") == std::string::npos
1071+
&& path_str.back() != ':')
10711072
|| path_str == str)
10721073
{
10731074
escaped_path.push_back(' ');

src/tailer/CMakeLists.txt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@ add_library(tailerpp tailerpp.hh tailerpp.cc)
88
target_link_libraries(tailerpp base)
99

1010
add_custom_command(
11-
OUTPUT tailerbin.h tailerbin.cc
12-
COMMAND bin2c -n tailer_bin tailerbin tailer
13-
DEPENDS bin2c tailer)
11+
OUTPUT tailerbin.h tailerbin.cc
12+
COMMAND bin2c -n tailer_bin tailerbin ${CMAKE_CURRENT_SOURCE_DIR}/tailer.main.py tailer
13+
DEPENDS bin2c tailer)
1414

15-
add_library(tailerservice tailer.looper.hh tailer.looper.cc
16-
tailer.looper.cfg.hh tailerbin.h tailerbin.cc)
17-
target_include_directories(tailerservice PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
15+
add_library(tailerservice
16+
tailer.looper.hh
17+
tailer.looper.cc
18+
tailer.looper.cfg.hh
19+
tailerbin.h
20+
tailerbin.cc)
21+
target_include_directories(tailerservice
22+
PUBLIC
23+
../third-party/digestible/include
24+
${CMAKE_CURRENT_BINARY_DIR}
25+
)
1826
target_link_libraries(tailerservice base)
1927

2028
add_executable(drive_tailer drive_tailer.cc)
2129

2230
target_include_directories(drive_tailer PUBLIC . .. ../fmtlib
23-
${CMAKE_CURRENT_BINARY_DIR}/..)
31+
${CMAKE_CURRENT_BINARY_DIR}/..)
2432
target_link_libraries(drive_tailer base tailercommon tailerpp ZLIB::ZLIB)

0 commit comments

Comments
 (0)