Commando - run commands against networking devices in batch mode

Go Report Github all releases

Commando is a tiny tool that enables users to collect command outputs from a single or a multiple networking devices defined in an inventory file.

asciicast

Install

Using the sudo-less installation script makes it easy to download pre-built binary to the current working directory under cmdo name:

# for linux and darwin OSes
bash -c "$(curl -sL https://raw.githubusercontent.com/hellt/cmdo/master/get.sh)"

Windows users are encouraged to use WSL, but if it is not possible, the .exe file can be found in Releases section.

Linux users can leverage pre-built deb/rpm packages that are also available in the Releases section. Either download the package manually, or set --use-pkg flag with the install script:

bash -c "$(curl -sL https://raw.githubusercontent.com/hellt/cmdo/master/get.sh)" -- --use-pkg

Quickstart

If you want to run commands against multiple devices at once:

  1. Create an inventory file with the devices information. An example inventory.yml file lists three different platforms.
  2. Run ./cmdo -i ; the tool will read the inventory file and output the results of the commands in the ./ output directory.

If you want to run commands against a single device:

  1. Use the CLI flags to define the device and commands to send:
    -a
    - IP/DNS name of the device
    -k - one of the supported platforms
    -u -p - SSH credentials
    -c - a single or a list of ::-delimited commands
    an example command could be:
    cmdo -o stdout -a clab-scrapli-srlinux -u admin -p admin -k nokia_srlinux -c "show version :: show system aaa"

Running commands in bulk

As indicated in the quickstart, commando can run commands against many devices as opposed to the singe-device operation.

For the bulk mode the devices are expressed in the sort-of inventory. The inventory file schema is simple, the network devices are defined under .devices element with each device identified by :

devices:
  :
  :
  :

Each device holds a number of options that define the device platform, auth parameters, and the commands to send:

devices:
  :
   # platform is one of arista_eos, cisco_iosxe, cisco_nxos, cisco_iosxr,
   # juniper_junos, nokia_sros, nokia_sros_classic, nokia_srlinux
   platform: string 
      address: string
      username: string
      password: string
      send-commands:
         - cmd1
         - cmd2
         - cmdN

send-commands list holds a list of commands which will be send towards a device. Check out the attached example inventory file to a reference.

Configuration options

  • --inventory | -i - sets the path to the inventory file
  • --add-timestamp | -t - appends the timestamp to the outputs directory, which results in the output directory to be named like outputs_2021-06-02T15:08:00+02:00.
  • --output | -o value - sets the output destination. Defaults to file which writes the results of the commands to the per-command files. If set to stdout, will print the commands to the terminal.
  • --filter | -f 'pattern' - a filter to apply to device name to select the devices to which the commands will be sent. Can be a Go regular expression.

For the single-device operation mode the following flags must be used to define a device:

  • --address | -a - address of the device
  • --platform | -k - one of the supported platform names
  • --username | -u - username
  • --password | -p - password
  • --command | -c - list of commands to send, can be delimited with :: to provide a list of commands

Supported platforms

Commando leverages scrapligo project to support the major network platforms:

Network OS Platform name
Arista EOS arista_eos
Cisco XR/XE/NXOS cisco_iosxr, cisco_iosxe, cisco_nxos
Juniper JunOS juniper_junos
Nokia SR OS (MD-CLI and Classic) nokia_sros, nokia_sros_classic

In addition to that list, commando has the ability to add community provided scrapli drivers, such as:

Network OS Platform name
Nokia SR Linux nokia_srlinux

Attributions

