parent
94c71259b5
commit
92b5930414
@ -0,0 +1,87 @@
|
||||
%PDF-1.3
|
||||
%“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com
|
||||
1 0 obj
|
||||
<<
|
||||
/F1 2 0 R
|
||||
>>
|
||||
endobj
|
||||
2 0 obj
|
||||
<<
|
||||
/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font
|
||||
>>
|
||||
endobj
|
||||
3 0 obj
|
||||
<<
|
||||
/Contents 8 0 R /MediaBox [ 0 0 612 792 ] /Parent 7 0 R /Resources <<
|
||||
/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
|
||||
>> /Rotate 0 /Trans <<
|
||||
|
||||
>>
|
||||
/Type /Page
|
||||
>>
|
||||
endobj
|
||||
4 0 obj
|
||||
<<
|
||||
/Contents 9 0 R /MediaBox [ 0 0 612 792 ] /Parent 7 0 R /Resources <<
|
||||
/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
|
||||
>> /Rotate 0 /Trans <<
|
||||
|
||||
>>
|
||||
/Type /Page
|
||||
>>
|
||||
endobj
|
||||
5 0 obj
|
||||
<<
|
||||
/PageMode /UseNone /Pages 7 0 R /Type /Catalog
|
||||
>>
|
||||
endobj
|
||||
6 0 obj
|
||||
<<
|
||||
/Author (anonymous) /CreationDate (D:20241104180641-05'00') /Creator (ReportLab PDF Library - www.reportlab.com) /Keywords () /ModDate (D:20241104180641-05'00') /Producer (ReportLab PDF Library - www.reportlab.com)
|
||||
/Subject (unspecified) /Title (untitled) /Trapped /False
|
||||
>>
|
||||
endobj
|
||||
7 0 obj
|
||||
<<
|
||||
/Count 2 /Kids [ 3 0 R 4 0 R ] /Type /Pages
|
||||
>>
|
||||
endobj
|
||||
8 0 obj
|
||||
<<
|
||||
/Filter [ /ASCII85Decode /FlateDecode ] /Length 2270
|
||||
>>
|
||||
stream
|
||||
GasaqgMYb8&:O"K%$3S2L?sf/fQ#c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WdoR3b*=%-oB`R]"3s6<nq?\\kG6i$,O9"bo$)[U7OLZ6Q<OW,.7(+\I+G4c%KT.J/s+Nm3"B4t6!d:h`d)7,W[$#\M13U.>8(NCcK-1&S?+4WmmfB`+TM[\2UOQk38WeWo$oW2t=GI&_R6";'j4bm$<C737!;rt\_Y:gukU)[GqB+6MmF_~>endstream
|
||||
endobj
|
||||
9 0 obj
|
||||
<<
|
||||
/Filter [ /ASCII85Decode /FlateDecode ] /Length 272
|
||||
>>
|
||||
stream
|
||||
Gap@Hd7T$G%#+0E'Z[g7ZE5nP>!ZTTe`[B_?#$_5Dedb9e$h8nKEMq%Et33B=Ll0a-fDsRrT<#Zi"Omh[=s+NX'aN8rM,Dm4B_Of9:oA7W(QBS9a2\2&J/NRNA;716'+BL0O5h.Ucf\MXI77eJU?W!]DXOK1h`5##+&cF7&?AO3ML.Q:mK+qPHEdO#:btJlO(7WDjc`?`MC$^g[I4mSu!jZZ]JlpcB_ZYiQ;q7Pp.T9Q:P$EObbV\N<ieu52Y/4TA]0es2O%'FGF1%~>endstream
|
||||
endobj
|
||||
xref
|
||||
0 10
|
||||
0000000000 65535 f
|
||||
0000000073 00000 n
|
||||
0000000104 00000 n
|
||||
0000000211 00000 n
|
||||
0000000404 00000 n
|
||||
0000000597 00000 n
|
||||
0000000665 00000 n
|
||||
0000000961 00000 n
|
||||
0000001026 00000 n
|
||||
0000003387 00000 n
|
||||
trailer
|
||||
<<
|
||||
/ID
|
||||
[<9407f775befdeb4ef8b5cf72ca950654><9407f775befdeb4ef8b5cf72ca950654>]
|
||||
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
|
||||
|
||||
/Info 6 0 R
|
||||
/Root 5 0 R
|
||||
/Size 10
|
||||
>>
|
||||
startxref
|
||||
3749
|
||||
%%EOF
|
@ -0,0 +1,92 @@
|
||||
import platform
|
||||
import socket
|
||||
import psutil
|
||||
import uuid
|
||||
from loguru import logger
|
||||
from typing import Dict
|
||||
import requests
|
||||
import time
|
||||
|
||||
def capture_system_data() -> Dict[str, str]:
|
||||
"""
|
||||
Captures extensive system data including platform information, user ID, IP address, CPU count,
|
||||
memory information, and other system details.
|
||||
|
||||
Returns:
|
||||
Dict[str, str]: A dictionary containing system data.
|
||||
"""
|
||||
try:
|
||||
system_data = {
|
||||
"platform": platform.system(),
|
||||
"platform_version": platform.version(),
|
||||
"platform_release": platform.release(),
|
||||
"hostname": socket.gethostname(),
|
||||
"ip_address": socket.gethostbyname(socket.gethostname()),
|
||||
"cpu_count": psutil.cpu_count(logical=True),
|
||||
"memory_total": f"{psutil.virtual_memory().total / (1024 ** 3):.2f} GB",
|
||||
"memory_available": f"{psutil.virtual_memory().available / (1024 ** 3):.2f} GB",
|
||||
"user_id": str(uuid.uuid4()), # Unique user identifier
|
||||
"machine_type": platform.machine(),
|
||||
"processor": platform.processor(),
|
||||
"architecture": platform.architecture()[0],
|
||||
}
|
||||
|
||||
# Get external IP address
|
||||
try:
|
||||
system_data["external_ip"] = requests.get("https://api.ipify.org").text
|
||||
except Exception as e:
|
||||
logger.warning("Failed to retrieve external IP: {}", e)
|
||||
system_data["external_ip"] = "N/A"
|
||||
|
||||
return system_data
|
||||
except Exception as e:
|
||||
logger.error("Failed to capture system data: {}", e)
|
||||
return {}
|
||||
|
||||
|
||||
|
||||
def log_agent_data(data_dict: dict, retry_attempts: int = 1) -> dict | None:
|
||||
"""
|
||||
Logs agent data to the Swarms database with retry logic.
|
||||
|
||||
Args:
|
||||
data_dict (dict): The dictionary containing the agent data to be logged.
|
||||
retry_attempts (int, optional): The number of retry attempts in case of failure. Defaults to 3.
|
||||
|
||||
Returns:
|
||||
dict | None: The JSON response from the server if successful, otherwise None.
|
||||
|
||||
Raises:
|
||||
ValueError: If data_dict is empty or invalid
|
||||
requests.exceptions.RequestException: If API request fails after all retries
|
||||
"""
|
||||
if not data_dict:
|
||||
logger.error("Empty data dictionary provided")
|
||||
raise ValueError("data_dict cannot be empty")
|
||||
|
||||
url = "https://swarms.world/api/get-agents/log-agents"
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer sk-f24a13ed139f757d99cdd9cdcae710fccead92681606a97086d9711f69d44869",
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=data_dict, headers=headers, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
result = response.json()
|
||||
return result
|
||||
|
||||
except requests.exceptions.Timeout:
|
||||
logger.warning("Request timed out")
|
||||
|
||||
except requests.exceptions.HTTPError as e:
|
||||
logger.error(f"HTTP error occurred: {e}")
|
||||
if response.status_code == 401:
|
||||
logger.error("Authentication failed - check API key")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"Error logging agent data: {e}")
|
||||
|
||||
logger.error("Failed to log agent data")
|
||||
return None
|
Loading…
Reference in new issue