Skip to content

Instantly share code, notes, and snippets.

@jcooklin
Created March 24, 2016 00:13
Show Gist options
  • Save jcooklin/66817a4cafd46506f95f to your computer and use it in GitHub Desktop.
Save jcooklin/66817a4cafd46506f95f to your computer and use it in GitHub Desktop.

Revisions

  1. jcooklin created this gist Mar 24, 2016.
    42 changes: 42 additions & 0 deletions -
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #!/bin/bash -x

    SESSION_NAME="snap-cpu"

    tmux has-session -t ${SESSION_NAME}

    if [ $? != 0 ]
    then
    # create the session
    tmux new-session -s ${SESSION_NAME} -n snapd -d

    # window 0 - snapd
    tmux send-keys -t ${SESSION_NAME} 'snapd -t 0 -l 1' C-m

    # window 1 - snapctl
    tmux new-window -n bash -t ${SESSION_NAME}

    # load plugins
    tmux send-keys -t ${SESSION_NAME}:1 'snapctl plugin load /usr/local/lib/snap/plugins/snap-plugin-collector-cpu' C-m
    tmux send-keys -t ${SESSION_NAME}:1 'snapctl plugin load /usr/local/lib/snap/plugins/snap-publisher-file' C-m
    tmux send-keys -t ${SESSION_NAME}:1 'snapctl plugin load /usr/local/lib/snap/plugins/snap-plugin-collector-perfevents' C-m
    tmux send-keys -t ${SESSION_NAME}:1 'snapctl task create --name cpu -t /usr/local/lib/snap/tasks/cpu-task.json' C-m
    tmux send-keys -t ${SESSION_NAME}:1 "snapctl task watch \$(snapctl task list | grep cpu | awk '{print \$1}')" C-m

    # window 2 memcached
    tmux new-window -n memcached -t ${SESSION_NAME}
    #tmux send-keys -t ${SESSION_NAME}:2 'docker run --name memcached -p 11211:11211 memcached:latest'

    # window 3 - graphite
    tmux new-window -n graphite -t ${SESSION_NAME}
    #tmux send-keys -t ${SESSION_NAME}:3 'docker run --name graphite -p 80:80 -p 2003-2004:2003-2004 --restart=always hopsoft/graphite-statsd'

    # window 4 - grafana
    tmux new-window -n grafana -t ${SESSION_NAME}
    #tmux send-keys -t ${SESSION_NAME}:4 'docker run -i -p 3000:3000 --link graphite --name grafana grafana/grafana'

    # window 5 - mutilator
    tmux new-window -n mutilator -t ${SESSION_NAME}
    tmux send-keys -t ${SESSION_NAME}:5 'docker run -it --name mutilator --link memcached nqnielsen/mutilate-docker'

    fi
    tmux attach -t ${SESSION_NAME}