ac82e156ca89ec7554e3cc9e2119c750c0b9b305

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

style(systemadmin): use `function` to avoid alias conflicts

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
  2index 9a212906041244d77a5539c5126c7354891cb3bd..8e5e0af71e75725542c5c27eefdcdce2632fb2c6 100644
  3--- a/plugins/systemadmin/systemadmin.plugin.zsh
  4+++ b/plugins/systemadmin/systemadmin.plugin.zsh
  5@@ -34,109 +34,109 @@ alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head
  6 alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
  7 
  8 # directory LS
  9-dls () {
 10+function dls() {
 11     print -l *(/)
 12 }
 13-psgrep() {
 14+function psgrep() {
 15     ps aux | grep "${1:-.}" | grep -v grep
 16 }
 17 # Kills any process that matches a regexp passed to it
 18-killit() {
 19+function killit() {
 20     ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
 21 }
 22 
 23 # list contents of directories in a tree-like format
 24 if ! (( $+commands[tree] )); then
 25-    tree () {
 26+    function tree() {
 27         find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
 28     }
 29 fi
 30 
 31 # Sort connection state
 32-sortcons() {
 33+function sortcons() {
 34     netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
 35 }
 36 
 37 # View all 80 Port Connections
 38-con80() {
 39+function con80() {
 40     netstat -nat|grep -i ":80"|wc -l
 41 }
 42 
 43 # On the connected IP sorted by the number of connections
 44-sortconip() {
 45+function sortconip() {
 46     netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
 47 }
 48 
 49 # top20 of Find the number of requests on 80 port
 50-req20() {
 51+function req20() {
 52     netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
 53 }
 54 
 55 # top20 of Using tcpdump port 80 access to view
 56-http20() {
 57+function http20() {
 58     sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -n 20
 59 }
 60 
 61 # top20 of Find time_wait connection
 62-timewait20() {
 63+function timewait20() {
 64     netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
 65 }
 66 
 67 # top20 of Find SYN connection
 68-syn20() {
 69+function syn20() {
 70     netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20
 71 }
 72 
 73 # Printing process according to the port number
 74-port_pro() {
 75+function port_pro() {
 76     netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1
 77 }
 78 
 79 # top10 of gain access to the ip address
 80-accessip10() {
 81+function accessip10() {
 82     awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
 83 }
 84 
 85 # top20 of Most Visited file or page
 86-visitpage20() {
 87+function visitpage20() {
 88     awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -n 20
 89 }
 90 
 91 # top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
 92-consume100() {
 93+function consume100() {
 94     awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
 95     # if django website or other website make by no suffix language
 96     # awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
 97 }
 98 
 99 # Website traffic statistics (G)
100-webtraffic() {
101+function webtraffic() {
102     awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
103 }
104