How Do I Ping a Host?

This tutorial will show you how to ping a server.

Please note: you can associate the Bithead template node com.bithead.template.ping to avoid writing this code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import ays
import time

from ays.api import ping

@ays.param(str, "host")
@ays.returns("ms")
async def main(session, host):
    ms = await ping(host)
    return ms

You will notice this sensor imports ping from the ays.api module. Please refer to the @ys API Reference for more functions.