mirror of
https://github.com/DaanSelen/meshbook.git
synced 2026-02-20 08:22:11 +00:00
Clarified readme and used examples.
This commit is contained in:
86
README.md
86
README.md
@@ -13,68 +13,94 @@ Then make a yaml with a target and some commands! See below examples as a guidel
|
|||||||
To install, follow the following commands:<br>
|
To install, follow the following commands:<br>
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
git clone https://github.com/daanselen/meshbook
|
||||||
cd ./meshbook
|
cd ./meshbook
|
||||||
python3 -m venv ./venv
|
python3 -m venv ./venv
|
||||||
source ./venv/bin/activate
|
source ./venv/bin/activate
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r ./meshbook/requirements.txt
|
||||||
```
|
```
|
||||||
Then you can use meshbook, for example:
|
Then you can use meshbook, for example:
|
||||||
```shell
|
```shell
|
||||||
python3 meshbook.py -pb examples/ping.yaml
|
python3 ./meshbook/meshbook.py -pb examples/echo.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example:
|
# Example:
|
||||||
|
|
||||||
For the example, I used the following yaml file:
|
For the example, I used the following yaml file:
|
||||||
|
|
||||||
```yaml
|
The below group: `Temp-Agents` has four devices, of which one is offline.<br>
|
||||||
---
|
|
||||||
name: Ping a single Point
|
|
||||||
company: Temp-Agents
|
|
||||||
tasks:
|
|
||||||
- name: Ping Cloudflare
|
|
||||||
command: "ping 1.1.1.1 -c 4"
|
|
||||||
```
|
|
||||||
|
|
||||||
The above group: `Temp-Agents` has four devices, of which one is offline.<br>
|
|
||||||
You can expand the command chain as follows:<br>
|
You can expand the command chain as follows:<br>
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
name: Ping Multiple Points
|
name: Ping Multiple Points
|
||||||
company: Temp-Agents
|
company: Temp-Agents
|
||||||
|
variables:
|
||||||
|
- name: host1
|
||||||
|
value: "1.1.1.1"
|
||||||
|
- name: host2
|
||||||
|
value: "ns.systemec.nl"
|
||||||
|
- name: command1
|
||||||
|
value: "ping"
|
||||||
|
- name: cmd_arguments
|
||||||
|
value: "-c 4"
|
||||||
tasks:
|
tasks:
|
||||||
- name: Ping Cloudflare
|
- name: Ping host1
|
||||||
command: "ping 1.1.1.1 -c 4"
|
command: "{{ command1 }} {{ host1 }} {{ cmd_arguments }}"
|
||||||
|
|
||||||
- name: Ping Google
|
- name: Ping host2
|
||||||
command: "ping 8.8.8.8 -c 4"
|
command: "{{ command1 }} {{ host2 }} {{ cmd_arguments }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
The following response it received when executing the first yaml of the above files.
|
The following response it received when executing the first yaml of the above files.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
python3 meshbook.py -pb examples/ping.yaml -s
|
python3 meshbook/meshbook.py -pb examples/variable_example.yaml -si
|
||||||
|
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
|
||||||
|
Running task: {'name': 'Ping host1', 'command': 'ping 1.1.1.1 -c 4'}
|
||||||
|
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
|
||||||
|
Current Batch: 1
|
||||||
|
Current response number: 1
|
||||||
|
Current Calculation: 1 % 3 = 1
|
||||||
|
Current Batch: 1
|
||||||
|
Current response number: 2
|
||||||
|
Current Calculation: 2 % 3 = 2
|
||||||
|
Current Batch: 1
|
||||||
|
Current response number: 3
|
||||||
|
Current Calculation: 3 % 3 = 0
|
||||||
|
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
|
||||||
|
Running task: {'name': 'Ping host2', 'command': 'ping ns.systemec.nl -c 4'}
|
||||||
|
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
|
||||||
|
Current Batch: 2
|
||||||
|
Current response number: 4
|
||||||
|
Current Calculation: 4 % 3 = 1
|
||||||
|
Current Batch: 2
|
||||||
|
Current response number: 5
|
||||||
|
Current Calculation: 5 % 3 = 2
|
||||||
|
Current Batch: 2
|
||||||
|
Current response number: 6
|
||||||
|
Current Calculation: 6 % 3 = 0
|
||||||
|
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
|
||||||
{
|
{
|
||||||
"Batch 1": [
|
"Batch 1": [
|
||||||
{
|
{
|
||||||
"action": "msg",
|
"action": "msg",
|
||||||
"type": "runcommands",
|
"type": "runcommands",
|
||||||
"result": "PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.\n64 bytes from 1.1.1.1: icmp_seq=1 ttl=59 time=6.88 ms\n64 bytes from 1.1.1.1: icmp_seq=2 ttl=59 time=6.50 ms\n64 bytes from 1.1.1.1: icmp_seq=3 ttl=59 time=6.46 ms\n64 bytes from 1.1.1.1: icmp_seq=4 ttl=59 time=6.51 ms\n\n--- 1.1.1.1 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3005ms\nrtt min/avg/max/mdev = 6.460/6.588/6.879/0.169 ms\n",
|
"result": "PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.\n64 bytes from 1.1.1.1: icmp_seq=1 ttl=59 time=6.70 ms\n64 bytes from 1.1.1.1: icmp_seq=2 ttl=59 time=6.51 ms\n64 bytes from 1.1.1.1: icmp_seq=3 ttl=59 time=6.51 ms\n64 bytes from 1.1.1.1: icmp_seq=4 ttl=59 time=6.52 ms\n\n--- 1.1.1.1 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3005ms\nrtt min/avg/max/mdev = 6.508/6.558/6.697/0.080 ms\n",
|
||||||
"responseid": "meshctrl",
|
"responseid": "meshctrl",
|
||||||
"nodeid": "MSI"
|
"nodeid": "MSI"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"action": "msg",
|
"action": "msg",
|
||||||
"type": "runcommands",
|
"type": "runcommands",
|
||||||
"result": "PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.\n64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=6.22 ms\n64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=6.07 ms\n64 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=5.97 ms\n64 bytes from 1.1.1.1: icmp_seq=4 ttl=57 time=5.90 ms\n\n--- 1.1.1.1 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3004ms\nrtt min/avg/max/mdev = 5.904/6.038/6.216/0.117 ms\n",
|
"result": "PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.\n64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=6.15 ms\n64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=6.43 ms\n64 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=5.94 ms\n64 bytes from 1.1.1.1: icmp_seq=4 ttl=57 time=5.87 ms\n\n--- 1.1.1.1 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3004ms\nrtt min/avg/max/mdev = 5.870/6.098/6.430/0.217 ms\n",
|
||||||
"responseid": "meshctrl",
|
"responseid": "meshctrl",
|
||||||
"nodeid": "server"
|
"nodeid": "server"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"action": "msg",
|
"action": "msg",
|
||||||
"type": "runcommands",
|
"type": "runcommands",
|
||||||
"result": "PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.\n64 bytes from 1.1.1.1: icmp_seq=1 ttl=59 time=6.83 ms\n64 bytes from 1.1.1.1: icmp_seq=2 ttl=59 time=6.64 ms\n64 bytes from 1.1.1.1: icmp_seq=3 ttl=59 time=6.65 ms\n64 bytes from 1.1.1.1: icmp_seq=4 ttl=59 time=6.53 ms\n\n--- 1.1.1.1 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3005ms\nrtt min/avg/max/mdev = 6.534/6.664/6.834/0.108 ms\n",
|
"result": "PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.\n64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=6.29 ms\n64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=6.05 ms\n64 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=5.88 ms\n64 bytes from 1.1.1.1: icmp_seq=4 ttl=57 time=5.99 ms\n\n--- 1.1.1.1 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3005ms\nrtt min/avg/max/mdev = 5.875/6.050/6.286/0.150 ms\n",
|
||||||
"responseid": "meshctrl",
|
"responseid": "meshctrl",
|
||||||
"nodeid": "raspberrypi5"
|
"nodeid": "raspberrypi5"
|
||||||
}
|
}
|
||||||
@@ -83,27 +109,29 @@ python3 meshbook.py -pb examples/ping.yaml -s
|
|||||||
{
|
{
|
||||||
"action": "msg",
|
"action": "msg",
|
||||||
"type": "runcommands",
|
"type": "runcommands",
|
||||||
"result": "PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=5.69 ms\n64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=5.22 ms\n64 bytes from 8.8.8.8: icmp_seq=3 ttl=118 time=5.19 ms\n64 bytes from 8.8.8.8: icmp_seq=4 ttl=118 time=5.16 ms\n\n--- 8.8.8.8 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3004ms\nrtt min/avg/max/mdev = 5.161/5.315/5.694/0.219 ms\n",
|
"result": "PING ns.systemec.nl (89.20.90.102) 56(84) bytes of data.\n64 bytes from roma.systemec.nl (89.20.90.102): icmp_seq=1 ttl=60 time=1.45 ms\n64 bytes from roma.systemec.nl (89.20.90.102): icmp_seq=2 ttl=60 time=1.10 ms\n64 bytes from roma.systemec.nl (89.20.90.102): icmp_seq=3 ttl=60 time=1.12 ms\n64 bytes from roma.systemec.nl (89.20.90.102): icmp_seq=4 ttl=60 time=1.14 ms\n\n--- ns.systemec.nl ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3003ms\nrtt min/avg/max/mdev = 1.100/1.199/1.448/0.143 ms\n",
|
||||||
"responseid": "meshctrl",
|
|
||||||
"nodeid": "MSI"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"action": "msg",
|
|
||||||
"type": "runcommands",
|
|
||||||
"result": "PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=5.65 ms\n64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=5.28 ms\n64 bytes from 8.8.8.8: icmp_seq=3 ttl=118 time=5.25 ms\n64 bytes from 8.8.8.8: icmp_seq=4 ttl=118 time=5.25 ms\n\n--- 8.8.8.8 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3004ms\nrtt min/avg/max/mdev = 5.246/5.357/5.648/0.168 ms\n",
|
|
||||||
"responseid": "meshctrl",
|
"responseid": "meshctrl",
|
||||||
"nodeid": "raspberrypi5"
|
"nodeid": "raspberrypi5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"action": "msg",
|
"action": "msg",
|
||||||
"type": "runcommands",
|
"type": "runcommands",
|
||||||
"result": "PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=4.94 ms\n64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=4.68 ms\n64 bytes from 8.8.8.8: icmp_seq=3 ttl=118 time=4.79 ms\n64 bytes from 8.8.8.8: icmp_seq=4 ttl=118 time=4.77 ms\n\n--- 8.8.8.8 ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3005ms\nrtt min/avg/max/mdev = 4.678/4.792/4.940/0.094 ms\n",
|
"result": "PING ns.systemec.nl (89.20.90.102) 56(84) bytes of data.\n64 bytes from ns.systemec.nl (89.20.90.102): icmp_seq=1 ttl=59 time=1.52 ms\n64 bytes from ns.systemec.nl (89.20.90.102): icmp_seq=2 ttl=59 time=1.26 ms\n64 bytes from ns.systemec.nl (89.20.90.102): icmp_seq=3 ttl=59 time=1.34 ms\n64 bytes from ns.systemec.nl (89.20.90.102): icmp_seq=4 ttl=59 time=1.27 ms\n\n--- ns.systemec.nl ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3006ms\nrtt min/avg/max/mdev = 1.255/1.345/1.523/0.107 ms\n",
|
||||||
"responseid": "meshctrl",
|
"responseid": "meshctrl",
|
||||||
"nodeid": "server"
|
"nodeid": "server"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": "msg",
|
||||||
|
"type": "runcommands",
|
||||||
|
"result": "PING ns.systemec.nl (89.20.90.102) 56(84) bytes of data.\n64 bytes from ns.systemec.nl (89.20.90.102): icmp_seq=1 ttl=62 time=7.21 ms\n64 bytes from roma.systemec.nl (89.20.90.102): icmp_seq=2 ttl=62 time=0.346 ms\n64 bytes from ns.systemec.nl (89.20.90.102): icmp_seq=3 ttl=62 time=0.358 ms\n64 bytes from roma.systemec.nl (89.20.90.102): icmp_seq=4 ttl=62 time=0.336 ms\n\n--- ns.systemec.nl ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 3018ms\nrtt min/avg/max/mdev = 0.336/2.061/7.205/2.969 ms\n",
|
||||||
|
"responseid": "meshctrl",
|
||||||
|
"nodeid": "MSI"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
All tasks completed successfully: Expected 6 Received 6
|
||||||
```
|
```
|
||||||
|
The above with `-si` is quite verbose. use `--help` to read about parameters.
|
||||||
|
|
||||||
# Important Notice:
|
# Important Notice:
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ variables:
|
|||||||
- name: cmd_arguments
|
- name: cmd_arguments
|
||||||
value: "-c 4"
|
value: "-c 4"
|
||||||
tasks:
|
tasks:
|
||||||
- name: Ping Cloudflare
|
- name: Ping host1
|
||||||
command: "{{ command1 }} {{ host1 }} {{ cmd_arguments }}"
|
command: "{{ command1 }} {{ host1 }} {{ cmd_arguments }}"
|
||||||
|
|
||||||
- name: Ping Google
|
- name: Ping host2
|
||||||
command: "{{ command1 }} {{ host2 }} {{ cmd_arguments }}"
|
command: "{{ command1 }} {{ host2 }} {{ cmd_arguments }}"
|
||||||
Reference in New Issue
Block a user