Compare commits
10 commits
024d00c22d
...
f62623af38
Author | SHA1 | Date | |
---|---|---|---|
f62623af38 | |||
2c78fccd1e | |||
15f3746f2e | |||
9af285c49d | |||
6f09301879 | |||
98483e3279 | |||
04446c9329 | |||
7c5a197872 | |||
4943442135 | |||
16c0f33b9e |
3 changed files with 52 additions and 20 deletions
|
@ -14,7 +14,3 @@ repos:
|
|||
rev: 22.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.10.1
|
||||
hooks:
|
||||
- id: isort
|
||||
|
|
26
README.md
26
README.md
|
@ -2,6 +2,22 @@
|
|||
|
||||
Nagios check for [T-Rex miner](https://github.com/trexminer/T-Rex).
|
||||
|
||||
# Security
|
||||
|
||||
T-Rex API must be opened in a secured way:
|
||||
* `--api-read-only`: accessible only in read-only, no modification
|
||||
* `--api-bind-http 127.0.0.1:4067`: (default) accessible only to local connections
|
||||
|
||||
If the check is executed **remotely**, you should add a **firewall rule** to allow only the host running the check to
|
||||
access the T-Rex API port.
|
||||
|
||||
**HTTPS** should be used:
|
||||
* `--api-https`
|
||||
* `--api-webserver-cert`
|
||||
* `--api-webserver-pkey`
|
||||
|
||||
See full [list of options](https://github.com/trexminer/T-Rex#usage).
|
||||
|
||||
# Installation
|
||||
|
||||
Using pip:
|
||||
|
@ -21,7 +37,15 @@ sudo apt-get install python3-nagiosplugin python3-requests
|
|||
# Usage
|
||||
|
||||
```
|
||||
./check_trex --help
|
||||
./check_trex.py --help
|
||||
```
|
||||
|
||||
# Examples
|
||||
|
||||
Nagios NRPE:
|
||||
|
||||
```
|
||||
command[check_trex]=/opt/check_trex/check_trex.py --hashrate-warning 60000000 --hashrate-critical 50000000 --uptime-critical 300 --uptime-warning 600
|
||||
```
|
||||
|
||||
# Contributing
|
||||
|
|
|
@ -5,8 +5,15 @@ import logging
|
|||
import sys
|
||||
|
||||
import requests
|
||||
from nagiosplugin import (Check, Context, Metric, Performance, Resource,
|
||||
ScalarContext, Summary)
|
||||
from nagiosplugin import (
|
||||
Check,
|
||||
Context,
|
||||
Metric,
|
||||
Performance,
|
||||
Resource,
|
||||
ScalarContext,
|
||||
Summary,
|
||||
)
|
||||
from nagiosplugin.state import Critical, Ok, Unknown, Warn
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -128,7 +135,7 @@ def setup_logging(args):
|
|||
|
||||
|
||||
def show_version():
|
||||
print("1.0.0")
|
||||
print("1.0.3")
|
||||
|
||||
|
||||
class BelowThresholdContext(Context):
|
||||
|
@ -195,29 +202,29 @@ class Trex(Resource):
|
|||
|
||||
if "hashrate" in data:
|
||||
hashrate = data["hashrate"]
|
||||
logger.debug(f"Hashrate is {hashrate}")
|
||||
logger.info(f"Hashrate is {hashrate}")
|
||||
metrics.append(Metric("hashrate", hashrate, context="hashrate"))
|
||||
|
||||
if "success" in data:
|
||||
success = bool(data["success"])
|
||||
if success:
|
||||
logger.debug("T-Rex is successfully started")
|
||||
logger.info("T-Rex is successfully started")
|
||||
else:
|
||||
logger.debug("T-Rex is not successfully started")
|
||||
logger.info("T-Rex is not successfully started")
|
||||
metrics.append(Metric("success", success, context="success"))
|
||||
|
||||
if "paused" in data:
|
||||
paused = bool(data["paused"])
|
||||
if paused:
|
||||
logger.debug("T-Rex is paused")
|
||||
logger.info("T-Rex is paused")
|
||||
else:
|
||||
logger.debug("T-Rex is not paused")
|
||||
logger.info("T-Rex is not paused")
|
||||
metrics.append(Metric("paused", paused, context="paused"))
|
||||
|
||||
if "uptime" in data:
|
||||
uptime = data["uptime"]
|
||||
seconds = "seconds" if uptime > 1 else "second"
|
||||
logger.debug(f"Uptime is {uptime} {seconds}")
|
||||
logger.info(f"Uptime is {uptime} {seconds}")
|
||||
metrics.append(Metric("uptime", uptime, context="uptime"))
|
||||
|
||||
for gpu in data.get("gpus"):
|
||||
|
@ -226,19 +233,19 @@ class Trex(Resource):
|
|||
|
||||
if "temperature" in gpu:
|
||||
temperature = gpu["temperature"]
|
||||
logger.debug(f"Temperature of {name} ({id}) is {temperature}C")
|
||||
logger.info(f"GPU {id} ({name}): temperature is {temperature}C")
|
||||
metrics.append(
|
||||
Metric("temperature", temperature, context="temperature")
|
||||
Metric(f"temperature_{id}", temperature, context="temperature")
|
||||
)
|
||||
|
||||
if "memory_temperature" in gpu:
|
||||
temperature = gpu["memory_temperature"]
|
||||
logger.debug(
|
||||
f"Memory temperature of {name} ({id}) is {memory_temperature}C"
|
||||
memory_temperature = gpu["memory_temperature"]
|
||||
logger.info(
|
||||
f"GPU {id} ({name}): memory temperature is {memory_temperature}C"
|
||||
)
|
||||
metrics.append(
|
||||
Metric(
|
||||
"memory_temperature",
|
||||
f"memory_temperature_{id}",
|
||||
memory_temperature,
|
||||
context="memory_temperature",
|
||||
)
|
||||
|
@ -289,6 +296,11 @@ def main():
|
|||
warning=args.temperature_warning,
|
||||
critical=args.temperature_critical,
|
||||
),
|
||||
ScalarContext(
|
||||
"memory_temperature",
|
||||
warning=args.memory_temperature_warning,
|
||||
critical=args.memory_temperature_critical,
|
||||
),
|
||||
TrexSummary(),
|
||||
)
|
||||
check.main()
|
||||
|
|
Loading…
Reference in a new issue