Name: parasol-app Version: 1.5 Release: 1 Summary: The parasol app package License: FIXME BuildArch: x86_64 Requires: python3.11, python3.11-requests, python3.11-pyyaml BuildRequires: python3.11-pip %description The parasol app package. %prep %build cat > parasol-app.service <<"EOF" [Unit] Description=Parasol App After=network.target [Service] Type=simple ExecStart=/usr/bin/parasol-app Restart=on-failure RestartSec=5s [Install] WantedBy=multi-user.target EOF cat > parasol-app.conf <<"EOF" app_url: http://webhook/url my_ip: 1.2.3.4 api_key: key EOF cat > performance-mode.conf <<"EOF" #if this file exists, use "performance mode" EOF cat > parasol-app <<"EOF" #!/usr/bin/python3.11 import os import requests import threading import time import uuid import yaml from requests.exceptions import ConnectionError _webhook_thread = None APP_VERSION = "1.5" CONFIG_PATH = "/etc/parasol-app.conf" CONFIG_D_PATH = "/etc/parasol-app.d/" last_webhook_high_cpu_state = None def call_webhook(high_cpu): global _webhook_thread if _webhook_thread is not None and _webhook_thread.is_alive(): _webhook_thread.join() headers = {"x-api-key": config['api_key']} session_id = str(uuid.uuid4()) data = {"input_type": "chat", "output_type": "chat", "server_ip": config['my_ip'], "input_value": "Normal CPU load", "session_id": session_id} if high_cpu: data['input_value'] = "High CPU load" data['input_value'] += f" detected on {config['my_ip']}" def _do_post(): try: # wait for the CPU load to rise/fall time.sleep(2) print(f"Reporting '{data['input_value']}' as session '{session_id}'") response = requests.post(config['app_url'], json=data, headers=headers, timeout=600) print(f"Report sent: {response.status_code} {response.text}") except ConnectionError: print("unable to connect to webhook, continuing") _webhook_thread = threading.Thread(target=_do_post) _webhook_thread.start() def read_yaml_file(file_path): with open(file_path, 'r') as file: data = yaml.safe_load(file) return data def conf_d_dir_has_perf_mode(conf_d_path): if len(os.listdir(conf_d_path)) == 0: return False return True config = read_yaml_file(CONFIG_PATH) while True: use_high_cpu = conf_d_dir_has_perf_mode(CONFIG_D_PATH) and APP_VERSION == "1.5" # bail out if we already called the webhook and the state didnt change if last_webhook_high_cpu_state != use_high_cpu: call_webhook(high_cpu = use_high_cpu) last_webhook_high_cpu_state = use_high_cpu if not use_high_cpu: time.sleep(2) EOF pip-3.11 install pyinstaller /usr/bin/python3.11 -m PyInstaller -F parasol-app %install mkdir -p %{buildroot}/etc/systemd/system install -m 644 parasol-app.service %{buildroot}/etc/systemd/system/ mkdir -p %{buildroot}/usr/bin install -m 755 dist/parasol-app %{buildroot}/usr/bin/ mkdir -p %{buildroot}/etc install -m 644 parasol-app.conf %{buildroot}/etc/ mkdir -p %{buildroot}/etc/parasol-app.d/ install -m 644 performance-mode.conf %{buildroot}/etc/parasol-app.d/ %files /etc/systemd/system/parasol-app.service /usr/bin/parasol-app %config(noreplace)/etc/parasol-app.conf %config(noreplace)/etc/parasol-app.d/performance-mode.conf %post systemctl daemon-reload %changelog * Tue Feb 17 2026 Example User - 1.5-1 new package