Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const cidrTools = require("cidr-tools");
- const ping = require("ping");
- const hosts = cidrTools.expand("10.0.1.0/24");
- const alive = [];
- Promise.all(
- hosts.map(host => {
- ping.promise.probe(host).then((res) => {
- if (res.alive) {
- console.log(res.host)
- }
- });
- })
- );
- console.log(alive);
- console.log(`done`);
- // Result
- []
- done
- 10.0.1.196
- 10.0.1.192
- 10.0.1.187
- 10.0.1.153
- 10.0.1.150
- 10.0.1.138
- 10.0.1.25
- 10.0.1.20
- 10.0.1.14
- 10.0.1.13
- 10.0.1.12
- 10.0.1.11
- 10.0.1.10
- 10.0.1.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement