Files
aitbc/services/monitor.py
aitbc 40ddf89b9c
Some checks failed
CLI Tests / test-cli (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
API Endpoint Tests / test-api-endpoints (push) Has been cancelled
docs: update CLI command syntax across workflow documentation
- Updated marketplace commands: `marketplace --action` → `market` subcommands
- Updated wallet commands: direct flags → `wallet` subcommands
- Updated AI commands: `ai-submit`, `ai-status` → `ai submit`, `ai status`
- Updated blockchain commands: `chain` → `blockchain info`
- Standardized command structure across all workflow files
- Affected files: MULTI_NODE_MASTER_INDEX.md, TEST_MASTER_INDEX.md, multi-node-blockchain-marketplace
2026-04-08 12:10:21 +02:00

49 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""
AITBC Monitor Service
"""
import time
import logging
import json
from pathlib import Path
import psutil
def main():
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('aitbc-monitor')
while True:
try:
# System stats
cpu_percent = psutil.cpu_percent()
memory_percent = psutil.virtual_memory().percent
logger.info(f'System: CPU {cpu_percent}%, Memory {memory_percent}%')
# Blockchain stats
blockchain_file = Path('/var/lib/aitbc/data/blockchain/aitbc/blockchain.json')
if blockchain_file.exists():
with open(blockchain_file, 'r') as f:
data = json.load(f)
logger.info(f'Blockchain: {len(data.get("blocks", []))} blocks')
# Marketplace stats
marketplace_dir = Path('/var/lib/aitbc/data/marketplace')
if marketplace_dir.exists():
listings_file = marketplace_dir / 'gpu_listings.json'
if listings_file.exists():
with open(listings_file, 'r') as f:
listings = json.load(f)
logger.info(f'Marketplace: {len(listings)} GPU listings')
time.sleep(30)
except (json.JSONDecodeError, FileNotFoundError, PermissionError, IOError) as e:
logger.error(f'Monitoring error: {type(e).__name__}: {e}')
time.sleep(60)
except psutil.Error as e:
logger.error(f'System monitoring error: {type(e).__name__}: {e}')
time.sleep(60)
if __name__ == "__main__":
main()