<commit_before>testnet-ripe-anchors
===================

`testnet-ripe-anchors.py` is a Python-script that checks network connectivity by contacting a random subset of [RIPE Atlas Anchors](https://atlas.ripe.net/about/anchors/).
It is inspired by a [blog post at RIPE labs](https://labs.ripe.net/Members/stephane_bortzmeyer/checking-your-internet-connectivity-with-ripe-atlas-anchors).

To test connectivity, it tries to send a HTTP request to a set of RIPE Atlas Anchors.


Quick start
-----------

*Note*:
If you get an error about being unable to import the requests-library, you will need to install it.
See the section about dependencies belof.


To test connectivity to 5% of the RIPE Atlas Anchors, run:

```
$ ./testnet-ripe-anchors.py
14 / 14 OK
```

If you only have IPv4 connectivity, you may want to run:

```
$ ./testnet-ripe-anchors.py --ipv4
7 / 7 OK
```


Options
-------

There are a number of options to control the behavior of this program.
To see a full list of options, run `./testnet-ripe-anchors.py --help`


### `--all`

Try to connect to all available targets.

Example:

```
$ ./testnet-ripe-anchors.py --all
294 / 298 OK
```


### `--count`

Number of targets to test against.

This can either be an absolute number, or a percentage of available targets.
For example, to test against 30 targets:

```
$ ./testnet-ripe-anchors.py --count=30
30 / 30 OK
```

To test against 10% of available targets:

```
$ ./testnet-ripe-anchors.py --count=10%
29 / 29 OK
```


### `--fail-threshold`

Failure threshold.
Exit with an error status if less than this number of targets respond.
This can be specified as both a percentage and as an absolute value.

Example using an absolute value:

```
$ ./testnet-ripe-anchors.py --count=50 --fail-threshold=40
35 / 50 OK
$ echo $?
1
```

Or using a percentage:

```
$ ./testnet-ripe-anchors.py --count=50 --fail-threshold=75%
35 / 50 OK
$ echo $?
1
```


### `--ipv4`

Test only IPv4 targets.

Example:

```
$ ./testnet-ripe-anchors.py --all --ipv4
148 / 149 OK
```


### `--ipv6`

Test only IPv6 targets.

Example:

```
$ ./testnet-ripe-anchors.py --all --ipv6
147 / 149 OK
```


### `--output`

Output format for presenting the output.

The following output formats are available:

#### `count`

A simple count of the number of targets reached.
This is most useful when used together with the `--count` option:

```
$ ./testnet-ripe-anchors.py --count=50 --output=count
48
```

#### `count_total`

Print the number of targets reached and the number of targets tried, as two numbers on one line:

```
$ ./testnet-ripe-anchors.py --output=count_total
13 14
```

Or in a shell script:

```
#!/bin/bash
set -e # Exit on error
./testnet-ripe-anchors.py --output=count_total | (
  read OK TOTAL
  echo "OK: $OK"
  echo "Total: $TOTAL"
)
```

#### `percent`

The percentage of test targets that we were able to reach:

```
$ ./testnet-ripe-anchors.py --output=percent
100.00
```

#### `verbose`
<commit_msg>Make README.md more readable<commit_after>testnet-ripe-anchors
===================

`testnet-ripe-anchors.py` is a Python-script that checks network connectivity by contacting a random subset of [RIPE Atlas Anchors](https://atlas.ripe.net/about/anchors/).
It is inspired by a [blog post at RIPE labs](https://labs.ripe.net/Members/stephane_bortzmeyer/checking-your-internet-connectivity-with-ripe-atlas-anchors).

To test connectivity, it tries to send a HTTP request to a set of RIPE Atlas Anchors.


Quick start
-----------

*Note*:
If you get an error about being unable to import the requests-library, you will need to install it.
See the section about dependencies belof.


To test connectivity to 5% of the RIPE Atlas Anchors, run:

```
$ ./testnet-ripe-anchors.py
14 / 14 OK
```

If you only have IPv4 connectivity, you may want to run:

```
$ ./testnet-ripe-anchors.py --ipv4
7 / 7 OK
```


Options
-------

There are a number of options to control the behavior of this program.
To see a full list of options, run `./testnet-ripe-anchors.py --help`


##### `--all`

Try to connect to all available targets.

Example:

```
$ ./testnet-ripe-anchors.py --all
294 / 298 OK
```


##### `--count`

Number of targets to test against.

This can either be an absolute number, or a percentage of available targets.
For example, to test against 30 targets:

```
$ ./testnet-ripe-anchors.py --count=30
30 / 30 OK
```

To test against 10% of available targets:

```
$ ./testnet-ripe-anchors.py --count=10%
29 / 29 OK
```


##### `--fail-threshold`

Failure threshold.
Exit with an error status if less than this number of targets respond.
This can be specified as both a percentage and as an absolute value.

Example using an absolute value:

```
$ ./testnet-ripe-anchors.py --count=50 --fail-threshold=40
35 / 50 OK
$ echo $?
1
```

Or using a percentage:

```
$ ./testnet-ripe-anchors.py --count=50 --fail-threshold=75%
35 / 50 OK
$ echo $?
1
```


##### `--ipv4`

Test only IPv4 targets.

Example:

```
$ ./testnet-ripe-anchors.py --all --ipv4
148 / 149 OK
```


##### `--ipv6`

Test only IPv6 targets.

Example:

```
$ ./testnet-ripe-anchors.py --all --ipv6
147 / 149 OK
```


##### `--output`

Output format for presenting the output.

The following output formats are available:

###### `count`

A simple count of the number of targets reached.
This is most useful when used together with the `--count` option:

```
$ ./testnet-ripe-anchors.py --count=50 --output=count
48
```

###### `count_total`

Print the number of targets reached and the number of targets tried, as two numbers on one line:

```
$ ./testnet-ripe-anchors.py --output=count_total
13 14
```

Or in a shell script:

```
#!/bin/bash
set -e # Exit on error
./testnet-ripe-anchors.py --output=count_total | (
  read OK TOTAL
  echo "OK: $OK"
  echo "Total: $TOTAL"
)
```

###### `percent`

The percentage of test targets that we were able to reach:

```
$ ./testnet-ripe-anchors.py --output=percent
100.00
```

###### `verbose`

{'fraction_non_alphanumeric': 0.15130142737195634, 'fraction_numerical': 0.02686817800167926, 'mean_word_length': 3.2879769618430528, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3152855', 'n_tokens_mistral': 2206, 'n_tokens_neox': 1990, 'n_words': 727}