mirror of https://github.com/tstack/lnav.git
[demo] add playground
This commit is contained in:
parent
cc598e3ae6
commit
84536d804c
|
@ -14,25 +14,26 @@ ADD https://github.com/tstack/lnav/releases/download/v0.11.0-beta2/lnav-0.11.0-m
|
|||
RUN unzip lnav-0.11.0-musl-64bit.zip
|
||||
|
||||
COPY docs/tutorials tutorials
|
||||
RUN gunzip /tutorials/playground/logs/*.gz
|
||||
|
||||
RUN useradd -rm -d /home/logs -s /bin/bash logs
|
||||
RUN echo 'logs:logs' | chpasswd
|
||||
RUN passwd -d logs
|
||||
RUN useradd -rm -d /home/playground -s /bin/bash playground
|
||||
RUN echo 'playground:playground' | chpasswd
|
||||
RUN passwd -d playground
|
||||
|
||||
RUN useradd -rm -d /home/tutorial1 -s /bin/bash tutorial1
|
||||
RUN echo 'tutorial1:tutorial1' | chpasswd
|
||||
RUN passwd -d tutorial1
|
||||
|
||||
RUN useradd -rm -d /home/debug -s /bin/bash debug
|
||||
RUN echo 'debug:debug' | chpasswd
|
||||
USER playground
|
||||
RUN /lnav-0.11.0/lnav -nN -c ":config /ui/theme monocai"
|
||||
|
||||
USER tutorial1
|
||||
RUN /lnav-0.11.0/lnav -nN -c ":config /ui/theme monocai"
|
||||
|
||||
USER root
|
||||
|
||||
RUN echo 'Match User logs' >> /etc/ssh/sshd_config
|
||||
RUN echo 'ForceCommand env LNAVSECURE=1 TERM=xterm-256color /lnav-0.11.0/lnav -d /tmp/lnav.err /demo' >> /etc/ssh/sshd_config
|
||||
RUN echo 'Match User playground' >> /etc/ssh/sshd_config
|
||||
RUN echo 'ForceCommand env PATH=/lnav-0.11.0:$PATH /tutorials/playground/run.sh' >> /etc/ssh/sshd_config
|
||||
RUN echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config
|
||||
RUN echo 'Match User tutorial1' >> /etc/ssh/sshd_config
|
||||
RUN echo 'ForceCommand env PATH=/lnav-0.11.0:$PATH /tutorials/tutorial1/run.sh' >> /etc/ssh/sshd_config
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
# Playground
|
||||
|
||||
Welcome to the **lnav** playground!
|
||||
|
||||
There are some sample files loaded into the log and text views.
|
||||
Press `q` to switch back to the log view and start exploring.
|
||||
You can also press `f` in this view to switch to the other
|
||||
text files that are loaded, like a markdown sample.
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
export LNAVSECURE=1
|
||||
export TERM=xterm-256color
|
||||
|
||||
timeout --foreground --kill-after=30s 10m lnav \
|
||||
/tutorials/playground/logs \
|
||||
/tutorials/playground/text \
|
||||
/tutorials/playground/index.md#playground
|
||||
|
||||
if [ $? = 124 ]; then
|
||||
echo "error: reached connection time limit, reconnect if you're not a bot."
|
||||
else
|
||||
echo "Thanks for trying out lnav! Have a nice day!"
|
||||
fi
|
|
@ -0,0 +1,157 @@
|
|||
An h1 header
|
||||
============
|
||||
|
||||
Paragraphs are separated by a blank line.
|
||||
|
||||
2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists
|
||||
look like:
|
||||
|
||||
* this one
|
||||
* that one
|
||||
* the other one
|
||||
|
||||
Note that --- not considering the asterisk --- the actual text
|
||||
content starts at 4-columns in.
|
||||
|
||||
> Block quotes are
|
||||
> written like so.
|
||||
>
|
||||
> They can span multiple paragraphs,
|
||||
> if you like.
|
||||
|
||||
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
|
||||
in chapters 12--14"). Three dots ... will be converted to an ellipsis.
|
||||
Unicode is supported. ☺
|
||||
|
||||
|
||||
|
||||
An h2 header
|
||||
------------
|
||||
|
||||
Here's a numbered list:
|
||||
|
||||
1. first item
|
||||
2. second item
|
||||
3. third item
|
||||
|
||||
Note again how the actual text starts at 4 columns in (4 characters
|
||||
from the left side). Here's a code sample:
|
||||
|
||||
# Let me re-iterate ...
|
||||
for i in 1 .. 10 { do-something(i) }
|
||||
|
||||
As you probably guessed, indented 4 spaces. By the way, instead of
|
||||
indenting the block, you can use delimited blocks, if you like:
|
||||
|
||||
~~~
|
||||
define foobar() {
|
||||
print "Welcome to flavor country!";
|
||||
}
|
||||
~~~
|
||||
|
||||
(which makes copying & pasting easier). You can optionally mark the
|
||||
delimited block for Pandoc to syntax highlight it:
|
||||
|
||||
~~~python
|
||||
import time
|
||||
# Quick, count to ten!
|
||||
for i in range(10):
|
||||
# (but not *too* quick)
|
||||
time.sleep(0.5)
|
||||
print i
|
||||
~~~
|
||||
|
||||
|
||||
|
||||
### An h3 header ###
|
||||
|
||||
Now a nested list:
|
||||
|
||||
1. First, get these ingredients:
|
||||
|
||||
* carrots
|
||||
* celery
|
||||
* lentils
|
||||
|
||||
2. Boil some water.
|
||||
|
||||
3. Dump everything in the pot and follow
|
||||
this algorithm:
|
||||
|
||||
find wooden spoon
|
||||
uncover pot
|
||||
stir
|
||||
cover pot
|
||||
balance wooden spoon precariously on pot handle
|
||||
wait 10 minutes
|
||||
goto first step (or shut off burner when done)
|
||||
|
||||
Do not bump wooden spoon or it will fall.
|
||||
|
||||
Notice again how text always lines up on 4-space indents (including
|
||||
that last line which continues item 3 above).
|
||||
|
||||
Here's a link to [a website](http://foo.bar), to a [local
|
||||
doc](local-doc.html), and to a [section heading in the current
|
||||
doc](#an-h2-header). Here's a footnote [^1].
|
||||
|
||||
[^1]: Footnote text goes here.
|
||||
|
||||
Tables can look like this:
|
||||
|
||||
size material color
|
||||
---- ------------ ------------
|
||||
9 leather brown
|
||||
10 hemp canvas natural
|
||||
11 glass transparent
|
||||
|
||||
Table: Shoes, their sizes, and what they're made of
|
||||
|
||||
(The above is the caption for the table.) Pandoc also supports
|
||||
multi-line tables:
|
||||
|
||||
-------- -----------------------
|
||||
keyword text
|
||||
-------- -----------------------
|
||||
red Sunsets, apples, and
|
||||
other red or reddish
|
||||
things.
|
||||
|
||||
green Leaves, grass, frogs
|
||||
and other things it's
|
||||
not easy being.
|
||||
-------- -----------------------
|
||||
|
||||
A horizontal rule follows.
|
||||
|
||||
***
|
||||
|
||||
Here's a definition list:
|
||||
|
||||
apples
|
||||
: Good for making applesauce.
|
||||
oranges
|
||||
: Citrus!
|
||||
tomatoes
|
||||
: There's no "e" in tomatoe.
|
||||
|
||||
Again, text is indented 4 spaces. (Put a blank line between each
|
||||
term/definition pair to spread things out more.)
|
||||
|
||||
Here's a "line block":
|
||||
|
||||
| Line one
|
||||
| Line too
|
||||
| Line tree
|
||||
|
||||
and images can be specified like so:
|
||||
|
||||
![example image](example-image.jpg "An exemplary image")
|
||||
|
||||
Inline math equations go in like so: $\omega = d\phi / dt$. Display
|
||||
math should get its own line and be put in in double-dollarsigns:
|
||||
|
||||
$$I = \int \rho R^{2} dV$$
|
||||
|
||||
And note that you can backslash-escape any punctuation characters
|
||||
which you wish to be displayed literally, ex.: \`foo\`, \*bar\*, etc.
|
|
@ -135,6 +135,9 @@ That's all for now, thanks for your time! Visit the
|
|||
download or install **lnav** for your system. The full
|
||||
documentation is available at https://docs.lnav.org
|
||||
|
||||
Press `q` to switch to the log view and then press `q` again to
|
||||
exit **lnav**.
|
||||
|
||||
## Colophon
|
||||
|
||||
The source for this tutorial is available here:
|
||||
|
|
|
@ -12,15 +12,25 @@ SYSLOG_DATE_FMT = "%b %d %H:%M:%S"
|
|||
ACCESS_LOG_DATE_FMT = "%d/%b/%Y:%H:%M:%S"
|
||||
GENERIC_DATE_FMT = "%Y-%m-%dT%H:%M:%S.%%s"
|
||||
|
||||
TEST_ADDRESSES = [
|
||||
"192.0.2.55",
|
||||
#"192.0.2.123",
|
||||
"192.0.2.33",
|
||||
#"192.0.2.2",
|
||||
]
|
||||
TEST_ADDRESSES = (
|
||||
["192.0.2.55"] * 20 +
|
||||
["192.0.2.44"] * 20 +
|
||||
["192.0.2.3"] * 40 +
|
||||
["192.0.2.100"] * 10 +
|
||||
["192.0.2.122"] * 30 +
|
||||
["192.0.2.42"] * 100
|
||||
)
|
||||
|
||||
TEST_USERNAMES = [
|
||||
"bob@example.com",
|
||||
"bob@example.com",
|
||||
"bob@example.com",
|
||||
"combatcarl@example.com",
|
||||
"combatcarl@example.com",
|
||||
"combatcarl@example.com",
|
||||
"combatcarl@example.com",
|
||||
"combatcarl@example.com",
|
||||
"combatcarl@example.com",
|
||||
"-",
|
||||
"-",
|
||||
"-",
|
||||
|
@ -39,6 +49,8 @@ TEST_METHODS = [
|
|||
"PUT",
|
||||
]
|
||||
|
||||
PATH_COMPS = "Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua".split()
|
||||
|
||||
TEST_URLS = [
|
||||
"/index.html",
|
||||
"/index.html",
|
||||
|
@ -50,6 +62,12 @@ TEST_URLS = [
|
|||
"/obj/1236?search=demo&start=1",
|
||||
]
|
||||
|
||||
for index in range(0, 50):
|
||||
path_list = []
|
||||
for count in range(random.randint(2, 8)):
|
||||
path_list.append(random.choice(PATH_COMPS))
|
||||
TEST_URLS.append("/".join(path_list))
|
||||
|
||||
TEST_VERSIONS = [
|
||||
"HTTP/1.0",
|
||||
"HTTP/1.0",
|
||||
|
@ -68,6 +86,12 @@ TEST_STATUS = [
|
|||
200,
|
||||
200,
|
||||
404,
|
||||
404,
|
||||
404,
|
||||
404,
|
||||
403,
|
||||
403,
|
||||
403,
|
||||
500
|
||||
]
|
||||
|
||||
|
@ -91,24 +115,44 @@ TEST_AGENTS = [
|
|||
"Apache-HttpClient/4.2.3 (java 1.5)",
|
||||
"Apache-HttpClient/4.2.3 (java 1.5)",
|
||||
"Apache-HttpClient/4.2.3 (java 1.5)",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
||||
"Roku4640X/DVP-7.70 (297.70E04154A)",
|
||||
"Roku4640X/DVP-7.70 (297.70E04154A)",
|
||||
"Roku4640X/DVP-7.70 (297.70E04154A)",
|
||||
]
|
||||
|
||||
START_TIME = datetime.datetime.fromtimestamp(1641898727)
|
||||
ACCESS_LOG_CURR_TIME = START_TIME
|
||||
SYSLOG_LOG_CURR_TIME = START_TIME
|
||||
|
||||
|
||||
def access_log_msgs():
|
||||
global ACCESS_LOG_CURR_TIME
|
||||
while True:
|
||||
now = datetime.datetime.now()
|
||||
ts = now - datetime.timedelta(seconds=1)
|
||||
ACCESS_LOG_CURR_TIME += datetime.timedelta(seconds=random.randrange(1, 3))
|
||||
yield '%s - %s [%s +0000] "%s %s %s" %s %s "%s" "%s"\n' % (
|
||||
random.choice(TEST_ADDRESSES),
|
||||
random.choice(TEST_USERNAMES),
|
||||
ts.strftime(ACCESS_LOG_DATE_FMT),
|
||||
ACCESS_LOG_CURR_TIME.strftime(ACCESS_LOG_DATE_FMT),
|
||||
random.choice(TEST_METHODS),
|
||||
random.choice(TEST_URLS),
|
||||
random.choice(TEST_VERSIONS),
|
||||
random.choice(TEST_STATUS),
|
||||
random.randint(16, 1024 * 1024),
|
||||
int(random.lognormvariate(1, 1) * 1000),
|
||||
random.choice(TEST_REFERRERS),
|
||||
random.choice(TEST_AGENTS)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
TEST_PROCS = [
|
||||
"server[123]",
|
||||
|
@ -133,13 +177,17 @@ TEST_MSGS = [
|
|||
"Received packet from %s" % random.choice(TEST_ADDRESSES),
|
||||
]
|
||||
|
||||
|
||||
def syslog_msgs():
|
||||
global SYSLOG_LOG_CURR_TIME
|
||||
while True:
|
||||
SYSLOG_LOG_CURR_TIME += datetime.timedelta(seconds=random.randrange(1, 3))
|
||||
yield '%s frontend3 %s: %s\n' % (
|
||||
datetime.datetime.now().strftime(SYSLOG_DATE_FMT),
|
||||
SYSLOG_LOG_CURR_TIME.strftime(SYSLOG_DATE_FMT),
|
||||
random.choice(TEST_PROCS),
|
||||
random.choice(TEST_MSGS),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
try:
|
||||
shutil.rmtree("/tmp/demo")
|
||||
|
@ -152,21 +200,26 @@ FILES = [
|
|||
("/tmp/demo/messages", syslog_msgs()),
|
||||
]
|
||||
|
||||
while True:
|
||||
COUNTER = 0
|
||||
while COUNTER < 5000:
|
||||
loop_inc = datetime.timedelta(seconds=random.weibullvariate(1, 1.5) * 500)
|
||||
ACCESS_LOG_CURR_TIME += loop_inc
|
||||
SYSLOG_LOG_CURR_TIME += loop_inc
|
||||
for fname, gen in FILES:
|
||||
for i in range(random.randrange(0, 4)):
|
||||
for i in range(random.randrange(4, 8)):
|
||||
COUNTER += 1
|
||||
with open(fname, "a+") as fp:
|
||||
if random.uniform(0.0, 1.0) < 0.01:
|
||||
line = next(gen)
|
||||
prefix = line[:50]
|
||||
suffix = line[50:]
|
||||
fp.write(prefix)
|
||||
time.sleep(random.uniform(0.5, 0.6))
|
||||
# time.sleep(random.uniform(0.5, 0.6))
|
||||
fp.write(suffix)
|
||||
else:
|
||||
fp.write(next(gen))
|
||||
# if random.uniform(0.0, 1.0) < 0.010:
|
||||
# fp.truncate(0)
|
||||
time.sleep(random.uniform(0.01, 0.02))
|
||||
#if random.uniform(0.0, 1.0) < 0.001:
|
||||
# time.sleep(random.uniform(0.01, 0.02))
|
||||
# if random.uniform(0.0, 1.0) < 0.001:
|
||||
# os.remove(fname)
|
||||
|
|
Loading…
Reference in New Issue