New rec-client script.

This commit is contained in:
Blallo 2019-03-23 19:09:38 +01:00
parent 1abd2592e1
commit 1ad214d1d4
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F

View file

@ -0,0 +1,88 @@
#!/usr/bin/env bash
SESSION="circolog"
TAIL="ctl"
DAEMON="d"
DWINDOW="${SESSION}:${DAEMON}"
TAILWINDOW="${SESSION}:${TAIL}"
d_send_command() {
tmux send-keys -t "${DWINDOW}.${1}" "${2}" Enter
}
tail_send_command() {
tmux send-keys -t "${TAILWINDOW}.${1}" "${2}" Enter
}
digit_command() {
local input=$2
for (( i=0; i<${#input}; i++ ))
do
sleep 0.1
tmux send-keys -t "${TAILWINDOW}.${1}" "${input:$i:1}"
done
sleep 2
tmux send-keys -t "${TAILWINDOW}.${1}" Enter
}
digit_comment() {
local input=$2
for (( i=0; i<${#input}; i++ ))
do
sleep 0.1
tmux send-keys -t "${TAILWINDOW}.${1}" "${input:$i:1}"
done
sleep 2
for (( i=0; i<${#input}; i++ ))
do
tmux send-keys -t "${TAILWINDOW}.${1}" "C-h"
done
}
config() {
tmux new -s $SESSION -n $TAIL -d
tmux new-window -t $SESSION -n $DAEMON
tmux split-window -v -t $DWINDOW
tmux set-option -t $SESSION status off
d_send_command 0 "circologd"
tail_send_command 0 "bash"
tail_send_command 0 "PS1='my-server ~ '"
tail_send_command 0 "clear"
}
logger_send() {
d_send_command 1 "logger -n 127.0.0.1 -P 9514 --rfc5424=nohost -t oper -d -p user.${2:-5} ${1}"
}
start_ctl() {
sleep 3;
digit_comment 0 "Let's take a look at circolog-tail, the circologd client to read and *filter* logs."
digit_command 0 "circolog-tail"
sleep 2
logger_send "This is a log message from some program."
sleep 2
logger_send "This is an error. Look at these nice colors we have." "3"
sleep 2
logger_send "This is a debug message." "7"
sleep 4
tail_send_command 0 "C-c"
sleep 1
digit_comment 0 "Let's see how to filter. The syntax is SQL-alike."
sleep 1
digit_command 0 "circolog-tail -where 'msg LIKE \"%error%\"'"
}
attach_session() {
tmux attach -t $TAILWINDOW
}
cleanup() {
send_command 0 "C-c"
tmux kill-session -t $SESSION
}
trap cleanup 2 15
config
start_ctl &
attach_session