Skip to content

Commit

Permalink
Added pingraph and wwwgraph commands
Browse files Browse the repository at this point in the history
  • Loading branch information
eko committed Jun 16, 2018
1 parent 2b20b52 commit 2e86472
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .brew
Expand Up @@ -19,6 +19,8 @@ echo '--> Install libraries and applications'
brew cask install iterm2
brew install bash
brew install ffmpeg
brew install rs/tap/jaggr
brew install rs/tap/jplot
brew install tmux
brew install reattach-to-user-namespace
brew install vim
Expand Down
14 changes: 13 additions & 1 deletion .functions
Expand Up @@ -276,7 +276,7 @@ function loc() {

# Uploads a file to transfer.sh and returns the public URL
# Usage: transfer <file>
transfer() {
function transfer() {
if [ $# -eq 0 ]; then
echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md";
return 1;
Expand All @@ -295,3 +295,15 @@ transfer() {
echo "\n";
rm -f $tmpfile;
}

# 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
}

# 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
}

0 comments on commit 2e86472

Please sign in to comment.