Advertisement
SuPeRMiNoR3

Pinger

Dec 8th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. network = require("network")
  2. event = require("event")
  3. computer = require("computer")
  4. send_payload = "mothertrucking"
  5.  
  6. toping = {"EnderRemote", "EnderOne", "EnderTwo", "EnderThree", "SuperServer", "SuperTablet", "FileServer"}
  7. pingids = {}
  8.  
  9. function process_ping(e, addr, id, payload)
  10. name = pingids[id].host
  11. time = pingids[id].time
  12. time = computer.uptime()-time
  13. print(name.." ["..addr.."]".. "  "..time)
  14. if payload ~= send_payload then print("Warning, Payload bad: "..payload) end
  15. end
  16.  
  17. event.listen("ping_reply", process_ping)
  18.  
  19. for index,host in pairs(toping) do
  20. pid = network.icmp.ping(host, send_payload)
  21. pingids[pid] = {host=host, time=computer.uptime()}
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement