Regular Expressions - Examples and Use Cases
Background
This post should serve as a repository of selected use-case reqular expressions, sorted by utility/name. It is predominantly centered around Linux and user-space utilies (with a certain amount of Cisco IOS-based examples as well in its heading and subheadings). It will hopefully be continually updated as I intent to keep adding to it as I see buld more regular expression use cases.
MDADM
The following was useful to gather mdadm information when I had an issue with a missing block device in a RAID array (which turned out to be SATA cables that where accidently swapped when performing maintenance/cleaning causing device unexpected device renaming which ultimately bumped a device off the array - sdb in my case). The examples here uses simple patterns to show the linux block devices in an array and looking for log entries
3 8 64 0 active sync /dev/sde
1 8 32 1 active sync /dev/sdc
4 8 48 2 active sync /dev/sdd
user@host:~$ cat /etc/mdadm/mdadm.conf | egrep '\/dev\/sd?'
DEVICE /dev/sdb /dev/sdc /dev/sdd /dev/sde
user@host:~$
user@host:~$ sudo dmesg | grep md0
[ 2.701684] md/raid:md0: device sdc operational as raid disk 1
[ 2.701686] md/raid:md0: device sdd operational as raid disk 2
[ 2.701687] md/raid:md0: device sde operational as raid disk 0
[ 2.702549] md/raid:md0: raid level 5 active with 3 out of 3 devices, algorithm 2
[ 2.702574] md0: detected capacity change from 0 to 8001304920064
user@host:~$
HDPARM
/dev/sda:
Serial Number: *** REDACTED ***
/dev/sdb:
Serial Number: *** REDACTED ***
/dev/sdc:
Serial Number: *** REDACTED ***
/dev/sdd:
Serial Number: *** REDACTED ***
/dev/sde:
Serial Number: *** REDACTED ***
user@host:~$
SCREEN
$(grep /var/log/messages ~/.screenrc)
$(grep virt_snapshot ~/.screenrc)
LVM
At some point, we might need to review LVM volumes to see where we can scale and resize etc. The following allowed me to quickly see everything at a glance in order to formulate a plan for resizing.
user@host:~$ sudo lvdisplay | egrep "LV (Name|Size)"
LV Name video
LV Size <4.02 TiB
LV Name audio
LV Size 750.00 GiB
LV Name hdimg
LV Size <2.51 TiB
LV Name swap
LV Size 16.00 GiB
LV Name var-tmp
LV Size 8.00 GiB
user@host:~$
Cisco IOS
show version
show etherchannel
No comments:
Post a Comment