LINUX - sys look thru - read everything in sys with find

WHAT IS THIS:
##############

/sys holds alot of information about the system and its current settings and devices. Sometimes you want to read all those values. Here is a nice script that runs through /sys and reads every file. The files that are readonly (ment to be read) are read no problem and saved to /tmp/all-sys-best.txt, and the files that are ment to be written to (they set certain settings) simply cant be read and error out. 

I give 3 variations of this command, based on if you want to ignore errors, save em to same file, or to seperate file.

Then monitor with watch (and if no watch then with a while loop), then if its too intense of a monitor there is a less intense watch (no ps command ran and for the watch script its ran less often).


*************************READ EVERYTHING*****************************


ALL OF THE SYS OUTPUT
#####################

MAIN COMMAND FOR FINDING EVERYTHING TO DO WITH DRIVE sdc:
# find /sys -type f -exec echo =======FILE: {}========== \; -exec cat {} \; > /tmp/all-sys-best.txt 2> /dev/null &

monitor size:
# watch -n0.1 '(ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs && ps ax | egrep find)'
while loop version:
# while true; do clear; echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs && ps ax | egrep find; sleep 1; done
while loop version if clear is missing:
# while true; do echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs && ps ax | egrep find; sleep 1; done

less resources (no need to run ps and and do it less often in the watch):
# watch -n1 '(ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs)'
while loop version:
# while true; do clear; echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs; sleep 1; done
while loop version if clear is missing:
# while true; do echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs; sleep 1; done


NOTE ERRORS WERE IGNORED, IF YOU WANT ERRORS SAVED TO SAME FILE
###############################################################

MAIN COMMAND:
# find /sys -type f -exec echo =======FILE: {}========== \; -exec cat {} \; > /tmp/all-sys-best.txt 2> /tmp/all-sys-best.txt &

monitor size:
# watch -n0.1 '(ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs && ps ax | egrep find)'
while loop version:
# while true; do clear; echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs && ps ax | egrep find; sleep 1; done
while loop version if clear is missing:
# while true; do echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs && ps ax | egrep find; sleep 1; done

less resources (no need to run ps and and do it less often in the watch):
# watch -n1 '(ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs)'
while loop version:
# while true; do clear; echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs; sleep 1; done
while loop version if clear is missing:
# while true; do echo =====`date`=====; ls -lisah /tmp/all-sys-best.txt && ls -lisa /tmp/all-sys-best.txt && jobs; sleep 1; done


IF YOU WANT ERRORS TO SEPERATE FILE
####################################

MAIN COMMAND:
# find /sys -type f -exec echo =======FILE: {}========== \; -exec cat {} \; > /tmp/all-sys-best.txt 2> /tmp/all-sys-best.err &

monitor size:
# watch -n0.1 '(ls -lisah /tmp/all-sys-best.* && ls -lisa /tmp/all-sys-best.* && jobs && ps ax | egrep find)'
while loop version:
# while true; do clear; echo =====`date`=====; ls -lisah /tmp/all-sys-best.* && ls -lisa /tmp/all-sys-best.* && jobs && ps ax | egrep find; sleep 1; done
while loop version if clear is missing:
# while true; do echo =====`date`=====; ls -lisah /tmp/all-sys-best.* && ls -lisa /tmp/all-sys-best.* && jobs && ps ax | egrep find; sleep 1; done

less resources (no need to run ps and and do it less often in the watch):
# watch -n1 '(ls -lisah /tmp/all-sys-best.* && ls -lisa /tmp/all-sys-best.* && jobs)'
while loop version:
# while true; do clear; echo =====`date`=====; ls -lisah /tmp/all-sys-best.* && ls -lisa /tmp/all-sys-best.* && jobs; sleep 1; done
while loop version if clear is missing:
# while true; do echo =====`date`=====; ls -lisah /tmp/all-sys-best.* && ls -lisa /tmp/all-sys-best.* && jobs; sleep 1; done



**************************BEING MORE SELECTIVE******************************


WHAT IS THIS?
##############

To not read the whole sys but only to be selective we will add -iwholename to find command

You will take what you want and surround it with *s and engulf it in double parenthesis (or single)

Lets say we need to look for all instances of sdc

-iwholename "*sdc*"

If im looking for raid

-iwholename "*raid*"

All of the examples below will use SEARCHWORD
-iwholename "*SEARCHWORD*"

Note the monitoring commands will stay identical


ALL OF THE SYS OUTPUT
#####################

MAIN COMMAND:
# find /sys -type f -iwholename "*SEARCHWORD*" -exec echo =======FILE: {}========== \; -exec cat {} \; > /tmp/all-sys-best.txt 2> /dev/null &

The monitoring commands stay the same, look at the above identical section for the none selective version.


NOTE ERRORS WERE IGNORED, IF YOU WANT ERRORS SAVED TO SAME FILE
###############################################################

MAIN COMMAND:
# find /sys -type f -iwholename "*SEARCHWORD*" -exec echo =======FILE: {}========== \; -exec cat {} \; > /tmp/all-sys-best.txt 2> /tmp/all-sys-best.txt &

The monitoring commands stay the same, look at the above identical section for the none selective version.


IF YOU WANT ERRORS TO SEPERATE FILE
####################################

MAIN COMMAND:
# find /sys -type f -iwholename "*SEARCHWORD*" -exec echo =======FILE: {}========== \; -exec cat {} \; > /tmp/all-sys-best.txt 2> /tmp/all-sys-best.err &

The monitoring commands stay the same, look at the above identical section for the none selective version.




SelectionFile type iconFile nameDescriptionSizeRevisionTimeUser
Comments