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 Request: Add time filter for "dmesg" #1166

Closed
MrPippin66 opened this issue Oct 19, 2020 · 2 comments
Closed

Feature Request: Add time filter for "dmesg" #1166

MrPippin66 opened this issue Oct 19, 2020 · 2 comments

Comments

@MrPippin66
Copy link

In troubleshooting, you're often only interested in events within a given time period.

I wish to advocate for an option to filter the output by events that have only occurred in a given time-frame.

For example, "ausearch" provides a "--start" and "--end" options to filter the time period.

I'd like to include the same filter type options as stated for "ausearch", though I'd primarily only be interested in being able to specify a unit of time with a value, namely minutes, hours and days.

So, an example might be:

"--start 2h" show all events from 2 hours ago till present

"--start 4h --end 2h" show all events from 4 hours ago till 2 hours ago

Having the command perform this would be far more efficient than scripting the timestamp comparison externally to the command.

@karelzak
Copy link
Collaborator

Yes, this is a good idea. I have thought about it time ago; my idea was --since and --until like used by git-log.

karelzak added a commit that referenced this issue Oct 21, 2020
$ ./dmesg --ctime --since '1 hour ago'
[Wed Oct 21 11:47:13 2020] AAA
[Wed Oct 21 11:55:48 2020] BBB

./dmesg --ctime --since '1 hour ago' --until '1 minutes ago'
[Wed Oct 21 11:47:13 2020] AAA

$ date
Wed 21 Oct 2020 12:05:07 PM CEST

$ dmesg --ctime --since '1 hour ago'
[Wed Oct 21 11:47:13 2020] AAA
[Wed Oct 21 11:55:48 2020] BBB

$ dmesg --ctime --since '1 hour ago' --until '10 minutes ago'
[Wed Oct 21 11:47:13 2020] AAA

Addresses: #1166
Signed-off-by: Karel Zak <kzak@redhat.com>
karelzak added a commit that referenced this issue Oct 21, 2020
$ date
Wed 21 Oct 2020 12:05:07 PM CEST

$ dmesg --ctime --since '1 hour ago'
[Wed Oct 21 11:47:13 2020] AAA
[Wed Oct 21 11:55:48 2020] BBB

$ dmesg --ctime --since '1 hour ago' --until '10 minutes ago'
[Wed Oct 21 11:47:13 2020] AAA

Addresses: #1166
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak
Copy link
Collaborator

Implemented (the first commit is obsolete and with broken commit message).

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

No branches or pull requests

2 participants