We can run a ping check on a particular IP address or hostname with the `ping` command:

```bash
ping -c 10 8.8.8.8
echo $?
```

This will attempt to send 10 packets to the IP address `8.8.8.8`. Then the `echo` will indicate the result, success or failure. We can use this result in an `if` statement like this:

```bash
if ping -c 10 8.8.8.8 > /dev/null; then
    echo "working"
else
    echo "not working"
fi
```

In order to calculate uptime, we should take many samples, add up the failures, and then divide the number of failures by the total tests.

We will be using the `bc` command to actually run the percentage calculation.

```bash
#!/bin/bash

IP=8.8.8.8

TEST_COUNT=0
FAILURES=0

while true; do
    TEST_COUNT=$((TEST_COUNT + 1))
    if ! ping -c 10 "$IP" > /dev/null; then
        FAILURES=$((FAILURES + 1))
    fi

    UPTIME=$(bc -l <<< "100 - 100 * $FAILURES / $TEST_COUNT")

    echo "uptime: $UPTIME"

    sleep 1m
done
```

Some possible ways to improve this further:

- Make the loop exactly one minute, instead of 1 minute plus the type it takes the `ping` command. This way, the result is more accurate.
- Use a continuously updating running average, instead of adding to the same `FAILURES` variable over the entire course of running the script.
- Store the results somewhere to make it useful.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence