### Install tlog from Source Source: https://github.com/scribery/tlog/blob/main/README.md Command to install tlog after building it from source. This uses the standard 'make install' command, typically requiring root privileges with 'sudo'. ```bash sudo make install ``` -------------------------------- ### Tlog Configuration File Examples Source: https://context7.com/scribery/tlog/llms.txt This section shows example configurations for tlog. It includes the file paths for system-wide recording and playback configurations, along with snippets demonstrating rate-limiting settings in `tlog-rec-session.conf` and Elasticsearch playback settings in `tlog-play.conf`. ```bash # System-wide recording configuration /etc/tlog/tlog-rec-session.conf # Playback configuration /etc/tlog/tlog-play.conf # Example rate-limiting in tlog-rec-session.conf: { "limit": { "rate": 10240, "burst": 51200, "action": "delay" }, "writer": "journal" } # Example Elasticsearch playback in tlog-play.conf: { "reader": "es", "es": { "baseurl": "http://localhost:9200/tlog-rsyslog/tlog/_search" } } ``` -------------------------------- ### Start Apache HTTP Server (systemctl) Source: https://github.com/scribery/tlog/blob/main/lib/tlitest/journal-good.txt This snippet demonstrates the command used to start the Apache HTTP server service. It requires administrative privileges and may prompt for authentication. The output shows the authentication process and successful service start. ```shell systemctl start httpd ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ==== Authentication is required to start 'httpd.service'. Authenticating as: localadmin1 Password: ==== AUTHENTICATION COMPLETE ==== ``` -------------------------------- ### Build Tlog from Source (Debian/RPM) Source: https://context7.com/scribery/tlog/llms.txt These shell commands provide instructions for installing build dependencies and compiling the tlog project from source on both Debian-based and RPM-based Linux distributions. It covers installing necessary packages, configuring the build, compiling, and installing the software, as well as creating an RPM package. ```bash # Install build dependencies (RPM-based) sudo yum install gcc make autoconf automake libtool \ systemd-devel json-c-devel libcurl-devel libutempter-devel # Install build dependencies (Debian-based) sudo apt-get install gcc make autoconf automake libtool pkg-config \ libsystemd-dev libjson-c-dev libcurl4-gnutls-dev libutempter-dev # Build from git source autoreconf -i -f ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make # Install sudo make install # Build RPM package from tarball rpmbuild -tb tlog-14.tar.gz # Generate source tarball ./configure --prefix=/usr --sysconfdir=/etc make dist ``` -------------------------------- ### C Macro Wrapping Example Source: https://github.com/scribery/tlog/blob/main/CONTRIBUTING.md Provides an example of how to wrap macros in C code for Tlog. It demonstrates the use of backslashes for line continuation within a macro definition, ensuring readability and proper syntax for complex macros. Specifically shows a `do-while(0)` structure for safety. ```c #define CMP_BOOL(_name) \ do { \ if (_name != t._name##_out) { \ FAIL(#_name " %s != %s", \ BOOL_STR(_name), BOOL_STR(t._name##_out)); \ } \ } while (0) ``` -------------------------------- ### Tlog I/O Transaction Example Source: https://github.com/scribery/tlog/blob/main/notes.txt Illustrates a typical I/O write operation within a transaction context. It shows the sequence of starting, committing, and aborting stream and I/O transactions, including error handling for writing delays and stream data. This pattern assumes that only top-level transactions will perform actual commit or abort actions, using a nesting counter. ```pseudocode tlog_io_trx_start(io) tlog_stream_trx_start(input) tlog_stream_trx_start(output) try writing delay to timing if failed: tlog_io_trx_abort(io) tlog_stream_trx_abort(input) tlog_stream_trx_abort(output) try writing stream if failed: tlog_io_trx_abort(io) tlog_stream_trx_abort(input) tlog_stream_trx_abort(output) tlog_io_trx_commit(io) tlog_stream_trx_commit(input) tlog_stream_trx_commit(output) ``` -------------------------------- ### C API: Creating JSON Readers Source: https://context7.com/scribery/tlog/llms.txt This C code illustrates how to create and utilize JSON readers with the tlog library. It provides examples for setting up file descriptor and Elasticsearch readers, reading messages, and handling potential errors during the process. ```c #include #include #include // Create file descriptor reader struct tlog_json_reader *reader = NULL; int fd = open("/var/log/tlog.json", O_RDONLY); tlog_grc grc = tlog_fd_json_reader_create(&reader, fd, // file descriptor true, // fd_owned 8192, // buffer size NULL); // match (recording ID) if (grc != TLOG_RC_OK) { fprintf(stderr, "Failed to create reader\n"); return 1; } // Read messages struct json_object *msg = NULL; while ((grc = tlog_json_reader_read(reader, &msg)) == TLOG_RC_OK && msg != NULL) { printf("Message: %s\n", json_object_to_json_string(msg)); json_object_put(msg); } tlog_json_reader_destroy(reader); // Create Elasticsearch reader const char *base_url = "http://localhost:9200/tlog-rsyslog/tlog/_search"; const char *query = "host:server AND session:17"; grc = tlog_es_json_reader_create(&reader, base_url, query, 100, // messages per request false); // verbose ``` -------------------------------- ### C Code Block Formatting and Control Flow Source: https://github.com/scribery/tlog/blob/main/CONTRIBUTING.md Demonstrates correct C code formatting for if-else statements, do-while, while loops, and switch statements. Emphasizes brace placement and indentation rules. No external dependencies are required, and it serves as a visual guide for developers. ```c if (a == b) { ... } if (a == b) { ... } else if (a > b) { ... } if (a == b) { do_something(); } else { do_something_else(); } do { do_something(); } while (cond); while (cond) { do_something(); } switch (expression) { case constant-expression: ... case constant-expression: ... default: ... } ``` -------------------------------- ### Create Symlink for Per-User Shell Recording (Bash) Source: https://github.com/scribery/tlog/blob/main/README.md This command creates a symbolic link to `tlog-rec-session`. The name of the symlink determines the shell that `tlog-rec-session` will execute and record. For example, `tlog-rec-session-shell-bin-zsh` will cause `tlog-rec-session` to start `/bin/zsh`. ```bash sudo ln -s tlog-rec-session /usr/bin/tlog-rec-session-shell-bin-zsh ``` -------------------------------- ### C API: Creating JSON Writers Source: https://context7.com/scribery/tlog/llms.txt This C code demonstrates how to create and use JSON writers with the tlog library. It includes examples for creating file descriptor, syslog, and journal writers, writing JSON messages, and cleaning up resources. ```c #include #include #include #include // Create file descriptor writer struct tlog_json_writer *writer = NULL; int fd = open("/var/log/tlog.json", O_WRONLY | O_CREAT | O_APPEND, 0600); tlog_grc grc = tlog_fd_json_writer_create(&writer, fd, true); if (grc != TLOG_RC_OK) { fprintf(stderr, "Failed to create writer\n"); return 1; } // Write JSON message const char *json_msg = "{\"ver\":\"2.3\",\"host\":\"localhost\"}"; grc = tlog_json_writer_write(writer, 1, (uint8_t*)json_msg, strlen(json_msg)); if (grc != TLOG_RC_OK) { fprintf(stderr, "Write failed\n"); } // Cleanup tlog_json_writer_destroy(writer); // Create syslog writer with LOG_INFO priority grc = tlog_syslog_json_writer_create(&writer, LOG_INFO); // Create journal writer with metadata grc = tlog_journal_json_writer_create(&writer, LOG_INFO, // priority true, // augment with fields "rec-12345", // recording ID "johndoe", // username 42); // session ID ``` -------------------------------- ### Play Back Terminal Session from File Source: https://github.com/scribery/tlog/blob/main/README.md Command to play back a previously recorded terminal session from a file using tlog-play. This example specifies the 'file' reader and the path to the log file. ```bash tlog-play --reader=file --file-path=tlog.log ``` -------------------------------- ### Play Back Recorded Sessions (Bash) Source: https://context7.com/scribery/tlog/llms.txt Illustrates how to use `tlog-play` to replay terminal session recordings from files. Supports playback at different speeds, continuous following of recordings (like `tail -f`), and starting playback in a paused state at a specific timestamp. Requires the `tlog-play` command-line utility and a recorded session file. ```bash # Play back from a file tlog-play --reader=file --file-path=session.log # Play back with 2x speed tlog-play --reader=file --file-path=session.log --speed=2 # Follow ongoing recording (like tail -f) tlog-play --reader=file --file-path=session.log --follow # Start paused and goto specific timestamp tlog-play --reader=file --file-path=session.log --paused --goto=60000 ``` -------------------------------- ### Configure PAM for Locale Environment on Fedora/RHEL Source: https://github.com/scribery/tlog/blob/main/README.md This PAM configuration snippet is used on Fedora and RHEL systems to ensure that locale environment variables are read from `/etc/locale.conf` before the session starts. This helps prevent locale configuration issues with `tlog-rec-session` by correctly setting the environment. ```pam session required pam_env.so readenv=1 envfile=/etc/locale.conf ``` -------------------------------- ### Record Terminal Session to File Source: https://github.com/scribery/tlog/blob/main/README.md Command to record terminal input and output to a file using tlog-rec. This example specifies the 'file' writer and the path for the log file. ```bash tlog-rec --writer=file --file-path=tlog.log ``` -------------------------------- ### Record to Systemd Journal (Bash) Source: https://context7.com/scribery/tlog/llms.txt Shows how to record terminal sessions directly to the systemd journal using `tlog-rec`. Recordings are stored as journal entries with searchable fields like `TLOG_USER`, `TLOG_SESSION`, `TLOG_REC`, and `TLOG_ID`. This method requires systemd to be installed and running. ```bash # Record session to journal with default priority (info) tlog-rec --writer=journal # The recording creates journal entries with searchable fields: # TLOG_USER - username that started the recording # TLOG_SESSION - audit session ID # TLOG_REC - host-unique recording ID # TLOG_ID - message ID within the recording ``` -------------------------------- ### Record to Syslog (Bash) Source: https://context7.com/scribery/tlog/llms.txt Provides examples of how to record terminal sessions to syslog using `tlog-rec`. The utility sends logs with default facility (`authpriv`) and priority (`info`). Syslog messages are typically found in `/var/log/auth.log` or `/var/log/secure` depending on the system. ```bash # Record to syslog with default facility (authpriv) and priority (info) tlog-rec --writer=syslog # Syslog messages appear in: # - /var/log/auth.log (Debian-based systems) # - /var/log/secure (RHEL/Fedora systems) ``` -------------------------------- ### Playback tlog from Elasticsearch Source: https://context7.com/scribery/tlog/llms.txt These bash commands demonstrate how to use the 'tlog-play' utility to playback tlog messages recorded in Elasticsearch. Examples include playback using a query string, following ongoing recordings, and using lax mode to ignore missing messages. ```bash # Playback from Elasticsearch using query string tlog-play --reader=es \ --es-baseurl=http://localhost:9200/tlog-rsyslog/tlog/_search \ --es-query='host:server AND session:17 AND timestamp:>=now-7d' # Follow ongoing Elasticsearch recording tlog-play --reader=es \ --es-baseurl=http://localhost:9200/tlog-rsyslog/tlog/_search \ --es-query='rec:12ca5b356065453fb50adfe57007658a-306a-26f2910' \ --follow # Playback with lax mode (ignore missing messages in partial recordings) tlog-play --reader=es \ --es-baseurl=http://localhost:9200/tlog-rsyslog/tlog/_search \ --es-query='user:johndoe AND timestamp:>=now-1h' \ --lax ``` -------------------------------- ### Example Tlog JSON Entry Source: https://github.com/scribery/tlog/blob/main/doc/log_format.md A sample JSON object representing a single log entry from the tlog system. It includes metadata like version, host, user, terminal type, session ID, and timing information, along with input and output text/binary data. ```json { "ver": "2.1", "host": "server.example.com", "rec": "e843f15839e54e7d83bdc8c128978586-22c2-5d24f15", "user": "johndoe", "term": "xterm", "session": 324, "id": 23, "pos": 345349, "time": 1600718060.667, "timing": "=80x24<5+1>6+3>30+6>20", "in_txt": "date\r", "in_bin": [], "out_txt": "date\r\nMon Nov 30 11:52:45 UTC 2015\r\n[johndoe@server ~]$ ", "out_bin": [] } ``` -------------------------------- ### Control Playback Speed and Position with tlog-play Source: https://github.com/scribery/tlog/blob/main/README.md These options provide fine-grained control over the playback process. `-s` adjusts the playback speed, `-g` seeks to a specific point in the recording, and `-p` starts playback in a paused state. ```bash tlog-play -s 2.0 ``` ```bash tlog-play -g 1000 ``` ```bash tlog-play -p ``` -------------------------------- ### C API: Lock and Unlock Session for Recording Source: https://context7.com/scribery/tlog/llms.txt This C code demonstrates how to manage session locking using the tlog library to prevent duplicate recordings. It includes functions to get the current session ID, acquire a lock, and release it, along with error handling. Dependencies include tlog/session.h. ```c #include // Get current session ID unsigned int session_id; tlog_grc grc = tlog_session_get_id(&session_id); if (grc != TLOG_RC_OK) { fprintf(stderr, "Failed to get session ID\n"); return 1; } // Lock session (prevents duplicate recording) struct tlog_errs *errs = NULL; bool acquired = false; grc = tlog_session_lock(&errs, session_id, geteuid(), getegid(), &acquired); if (grc != TLOG_RC_OK) { tlog_errs_print(stderr, errs); tlog_errs_destroy(&errs); return 1; } if (!acquired) { printf("Session is already being recorded\n"); return 1; } // ... perform recording ... // Unlock session when done grc = tlog_session_unlock(&errs, session_id, geteuid(), getegid()); tlog_errs_destroy(&errs); ``` -------------------------------- ### C API: Record Session with JSON Configuration Source: https://context7.com/scribery/tlog/llms.txt This C code snippet demonstrates how to set up and execute a session recording using the tlog library. It configures recording parameters via a JSON object, specifies the program to record, and handles the recording process, including error checking. Dependencies include tlog headers and json-c. ```c #include #include #include // Setup recording configuration struct tlog_errs *errs = NULL; struct json_object *conf = json_object_new_object(); // Configure writer type and parameters json_object_object_add(conf, "writer", json_object_new_string("file")); json_object_object_add(conf, "file", json_object_new_object()); json_object_object_add(json_object_object_get(conf, "file"), "path", json_object_new_string("/var/log/session.log")); // Setup command to record const char *path = "/bin/bash"; char *argv[] = {"/bin/bash", "-l", NULL}; // Execute recording int status = 0; int signal = 0; tlog_grc grc = tlog_rec(&errs, getuid(), // euid getgid(), // egid "Recording session", // help message conf, // configuration TLOG_REC_OPT_SEARCH_PATH, // options path, // program path argv, // program argv STDIN_FILENO, // stdin STDOUT_FILENO, // stdout STDERR_FILENO, // stderr &status, // exit status &signal); // termination signal if (grc != TLOG_RC_OK) { tlog_errs_print(stderr, errs); tlog_errs_destroy(&errs); return 1; } json_object_put(conf); ``` -------------------------------- ### Build tlog from Git Source Source: https://github.com/scribery/tlog/blob/main/README.md Commands to generate build system files and configure the build process for tlog when building from a Git repository. This involves using autoconf, automake, and libtool, followed by the standard configure and make steps. ```bash autoreconf -i -f ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var && make ``` -------------------------------- ### Build tlog RPM Package Source: https://github.com/scribery/tlog/blob/main/README.md Commands to build an SRPM (Source RPM) or a binary RPM package from a tlog source tarball. This is typically done using the rpmbuild command with the -ts or -tb flags. ```bash rpmbuild -ts rpmbuild -tb ``` -------------------------------- ### Configuring User Session Recording (Bash) Source: https://context7.com/scribery/tlog/llms.txt Details the steps to configure `tlog-rec-session` as a user's login shell for recording entire sessions. Includes commands for setting the login shell, creating symlinks for specific shell preferences, and setting up the session lock directory for multi-user recording. Requires root privileges for `usermod` and directory operations. ```bash # Set tlog-rec-session as user's login shell sudo usermod -s /usr/bin/tlog-rec-session username # Create symlink for specific shell preference sudo ln -s tlog-rec-session /usr/bin/tlog-rec-session-shell-bin-zsh # Assign symlinked shell to user (will record zsh sessions) sudo usermod -s /usr/bin/tlog-rec-session-shell-bin-zsh username # Create session lock directory for multi-user recording sudo mkdir -p /var/run/tlog sudo chown tlog:tlog /var/run/tlog sudo chmod 755 /var/run/tlog ``` -------------------------------- ### Play Back from Systemd Journal (Bash) Source: https://context7.com/scribery/tlog/llms.txt Demonstrates playing back terminal recordings stored in the systemd journal using `tlog-play`. Supports filtering playback by recording ID, user, and time constraints. Can also follow ongoing journal recordings and read from specific journal namespaces (systemd >= 245). Requires `tlog-play` and access to the systemd journal. ```bash # Playback using recording ID tlog-play --reader=journal --journal-match=TLOG_REC=12ca5b356065453fb50adfe57007658a-306a-26f2910 # Playback with time constraints tlog-play --reader=journal \ --journal-match=TLOG_USER=johndoe \ --journal-since="2024-01-15 10:00:00" \ --journal-until="2024-01-15 11:00:00" # Follow ongoing journal recording tlog-play --reader=journal --journal-match=TLOG_SESSION=2 --follow # Read from specific journal namespace (systemd >= 245) tlog-play --reader=journal --journal-namespace=user-1000 --journal-match=TLOG_REC= ``` -------------------------------- ### C Function Declaration Formatting Source: https://github.com/scribery/tlog/blob/main/CONTRIBUTING.md Illustrates the specific C code formatting for function declarations in Tlog. It shows how 'static' and return type are placed on the same line, while the function name is on a new line. This ensures consistent function signature presentation. ```c static tlog_grc tlog_play_run(struct tlog_errs **perrs, int *psignal) { ... } ``` -------------------------------- ### Record Terminal Sessions to a File (Bash) Source: https://context7.com/scribery/tlog/llms.txt Demonstrates how to use `tlog-rec` to record terminal I/O to a file. Supports recording specific commands, custom shells, and includes options for file path specification. Relies on the `tlog-rec` command-line utility. ```bash # Record a shell session to a file tlog-rec --writer=file --file-path=session.log # Execute specific command with recording tlog-rec --writer=file --file-path=output.log ls -la /home # Record with custom shell tlog-rec --writer=file --file-path=bash_session.log --shell=/bin/bash ``` -------------------------------- ### List HTTP Processes (ps) Source: https://github.com/scribery/tlog/blob/main/lib/tlitest/journal-good.txt This snippet demonstrates how to list all running processes related to 'http' using the 'ps -ef' command piped to grep. It helps in identifying and monitoring Apache HTTP server processes. ```shell ps -ef|grep http root 1581 1 1 13:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1582 1581 0 13:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1583 1581 0 13:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1584 1581 0 13:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND apache 1585 1581 0 13:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND localus+ 1798 1537 0 13:26 pts/2 00:00:00 grep --color=auto http ``` -------------------------------- ### Timing String Format Source: https://context7.com/scribery/tlog/llms.txt This section explains the syntax used in the 'timing' field of tlog JSON messages. It details codes for setting window size, reading input/output characters, introducing delays, and handling binary data or replacement characters. ```text # Timing syntax examples: =80x24 # Set window size to 80 columns x 24 rows <5 # Read 5 input characters from in_txt >6 # Read 6 output characters from out_txt +1000 # Delay 1000 milliseconds [2/3 # Skip 2 replacement chars in in_txt, read 3 bytes from in_bin ]1/4 # Skip 1 replacement char in out_txt, read 4 bytes from out_bin # Full example: "=80x24<5+1>6+3>30+6>20" # 1. Set window to 80x24 # 2. Read 5 input chars # 3. Wait 1ms # 4. Read 6 output chars # 5. Wait 3ms # 6. Read 30 output chars # 7. Wait 6ms # 8. Read 20 output chars ``` -------------------------------- ### Create tlog Source Tarball Source: https://github.com/scribery/tlog/blob/main/README.md Command to generate a source tarball for tlog. This is useful for distribution or for building RPM packages. It uses the configure script with specific prefix and sysconfdir options before running make dist. ```bash ./configure --prefix=/usr --sysconfdir=/etc && make dist ``` -------------------------------- ### Record to Systemd Journal with tlog-rec Source: https://github.com/scribery/tlog/blob/main/README.md This command initiates recording of the terminal session to the Systemd Journal. It leverages the `--writer=journal` option. The utility also copies specific JSON fields to Journal fields for enhanced searchability. ```bash tlog-rec --writer=journal ``` -------------------------------- ### Handling Incomplete UTF-8 Sequences for Logging Source: https://github.com/scribery/tlog/blob/main/notes.txt This snippet demonstrates the logic for processing input byte streams to correctly identify and handle UTF-8 sequences, whether they are complete, incomplete, or contain invalid bytes. It manages writing complete text sequences to a text fork and invalid sequences or single bytes to a binary fork, ensuring that log data is accurately represented. ```pseudocode if invalid byte encountered if sequence is empty write one byte from input buffer to binary fork else write binary sequence from utf8 buffer else if sequence is incomplete add another byte if not added break else write text sequence from utf8 buffer ``` -------------------------------- ### Follow Ongoing Recordings with tlog-play Source: https://github.com/scribery/tlog/blob/main/README.md This option enables tlog-play to continuously monitor and display new messages as they appear in the recording, similar to the `tail -f` command. This is useful for observing live terminal sessions. ```bash tlog-play -f ``` -------------------------------- ### Playback tlog from Elasticsearch using tlog-play Source: https://github.com/scribery/tlog/blob/main/README.md This command demonstrates how to use the `tlog-play` tool to playback tlog messages from Elasticsearch. It specifies the Elasticsearch reader, the Elasticsearch base URL pointing to the search endpoint, and an Elasticsearch query string to filter messages by host, timestamp, and session ID. The `--follow` option can be used to continuously stream new messages. ```bash tlog-play -r es \ --es-baseurl=http://localhost:9200/tlog-rsyslog/tlog/_search \ --es-query='host:server AND timestamp:>=now-7d AND session:17' ``` -------------------------------- ### Transaction Management Interface (C) Source: https://github.com/scribery/tlog/blob/main/notes.txt Defines the core interface for transaction management, including backup, restore, and data transfer functions. It outlines how objects can participate in transactions, specifying their storage size, mask location, and transfer function. ```C typedef struct { size_t store_size; /* The size of the object's transaction store */ void* pmask; /* Location of the object's transaction mask */ int (*xfr)(void* obj, void* store, int mode); /* Transaction data transfer function */ } TransactionInterface; /* Transaction management functions */ void TRX_BEGIN(); void TRX_ABORT(); ``` -------------------------------- ### Rate-Limiting Recording (Bash) Source: https://context7.com/scribery/tlog/llms.txt Demonstrates how to apply rate-limiting to terminal I/O recording using `tlog-rec`. Options include throttling to a specific rate with a burst capacity and setting the action to `delay` or `drop`. The `pass` action disables rate-limiting. These settings help manage bandwidth and system load. ```bash # Throttle recording to 10KB/s with 50KB burst, delay when exceeded tlog-rec --writer=file --file-path=limited.log \ --limit-rate=10240 \ --limit-burst=51200 \ --limit-action=delay # Drop I/O exceeding limits (no slowdown to user) tlog-rec --writer=journal \ --limit-rate=8192 \ --limit-burst=32768 \ --limit-action=drop # Pass all data through (disable rate limiting) tlog-rec --writer=file --file-path=unlimited.log --limit-action=pass ``` -------------------------------- ### UTF-8 Sequence State Management Logic Source: https://github.com/scribery/tlog/blob/main/notes.txt This pseudocode illustrates the state transitions for managing UTF-8 sequences. It tracks whether a sequence has ended and whether it is a valid UTF-8 sequence, helping to determine how to process and log the data (either as text or binary). This is crucial for accurately reconstructing terminal interactions. ```pseudocode ended valid 0 0 sequence in progress 0 1 impossible 1 0 sequence terminated by invalid byte 1 1 sequence completed ended complete 0 0 sequence in progress 0 0 impossible 1 0 seqence terminated by invalid byte 1 1 sequence completed ``` -------------------------------- ### Configure Rsyslog for Elasticsearch Output (Rsyslog Configuration) Source: https://context7.com/scribery/tlog/llms.txt Shows how to configure `rsyslog` to forward `tlog` messages to Elasticsearch. This involves setting the maximum message size, loading the `omelasticsearch` module, and defining a template to format the log data into a structure suitable for Elasticsearch. This configuration is added to `/etc/rsyslog.conf`. ```rsyslog # Increase max message size (payload + 1KB overhead) $MaxMessageSize 3k # Load Elasticsearch output module $ModLoad omelasticsearch # Template to massage JSON for Elasticsearch template(name="tlog" type="list") { constant(value="{") property(name="timegenerated" outname="timestamp" format="jsonf" dateFormat="rfc3339") constant(value=",") property(name="msg" regex.expression="{\(.*\)" regex.submatch="1") constant(value="\n") } # Example action to send tlog messages to Elasticsearch (assuming default port and index) # *.* action(type="omelasticsearch" template="tlog") ``` -------------------------------- ### Check Apache HTTP Server Status (systemctl) Source: https://github.com/scribery/tlog/blob/main/lib/tlitest/journal-good.txt This snippet shows the command to check the status of the Apache HTTP server service. The output provides detailed information about the service, including its loaded state, active status, main process ID, and resource usage. ```shell systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2018-11-28 13:26:14 CST; 8s ago Docs: man:httpd.service(8) Main PID: 1581 (httpd) Status: "Started, listening on: port 80" Tasks: 213 (limit: 17972) Memory: 29.0M CGroup: /system.slice/httpd.service ├─1581 /usr/sbin/httpd -DFOREGROUND ├─1582 /usr/sbin/httpd -DFOREGROUND ├─1583 /usr/sbin/httpd -DFOREGROUND ├─1584 /usr/sbin/httpd -DFOREGROUND └─1585 /usr/sbin/httpd -DFOREGROUND ``` -------------------------------- ### Playback from Systemd Journal with tlog-play Source: https://github.com/scribery/tlog/blob/main/README.md This command plays back recordings from the Systemd Journal. It utilizes options like `-r journal` to specify the source, and `-M TLOG_REC=` to filter recordings by a specific ID found in the Journal's TLOG_REC field. ```bash tlog-play -r journal -M TLOG_REC=12ca5b356065453fb50adfe57007658a-306a-26f2910 ``` -------------------------------- ### Route tlog Messages to Elasticsearch Source: https://context7.com/scribery/tlog/llms.txt This configuration snippet shows how to set up rsyslog to route tlog messages to Elasticsearch using the omelasticsearch output plugin. It specifies the Elasticsearch server, index, type, and enables bulk mode for efficiency. ```rsyslog if $!_UID == "123" then { action(name="tlog-elasticsearch" type="omelasticsearch" server="localhost" searchIndex="tlog-rsyslog" searchType="tlog" bulkmode="on" template="tlog") ~ } ``` -------------------------------- ### Playback Partial or Corrupted Recordings with tlog-play Source: https://github.com/scribery/tlog/blob/main/README.md This option instructs tlog-play to ignore missing or out-of-order log messages, allowing playback of incomplete or potentially corrupted recordings. This is useful when data integrity is less critical than recovering partial information. ```bash tlog-play --lax ``` -------------------------------- ### Tlog Interactive Playback Controls Source: https://context7.com/scribery/tlog/llms.txt This describes the keyboard controls available during interactive playback of tlog recordings. It covers actions such as pausing, resuming, adjusting playback speed, stepping through frames, fast-forwarding, and quitting. ```text SPACE or p Pause/resume playback { } Halve or double playback speed . Step through recording (single frame) G Fast-forward to end (useful with --follow) Or goto specific timestamp q Quit playback ``` -------------------------------- ### Configure Rsyslog for Elasticsearch Output Source: https://github.com/scribery/tlog/blob/main/README.md These Rsyslog configurations are necessary to enable sending tlog messages to an Elasticsearch instance. It involves setting the maximum message size and loading the Elasticsearch output module. These directives should be placed appropriately within the Rsyslog configuration file. ```rsyslog $MaxMessageSize 3k $ModLoad omelasticsearch ``` -------------------------------- ### ABNF Syntax for Window Size Source: https://github.com/scribery/tlog/blob/main/doc/log_format.md Defines the syntax for specifying new window dimensions (width and height) in columns and rows, respectively. This is a formal grammar rule. ```abnf window = "=" 1*DIGIT "x" 1*DIGIT ``` -------------------------------- ### UTF-8 Sequence Processing Flow Source: https://github.com/scribery/tlog/blob/main/notes.txt This pseudocode outlines the high-level loop for processing a sequence of bytes, determining if it should be treated as text or binary. It handles the completion and validity checks of UTF-8 sequences before writing them to the appropriate output fork, ensuring proper logging of terminal data. ```pseudocode sequence of bytes / \ / \ text binary while true if the sequence has ended If it is valid UTF-8 finish writing it to text fork else finish writing it to binary fork get a sequence the sequence: binary or text length how much is written ``` -------------------------------- ### Rate-Limit Recording Messages with tlog-rec Source: https://github.com/scribery/tlog/blob/main/README.md These options allow for throttling the rate at which recording messages are logged to prevent excessive I/O. `--limit-rate` sets the maximum bytes per second, `--limit-burst` defines the allowable burst size, and `--limit-action` specifies how to handle exceeding limits (pass, delay, or drop). ```bash tlog-rec --limit-rate=10000 --limit-burst=5000 --limit-action=delay ``` -------------------------------- ### Transaction Management Functions (C) Source: https://github.com/scribery/tlog/blob/main/notes.txt Provides the basic functions for initiating and aborting transactions. These functions are part of the transaction management system, likely interacting with object-specific interfaces for saving and restoring state. ```C /* Transaction management function */ void trx_begin(); void trx_abort(); ``` -------------------------------- ### Change User Shell to Tlog Recorder (Bash) Source: https://github.com/scribery/tlog/blob/main/README.md This command changes the login shell of a specified user to `tlog-rec-session`. This is the primary step to enable session recording for that user. The command requires root privileges. ```bash sudo usermod -s /usr/bin/tlog-rec-session ``` -------------------------------- ### SSSD Integration for Selective Tlog Recording Source: https://context7.com/scribery/tlog/llms.txt This configuration snippet illustrates how to integrate tlog with SSSD (System Security Services Daemon) to selectively record sessions for specific users or groups. By modifying `/etc/sssd/sssd.conf`, administrators can define recording scopes, users, and groups, enabling tlog to record sessions only for those specified. ```bash # Configure SSSD to record specific users/groups # Edit /etc/sssd/sssd.conf [session_recording] scope = some users = user1, user2 groups = admins, developers # SSSD will automatically use tlog-rec-session for specified users # while preserving their original shell preferences ``` -------------------------------- ### System Authentication Failure Log Source: https://github.com/scribery/tlog/blob/main/lib/tlitest/journal-good.txt This log entry records a failed password check for the 'root' user, indicating a potential security event or incorrect login attempt. The log is sourced from syslog. ```log password check failed for user (root) ``` -------------------------------- ### Send tlog messages to Elasticsearch Source: https://github.com/scribery/tlog/blob/main/README.md This rsyslog action sends tlog messages to an Elasticsearch server. It specifies the server, index, type, and uses bulk mode for efficiency. The messages are formatted using the 'tlog' template. ```rsyslog action(name="tlog-elasticsearch" type="omelasticsearch" server="localhost" searchIndex="tlog-rsyslog" searchType="tlog" bulkmode="on" template="tlog") ``` -------------------------------- ### JSON Log Message Format Source: https://context7.com/scribery/tlog/llms.txt This JSON object represents the structure of a tlog log message when formatted as JSON. It includes fields such as version, host, recording ID, user, session, timestamps, and the actual input/output text data. ```json { "ver": "2.3", "host": "server.example.com", "rec": "e843f15839e54e7d83bdc8c128978586-22c2-5d24f15", "user": "johndoe", "term": "xterm", "session": 324, "id": 23, "pos": 345349, "time": 1600718060.667, "timing": "=80x24<5+1>6+3>30+6>20", "in_txt": "date\r", "in_bin": [], "out_txt": "date\r\nMon Nov 30 11:52:45 UTC 2015\r\n[johndoe@server ~]$ ", "out_bin": [] } ``` -------------------------------- ### Send tlog messages to a local file Source: https://github.com/scribery/tlog/blob/main/README.md This rsyslog action writes tlog messages to a specified local file for debugging purposes. It sets the file path and creation mode, and uses the 'tlog' template for formatting. ```rsyslog action(name="tlog-file" type="omfile" file="/var/log/tlog.log" fileCreateMode="0600" template="tlog") ``` -------------------------------- ### Rsyslog Template for Elasticsearch JSON Formatting Source: https://github.com/scribery/tlog/blob/main/README.md This Rsyslog template formats the tlog messages into a JSON structure suitable for Elasticsearch. It includes a real-time timestamp in RFC3339 format and extracts the message payload. This template is used in conjunction with the `omelasticsearch` module. ```rsyslog template(name="tlog" type="list") { constant(value="{") property(name="timegenerated" outname="timestamp" format="jsonf" dateFormat="rfc3339") constant(value=",") property(name="msg" regex.expression="{\(.*\)" regex.submatch="1") constant(value="\n") } ``` -------------------------------- ### Complete tlog message routing rule Source: https://github.com/scribery/tlog/blob/main/README.md This is a complete rsyslog rule that filters messages from 'tlog-rec-session' running as user UID 123, sent via journald. It then sends these messages to Elasticsearch and a local file, and finally discards them to prevent further processing. ```rsyslog if $!_UID == "123" then { action(name="tlog-elasticsearch" type="omelasticsearch" server="localhost" searchIndex="tlog-rsyslog" searchType="tlog" bulkmode="on" template="tlog") action(name="tlog-file" type="omfile" file="/var/log/tlog.log" fileCreateMode="0600" template="tlog") ~ } ``` -------------------------------- ### Filter tlog messages using UID with imuxsock Source: https://github.com/scribery/tlog/blob/main/README.md This rsyslog rule filters messages from tlog when using the imuxsock module. It requires enabling `SysSock.Annotate` and `SysSock.ParseTrusted` options for the module. The condition checks the UID of the tlog session. ```rsyslog module(load="imuxsock" SysSock.Annotate="on" SysSock.ParseTrusted="on") if $!uid == "" then { # ... actions ... } ``` -------------------------------- ### Filter tlog messages using UID with imjournal Source: https://github.com/scribery/tlog/blob/main/README.md This rsyslog rule filters messages originating from tlog when using the imjournal module. It requires rsyslog version 8.17.0 or later. The condition checks the UID of the tlog session. ```rsyslog if $!_UID == "" then { # ... actions ... } ``` -------------------------------- ### Filter tlog messages using program name Source: https://github.com/scribery/tlog/blob/main/README.md This rsyslog rule filters messages based on the program name, specifically 'tlog-rec-session'. This method is less secure as any program can spoof the program name. ```rsyslog if $programname == "tlog-rec-session" then { # ... actions ... } ``` -------------------------------- ### Discard tlog messages Source: https://github.com/scribery/tlog/blob/main/README.md This rsyslog discard action ('~') stops further processing of tlog messages after they have been sent to their intended destinations. ```rsyslog ~ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.