Run commands on remote hosts, inspecting key indicators to manage infrastructure

inspector

This is a very basic ssh helper tool to manage a smaller (few 100s up to a few 1000s) fleet of servers. The main point of inspector is to provide key insights into system details, for example, so you know which software you're running, OS and kernel versions, which hosts need upgrades, performance metrics, and basically whatever you can script into a ssh command.

To configure inspector, create inspector.yml with:

  • The aliases section gives you the ability to create a shorthand commands, which you can invoke over with the first argument. Using run is a reserved keyword.
  • The columns section defines output columns for each server. When you run inspector without arguments, all these values are being retrieved and a table is printed.
  • The servers section is a list of remote servers to connect to.

Example configuration:

aliases:
  uptime: uptime
  kernel: uname -v

columns:
- name: Docker
  command: docker version -f '{{ .Server.Version }}' 2>/dev/null || echo None
- name: Containers
  command: docker ps -a --format '{{ .Names }}' | wc -l
- name: Go
  command: go version 2>/dev/null || echo None

servers:
- docker1
- docker3
- docker4
- docker5
- docker6
- docker7
- docker8
- docker9

Asuming inspector is in your execution path, you can then run:

  • inspector - Provides a general overview of your defined servers (columns)
  • inspector uptime - Runs the uptime alias over your servers
  • inspector run uname -r - Runs uname -r on all hosts

Example output:

Server               Docker    Containers  Go                               
docker1              19.03.5   3           None                             
docker3              18.09.0   4           None                             
docker4              18.09.0   4           None                             
docker5              19.03.11  3           None                             
docker6              18.09.5   14          None                             
docker7              18.09.5   18          None                             
docker8              18.09.5   18          None                             
docker9              18.09.5   19          None    

Performance

Each ssh connection is created in parallel and individual columns are run serially. This means that the response from your fleet will be available to you within seconds, not minutes.

For a fleet of 60 servers, getting the complete info or uptime, just like defined above, the response takes 2 seconds. If the limitation is the connection rate itself, then we can asume that we can query 1000 servers and get the complete response in about 30 seconds.

  • 10 servers about 0.6sec
  • 60 servers about 1.8sec
  • 1000 severs about 20-25 sec? (estimate)

If you have a fleet of 1000s of servers, I'd be interested to know how well inspector performs for running uptime on all of them.

Other

The authentication uses SSH Agent, or a PrivateKey which should either be under .ssh/id_rsa or $HOME/.ssh/id_rsa. The root user is used to connect to remote hosts.

Ideas

Depending on our internal usage of inspector, the following features may be added. If you're using inspector and are familiar with Go, feel free to open an issue to discuss requirements before submitting a PR.

  • Ability to sort by column
  • Set non-root user and use sudo
  • Output machine readable results (json)
  • Enable support for known_hosts
  • Daemon mode with continous monitoring + prometheus export?
  • A better commands and flags implementation (* Don't bother with this one, we have some ideas and are very particular / peculiar about flag packages)
Similar Resources

Automatically update your Windows hosts file with the WSL2 VM IP address

Automatically update your Windows hosts file with the WSL2 VM IP address

Jan 9, 2023

Project helps to identify the network, broadcast address and no of possible hosts

network_identifier Project helps to identify the network, broadcast address and no of possible hosts for Ipv4 address To use it directly as a go file

Dec 3, 2021

Quickly find all IPv6 and IPv4 hosts in a LAN.

invaentory Quickly find all IPv6 and IPv4 hosts in a LAN. Overview 🚧 This project is a work-in-progress! Instructions will be added as soon as it is

May 17, 2022

Simple dashboard to check if hosts are up (via ICMP)

About ping-dashboard is a simple dashboard to quickly check if a large amount of hosts are up (via ICMP). Building $ cd /path/to/build/directory $ GOB

Jan 14, 2022

KeeneticRouteToVpn is simple app updating Keenetic Router rules for some hosts to go through VPN interface.

KeeneticRouteToVpn KeeneticRouteToVpn is simple app updating Keenetic Router rules for some hosts to go through VPN interface. It has defaults values

Oct 8, 2022

Test ssh login key acceptance without having the private key

ssh-key-confirmer This confirms if a SSH public key is listed as a authorized_key on a system Usage $ ssh-key-confirmer -i ./id_rsa.pub [email protected]

Dec 30, 2022

Erda's infrastructure framework

Erda's infrastructure framework

Erda Infra Translations: English | 简体中文 Erda Infra is a lightweight microservices framework implements by golang, which offers many useful modules and

Nov 18, 2022
Related tags
Encode and Decode Message Length Indicators for TCP/IP socket based protocols

SimpleMLI A Message Length Indicator Encoder/Decoder Message Length Indicators (MLI) are commonly used in communications over raw TCP/IP sockets. This

Nov 24, 2022
Simple tool for connecting to remote hosts via ssh written on GO.

sshmenu is a simple tool for connecting to remote hosts via ssh written on GO. Great if you have trouble remembering IP addresses, hostnames, usernames or path to a key file.

Jul 21, 2022
The rest api that can manage the iptables rules of the remote host

fiewall-api firewall api是基于firewalld来远程管理iptables规则的rest-api,无需部署agent Features 指定一个主机ip,让这个主机上的iptables增加一个规则 处理单个IP或CIDR范围(xx.xx.xx.xx/mask,mac,inte

Mar 24, 2022
Lightweight rest api that allows users to run Powershell commands over HTTP.

Powershell Proxy Lightweight rest api that allows users to run Powershell commands over HTTP. Requests require a valid JWT and responses are returned

Mar 18, 2022
red-tldr is a lightweight text search tool, which is used to help red team staff quickly find the commands and key points they want to execute, so it is more suitable for use by red team personnel with certain experience.
red-tldr is a lightweight text search tool, which is used to help red team staff quickly find the commands and key points they want to execute, so it is more suitable for use by red team personnel with certain experience.

Red Team TL;DR English | 中文简体 What is Red Team TL;DR ? red-tldr is a lightweight text search tool, which is used to help red team staff quickly find t

Jan 5, 2023
Simple hosts file management in Golang (deprecated).
Simple hosts file management in Golang (deprecated).

Goodhosts (deprecated) This library is now deprecated. See the goodhosts organisation for the current maintained version. Simple hosts file (/etc/host

Mar 17, 2022
Reverse Proxying + Static File Serving + Let's Encrypt + multiple hosts

Slashing This is a HTTPS server, which aims to replace my personal nginx usages. Currently, it serves Reverse Proxying (e.g. to a Python-Flask,Java,PH

Jul 29, 2021
Sep 23, 2022
Fetches one or more DNS zones via AXFR and dumps in Unix hosts format for local use

axfr2hosts About axfr2hosts is a tool meant to do a DNS zone transfer in a form of AXFR transaction of one or more zones towards a single DNS server a

Aug 9, 2022
Prometheus exporter for ping metrics such as RTT, packet loss, and jitter to any number of hosts.

ping_exporter Command ping_exporter provides a Prometheus exporter for ping metrics such as RTT, packet loss, and jitter to any number of hosts. Usage

Sep 24, 2022