c0a6f8a8a22316b6e48319f05a6e63fb6ea14fe6
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/systemadmin/systemadmin.zsh b/plugins/systemadmin/systemadmin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..f5e44c66f500850daa234c407825493ad0ec58f9
4--- /dev/null
5+++ b/plugins/systemadmin/systemadmin.zsh
6@@ -0,0 +1,159 @@
7+# ------------------------------------------------------------------------------
8+# Description
9+# -----------
10+#
11+# This is one for the system administrator, operation and maintenance.
12+# Some of which come from http://justinlilly.com/dotfiles/zsh.html
13+#
14+# ------------------------------------------------------------------------------
15+# Authors
16+# -------
17+#
18+# * Dongweiming <ciici123@gmail.com>
19+#
20+# ------------------------------------------------------------------------------
21+
22+function retval() {
23+ if [[ -z $1 ]];then
24+ echo '.'
25+ else
26+ echo $1
27+ fi
28+}
29+
30+function retlog() {
31+ if [[ -z $1 ]];then
32+ echo '/var/log/nginx/access.log'
33+ else
34+ echo $1
35+ fi
36+}
37+
38+alias ping='ping -c 5'
39+alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."'
40+alias path='echo -e ${PATH//:/\\n}'
41+alias mkdir='mkdir -pv'
42+# get top process eating memory
43+alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
44+alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10'
45+# get top process eating cpu if not work try excute : export LC_ALL='C'
46+alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr'
47+alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr | head -10'
48+# top10 of the history
49+alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
50+
51+# directory LS
52+dls () {
53+ ls -l | grep "^d" | awk '{ print $9 }' | tr -d "/"
54+}
55+psgrep() {
56+ ps aux | grep "$(retval $1)" | grep -v grep
57+}
58+# Kills any process that matches a regexp passed to it
59+killit() {
60+ ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
61+}
62+
63+# list contents of directories in a tree-like format
64+if [ -z "\${which tree}" ]; then
65+ tree () {
66+ find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
67+ }
68+fi
69+
70+# Sort connection state
71+sortcons() {
72+ netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
73+}
74+
75+# View all 80 Port Connections
76+con80() {
77+ netstat -nat|grep -i ":80"|wc -l
78+}
79+
80+# On the connected IP sorted by the number of connections
81+sortconip() {
82+ netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
83+}
84+
85+# top20 of Find the number of requests on 80 port
86+req20() {
87+ netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
88+}
89+
90+# top20 of Using tcpdump port 80 access to view
91+http20() {
92+ sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -20
93+}
94+
95+# top20 of Find time_wait connection
96+timewait20() {
97+ netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
98+}
99+
100+# top20 of Find SYN connection
101+syn20() {
102+ netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20
103+}
104+
105+# Printing process according to the port number