SYSPOSIS
This file provides a couple of useful examples of recs chains and how each of them break down. This is meant as a learning tool for folks new recs that would like to see some cool things you can do with RecordStream. Another good resource is 'man recs-story' which is a humorous story meant to get the newest users used to recs.
EXAMPLE: How many processes are each user running?
How many processes are each of the users on my system running?
recs-fromps | recs-collate --key uid -a count | recs-sort --key count=n | recs-totable
Broken down this is:
1. recs-fromps - First get the records of all the prcesses currently running
2. recs-collate --key uid -a count
Grouping by the uid field, count how many records fall into the group
3. recs-sort --key count=n
Sort the resulting records by the count key
numerical (rather than lexically)
4. recs-totable - Print the output in a nicely formatted table.
EXAMPLE: How many processes for each user at each priority level?
How many processes are each user on the system running at each priority level?
recs-fromps | recs-collate --key uid,priority -a count | recs-toptable --x priority --y uid --v count
Broken down:
1. recs-fromps - First get the records of all the prcesses currently running
2. recs-collate --key uid,priority -a count
Grouping by the uid and the priority field, count how many records fall
into the group
3. recs-toptable --x priority --y uid -v count
Create a 2 dimensional table, across the top put the priority values, down
the side put the uid. In put the value of the count field in the cell
Example: Prep a report on number of modules loggin to Xorg.log
What Xorg modules put information in my Xorg.log at startup, and what log level are they logged at? I need this in csv format for importing into a spreadsheet program.
recs-frommultire --re 'type,module=\((\S*)\) ([^:]+):' /var/log/Xorg.0.log | recs-collate --key type,module -a ct | recs-sort --key ct=n | recs-tocsv --header
1. recs-frommultire --re 'type,module=\((\S*)\) ([^:]+):' /var/log/Xorg.0.log
Parse out the type and module from the Xorg log file. That regex reads
capture text inside literal '()', then capture text after a space up to the
first ':'.
2. recs-collate --key type,module -a ct
Collate records into groups of type-modules. Count how many in each group
across all records.
3. recs-sort --key ct=n
Sort by the count, numerically.
4. recs-totable --spreadsheet --delim ','
Output a table in spreadsheet format (no ASCII art), delimited by commas
instead of tabs
See Also
- RecordStream(3) - Overview of the scripts and the system
- recs-story(3) - A humorous introduction to RecordStream