omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    3
    19
    2504
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DavinE
      DavinE last edited by

      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
      Online

      The 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 ?

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @DavinE last edited by

        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

        1 Reply Last reply Reply Quote 0
        • DavinE
          DavinE last edited by

          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.

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @DavinE last edited by

            @DavinE so, sorry, I think I can't help you, not sincerely sure I understand correctly.

            DavinE 1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              What NAS are you using?

              DavinE 1 Reply Last reply Reply Quote 0
              • DavinE
                DavinE @cvp last edited by

                @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 ?

                cvp 1 Reply Last reply Reply Quote 0
                • DavinE
                  DavinE @JonB last edited by

                  @JonB said:

                  What NAS are you using?

                  I'm using a Synology DS 718+

                  DavinE 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @DavinE last edited by

                    @DavinE said

                    Shall I explain it again in another way ?

                    Not needed if @JonB helps you, who could do it better?

                    DavinE 1 Reply Last reply Reply Quote 0
                    • DavinE
                      DavinE @cvp last edited by

                      @cvp said:

                      @DavinE said

                      Shall I explain it again in another way ?

                      Not needed if @JonB helps you, who could do it better?

                      The one who understands it better ^^

                      cvp 1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @DavinE last edited by

                        @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?

                        1 Reply Last reply Reply Quote 0
                        • DavinE
                          DavinE @DavinE last edited by

                          @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 Server import mysql.connector

                          cvp 1 Reply Last reply Reply Quote 0
                          • cvp
                            cvp @DavinE last edited by

                            @DavinE oups, no expérience with this "connector". Hoping that your detailed answers will help @jonb to help you...

                            DavinE 1 Reply Last reply Reply Quote 0
                            • DavinE
                              DavinE @cvp last edited by

                              @cvp said:

                              @DavinE oups, no expérience with this "connector". Hoping that your detailed answers will help @jonb to help you...

                              I Hope so too @JonB

                              1 Reply Last reply Reply Quote 0
                              • DavinE
                                DavinE last edited by

                                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 ?

                                1 Reply Last reply Reply Quote 0
                                • JonB
                                  JonB last edited by

                                  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.

                                  DavinE 1 Reply Last reply Reply Quote 0
                                  • DavinE
                                    DavinE @JonB last edited by

                                    @JonB said:

                                    Have you checked out Synology python API?

                                    https://github.com/N4S4/synology-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.

                                    1 Reply Last reply Reply Quote 0
                                    • JonB
                                      JonB last edited by

                                      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)

                                      DavinE 2 Replies Last reply Reply Quote 0
                                      • DavinE
                                        DavinE @JonB last edited by

                                        @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.

                                        1 Reply Last reply Reply Quote 0
                                        • DavinE
                                          DavinE @JonB last edited by DavinE

                                          @JonB

                                          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

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post
                                          Powered by NodeBB Forums | Contributors