Upgrade to Pro — share decks privately, control downloads, hide ads and more …

mkr + peco + tmux + ssh

mkr + peco + tmux + ssh

Mackerel Meetup #10 Tokyo

Yuuki Tsubouchi (yuuk1)

April 27, 2017
Tweet

More Decks by Yuuki Tsubouchi (yuuk1)

Other Decks in Programming

Transcript

  1. mkr + peco + tmux + ssh
    ͸ͯͳ id:y_uuki
    Mackerel Meetup #10 Tokyo

    View full-size slide

  2. αʔϏεɾϩʔϧ໊Λ
    ͠΅Γ͜Έબ୒ͭͭ͠ɺ
    બΜͩϩʔϧͷϗετ܈ʹ
    ಉ࣌ϩάΠϯ

    View full-size slide

  3. αʔϏεɾϩʔϧ໊Λ
    ͠΅Γ͜Έબ୒ͭͭ͠ɺ
    બΜͩϩʔϧͷϗετ܈ʹ
    ಉ࣌ϩάΠϯ
    5ඵ

    View full-size slide

  4. http://blog.yuuk.io/entry/tmux-ssh-mackerel

    View full-size slide

  5. mkr + tmux + ssh

    View full-size slide

  6. $ mkr hosts
    —service bookmark
    --role proxy

    View full-size slide

  7. $ mkr hosts
    —service bookmark
    --role proxy
    | jq -rM “.[].name"

    View full-size slide

  8. tssh = tmux + ssh
    https://github.com/yuuki/opstools/blob/master/tssh

    View full-size slide

  9. $ tssh $(mkr hosts
    —service bookmark
    --role proxy
    | jq -rM “.[].name")

    View full-size slide

  10. $ tssh $(roles bookmark proxy)
    (zsh functionԽ)

    View full-size slide

  11. ͸ͯͳʹ͸ϩʔϧ͕ͨ͘͞Μʂ
    1000+ roles

    View full-size slide

  12. ϩʔϧ໊֮͑ͯͳ͍໰୊

    View full-size slide

  13. mkr + peco + tmux + ssh

    View full-size slide

  14. function peco-mkr-roles() {
    local selected_role=$(mkr services | jq -rM '[.[]
    | .name as $name | .roles // [] | map("\($name) \
    (.)")] | flatten | .[]' | peco)
    if [ -n "${selected_role}" ]; then
    local BUFFER="tssh \`roles "$
    {selected_role}"\`"

    zle clear-screen
    }
    zle -N peco-mkr-roles

    View full-size slide

  15. $ mkr services
    | jq -rM '[.[] | .name as $name
    | .roles // [] | map("\($name) \(.)")]
    | flatten | .[]'
    | peco

    View full-size slide

  16. pecoͰ
    ϩʔϧͷ͠΅Γ͜ΈΛ͔͚ͨޙ
    $ tssh $(roles bookmark proxy)
    Λ࣮ߦ

    View full-size slide

  17. 1. Ctrl + w (೚ҙ)
    2. ϩʔϧҰཡදࣔ
    3. ͠΅Γ͜Έબ୒
    4. tssh࣮ߦ

    View full-size slide

  18. 1. Ctrl + w (೚ҙ)
    2. ϩʔϧҰཡදࣔ
    3. ͠΅Γ͜Έબ୒
    4. tssh࣮ߦ
    5ඵ

    View full-size slide

  19. Mackerel API

    ͍ͭ΋࢖͍ͬͯΔ
    πʔϧ

    View full-size slide

  20. Mackerel API

    ͍ͭ΋࢖͍ͬͯΔ
    πʔϧ
    ΤϯδχΞΛ
    ϫΫϫΫͤ͞Δ

    View full-size slide