The livelogsyslog script is a utility designed for real-time monitoring of the most recent Syslog messages. It dynamically identifies and tails the latest Syslog file, providing administrators and users with immediate, live access to new log entries as they are recorded. This is particularly useful for troubleshooting, monitoring system activities, or auditing in environments where Syslog is used for logging system and application messages.



#!/bin/bash
###########################################################################
#
# syslogLivelog.sh
#
# you can add an alias command for that script:
# add to file /etc/bashrc
# alias syslogLivelog='/opt/myprog/bin/syslogLivelog.sh'
#
###########################################################################

# checkmk site name to check syslog files
SITE="your-site"

# Directory to monitor
DIRECTORY="/omd/sites/$SITE/var/mkeventd/messages"

# Find the most recent file in the specified directory
LATEST_FILE=$(find "$DIRECTORY" -type f -printf "%T@ %p\n" | sort -n | tail -1 | cut -d' ' -f2-)

if [ -z "$LATEST_FILE" ]; then
echo "No files found in the directory."
else
echo "Tailing the latest file: $LATEST_FILE"
tail -f "$LATEST_FILE"
fi

computer2know :: thank you for your visit :: have a nice day :: © 2024