Owner
Roman Dodin
Network Automation
Roman Dodin
Comments
  • fix: fix borked concurrency bits

    fix: fix borked concurrency bits

    @glspi is maybe testing this a bit more, but we realized we were uh... not very concurrent 🤣

    tldr; the resp := <- rCh was blocking on each device waiting for response. so just moved things around a bit and created a dummy object to send into channel so we can always have the device name bound to response even if things fail early (as in no scrapligo response object gets created because we send nil to the rCh).

  • Feature Request: Clean 'unsafe' characters from output file names

    Feature Request: Clean 'unsafe' characters from output file names

    When running commands and storing the output in the files, there are characters in the file names that are safe for Linux systems but they cannot be transferred to some other OS hosts without renaming all the files with output from that particular command with the offending characters. Perhaps an additional switch could be added to make the output file names safe (since you do lose some information this way.)

    The approach I was taking was convert anything in the character class [^\w-_] and change it to an _ character. Then do a second pass to remove any contiguous [-_] characters and replace them with a single hyphen or underscore (which ever came first.)

  • Add feature to append any commands to original commands.

    Add feature to append any commands to original commands.

    I think it is convenient to run commands add hoc against the devices defined in the inventory without editing the original inventory file everytime. If this pull-req does not match your design concept, feel free to reject it.

    $ cmdo -i inventory.yml -c 'show interface description'
    $ cmdo -i inventory.yml -c 'show interface description | include Gi'
    
  • added inventory defaults ++ extras

    added inventory defaults ++ extras

    Sorry for PR without checking if you're even interested in this -- was just playing about with commando and had this so figured I'd raise this just in case you were interested!

    TL;DR -- added defaults and "extras" to inventory yaml.

    Defaults: fairly self explanatory -- figured rather than having to have username/password entered for every device having a default setting would be cool. The implementation is pretty basic -- just load a slice of options with the defaults coming first -- that way any device specific settings override the defaults.

    Extras: could do without the "extras" parent, but basically its just "extra" stuff... hence the name. Things that folks probably wouldn't mess with too often -- port, auth strict key (I left false as the default, but now users can turn it on if they want), transport type (you know I love me the system transport! though this of course could break for windows users), ssh config file, and the secondary password (so we can deal with "enable" passwords).

    Carl

  • Fail when using commands from inventory file

    Fail when using commands from inventory file

    It seems there is a regression when using commands from the inventory file.

     devices:
      sros:
        platform: nokia_sros_classic
        address:myrouter
        send-commands:
          - show version
          - show router interface
          - admin display-config
    

    In this case cmds array has one empty entry in inventory.go. I workarround the issue for now by testing cmds[0] but there maybe a beter way.

    cmds := strings.Split(app.commands, "::")
    
    	if cmds[0] != "" {
    		for _, device := range i.Devices {
    			device.SendCommands = cmds
    		}
    	}
    
  • Fix single host creds

    Fix single host creds

    👋 just noticed that I think the last time I reswizzled some stuff with creds I broke credentials getting set for "single device" mode. this fixes that!

  • fix get.sh and update transports example

    fix get.sh and update transports example

    Hi, I am friends with carlm fyi if you have questions, he told me to just submit a PR on this..

    The install script was no longer installing correctly on multiple pc's and os types. I'm not sure what changed, but it could no longer pull the latest release and set the version properly, causing the download url for the .tgz to be incorrect. Switching the url to api.github.com/repos and tweaking the sed command allows it to work again. I created a new variable since the url was used in a few spots, hope that's ok.

    I tested installing old versions and updating to the latest version.

    Also, the example for transports had 'credentials:' instead of 'transports:' so I updated that as well.

  • Cfg

    Cfg

    Sorry for giant pr...

    Took the send-file branch you had and added cfg support as well. Also broke stuff out into a few different files just for sanity sake, but we can easily squash that back into cmdo.go if ya prefer!

  • pin to 0.1.1 to handle secondary auth better!

    pin to 0.1.1 to handle secondary auth better!

    0.1.1 makes secondary auth handling much better -- w/ 0.1.0 if a device does not have a secondary (enable) password, we just sit there and hang waiting for a timeout then continue on like nothing happened. w/ 0.1.1 we "bail out" of the interactive prompt handling if we see a prompt come back from the device -- much smarter/faster!

  • Fix Cfg Output

    Fix Cfg Output

    • bumps pin for scrapli -> current dev branch that we've been discussing for the kne bits
    • updates the Failed bits to the new setup where failed is an error instead of a bool
    • actually write out cfg results (tested it and its pretty slick!)

    draft since will probably just update pin to master (and maybe even make a real scrapligo release?!?!?) after things are dialed in on the kne side of things!

  • added support for config snippets

    added support for config snippets

    this PR adds support for

    • send-commands-from-file
    • send-configs
    • send-configs-from-file device-level options

    The idea is to allow pushing some config to the devices before scrpaligo has cfg support.

    /cc @carlmontanari

