Comments (1)
server.ram
(and server._info['ram']
) returns data from the _info dictionary which is requested just one time - when AternosServer object is created.
You can update it manually calling server.fetch()
, but if you send this request in a loop for auto-updates, Aternos might suspend your account, so you should use websocket streams.
When your Minecraft server is online, there is a used RAM indicator on the server panel page (aternos.org/panel) that is updated in real-time by a script which receives data from a websocket server at aternos.org/hermes. But we have to subscript to the "used RAM (heap)" stream, more about streams.
Here's how to do it in python-aternos:
import asyncio
from python_aternos import Client, atwss
at = Client.from_credentials('username', 'password')
srv = at.list_servers()[0]
socket = srv.wss() # AternosWss object
# handler for used RAM stream
@socket.wssreceiver(atwss.Streams.ram)
async def ram(used):
# used is int
print('Current RAM usage:', used, 'bytes')
# starting minecraft server
srv.start()
# connecting to websocket
# this function also sends streams subscriptions
asyncio.run(socket.connect())
That's all. Run the script and you'll get output like: Current RAM usage: 879372712 bytes
from python-aternos.
Related Issues (20)
- Unable to bypass Cloudflare protection
- Unable to parse lastStatus object
- Download an aternos Drive backup HOT 1
- Documentation HOT 2
- Getting server domain/address/subdomain doesn't work HOT 4
- Login with username and password doesn't work HOT 5
- Aternos detects using this HOT 5
- A way to possibly Change user permissions?
- Check username and password HOT 3
- Check your username and password
- 503 Service unavaliable HOT 2
- 400 error at /players HOT 6
- Unable to parse lastStatus object HOT 5
- How to get dymanic ip? HOT 2
- Unable to start server. HOT 2
- :( HOT 1
- bruh im banned from aternos after 1 day -_- HOT 1
- ServerStartError fails to import HOT 1
- Error in Client() HOT 3
- Aternos responding `This username doesn't exist` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-aternos.