Real-Time Log Viewing with opsi-cli log view

Real-Time Log Viewing with opsi-cli log view

The powerful command-line tool opsi-cli for managing opsi servers and clients has been enhanced with an exciting new feature: the log plugin!

It lets you view server and client logs in real-time using the opsi-Messagebus. Logs are pushed to you instantly as they are generated. With opsi-cli log view, you can view logs from any machine without needing to log in from the opsi server, making troubleshooting convenient and immediate.

Core Features

The opsi-cli log view offers several key features:

  • Server Logs: Stream logs directly from the server using the --log-type opsiconfd option.
  • Client Logs: View client logs using the --log-type opsiclientd option. Logs can be either stored on the server or fetched directly from the client using the --live option for immediate access.
  • Live Log Streaming: Continuously follow logs in real-time with the --follow option, allowing you to monitor logs as they are generated.
  • Log Level Filtering: Apply filters using the --log-level option to display only the log messages that fall under specific log levels, from 1 to 8, for targeted analysis and improved clarity.

Options, Internals, and Examples

Here’s a quick overview of the available options and how they work behind the scenes.

opsi-cli log view –help.

The main argument is HOST_ID, which specifies the ID of the host for which logs are to be displayed.

Behind the Scenes: opsi-MessageBus Connection

The plugin connects to the opsi-Messagebus to communicate with server and client machines. It checks if the specified host is connected and, if not, raises an error. Depending on the log type, the plugin determines the appropriate service or host to retrieve the logs from. It then sends a request to transfer the log file.

Examples

Here are some examples of how you can use opsi-cli log view in different scenarios:

  1. Streaming Server Logs in Real-Time

You can stream server logs and follow them in real-time using the --log-type opsiconfd and --follow options. This setup allows you to keep an eye on server activities as they occur. The plugin retrieves server logs from /var/log/opsi/opsiconfd/opsiconfd.log.

opsi-cli log view HOST_ID –log-type opsiconfd –follow

  1. Viewing Logs Directly from the Client

Need immediate access to client logs? Just use the --log-type opsiclientd and --live options to view client logs directly from the client. This ensures you get the logs as they are generated.

If you use the --live option, the plugin retrieves client logs directly from the client. Otherwise, it fetches logs stored on the server at /var/log/opsi/clientconnect/{host_id}.log.

opsi-cli log view HOST_ID –log-type opsiclientd –live –follow

Tip

Logs are formatted with different colors to enhance readability, with each log level using a distinct color. If you prefer a plain text format or have accessibility concerns, you can disable color formatting. Use the general --no-color option or set the environment variable NO_COLOR.

opsi-cli --no-color log view [OPTIONS] HOST_ID


opsi-cli log view offers a convenient way to view relevant logs in real-time. The simplicity and flexibility of the log plugin and its view option make it an essential addition to the opsi-cli toolset, ensuring smooth operation of the opsi environment.

So next time you need to troubleshoot, give opsi-cli log view a try and enjoy the ease of real-time log viewing. Please share your experience and get support in the opsi forum.

Related Posts

opsi Docker on ARM64: Cost-Efficient Solutions for Small Businesses

opsi Docker on ARM64: Cost-Efficient Solutions for Small Businesses

Build opsi Depot Servers with a Single Board Computer and external Hard Drives.

Read More
Simplifying Remote Administration: An Introduction to JSON-RPC and opsi-cli

Simplifying Remote Administration: An Introduction to JSON-RPC and opsi-cli

Explore the world of JSON-RPC and learn more about the opsi-cli command jsonrpc. It offers a user-friendly way to execute JSON-RPC methods on an opsi server, simplifying the process of remote administration of your opsi environment.

Read More
opsi at T-DOSE 2023: A personal Report

opsi at T-DOSE 2023: A personal Report

Get a behind-the-scenes look at T-DOSE 2023, an Open Source technology conference that brought together experts and enthusiasts from all over the world. As an attendee of the conference, I was excited to be a part of this event and meet members of other Open Source projects.

Read More