$ cat idea.txt
I want a command-line tool that pings my servers. It needs to read a list of
IPs from a JSON file. If a server is down, it should write an error to a log
file. Use my local mesh for the JSON reader and file logger, but use DeepSeek
to write the asynchronous ping concurrency logic so it's super fast.
$ cat > build/server_list.json
[
"8.8.8.8",
"1.1.1.1",
"127.0.0.1",
"this.is.a.fake.server.that.will.fail"
]
$ cat > test.js
/ test.js
const { executePingBatch } = require('./build/PING_EXECUTOR');
executePingBatch(['8.8.8.8', '1.1.1.1', 'bad-ip-test']).then(console.log);
$ node test.js
[
{
ip: '8.8.8.8',
alive: true,
output: 'PING 8.8.8.8 (8.8.8.8): 56 data bytes
' +
'64 bytes from 8.8.8.8: seq=0 ttl=42 time=29.933 ms
' +
'
' +
'--- 8.8.8.8 ping statistics ---
' +
'1 packets transmitted, 1 packets received, 0% packet loss
' +
'round-trip min/avg/max = 29.933/29.933/29.933 ms
'
},
{
ip: '1.1.1.1',
alive: true,
output: 'PING 1.1.1.1 (1.1.1.1): 56 data bytes
' +
'64 bytes from 1.1.1.1: seq=0 ttl=42 time=19.384 ms
' +
'
' +
'--- 1.1.1.1 ping statistics ---
' +
'1 packets transmitted, 1 packets received, 0% packet loss
' +
'round-trip min/avg/max = 19.384/19.384/19.384 ms
'
},
{
ip: 'bad-ip-test',
alive: false,
error: 'Command failed: ping -c 1 -W 1 bad-ip-test
' +
"ping: bad address 'bad-ip-test'
"
}
]
$