Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sc tail #208

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Feature/sc tail #208

wants to merge 4 commits into from

Conversation

ajshedivy
Copy link
Collaborator

@ajshedivy ajshedivy commented Feb 20, 2023

Explain the reasoning for this pull request. For instance, is it for a new feature, bug fix, code style/cleanup, or something else? If fixing an open issue, please link to it here.

Add wrapper script for getting live tail of current service. Here is an example command line call for getting the tail of a log file:

/QOpenSys/pkgs/bin/sc loginfo $1 | /QOpenSys/pkgs/bin/cut -d ':' -f 2 | /QOpenSys/pkgs/bin/xargs tail
  • The "|" symbol is used to pipe the output of the "cut" command to the "xargs" command.
  • The "xargs" command is used to pass the path to the log file as an argument to the "tail" command.
  • The "tail" command will display the last 10 lines of the log file by default.

Any additional comments/context?

TODO:

@ajshedivy ajshedivy requested a review from ThePrez February 20, 2023 23:44
Copy link
Owner

@ThePrez ThePrez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the review comment, please :

  • Update the README with the new command/usage
  • Create an issue to track the creation of the man page for the new command (or include those changes in this PR)

echo "No log file found for service $SERVICE"
exit 1
fi

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took another look at the mainline sc code and realize we need to account for the case where sc loginfo provides one or more spooled files

m_logger.println(m_mainService.getName() + ": " + StringUtils.colorizeForTerminal(splf, ColorSchemeConfig.get("INFO")));

As far as I know, there's no already-made utility for displaying spooled files in a terminal, and definitely nothing analagous to tail -f. Some ideas:

  • Just say something like "unable to tail files, here's the spooled files you can look at, though"
  • Build a utility to display spooled files in a terminal. If so, would we include it in SC ? Some other package?
  • run the SQL for SYSTOOLS.SPOOLED_FILE_DATA() through db2util

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, there's no already-made utility for displaying spooled files in a terminal

There is the QSHELL catsplf command, which can be run from PASE environment like this:

qsh -c "catsplf -j 123456/USER/JOB <spoolfilename> <spoolfilenumber>"

But I don't know if it's to cumbersome?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrjorgensen, cool! I think we should use that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add support for "tailing" spool files. What would be the best way to configure a service that creates spool files to test this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found splf documentation 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design, I can only view the spool file if the service has stopped (per quickstart demo). If I call catsplf on a running service I get the following output:

catsplf: 001-2003 Error CPF3482 found processing spool file QPRINT, number 1.

but once the service is stopped, I can no longer view the DSPSPLF command from loginfo. sctail works great on running services, since we can access the log file via existing sc commands. In the spool file case, we would need to track the qualified job of the service which would require changing the sc base code unless there is another way to get that service information

Copy link
Collaborator

@chrjorgensen chrjorgensen Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajshedivy Spool files have (and always have had) the problem that the output is written in blocks and the latest output can not be seen until that block has finished and another block is created. Your problem is the same as when the `DSPSPLF´ command is used - or when the SYSTOOLS.SPOOLED_FILE_DATA() is used.

This makes spool files unsuitable for logs IMHO... writing to streamfiles is much better!

@ThePrez Do you know if it's possible to redirect spool output to a streamfile, while the spool file is open? If not, then I don't think a tail option for spool files can be done...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrjorgensen I don't think so, while the splf is still open :(

scripts/sctail Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants