shellgraph

Run a scan

Scan a VLAN by hand, from the menus or with flags, and act on the result of each address.

Scan from the menus

  1. Run the scan command without arguments.

    shellgraph scan
    
  2. Type the number of the Environment and press Enter.

  3. Type the number of the VLAN and press Enter.

Scan without menus

Give the name or the ID of the Environment and of the VLAN:

shellgraph scan --env Production --vlan app-10

The server UI shows this command for each VLAN, in the Collector command column.

Read the result

The collector writes one line for each address with SSH, then a summary:

Scanning Production / app-10 (10.0.10.0/24) with user "shellgraph"...
  10.0.10.12     ok       db01, 4 services
  10.0.10.15     auth_failed ssh: handshake failed: ssh: unable to authenticate
Done: 1 ok, 0 partial, 1 auth_failed, 0 hostkey_changed, 0 error, 252 no_ssh.
  no_ssh     3  refused: the host answers, but port 22 is closed
  no_ssh   249  timeout: no answer in 1.5s (the host is down, or a firewall drops the packets)
Report sent (scan 7). Map: https://shellgraph.example.net/environments/1/map

An address without an answer on the SSH port (no_ssh) has no line. The summary counts the no_ssh addresses for each reason. To see the line of each no_ssh address, add --verbose. For the meaning of each status and what to do, see Scan results.

Find more short connections

A scan reads the sockets 3 times, 5 seconds apart. For a VLAN with short connections, take more samples:

shellgraph scan --env Production --vlan app-10 --samples 6 --interval 10s

Scan a large VLAN

The collector connects to 32 addresses at the same time. A firewall or an IPS (intrusion prevention system) between the collector and the VLAN can see this as a port scan. Then it drops the packets from the collector, and the next addresses get the status no_ssh. The collector cannot know that the firewall dropped the packets. These addresses have the reason timeout.

The symptom: a VLAN with many servers, but the scan finds only some of them. For example, 13 hosts in a VLAN of 500 servers.

Warning: a host with the status no_ssh leaves the VLAN on the server. A host in no VLAN is deleted. A blocked scan can delete many hosts from the map.

  1. Before the first scan of a large VLAN, run the scan with --dry-run. Compare the number of ok and partial hosts with the number of servers in the VLAN.

    shellgraph scan --env Production --vlan app-10 --dry-run > /dev/null
    
  2. If the number is too low, run the scan again with a lower concurrency.

    shellgraph scan --env Production --vlan app-10 --concurrency 4 --dry-run > /dev/null
    
  3. If the number increases, the firewall limits the collector. Use the lower concurrency for all scans of this VLAN. Or ask the network team to allow the collector machine.

  4. If the number does not change, find the reason of a missing address:

    shellgraph scan --env Production --vlan app-10 --verbose --dry-run 2>&1 >/dev/null | grep 10.0.10.40
    
    • refused: the host answers, but no SSH server listens on the port. Make sure that the SSH port of the VLAN is correct.
    • timeout: no answer. Run the scan again with --tcp-timeout 5s. If the host is found, the network is slow. Use the higher timeout for all scans of this VLAN.
    • unreachable: no host has this address, or a router rejects the collector.
  5. Test the missing address by hand from the collector machine.

    nc -vz -w 2 10.0.10.40 22
    

    If the test fails, a route or an ACL blocks the collector. If the test succeeds, the host answers in more than the TCP timeout, or it answers only some of the time.

  6. Make sure that the CIDR in the server UI is correct. The Scanning line shows it.

A lower concurrency makes the scan slower. Each host takes approximately samples × interval (15 seconds with the defaults). For a /22 VLAN with --concurrency 4, the scan can take more than 1 hour.

Test without a change on the server

Print the report and send nothing:

shellgraph scan --env Production --vlan app-10 --dry-run

Send a report again

If the collector cannot send the report, it tries 3 times. Then it keeps the report and shows this message:

error: server: 504 Gateway Timeout
The report is in /home/user/.config/shellgraph/pending/vlan-3-20261019T120000Z.json.gz. Send it later with 'shellgraph send'
  1. Find and correct the cause (for example, the server or a proxy is slow or stopped).

  2. Send the pending reports. You do not have to scan again.

    shellgraph send
    

Send the pending reports before the next scan of the same VLAN. A scan that sends its report deletes the older pending reports of its VLAN.

Note: if the server received the report but the answer did not arrive, the server can show the same scan two times. This has no effect on the map.

Stop a scan

Press Ctrl-C. The collector sends nothing, and the data on the server does not change.