Added kuma

This commit is contained in:
Luca Gambarotto 2024-01-14 18:51:42 +01:00
parent 0aed159923
commit 9d22f7d0ab
7 changed files with 5418 additions and 0 deletions

View File

@ -0,0 +1,107 @@
import json
import copy
import openpyxl
def get_colors():
colors = ["#E74C3C", "#9B59B6", "#2980B9", "#27AE60", "#F1C40F", "#D35400", "#95A5A6", "#2E4053"]
return colors
def load_json_file(file_path):
try:
with open(file_path, 'r') as file:
data = json.load(file)
return data
except FileNotFoundError:
print(f"Error: File '{file_path}' not found.")
except json.JSONDecodeError:
print(f"Error: Unable to decode JSON in '{file_path}'. Check if the file is a valid JSON.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
def get_tag(tag_name, monitor_id):
colors = get_colors()
if not hasattr(get_tag, "tags"):
get_tag.tags = {}
if not hasattr(get_tag, "tag_id"):
get_tag.tag_id = 0
if not hasattr(get_tag, "id"):
get_tag.id = 0
tag = copy.deepcopy(get_tag.tags.get(tag_name, None))
# Access and modify the static variable
if not tag:
get_tag.tag_id += 1
tag = load_json_file('tag_object.json')
tag["name"] = tag_name
tag["tag_id"] = get_tag.tag_id
tag["color"] = colors[get_tag.tag_id % len(colors)]
get_tag.tags[tag_name] = tag
tag["monitor_id"] = monitor_id
get_tag.id += 1
tag["id"] = get_tag.id
return tag
def get_monitor(name, ip_address, tag_list):
if not hasattr(get_monitor, "id"):
get_monitor.id = 0
get_monitor.id += 1
monitor = load_json_file('monitor_object.json')
monitor["id"] = get_monitor.id
monitor["name"] = name
monitor["pathName"] = name
monitor["hostname"] = ip_address
tags = monitor.get('tags', [])
for tag in tag_list:
tag_obj = get_tag(tag, get_monitor.id)
tags.append(tag_obj)
return monitor
def read_excel_file(file_path):
df = openpyxl.load_workbook(file_path)
df = df.active
return df
# Load the JSON file
outer_structure = load_json_file('outer_structure.json')
monitorList = outer_structure.get('monitorList', [])
data = read_excel_file("Z:\ips.xlsx")
for row_num in range(1, data.max_row + 1):
service_name = data.cell(row=row_num, column=2).value
ip_address = data.cell(row=row_num, column=1).value
tag = data.cell(row=row_num, column=4).value
if service_name is not None:
monitorList.append(get_monitor(service_name, ip_address, [tag]))
# Save the configuration json
file_path = "monitor_configuration.json"
with open(file_path, 'w') as json_file:
json.dump(outer_structure, json_file, indent=2)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,89 @@
{
"id": 1,
"name": "Gateway",
"description": null,
"pathName": "Gateway",
"parent": null,
"childrenIDs": [],
"url": "https://",
"method": "GET",
"hostname": "10.0.0.2",
"port": null,
"maxretries": 0,
"weight": 2000,
"active": true,
"forceInactive": false,
"type": "ping",
"timeout": 48,
"interval": 180,
"retryInterval": 180,
"resendInterval": 0,
"keyword": null,
"invertKeyword": false,
"expiryNotification": false,
"ignoreTls": false,
"upsideDown": false,
"packetSize": 56,
"maxredirects": 10,
"accepted_statuscodes": [
"200-299"
],
"dns_resolve_type": "A",
"dns_resolve_server": "1.1.1.1",
"dns_last_result": null,
"docker_container": "",
"docker_host": null,
"proxyId": null,
"notificationIDList": {},
"tags": [],
"maintenance": false,
"mqttTopic": "",
"mqttSuccessMessage": "",
"databaseQuery": null,
"authMethod": null,
"grpcUrl": null,
"grpcProtobuf": null,
"grpcMethod": null,
"grpcServiceName": null,
"grpcEnableTls": false,
"radiusCalledStationId": null,
"radiusCallingStationId": null,
"game": null,
"gamedigGivenPortOnly": true,
"httpBodyEncoding": null,
"jsonPath": null,
"expectedValue": null,
"kafkaProducerTopic": null,
"kafkaProducerBrokers": [],
"kafkaProducerSsl": false,
"kafkaProducerAllowAutoTopicCreation": false,
"kafkaProducerMessage": null,
"screenshot": null,
"headers": null,
"body": null,
"grpcBody": null,
"grpcMetadata": null,
"basic_auth_user": null,
"basic_auth_pass": null,
"oauth_client_id": null,
"oauth_client_secret": null,
"oauth_token_url": null,
"oauth_scopes": null,
"oauth_auth_method": "client_secret_basic",
"pushToken": null,
"databaseConnectionString": null,
"radiusUsername": null,
"radiusPassword": null,
"radiusSecret": null,
"mqttUsername": "",
"mqttPassword": "",
"authWorkstation": null,
"authDomain": null,
"tlsCa": null,
"tlsCert": null,
"tlsKey": null,
"kafkaProducerSaslOptions": {
"mechanism": "None"
},
"includeSensitiveData": true
}

View File

@ -0,0 +1,5 @@
{
"version": "1.23.11",
"notificationList": [],
"monitorList": []
}

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"id": 8,
"monitor_id": 1,
"tag_id": 2,
"value": "",
"name": "Network",
"color": "#1ABC9C"
}

9
kuma/readme.md Normal file
View File

@ -0,0 +1,9 @@
# Uptime Kuma
# Setup
```bash
docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
```
# Configuration file generation
Use the script in generate_configuration, setting the correct path to the excel recap file.