• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to understand if host is up or down using API?

    Scheduled Pinned Locked Moved
    General Problems
    api api help host
    4
    14
    1.8k
    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.
    • george1421G
      george1421 Moderator @davide1611
      last edited by

      @davide1611 said in How to understand if host is up or down using API?:

      When I call GET on /fog/host I receive a JSON with a key-value field “ip”:“” but it’s always empty.

      To answer this we will probably need to get an @Developer to respond. One thing you will need to confirm is that the FOG server can resolve the target computer name to DNS name to IP address properly. A simple way to check is to log into the fog server and try to ping a target computer by the name FOG knows the host as without the FQDN name. So if the computer is known as usnyc002 try to ping with this command ping usnyc002 with no domain name. If the system responds with the correct IP address and a ping is returned then the FOG server is setup correctly.

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

      Tom ElliottT 1 Reply Last reply Reply Quote 1
      • S
        Sebastian Roth Moderator
        last edited by

        @davide1611 @george1421 I have this on my list but didn’t get to it yet. Will be soon.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        1 Reply Last reply Reply Quote 1
        • Tom ElliottT
          Tom Elliott @george1421
          last edited by

          @george1421 The IP field was a remnant of before 0.32 days. It has since been done away with, at least from within the GUI. The field is still present, but does not get populated.

          I believe this was used before DNS capabilities were added to the init’s, and the IP field was likely a required field.

          The IP field has no bearing on up or down status.

          In more recent versions, the PING Status field is an indicator. This is a host field and is updated every 5 minutes (by default).

          It uses error codes to obtain status’ though. https://gist.github.com/gabrielfalcao/4216897

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

          george1421G 1 Reply Last reply Reply Quote 1
          • george1421G
            george1421 Moderator @Tom Elliott
            last edited by

            @Tom-Elliott Thank you for the feedback. Do you know if there is a way via the API to see if FOG is reporting if the target system is up or down? I think that is the root of what the OP is looking for. I think a simple yep or nope on a api status call would be good enough (speaking not really knowing the intent of the OP).

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

            Tom ElliottT 1 Reply Last reply Reply Quote 0
            • Tom ElliottT
              Tom Elliott @george1421
              last edited by

              @george1421 The ping status field of the host is updated every 5 minutes.

              If it’s not a 0, it’s unreachable or has some issue one way or the other.

              This field can be retrieved off the host element.

              JSON = hosts[0].pingstatus should work.

              If you’re looking for on the fly up/down status, no, that does not exist. It would be recommended as a part of the api call to do a ping of the host name.

              So:

              API call -> Get hosts and names -> loop through those hosts and ping to determine status on the fly. It’s pretty simple I think.

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

              Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

              Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

              D 1 Reply Last reply Reply Quote 1
              • Tom ElliottT
                Tom Elliott
                last edited by Tom Elliott

                To add on,

                Even if FOG provided an on the fly method, it’s no different than doing it programmatically within the API script being called.

                For example:

                On the fly would, when you try to get the host, you’d have to get the names/ids of the host, then call the api to get the on the fly status.

                So:

                1. API call to get host/hosts you want.
                2. API call to get the status on the fly.

                Using the “let’s ping the host ourselves”:

                1. API call to get the host/hosts you want.
                2. Looping through those hosts returned, ping the host to get the status.

                Either way, you’re doing multiple calls.

                Why 2 requests in either way?

                If you were to get an on the fly status of all hosts at the time the API request is made for every host, you’d be blocking the server until all those hosts status’ returned.

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                1 Reply Last reply Reply Quote 0
                • D
                  davide1611 @Tom Elliott
                  last edited by

                  @Tom-Elliott Thanks for your feedback. Everything very clear.
                  Last thing, I receive from GET: /fog/host the field pingstatus as an HTML tag:

                  "pingstatus": "<i class=\\"icon-ping-fos fa fa-cogs green\\" data-toggle=\\"tooltip\\" data-placement=\\"right\\" title=\\"FOS\\"><\\/i>",
                  

                  Do you know why it is HTML tag rather than an error code? Thanks.

                  Tom ElliottT 1 Reply Last reply Reply Quote 0
                  • Tom ElliottT
                    Tom Elliott @davide1611
                    last edited by

                    @davide1611 To limit how the page needs to present it (attempt to make the api calls more implicit as it is stateless so why not use what we can.

                    For working-1.6 I’ve added pingstatuscode and pingstatustext which will present the physical code and the socket_strerror from php.

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                    Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                    Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                    1 Reply Last reply Reply Quote 0
                    • Tom ElliottT
                      Tom Elliott
                      last edited by

                      Also added this to the latest dev-branch.

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                      1 Reply Last reply Reply Quote 1
                      • D
                        davide1611
                        last edited by

                        Thank you!

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post

                        249

                        Online

                        12.0k

                        Users

                        17.3k

                        Topics

                        155.2k

                        Posts
                        Copyright © 2012-2024 FOG Project