Skip to content

Commit

Permalink
Added processgraph function
Browse files Browse the repository at this point in the history
  • Loading branch information
eko committed Jun 16, 2018
1 parent 2e86472 commit 57d9b89
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .functions
Expand Up @@ -297,13 +297,19 @@ function transfer() {
}

# Graph ping between host and a given hostname
# Usage: ping <host>
function pingraph {
while true; do echo '{"value": '`ping -c 1 $1 | awk -F"=| " 'NR==2 {print $10}'`'}'; sleep 0.5; done | jplot value
# Usage: pinggraph <host>
function pinggraph {
while true; do echo '{"ping": '`ping -c 1 $1 | awk -F"=| " 'NR==2 {print $10}'`'}'; sleep 0.2; done | jplot --steps 500 ping
}

# Graph (using curl and jplot) website response times
# Usage: wwwgraph <url>
function wwwgraph {
while true; do curl -s -o /dev/null -w '{"lookup": %{time_namelookup}, "connect": %{time_connect}, "appconnect": %{time_appconnect}, "pretransfer": %{time_pretransfer}, "redirect": %{time_redirect}, "starttransfer": %{time_starttransfer}, "total": %{time_total}}' $1 | sed -E 's/([0-9]),([0-9])/\1.\2/g'; sleep 1.5; done | jplot lookup+connect+appconnect+pretransfer+redirect+starttransfer+total
}

# Graph a process CPU and memory usage
# Usage: processgraph <name> (Chrome, node, ...)
function processgraph {
while true; do ps aux | grep $1 | grep -v grep | awk '{ cpu += $3; mem += $4} END {print "{\"cpu\":"cpu",\"mem\":"mem"}"}' | sed -E 's/([0-9]),([0-9])/\1.\2/g'; sleep 0.2; done | jplot --steps 600 cpu+mem
}

0 comments on commit 57d9b89

Please sign in to comment.