sopyanx

dhcp lease to netwatch

Sep 17th, 2019
1,419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. :if ($leaseBound = "1") do={/tool netwatch add down-script=":local BotID \"980842675:AAFLvPe4GuY25HeSRcxARu_BbSCx5OTf7Z4\
  2. \";\r\
  3. \n:local CHID \"550242591\";\r\
  4. \n:local avgRtt;\r\
  5. \n:local pin\r\
  6. \n:local pout\r\
  7. \n:local datetime \"\$[/system clock get date] \$[/system clock get time]\
  8. \"\r\
  9. \n:local hostname [[/ip dhcp-server lease get [find address=\$host] host-n\
  10. ame]]\r\
  11. \n:local mac [[/ip dhcp-server lease get [find address=\$host] mac-address\
  12. ]]\r\
  13. \n:local server [[/ip dhcp-server lease get [find address=\$host] active-s\
  14. erver]]\r\
  15. \n#Ping it real good\r\
  16. \n/tool flood-ping \$host count=10 do={\r\
  17. \n:if (\$sent = 10) do={\r\
  18. \n:set avgRtt \$\"avg-rtt\"\r\
  19. \n:set pout \$sent\r\
  20. \n:set pin \$received\r\
  21. \n}\r\
  22. \n}\r\
  23. \n:local ploss (100 - ((\$pin * 100) / \$pout))\r\
  24. \n:local logmsg (\"Ping Average for \$host - \".[:tostr \$avgRtt].\"ms - p\
  25. acket loss: \".[:tostr \$ploss].\"%\")\r\
  26. \n:log info \$logmsg\r\
  27. \n:local text \"Router Id:* \$[/system identity get name] * %0A\\\r\
  28. \nTanggal : _\$datetime_%0A\\\r\
  29. \nPing : _\$host_%0A\\\r\
  30. \nHost Name : _\$hostname_%0A\\\r\\
  31. \nMAC : _\$mac_%0A\\\r\\
  32. \nServer : _\$server_%0A\\\r\\
  33. \nLog : _\$logmsg_\"\r\
  34. \n/tool fetch url=\"https://api.telegram.org/bot\$BotID/sendmessage\?chat_\
  35. id=\$CHID&text=\$text\" keep-result=no;\r\
  36. \n" host=$leaseActIP up-script=":local BotID \"980842675:AAFLvPe4GuY25He\
  37. SRcxARu_BbSCx5OTf7Z4\";\r\
  38. \n:local CHID \"550242591\";\r\
  39. \n:local avgRtt;\r\
  40. \n:local pin\r\
  41. \n:local pout\r\
  42. \n:local datetime \"\$[/system clock get date] \$[/system clock get time]\
  43. \"\r\
  44. \n:local hostname [[/ip dhcp-server lease get [find address=\$host] host-n\
  45. ame]]\r\
  46. \n:local mac [[/ip dhcp-server lease get [find address=\$host] mac-address\
  47. ]]\r\
  48. \n:local server [[/ip dhcp-server lease get [find address=\$host] server]]\
  49. \r\
  50. \n#Ping it real good\r\
  51. \n/tool flood-ping \$host count=10 do={\r\
  52. \n:if (\$sent = 10) do={\r\
  53. \n:set avgRtt \$\"avg-rtt\"\r\
  54. \n:set pout \$sent\r\
  55. \n:set pin \$received\r\
  56. \n}\r\
  57. \n}\r\
  58. \n:local ploss (100 - ((\$pin * 100) / \$pout))\r\
  59. \n:local logmsg (\"Ping Average for \$host - \".[:tostr \$avgRtt].\"ms - p\
  60. acket loss: \".[:tostr \$ploss].\"%\")\r\
  61. \n:log info \$logmsg\r\
  62. \n:local text \"Router Id:* \$[/system identity get name] * %0A\\\r\
  63. \nTanggal : _\$datetime_%0A\\\r\
  64. \nPing : _\$host_%0A\\\r\
  65. \nHost Name : _\$hostname_%0A\\\r\\
  66. \nMAC : _\$mac_%0A\\\r\\
  67. \nServer : _\$server_%0A\\\r\\
  68. \nLog : _\$logmsg_\"\r\
  69. \n/tool fetch url=\"https://api.telegram.org/bot\$BotID/sendmessage\?chat_\
  70. id=\$CHID&text=\$text\" keep-result=no;\r\
  71. \n"
  72. } else={
  73. /tool netwatch remove [find host=$leaseActIP]
  74. }
Add Comment
Please, Sign In to add comment