Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
NAS-Server Status // Online or Offline
-
I have a question how i can solve this Problem...
here is a Picture: https://imgur.com/a/ZCPHIoC
I intended to display the server status:
Offline
starting
OnlineThe problem is everything I tried is not what I want and search....
Do you have a solution for this ?Furthermore I would have to get as long as I am in the app the server would not go into hibernation....
do you know how I could do that or if that is even feasible ?
-
E @DavinE I guess that to see this page, you have to open the http url of the server?
If yes, you could use requests to get the entire page text and analyze its content -
No, guessed wrong xD
The page which I have attached as an image is in Pythonista I just want to check in advance whether the server is online because after this page checks are done where you never know exactly what happens because if the server is offline can take up to 1 minute until something happens. -
@DavinE so, sorry, I think I can't help you, not sincerely sure I understand correctly.
-
What NAS are you using?
-
@cvp said:
so, sorry, I think I can't help you, not sincerely sure I understand correctly.
Shall I explain it again in another way ?
-
-
-
-
@DavinE Anyway, perhaps Knowing NAS type could help. And I guess that your ping topic is also linked to this problem. Do you connect a Pythonista script to your NAS and if yes, via which protocol?
-
@cvp said:
@DavinE Anyway, perhaps Knowing NAS type could help.
I'm using a Synology DS 718+
@cvp said:
And I guess that your ping topic is also linked to this problem.
yes, that's correct. I wanted to try to see if the NAS is on or off which unfortunately does not work :(
@cvp said:
Do you connect a Pythonista script to your NAS and if yes, via which protocol?
Yes, of course That's the whole point behind why I use Pythonista.
My "protocol" is an MySQL Serverimport mysql.connector
-
-
-
I found this Script:
import sys import socket def servertest(argv): host = 'xx' port = 'Xxx' args = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM) for family, socktype, proto, canonname, sockaddr in args: s = socket.socket(family, socktype, proto) try: s.connect(sockaddr) except socket.error: return False else: s.close() return True if __name__ == "__main__": if servertest(sys.argv): print("Server is UP") else: print("Server is DOWN")
But since my NAS is never off but only in sleep mode I always get the message: Server is UP can I get around this ?
-
Have you checked out Synology python API?
https://github.com/N4S4/synology-api
I'm not sure if you can check hybernation status, but this might kick start things (say, try to run a file station download).
Also, if I understand your issue is long timeout on MySQL connect -- _mysql.connect() let's you specify a connect_timeout value, which you could set to something short to see if server is responding.
You can also execute ssh commands via paramiko -- I'm not sure if there is a shell command that let's you turn off hibernation. Frankly, on my DSM, it doesn't take that long to come out of hibernation, but I might be using things differently.
-
@JonB said:
Have you checked out Synology python API?
No i don‘t checked Synology-API, but now i did....
Unfortunately, this is not what I'm looking for, since every time I query it, the sleep mode is interrupted.
I'm not sure if you can check hybernation status, but this might kick start things (say, try to run a file station download).
I guess that's true...
I could now go here and after opening the app simply create a loop where every x minutes a query would be created so that the DS would not go into sleep mode for now or ?Also, if I understand your issue is long timeout on MySQL connect -- _mysql.connect() let's you specify a connect_timeout value, which you could set to something short to see if server is responding.
This was a good idea, but unfortunately the DS is first brought out of sleep mode and this takes longer than my set time of 1 second so that it unfortunately does not work.
You can also execute ssh commands via paramiko -- I'm not sure if there is a shell command that let's you turn off hibernation. Frankly, on my DSM, it doesn't take that long to come out of hibernation, but I might be using things differently.
SSH I would have to look first again with my Key's etc....
And yes, as I said with me it takes up to 1 minute until he creates the query when the DS goes out. -
So, are you trying to keep your NAS from sleeping while using the app? Or always? Or just want to prevent an error when it does sleep, by extending the timeout? (You could set a two minute timeout if you want to avoid an error)
-
@JonB said:
So, are you trying to keep your NAS from sleeping while using the app?
Yes, that was exactly my thought.
Or just want to prevent an error when it does sleep, by extending the timeout? (You could set a two minute timeout if you want to avoid an error)
I never got any errors, it's just stupid when you don't do anything for a longer time or some things need a longer time and then it's in sleep mode.
-
Do you happen to know what permissions a user needs to work with Synology-api ?
if I put the user I created for my app in the admin group it works, otherwise not but would not like to share the admin for it.EDIT:
I have adjusted the query.
filestation.FileStation