Update sijapi.15s.py

This commit is contained in:
Sangye Ince-Johannsen 2024-09-26 02:19:49 +02:00
parent 322fa46819
commit e6f9aa8f70

View file

@ -1,13 +1,21 @@
#!/usr/bin/env python3
# <swiftbar.title>tailscaled2</swiftbar.title>
# <swiftbar.author>SIJ (Updated)</swiftbar.author>
# <swiftbar.author.github>ioflux</swiftbar.author.github>
# <swiftbar.desc>Monitors Tailscale, VPN, and server status across multiple servers.</swiftbar.desc>
# <swiftbar.title>sijapi</swiftbar.title>
# <swiftbar.author>sij.law</swiftbar.author>
# <swiftbar.author.github>sij.ai</swiftbar.author.github>
# <swiftbar.desc>Monitors Tailscale, VPN, and sijapi server and Postgres status across multiple servers.</swiftbar.desc>
# <swiftbar.hideRunInTerminal>true</swiftbar.hideRunInTerminal>
# <swiftbar.hideDisablePlugin>true</swiftbar.hideDisablePlugin>
# <swiftbar.hideSwiftBar>true</swiftbar.hideSwiftBar>
# <swiftbar.hideDisablePlugin>false</swiftbar.hideDisablePlugin>
# <swiftbar.hideSwiftBar>false</swiftbar.hideSwiftBar>
# <swiftbar.refreshEveryNSeconds>15</swiftbar.refreshEveryNSeconds>
# STEP 1: Update this path to point to your sijapi directory:
sijapi_dir = '/Users/sij/workshop/sijapi'
# STEP 2: Ensure ./sijapi/config/sys.yaml exists in your sijapi directory and contains your correct configuration. You can work off the template provided at sys.yaml-example.
config_yaml = f'{sijapi_dir}/sijapi/config/sys.yaml'
# STEP 3: Install 'vitals' (https://sij.ai/sij/vitals) in your server(s) PATH(s).
import subprocess
import json
import yaml
@ -29,11 +37,6 @@ for old_script in glob.glob(os.path.join(temp_dir, 'swiftbar_vpn_*.sh')):
except OSError:
pass # Ignore errors in cleanup
# STEP 1: Update this path to point to your sijapi directory:
sijapi_dir = '/Users/sij/workshop/sijapi'
# STEP 2: Ensure ./sijapi/config/api.yaml exists in your sijapi directory and contains your correct configuration. You can work off the template provided at api.yaml-example.
config_yaml = f'{sijapi_dir}/sijapi/config/api.yaml'
with open(config_yaml, 'r') as stream:
config = yaml.safe_load(stream)
servers = config['POOL']
@ -210,6 +213,9 @@ for server_info in server_infos:
postgres_symbol = '' if server_info['postgres_ok'] else ''
print(f"{health_symbol} Health {postgres_symbol} Postgres")
vpn_path = server_info['vpn_path']
print()
print('---')
print()
print()
print('---')