Skip to content

Commit

Permalink
Merge pull request #6 from danielringch/release/1.3.0
Browse files Browse the repository at this point in the history
Release/1.3.0
  • Loading branch information
danielringch authored Sep 7, 2023
2 parents d798ddb + f578070 commit 37e0147
Show file tree
Hide file tree
Showing 24 changed files with 666 additions and 231 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ The hardware related plugins will only work on linux. All other should run on an
- [diskfree](docu/plugin/diskfree.md): Disk free space monitoring.
- [pingdrive](docu/plugin/pingdrive.md): Supervises disk activity and pings drives if too inactive. Prevents head parking and sends alerts in case of drives going offline.
- [smartctl](docu/plugin/smartctl.md): Checks drive health using S.M.A.R.T. and provides some logging.
- Energy management
- [opendtu](docu/plugin/opendtu.md): Solar farm monitoring for Hoymiles inverters and openDTU.
- General
- [eccram](docu/plugin/eccram.md): Checks the error statistics of ECC RAM.
- [messagerelay](docu/plugin/messagerelay.md): Relays messages received via http post request to the interfaces.
Expand Down
8 changes: 8 additions & 0 deletions config/plugin/opendtu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "my_opendtu" #unique name
check_interval: "0 * * * *" #cron schedule expression
summary_interval: "0 0 * * *" #cron schedule expression
alert_mute_interval: 24 #hours
host: "192.168.4.1:80"
database: "~/myDb.sqlite"
verbose_csv_export: "~/myVerboseCsv.csv" #optional
summary_csv_export: "~/mySummaryCsv.csv" #optional
25 changes: 15 additions & 10 deletions config/plugin/serviceping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ name: "my_serviceping" #unique name
summary_interval: "0 0 * * *" #cron schedule expression
check_interval: "0 * * * *" #cron schedule expression
alert_mute_interval: 24 #hours
chia: #optional
cert: "~/.chia/mainnet/config/ssl/full_node/private_full_node.crt"
key: "~/.chia/mainnet/config/ssl/full_node/private_full_node.key"
host: "127.0.0.1:8555"
flexfarmer: #optional
host: "127.0.0.1:8080"
sia: #optional
host: "127.0.0.1:9980"
storj: #optional
host: "127.0.0.1:14002"
hosts:
my_host_1: # optional
type: chia
cert: "~/.chia/mainnet/config/ssl/full_node/private_full_node.crt"
key: "~/.chia/mainnet/config/ssl/full_node/private_full_node.key"
host: "127.0.0.1:8555"
my_host_2: # optional
type: flexfarmer
host: "127.0.0.1:8080"
my_host_3: # optional
type: sia
host: "127.0.0.1:9980"
my_host_4: # optional
type: storj
host: "127.0.0.1:14002"
4 changes: 3 additions & 1 deletion config/plugin/storjnode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ check_interval: "*/15 * * * *" #cron schedule expression
summary_interval: "0 0 * * *" #cron schedule expression
accounting_interval: "0 0 3 * *" #cron schedule expression
alert_mute_interval: 24 #hours
host: "127.0.0.1:14002"
hosts:
my_storj_host: "127.0.0.1:14002" #optional
my_other_storj_host: "192.168.0.1:14003" #optional
database: "~/myDb.sqlite"
csv_export: "~/myCsv.csv" #optional
2 changes: 2 additions & 0 deletions config/xiamon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ plugins:
eccram: "plugin/eccram.yaml" #optional
flexfarmer: "plugin/flexfarmer.yaml" #optional
flexpool: "plugin/flexpool.yaml" #optional
messagerelay: "plugin/messagerelay.yaml" #optional
opendtu: "plugin/opendtu.yaml" #optional
pingdrive: "plugin/pingdrive.yaml" #optional
serviceping: "plugin/serviceping.yaml" #optional
siahost: "plugin/siahost.yaml" #optional
Expand Down
2 changes: 2 additions & 0 deletions docu/main_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins:
flexfarmer: "plugin/flexfarmer.yaml" #optional
flexpool: "plugin/flexpool.yaml" #optional
messagerelay: "plugin/messagerelay.yaml" #optional
opendtu: "plugin/opendtu.yaml" #optional
pingdrive: "plugin/pingdrive.yaml" #optional
serviceping: "plugin/serviceping.yaml" #optional
siahost: "plugin/siahost.yaml" #optional
Expand Down Expand Up @@ -52,6 +53,7 @@ The following plugins are available:
- flexfarmer
- flexpool
- messagerelay
- opendtu
- pingdrive
- serviceping
- siahost
Expand Down
45 changes: 45 additions & 0 deletions docu/plugin/opendtu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# The Xiamon opendtu plugin

