23 lines
639 B
Python
23 lines
639 B
Python
|
|
import asyncio
|
||
|
|
import asyncssh
|
||
|
|
|
||
|
|
async def main():
|
||
|
|
async with asyncssh.connect(
|
||
|
|
"132.243.17.164", port=2292, username="dimon",
|
||
|
|
password="123456789987654321", known_hosts=None,
|
||
|
|
) as conn:
|
||
|
|
# CPU: два замера /proc/stat с паузой 1 сек
|
||
|
|
r = await conn.run("grep '^cpu ' /proc/stat; sleep 1; grep '^cpu ' /proc/stat")
|
||
|
|
print("CPU lines:")
|
||
|
|
print(r.stdout)
|
||
|
|
# RAM
|
||
|
|
r = await conn.run("free -m")
|
||
|
|
print("FREE:")
|
||
|
|
print(r.stdout)
|
||
|
|
# DISK
|
||
|
|
r = await conn.run("df -m /")
|
||
|
|
print("DF:")
|
||
|
|
print(r.stdout)
|
||
|
|
|
||
|
|
asyncio.run(main())
|