Related tags
A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode.

aliyun-dns A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode. Installation Install aliyun-cli. Usage $ aliyun-dns -h A wra

Dec 21, 2021
This utility verifies all commands used by a shell script against an allow list

Find external commands required by shell scripts When writing shell scripts that need to run portably across multiple hosts and platforms, it's useful

Aug 15, 2022
CLI to run your dataframes against SLU service and generated labeled dataframe.

trail CLI to run your dataframes against different services (currently, SLU service). Setup Get the latest binaries from the releases here. Choose the

Nov 12, 2021
painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Dec 14, 2022
Command-line tool to load csv and excel (xlsx) files and run sql commands
Command-line tool to load csv and excel (xlsx) files and run sql commands

csv-sql supports loading and saving results as CSV and XLSX files with data processing with SQLite compatible sql commands including joins.

Nov 2, 2022
Handy commands to run in Go projects

Handy commands to run in Go projects

Jan 3, 2023
Run commands when files change.
Run commands when files change.

Crow crow is a simple command-line utility that lets you run arbitrary commands when certain files change. Demo A demonstration of crow being used to

Nov 22, 2022
Commands to Build and Run dockerized-go-service

Dockerized Go Service Commands to Build and Run dockerized-go-service Syntax: $ docker image build /path/to -t imageName:version -t imageName:revision

Oct 24, 2021
Count once - Just once? no, when appear many it run once, but it can run many times

countOnce just once? no, when appear many it run once, but it can run many times

Jan 29, 2022
F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!
F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely.

Dec 31, 2022
kubeaudit helps you audit your Kubernetes clusters against common security controls

kubeaudit helps you audit your Kubernetes clusters against common security controls

Dec 30, 2022
ntest is a cross-platform cli app that runs multiple tests against any address.
ntest is a cross-platform cli app that runs multiple tests against any address.

ntest ntest is a cross-platform cli app that runs multiple tests against any address. About ntest Having the ability to run common tests against any d

Jan 3, 2022
This plugin will analyse the JFrog Platform instance and provide the non conformance against the best practices based on the predefines rules.

hello-frog About this plugin This plugin is a template and a functioning example for a basic JFrog CLI plugin. This README shows the expected structur

Nov 30, 2021
Simple command line tool to control TP-Link HS100 and HS110 Devices

tplink-hs1x-cli A simple app to control TPLink HS100 and HS110 devices. Sometimes it is just easier to use a simple cli tool to turn the lights on and

Nov 9, 2021
Tabouli: a TUI for interacting with firmware/embedded devices that support a CLI via serial interface/virtual COM Port
Tabouli: a TUI for interacting with firmware/embedded devices that support a CLI via serial interface/virtual COM Port

Tabouli Information Tabouli is a TUI for interacting with firmware/embedded devi

Apr 2, 2022
🧑‍💻📊 Show off your most used shell commands
🧑‍💻📊 Show off your most used shell commands

tsukae ??‍?? ?? Tsukae, 使え - means use in Japanese (so it refers to commands that you use) Built on top of termui and cobra Big shoutout to jokerj40 f

Dec 17, 2022
cTRL is a server for remote execution of pending tasks and commands in real time, supporting a queue with continuous thread limiting and throttling.

Документация на русском: https://github.com/eltaline/ctrl/blob/master/README-RUS.md cTRL is a server written in Go language that uses a modified versi

Mar 3, 2022
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.

Sampler. Visualization for any shell command. Sampler is a tool for shell commands execution, visualization and alerting. Configured with a simple YAM

Dec 28, 2022
Go Library to Execute Commands Over SSH at Scale
Go Library to Execute Commands Over SSH at Scale

Go library to handle tens of thousands SSH connections and execute the command(s) with higher-level API for building network device / server automation.

Dec 9, 2022