This plugin monitors Hoymiles solar invertes connected to an [openDTU](https://github.com/tbnobody/OpenDTU).

## **Configuration template**

The basic configuration information can be found [here](../config_basics.md).

```yaml
name: "my_opendtu" #unique name
check_interval: "0 * * * *" #cron schedule expression
summary_interval: "0 0 * * *" #cron schedule expression
alert_mute_interval: 24 #hours
host: "192.168.4.1:80"
database: "~/myDb.sqlite"
verbose_csv_export: "~/myVerboseCsv.csv" #optional
summary_csv_export: "~/mySummaryCsv.csv" #optional
```
## **Basic setup**
For the key **host**, you need ip address and port of your openDTU. The ip address depends on your network setup, while the port is usually `80`.

The plugin uses an internal database, its path is configured by the key **database**.

## **Checks**

The plugin checks the energy statistics and saves them to its database. If the key **verbose_csv_export** is set, the data is also dumped into a csv file.

No alerts are sent in any case.

The [execution interval](../config_basics.md) is set by the key **check_interval**.

## **Summary**

A summary is sent to the **info** channel, containing the following information:

- Fed-in energy since last summary
- Total fed-in energy

This data is also dumped into a csv file, if the key **summary_csv_export** is set.

A table with more detailed information is sent to the **verbose** channel.

The [execution interval](../config_basics.md) is set by the key **summary_interval**. It is strongly recommended to trigger the summary at night when the inverter is offline; otherwise, the results may be incorrect.
38 changes: 24 additions & 14 deletions docu/plugin/serviceping.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,49 @@ name: "my_serviceping" #unique name
summary_interval: "0 0 * * *" #cron schedule expression
check_interval: "0 * * * *" #cron schedule expression
alert_mute_interval: 24 #hours
chia: #optional
cert: "~/.chia/mainnet/config/ssl/full_node/private_full_node.crt"
key: "~/.chia/mainnet/config/ssl/full_node/private_full_node.key"
host: "127.0.0.1:8555"
flexfarmer: #optional
host: "127.0.0.1:8080"
sia: #optional
host: "127.0.0.1:9980"
storj: #optional
host: "127.0.0.1:14002"
hosts:
my_host_1: # optional
type: chia
cert: "~/.chia/mainnet/config/ssl/full_node/private_full_node.crt"
key: "~/.chia/mainnet/config/ssl/full_node/private_full_node.key"
host: "127.0.0.1:8555"
my_host_2: # optional
type: flexfarmer
host: "127.0.0.1:8080"
my_host_3: # optional
type: sia
host: "127.0.0.1:9980"
my_host_4: # optional
type: storj
host: "127.0.0.1:14002"
```
## **Basic setup**
The services to monitor are listed under the key **hosts**. For each service, the displayed name is set as a key.
The key **type** sets the type of service, supported values are `chia`, `flexfarmer`, `sia` and `storj`.

### ***Chia***

The configuration for chia is set by the key **chia**. The configuration is the same as for the chia full node plugin and can be found [here](chianode.md).
The configuration is the same as for the chia full node plugin and can be found [here](chianode.md).

### ***Flexfarmer***

The configuration for flexfarmer is set by the key **flexfarmer** and has the **host** as value.
The key **host** specifies the ip and port of the flexfarmer instance.

The key **api_server_listen** in flexfarmers configuration file needs to be set to `localhost:8080` (access of same machine) or `0.0.0.0:8080` (access in local network) to enable flexfarmers API server.

The port of the api server in the flexfarmer configuration template is set to 8080. In practice, this port is often already in use by other http servers on the machine, feel free to choose a different port.

### ***Sia***

The configuration for sia is set by the key **sia**. The configuration is the same as for the siahost plugin and can be found [here](siahost.md). Since this plugin only does readonly calls, no api password is required.
The key **host** specifies the ip and port of the siad instance. For more information, see the documentation of the [siahost plugin](siahost.md). No api password is required for this plugin.

### ***Storj***

The configuration for storj is set by the key **storj**. The configuration is the same as for the storj plugin and can be found [here](storjnode.md).
The key **host** specifies the ip and port of the storj instance. For more information, see the documentation of the [storj plugin](storjnode.md).


## **Check**

Expand Down
21 changes: 13 additions & 8 deletions docu/plugin/storjnode.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The Xiamon storjnode plugin

This plugin monitors a storj SNO instance.
This plugin monitors one or multiple storj SNO instances.

## **Configuration template**

Expand All @@ -12,26 +12,29 @@ check_interval: "*/15 * * * *" #cron schedule expression
summary_interval: "0 0 * * *" #cron schedule expression
accounting_interval: "0 0 3 * *" #cron schedule expression
alert_mute_interval: 24 #hours
host: "127.0.0.1:14002"
hosts:
my_storj_host: "127.0.0.1:14002" #optional
my_other_storj_host: "192.168.0.1:14003" #optional
database: "~/myDb.sqlite"
csv_export: "~/myCsv.csv" #optional
```
## **Basic setup**
The storjhost is usually `127.0.0.1:14002` and is configured by the key **host**.
A storj SNO instance usually uses port `14002`. All monitored instances and their aliases are configured as list below the key **hosts**.

The plugin uses an internal database, its path is configured by the key **database**.

## **Checks**

The plugin checks the health of the storj instance and sends an alert if one of the following conditions is true:
The plugin checks the health of all storj SNO instances and sends an alert if:

- Software version is outdated
- the instance is offline
- the software version is outdated
- QUIC is not enabled
- No satellite is connected
- Node is suspended or disqualified by a satellite
- Storage space is overused
- no satellite is connected
- the node is suspended or disqualified by a satellite
- storage space is overused

The [execution interval](../config_basics.md) is set by the key **check_interval**.

Expand All @@ -46,6 +49,8 @@ A summary is sent to the **info** channel, containing the following information:
- Earnings since last summary (exlcuding held earnings)
- Total earnings of the month (exlcuding held earnings)

The same information broken down by storj SNO instance is written to the **verbose** channel.

Traffic information is not available if the month changes between two summaries.

The [execution interval](../config_basics.md) is set by the key **summary_interval**.
Expand Down
17 changes: 16 additions & 1 deletion xiamon/src/core/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,19 @@ def autorange(value, base=1000):
result = value / (base ** exp)
if result < 1000:
return result, prefix
raise OverflowError()
raise OverflowError()

@staticmethod
def reverse_autorange(value, unit, base_unit, base=1000):
prefix = unit[0:-(len(base_unit))]
if len(prefix) == 0:
return value
if prefix in prefixes_upwards:
exp = prefixes_upwards[prefix]
elif prefix in prefixes_downwards:
exp = prefixes_downwards[prefixes_downwards]
else:
raise ValueError()

return value * (base ** exp)

3 changes: 2 additions & 1 deletion xiamon/src/core/storjapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def __init__(self, host, plugin):
self.__host = host
self.__plugin = plugin

def create_session(self):
@staticmethod
def create_session():
session = aiohttp.ClientSession()
return session

Expand Down
5 changes: 5 additions & 0 deletions xiamon/src/core/storjresponses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class Storjnodedata:
def __init__(self, json):
self.__id = json['nodeID']
self.__quic = (json['quicStatus'] == "OK")
self.__uptodate = json['upToDate']
self.__traffic = int(json['bandwidth']['used'])
Expand All @@ -18,6 +19,10 @@ def __init__(self, json):
if satellite['suspended'] is not None:
self.__suspended += 1

@property
def id(self):
return self.__id

@property
def quic(self):
return self.__quic
Expand Down
6 changes: 6 additions & 0 deletions xiamon/src/core/tablerenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ class Tablerenderer:
def __init__(self, header = []):
self.data = defaultdict(list, { x:[] for x in header })

def add_row(self, data):
i = 0
for col in self.data.values():
col.append(data[i] if len(data) > i else '')
i += 1

def reverse(self):
rows = max(len(x) for x in self.data.values())
for column in self.data.values():
Expand Down
1 change: 1 addition & 0 deletions xiamon/src/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .flexfarmer import *
from .flexpool import *
from .messagerelay import *
from .opendtu import *
from .pingdrive import *
from .serviceping import *
from .siahost import *
Expand Down
1 change: 1 addition & 0 deletions xiamon/src/plugins/opendtu/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .opendtu import Opendtu
Loading

0 comments on commit 37e0147

Please sign in to comment.