Commit 0871594f authored by DBX12's avatar DBX12 Committed by Marc Cornellà

systemadmin: refactor plugin and fix README (#7295)

parent ecb46c3e
This diff is collapsed.
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function retval() {
if [[ -z $1 ]];then
echo '.'
else
echo $1
fi
}
function retlog() { function retlog() {
if [[ -z $1 ]];then if [[ -z $1 ]];then
echo '/var/log/nginx/access.log' echo '/var/log/nginx/access.log'
...@@ -29,8 +21,8 @@ function retlog() { ...@@ -29,8 +21,8 @@ function retlog() {
} }
alias ping='ping -c 5' alias ping='ping -c 5'
alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."' alias clr='clear; echo Currently logged in on $TTY, as $USER in directory $PWD.'
alias path='echo -e ${PATH//:/\\n}' alias path='print -l $path'
alias mkdir='mkdir -pv' alias mkdir='mkdir -pv'
# get top process eating memory # get top process eating memory
alias psmem='ps -e -orss=,args= | sort -b -k1,1n' alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
...@@ -43,10 +35,10 @@ alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' ...@@ -43,10 +35,10 @@ alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
# directory LS # directory LS
dls () { dls () {
ls -l | grep "^d" | awk '{ print $9 }' | tr -d "/" print -l *(/)
} }
psgrep() { psgrep() {
ps aux | grep "$(retval $1)" | grep -v grep ps aux | grep "${1:-.}" | grep -v grep
} }
# Kills any process that matches a regexp passed to it # Kills any process that matches a regexp passed to it
killit() { killit() {
...@@ -54,10 +46,10 @@ killit() { ...@@ -54,10 +46,10 @@ killit() {
} }
# list contents of directories in a tree-like format # list contents of directories in a tree-like format
if [ -z "\${which tree}" ]; then if ! (( $+commands[tree] )); then
tree () { tree () {
find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
} }
fi fi
# Sort connection state # Sort connection state
...@@ -97,7 +89,7 @@ syn20() { ...@@ -97,7 +89,7 @@ syn20() {
# Printing process according to the port number # Printing process according to the port number
port_pro() { port_pro() {
netstat -ntlp | grep "$(retval $1)" | awk '{print $7}' | cut -d/ -f1 netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1
} }
# top10 of gain access to the ip address # top10 of gain access to the ip address
...@@ -134,7 +126,7 @@ httpstatus() { ...@@ -134,7 +126,7 @@ httpstatus() {
# Delete 0 byte file # Delete 0 byte file
d0() { d0() {
find "$(retval $1)" -type f -size 0 -exec rm -rf {} \; find "${1:-.}" -type f -size 0 -exec rm -rf {} \;
} }
# gather external ip address # gather external ip address
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment