DevOps (Operations) Cheatsheet
Determine open files (file descriptors) for all processes by a user
1
|
|
Check iowait and disk stats
Use sar (which you will have had to install and enable previously) or…
1
|
|
Create CSV from data in MongoDB
Please note that this requires jq 1.5 or greater for the join feature
First, create a js file “myquery.js” containing the query you would like to run
1 2 3 |
|
This sets the database to mydatabase
, lets us read from a slave in a replicaset (only do
this if you are using a replicaset), then finds all records in the users collection, only
selecting the _id
and converting it to an array
To execute this script against your DB from the command line, you would then do something like
1
|
|
First, remove the extra data thats been added before and after the []’s in the output file so it is valid json
Then parse the json data and convert it to a CSV
1
|
|
The last step is to add a header to your CSV file “` sed -i “Email Address, Hashpass” user_emails_hashpass.csv
LVM Notes
To import a Logical Volume that was not exported before being removed from a host, you can use
vgchange -ay
to import the LV again. You will likely have to run pvscan
and vgscan
before doing this.