Skip to content

Instantly share code, notes, and snippets.

ps aux | grep 'httpd' | awk '{print "PID ->" $2 " MEM ->" $6/1024 " MB";}'
watch -n 1 "echo -n 'Apache Processes: ' && ps -C httpd --no-headers | wc -l && free -m"
ps -ylC httpd --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
1) process tree
pstree -p | grep httpd
2) sessions memory
ps aux | grep 'httpd' | awk '{print "PID ->" $2 " MEM ->" $6/1024 " MB";}'
@hermes-pimentel
hermes-pimentel / change-ec2-pem-file.txt
Created January 3, 2017 17:53
Change ec2 .pem file
1) copy key to new instance. My-new-key.pem to .ssh
2) change permissions (chmod 400)
3) run as ec2-user/centos/ubuntu:
cd .ssh
ssh-keygen -f My-new-key.pem -y >> authorized_keys
Wow! I Didn't Know You Could Do That In vi
compiled by: Patricia Bender
ESC = the escape key
RET = the return key
char = any lowercase character
8 = any number
num = any number
@hermes-pimentel
hermes-pimentel / fio.txt
Last active January 30, 2019 18:28
how fio works
This is a quick tldr; there are many other situations and options you could consider.
FIO man page
IOP/s = Input or Output operations per second
Throughput = How many MB/s can you read/write continuously
Variables worth tuning based on your situation:
--iodepth
The iodepth is very dependant on your hardware.
journalctl
This will display the logs with the oldest entries first. Although this is simple, it is not very useful since we do not tend to read logs like a book.
By default journalctl displays the logs in a pager. It shows you one page of logs requiring you to hit the space bar to proceed. Also long log lines WILL NOT wrap, they will trail off the right side of the screen. You can use the right arrow to see the rest of the line.
We will talk more about changing the way the logs are displayed in a different article. Let's move on to some basic log viewing commands.
Diplaying Logs by Date
@hermes-pimentel
hermes-pimentel / gist:7d8a542e50d2d455c1d3c5b58f9ec2f8
Created September 6, 2017 23:25 — forked from keithchambers/gist:80b60559ad83cebf1672
Ansible role to set 'noop' i/o scheduler (CentOS 7)
---
- name: test if grub configured for noop i/o scheduler
command: egrep -q 'elevator=noop' /boot/grub2/grub.cfg
register: grub
changed_when: no
failed_when: grub_test.rc == 2
- name: configure grub for noop i/o scheduler
sudo: yes
command: grubby --update-kernel=ALL --args=elevator=noop
@hermes-pimentel
hermes-pimentel / bootstrap_jupyter.sh
Created September 12, 2017 17:30 — forked from nicor88/bootstrap_jupyter.sh
Bootstrap action to install Conda and Jupyter on EMR
#!/usr/bin/env bash
set -x -e
JUPYTER_PASSWORD=${1:-"myJupyterPassword"}
NOTEBOOK_DIR=${2:-"s3://myS3Bucket/notebooks/"}
# home backup
if [ ! -d /mnt/home_backup ]; then
sudo mkdir /mnt/home_backup
sudo cp -a /home/* /mnt/home_backup
@hermes-pimentel
hermes-pimentel / jupyter_notebook_ngnix_proxy.txt
Last active September 16, 2017 15:13
Jupyter Notebook Ngnix Proxy Config Working.
# Jupyter configuration #
c.NotebookApp.open_browser = False
c.NotebookApp.port = 9090
c.NotebookApp.password = u'sha1:somepass'
c.Authenticator.admin_users = {'hadoop'}
c.LocalAuthenticator.create_system_users = True
c.NotebookApp.contents_manager_class = 's3contents.S3ContentsManager'
c.S3ContentsManager.bucket_name = 'my-bucket'
c.S3ContentsManager.prefix = 'notebooks'
@hermes-pimentel
hermes-pimentel / README.md
Created April 3, 2018 05:27 — forked from guillaumevincent/README.md
Windows Service with Python 3.5 and pyinstaller