Skip to content

Instantly share code, notes, and snippets.

@davidalger
Last active February 2, 2024 09:17

Revisions

  1. davidalger revised this gist Apr 7, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions sysadmin-shortcuts.md
    Original file line number Diff line number Diff line change
    @@ -58,8 +58,7 @@
    ### Monitor number of connections in a TIME_WAIT state

    watch -d -n1 'ss -na state time-wait dport = :3306 or dport = :6379 or dport = :6380 or dport = :6381 | awk '\''{print $(NF)" "$(NF-1)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -n'

    watch -n0.25 'ss -na state established sport = :3306 or sport = :6379 or sport = :6380 or sport = :6381 | awk '\''{print $(NF-1)" "$(NF)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -nr'
    watch -d -n1 'ss -na state established sport = :3306 or sport = :6379 or sport = :6380 or sport = :6381 | awk '\''{print $(NF-1)" "$(NF)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -nr'

    ### Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare

  2. davidalger revised this gist Apr 7, 2020. 1 changed file with 18 additions and 17 deletions.
    35 changes: 18 additions & 17 deletions sysadmin-shortcuts.md
    Original file line number Diff line number Diff line change
    @@ -1,73 +1,74 @@

    ## list listening ports
    ### list listening ports

    sudo lsof -nP -iTCP -sTCP:LISTEN
    sudo netstat -plunt

    # flush DNS on Mojave
    ### flush DNS on Mojave

    sudo killall -HUP mDNSResponder

    # immediately sleep displays
    ### immediately sleep displays

    pmset displaysleepnow

    # monitor redis utilization
    ### monitor redis utilization

    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

    # redis sentinel (find active master)
    ### redis sentinel (find active master)

    redis-cli -h redis-node -p 26379 info sentinel | grep name=obj | head -n1 | tr , $'\n' | grep address | cut -d= -f2 | sed 's/:/ -p /'

    # human readable memory info
    ### human readable memory info

    cat /proc/meminfo | grep Mem | awk '{print $1" "$2/1024/1024" GB"}'

    # sort uniq nginx errors
    ### sort uniq nginx errors

    zgrep '2016/11/30' /var/log/nginx/*error.log* \
    | perl -p -e 's/^(.*?):.*(\[[a-z]+\]) [0-9]+#[0-9]+:(?: \*[0-9]+)? (.*?,|.*?) (?:client: [0-9\.]+, )?(.*)$/$1 $2 $3 $4/' \
    | perl -p -e 's/, (?:referrer|host|request): "[^"\n]+"//g' | perl -p -e 's/client_temp\/[0-9]+/client_temp\/<tmp_number>/' \
    | sort | uniq -c | sort -n | less

    # sort nginx log files by date
    ### sort nginx log files by date

    cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M

    # enumerate ssl ciphers
    ### enumerate ssl ciphers

    nmap --script ssl-enum-ciphers -p 443 <hostname>

    # http memory
    ### http memory

    ps aux | grep 'http' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'

    # show memory usage for php-fpm by user
    ### show memory usage for php-fpm by user

    ps --no-headers -o size,pid,user,command --sort -size -C php-fpm -U www-prod | awk '{ hr=$1/1024 ; printf("%13.2f Mb %s ",hr,$2) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'

    # show average memory usage for php-fpm by user
    ### show average memory usage for php-fpm by user

    ps --no-headers -o size,cmd -C php-fpm -U www-prod | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

    # show size of installed RAM
    ### show size of installed RAM

    dmidecode -t 17 | grep Size | awk '{s+=$2} END {print s/1024 " GB"}'
    ansible -i inventory-* all -b -m shell -a 'dmidecode -t 17 | grep Size | awk '\''{s+=$2} END {print s/1024 " GB"}'\'''

    # Monitor number of connections in a TIME_WAIT state
    ### Monitor number of connections in a TIME_WAIT state

    watch -d -n1 'ss -na state time-wait dport = :3306 or dport = :6379 or dport = :6380 or dport = :6381 | awk '\''{print $(NF)" "$(NF-1)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -n'

    watch -n0.25 'ss -na state established sport = :3306 or sport = :6379 or sport = :6380 or sport = :6381 | awk '\''{print $(NF-1)" "$(NF)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -nr'

    # Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare
    ### Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare

    https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe

    Host *
    IPQoS=throughput

    # Cleanup nearly full /boot partition
    ### Cleanup nearly full /boot partition

    https://unix.stackexchange.com/a/105029/46493

  3. davidalger revised this gist Apr 6, 2020. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions sysadmin-shortcuts.md
    Original file line number Diff line number Diff line change
    @@ -62,12 +62,14 @@

    # Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare

    * https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe
    https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe

    Host *
    IPQoS=throughput

    # Cleanup nearly full /boot partition; ref: https://unix.stackexchange.com/a/105029/46493
    # Cleanup nearly full /boot partition

    https://unix.stackexchange.com/a/105029/46493

    yum install yum-utils
    package-cleanup --oldkernels --count=2
  4. davidalger revised this gist Apr 6, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sysadmin-shortcuts.md
    Original file line number Diff line number Diff line change
    @@ -62,7 +62,7 @@

    # Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare

    https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe
    * https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe

    Host *
    IPQoS=throughput
  5. davidalger revised this gist Apr 6, 2020. 2 changed files with 73 additions and 57 deletions.
    57 changes: 0 additions & 57 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -1,57 +0,0 @@

    # list listening ports
    sudo lsof -nP -iTCP -sTCP:LISTEN
    sudo netstat -plunt

    # flush DNS on Mojave
    sudo killall -HUP mDNSResponder

    # immediately sleep displays
    pmset displaysleepnow

    # monitor redis utilization
    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

    # redis sentinel (find active master)
    redis-cli -h redis-node -p 26379 info sentinel | grep name=obj | head -n1 | tr , $'\n' | grep address | cut -d= -f2 | sed 's/:/ -p /'

    # human readable memory info
    cat /proc/meminfo | grep Mem | awk '{print $1" "$2/1024/1024" GB"}'

    # sort uniq nginx errors
    zgrep '2016/11/30' /var/log/nginx/*error.log* \
    | perl -p -e 's/^(.*?):.*(\[[a-z]+\]) [0-9]+#[0-9]+:(?: \*[0-9]+)? (.*?,|.*?) (?:client: [0-9\.]+, )?(.*)$/$1 $2 $3 $4/' \
    | perl -p -e 's/, (?:referrer|host|request): "[^"\n]+"//g' | perl -p -e 's/client_temp\/[0-9]+/client_temp\/<tmp_number>/' \
    | sort | uniq -c | sort -n | less

    # sort nginx log files by date
    cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M

    # enumerate ssl ciphers
    nmap --script ssl-enum-ciphers -p 443 <hostname>

    # http memory
    ps aux | grep 'http' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'

    # show memory usage for php-fpm by user
    ps --no-headers -o size,pid,user,command --sort -size -C php-fpm -U www-prod | awk '{ hr=$1/1024 ; printf("%13.2f Mb %s ",hr,$2) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'

    # show average memory usage for php-fpm by user
    ps --no-headers -o size,cmd -C php-fpm -U www-prod | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

    # show size of installed RAM
    dmidecode -t 17 | grep Size | awk '{s+=$2} END {print s/1024 " GB"}'
    ansible -i inventory-* all -b -m shell -a 'dmidecode -t 17 | grep Size | awk '\''{s+=$2} END {print s/1024 " GB"}'\'''

    # Monitor number of connections in a TIME_WAIT state
    watch -d -n1 'ss -na state time-wait dport = :3306 or dport = :6379 or dport = :6380 or dport = :6381 | awk '\''{print $(NF)" "$(NF-1)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -n'

    # Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare
    https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe

    Host *
    IPQoS=throughput

    # Cleanup nearly full /boot partition; ref: https://unix.stackexchange.com/a/105029/46493
    yum install yum-utils
    package-cleanup --oldkernels --count=2
    73 changes: 73 additions & 0 deletions sysadmin-shortcuts.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@

    ## list listening ports

    sudo lsof -nP -iTCP -sTCP:LISTEN
    sudo netstat -plunt

    # flush DNS on Mojave

    sudo killall -HUP mDNSResponder

    # immediately sleep displays

    pmset displaysleepnow

    # monitor redis utilization

    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

    # redis sentinel (find active master)

    redis-cli -h redis-node -p 26379 info sentinel | grep name=obj | head -n1 | tr , $'\n' | grep address | cut -d= -f2 | sed 's/:/ -p /'

    # human readable memory info

    cat /proc/meminfo | grep Mem | awk '{print $1" "$2/1024/1024" GB"}'

    # sort uniq nginx errors

    zgrep '2016/11/30' /var/log/nginx/*error.log* \
    | perl -p -e 's/^(.*?):.*(\[[a-z]+\]) [0-9]+#[0-9]+:(?: \*[0-9]+)? (.*?,|.*?) (?:client: [0-9\.]+, )?(.*)$/$1 $2 $3 $4/' \
    | perl -p -e 's/, (?:referrer|host|request): "[^"\n]+"//g' | perl -p -e 's/client_temp\/[0-9]+/client_temp\/<tmp_number>/' \
    | sort | uniq -c | sort -n | less

    # sort nginx log files by date

    cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M

    # enumerate ssl ciphers

    nmap --script ssl-enum-ciphers -p 443 <hostname>

    # http memory

    ps aux | grep 'http' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'

    # show memory usage for php-fpm by user

    ps --no-headers -o size,pid,user,command --sort -size -C php-fpm -U www-prod | awk '{ hr=$1/1024 ; printf("%13.2f Mb %s ",hr,$2) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'

    # show average memory usage for php-fpm by user

    ps --no-headers -o size,cmd -C php-fpm -U www-prod | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

    # show size of installed RAM

    dmidecode -t 17 | grep Size | awk '{s+=$2} END {print s/1024 " GB"}'
    ansible -i inventory-* all -b -m shell -a 'dmidecode -t 17 | grep Size | awk '\''{s+=$2} END {print s/1024 " GB"}'\'''

    # Monitor number of connections in a TIME_WAIT state

    watch -d -n1 'ss -na state time-wait dport = :3306 or dport = :6379 or dport = :6380 or dport = :6381 | awk '\''{print $(NF)" "$(NF-1)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -n'

    # Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare

    https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe

    Host *
    IPQoS=throughput

    # Cleanup nearly full /boot partition; ref: https://unix.stackexchange.com/a/105029/46493

    yum install yum-utils
    package-cleanup --oldkernels --count=2
  6. davidalger revised this gist Apr 6, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,9 @@ pmset displaysleepnow
    # monitor redis utilization
    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

    # redis sentinel (find active master)
    redis-cli -h redis-node -p 26379 info sentinel | grep name=obj | head -n1 | tr , $'\n' | grep address | cut -d= -f2 | sed 's/:/ -p /'

    # human readable memory info
    cat /proc/meminfo | grep Mem | awk '{print $1" "$2/1024/1024" GB"}'

  7. davidalger revised this gist Mar 27, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@

    # list listening ports (on macOS followed by command for Linux)
    sudo lsof -i -n -P | grep LISTEN
    # list listening ports
    sudo lsof -nP -iTCP -sTCP:LISTEN
    sudo netstat -plunt

    # flush DNS on Mojave
  8. davidalger revised this gist Nov 15, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -49,3 +49,6 @@ https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-
    Host *
    IPQoS=throughput

    # Cleanup nearly full /boot partition; ref: https://unix.stackexchange.com/a/105029/46493
    yum install yum-utils
    package-cleanup --oldkernels --count=2
  9. davidalger revised this gist Sep 12, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,9 @@ sudo netstat -plunt
    # flush DNS on Mojave
    sudo killall -HUP mDNSResponder

    # immediately sleep displays
    pmset displaysleepnow

    # monitor redis utilization
    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

  10. davidalger revised this gist Jul 8, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,9 @@
    sudo lsof -i -n -P | grep LISTEN
    sudo netstat -plunt

    # flush DNS on Mojave
    sudo killall -HUP mDNSResponder

    # monitor redis utilization
    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

  11. davidalger revised this gist Jun 4, 2019. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -36,3 +36,10 @@ ansible -i inventory-* all -b -m shell -a 'dmidecode -t 17 | grep Size | awk '\'

    # Monitor number of connections in a TIME_WAIT state
    watch -d -n1 'ss -na state time-wait dport = :3306 or dport = :6379 or dport = :6380 or dport = :6381 | awk '\''{print $(NF)" "$(NF-1)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -n'

    # Add following bit to ~/.ssh/config on Fedora 29 when running in VMWare
    https://superuser.com/questions/1371506/from-vmware-and-fedora-29-ssh-to-remote-machine-cause-broken-pipe

    Host *
    IPQoS=throughput

  12. davidalger revised this gist Dec 1, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,9 @@ cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M
    # enumerate ssl ciphers
    nmap --script ssl-enum-ciphers -p 443 <hostname>

    # http memory
    ps aux | grep 'http' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'

    # show memory usage for php-fpm by user
    ps --no-headers -o size,pid,user,command --sort -size -C php-fpm -U www-prod | awk '{ hr=$1/1024 ; printf("%13.2f Mb %s ",hr,$2) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'

  13. davidalger revised this gist Nov 17, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,8 @@

    # list listening ports (on macOS followed by command for Linux)
    sudo lsof -i -n -P | grep LISTEN
    sudo netstat -plunt

    # monitor redis utilization
    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

  14. David Alger revised this gist Aug 20, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -26,3 +26,6 @@ ps --no-headers -o size,cmd -C php-fpm -U www-prod | awk '{ sum+=$1 } END { prin
    # show size of installed RAM
    dmidecode -t 17 | grep Size | awk '{s+=$2} END {print s/1024 " GB"}'
    ansible -i inventory-* all -b -m shell -a 'dmidecode -t 17 | grep Size | awk '\''{s+=$2} END {print s/1024 " GB"}'\'''

    # Monitor number of connections in a TIME_WAIT state
    watch -d -n1 'ss -na state time-wait dport = :3306 or dport = :6379 or dport = :6380 or dport = :6381 | awk '\''{print $(NF)" "$(NF-1)}'\'' | sed '\''s/:[^ ]*$//g'\'' | sort | uniq -c | sort -n'
  15. David Alger revised this gist Jul 13, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -22,3 +22,7 @@ ps --no-headers -o size,pid,user,command --sort -size -C php-fpm -U www-prod | a

    # show average memory usage for php-fpm by user
    ps --no-headers -o size,cmd -C php-fpm -U www-prod | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

    # show size of installed RAM
    dmidecode -t 17 | grep Size | awk '{s+=$2} END {print s/1024 " GB"}'
    ansible -i inventory-* all -b -m shell -a 'dmidecode -t 17 | grep Size | awk '\''{s+=$2} END {print s/1024 " GB"}'\'''
  16. David Alger revised this gist May 4, 2017. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -17,5 +17,8 @@ cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M
    # enumerate ssl ciphers
    nmap --script ssl-enum-ciphers -p 443 <hostname>

    # show memory usage by process (source: http://php.ingewikkeld.net/entry/human-readable-memory-usage-in-linux-per-process)
    ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb %s ",hr,$2) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
    # show memory usage for php-fpm by user
    ps --no-headers -o size,pid,user,command --sort -size -C php-fpm -U www-prod | awk '{ hr=$1/1024 ; printf("%13.2f Mb %s ",hr,$2) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'

    # show average memory usage for php-fpm by user
    ps --no-headers -o size,cmd -C php-fpm -U www-prod | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
  17. David Alger revised this gist May 3, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -16,3 +16,6 @@ cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M

    # enumerate ssl ciphers
    nmap --script ssl-enum-ciphers -p 443 <hostname>

    # show memory usage by process (source: http://php.ingewikkeld.net/entry/human-readable-memory-usage-in-linux-per-process)
    ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb %s ",hr,$2) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
  18. David Alger revised this gist May 1, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

    # human readable memory info
    cat /proc/meminfo | grep MemTotal | awk '{print $2/1024/1024 " GB"}'
    cat /proc/meminfo | grep Mem | awk '{print $1" "$2/1024/1024" GB"}'

    # sort uniq nginx errors
    zgrep '2016/11/30' /var/log/nginx/*error.log* \
  19. David Alger revised this gist Apr 28, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -13,3 +13,6 @@ zgrep '2016/11/30' /var/log/nginx/*error.log* \

    # sort nginx log files by date
    cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M

    # enumerate ssl ciphers
    nmap --script ssl-enum-ciphers -p 443 <hostname>
  20. David Alger revised this gist Jan 24, 2017. No changes.
  21. David Alger revised this gist Jan 24, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -10,3 +10,6 @@ zgrep '2016/11/30' /var/log/nginx/*error.log* \
    | perl -p -e 's/^(.*?):.*(\[[a-z]+\]) [0-9]+#[0-9]+:(?: \*[0-9]+)? (.*?,|.*?) (?:client: [0-9\.]+, )?(.*)$/$1 $2 $3 $4/' \
    | perl -p -e 's/, (?:referrer|host|request): "[^"\n]+"//g' | perl -p -e 's/client_temp\/[0-9]+/client_temp\/<tmp_number>/' \
    | sort | uniq -c | sort -n | less

    # sort nginx log files by date
    cat access-log.txt | cut -d: -f2- | sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M
  22. David Alger revised this gist Nov 30, 2016. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -4,3 +4,9 @@ redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

    # human readable memory info
    cat /proc/meminfo | grep MemTotal | awk '{print $2/1024/1024 " GB"}'

    # sort uniq nginx errors
    zgrep '2016/11/30' /var/log/nginx/*error.log* \
    | perl -p -e 's/^(.*?):.*(\[[a-z]+\]) [0-9]+#[0-9]+:(?: \*[0-9]+)? (.*?,|.*?) (?:client: [0-9\.]+, )?(.*)$/$1 $2 $3 $4/' \
    | perl -p -e 's/, (?:referrer|host|request): "[^"\n]+"//g' | perl -p -e 's/client_temp\/[0-9]+/client_temp\/<tmp_number>/' \
    | sort | uniq -c | sort -n | less
  23. David Alger created this gist Nov 29, 2016.
    6 changes: 6 additions & 0 deletions sysadmin-shortcuts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@

    # monitor redis utilization
    redis-cli -p 6381 info | grep -E '(memory.*human|keyspace|total)'

    # human readable memory info
    cat /proc/meminfo | grep MemTotal | awk '{print $2/1024/1024 " GB"}'