ArcShell

Log Monitoring

This short code block shows how easy it is to monitor logs with ArcShell. New lines are read from the file using logmon_read_log and piped to a handler called var_log_messages. Notifications and other actions are configured within the handler.

logmon_read_log -max 10 "/var/log/messages" | \
   logmon_handle_log -stdin "var_log_messages"

Reference

logmon_register_file

Copies the contents of ‘file_name’ to the zero buffer. Used for testing.

> logmon_register_file "file_name"

logmon_cat

Returns the specified buffer to standard out.

> logmon_cat [-buffer,-b "X"]

logmon_reset

Removes all buffer files and resets a couple of global variables.

> logmon_reset

logmon_read_log

This function is used to intermittently check files for new lines and return only those lines.

> logmon_read_log [-new,-n] [-max,-m X] "filePath"
# -new: If file is new existing lines are treated as new lines.
# -max: Limit amount of data that can be returned to X megabytes. Defaults to 10.

logmon_handle_log

Process input and scan it using a log handler.

> logmon_handle_log [-stdin] [-meta "X"] ["source_file"] "log_handler"
# -stdin: Read log input from standard in.
# -meta: Sets the meta value which can be referenced in the handler.
# source_file: Source file containing the data we want to scan.
# log_handler: The name of a log handler.

logmon_extract

Used in a handler to return and remove matching lines from the specified buffer.

> logmon_extract [-ignorecase, -i] [-buffer,-b X] ["regex"]
# -i: Ignore case.
# -buffer: Buffer number to grep from.
# regex: Regular expression.

logmon_grep

Used in a handler to return matching lines from the specified buffer.

> logmon_grep [-i] [-buffer,-b X] ["regex"]
# -i: Ignore case.
# -buffer: Buffer number to grep from.
# regex: Regular expression.

logmon_write

Used in a handler to write standard input to the specified buffer.

> logmon_write [-buffer,-b X] [buffer_no]
# -buffer: The buffer number to write to.
# buffer_no: Also the buffer number to write to.

logmon_remove

Used in a handler to remove matching lines from the specified buffer.

> logmon_remove [-i] [-buffer,-b X] ["regex"]
# -i: Ignore case.
# -buffer: Buffer number to write to.
# regex: Regular expression.

logmon_meta_value

Used in a handler to return the value of the ‘-meta’ argument.

> logmon_meta_value

logmon_forget_file

Remove the object library reference to a file.

> logmon_forget_file "filePath"