Some checks failed
CLI Tests / test-cli (push) Failing after 4s
Deploy to Testnet / deploy-testnet (push) Successful in 1m40s
Documentation Validation / validate-docs (push) Failing after 12s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 2m42s
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 34s
Package Tests / Python package - aitbc-core (push) Successful in 27s
Package Tests / Python package - aitbc-crypto (push) Successful in 13s
Package Tests / Python package - aitbc-sdk (push) Successful in 16s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 18s
Python Tests / test-python (push) Failing after 50s
Security Scanning / security-scan (push) Failing after 43s
Multi-Node Stress Testing / stress-test (push) Successful in 12s
Cross-Node Transaction Testing / transaction-test (push) Successful in 9s
- Created aitbc/_version.py with centralized version definition - Updated aitbc/__init__.py to import __version__ from _version module - Updated constants.py to use __version__ for PACKAGE_VERSION - Replaced print() calls with logger in decorators.py, events.py, queue_manager.py, and state.py - Added logger initialization using get_logger(__name__) in config.py, decorators.py, events.py, queue_manager.py, and state.py - Added cli/commands
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
AITBC Monitor Service
|
|
"""
|
|
|
|
import time
|
|
import json
|
|
from pathlib import Path
|
|
import psutil
|
|
|
|
from aitbc import get_logger, DATA_DIR
|
|
|
|
def main():
|
|
logger = get_logger('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 = DATA_DIR / '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 = DATA_DIR / '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()
|