rubytune logo


Rails Devops Cheatsheet

A collection of command line tips and time-saving snippets curated by Rubytune

 Not all snippets work on all distros! Boo! Make sure you know what you are doing!
You might have to apt-get/homebrew/etc. Corrections and tip-offs to sudara@rubytune.com
  Download the PDF  

Copy  

Process Basics


All processes, with params + hierarchy  

Show all ruby-related PIDs and processes  

What is a process doing?  

What files does a process have open?
 (also nice to detect ruby version of a process)  

Flavors of kill  

Keep an eye on a process  


Memory


How much mem is free?
 Learn how to read output  

Are we swapping?
 First line is avg since boot  

List the top 10 memory hogs  

Detect OOM and other bad things  

Disable OOM killer for a process  /proc/$PID/oom_adj"/>  


Disk/Files


Check reads/writes per disk  

Files (often logs) marked for deletion but not yet deleted  

Overview of all disks  

Usage of this dir and all subdirs  

Find files over 100MB  

Low hanging fruit for free space. 
Check /var/log too!  

Find files created within the last 7 days  

Find files older than 14 days  

Delete files older than 14 days  

Monitor a log file for an IP or anything else  

Generate a large file (count * bs = total bytes)  


Network


TCP sockets in use  

Get IP/Ethernet info  

host <‖> IP resolution  

Curl, display headers (I), follow redirects (L)  

Traceroute with stats over time (top for traceroute)  Requires install  

Traceroute using TCP to avoid ICMP blockage  

List any IP blocks/rules 

Drop any network requests from IP  

Show traffic by port  

Show all ports listening with process PID  

D/L speed test (don't run in prod! :)  


Terminal & Screen


Start a screen session as the current user  

Join/re-attach to a screen session  

Record a terminal session  filename.timing"/>  

Playback a recorded terminal session  


Tips n Tricks


Run Previous command as root  

Change to last working dir  

Run something forever  



Databases


"Tail" all queries hitting mysql.  Learn more  

Connect to production mysql locally on port 3307 via ssh  Learn More