我需要得到“http://localhost:8529/_admin/cluster/health“的网址,可以检查作为javascript的arangodb集群的状态。
它由如下js文件组成。
// 20200611141601
// http://203.255.92.193:8529/_admin/cluster/health
{
"Health": {
"PRMR-3f6a6958-cef1-4326-a7c6-fb20cd921726": {
"Timestamp": "2020-06-09T04:32:09Z",
"SyncStatus": "SERVING",
"Status": "GOOD",
"Host": "39f18558358b46eca3504bd0b4ebed26",
"Version": "3.6.3-1",
"SyncTime": "2020-06-09T04:32:08Z",
"Endpoint": "tcp://203.255.92.194:8530",
"LastAckedTime": "2020-06-09T04:32:08Z",
"Engine": "rocksdb",
"ShortName": "DBServer0001",
"Role": "DBServer",
"CanBeDeleted": false
},
"CRDN-4063e580-4ae0-4b89-ba5a-5b4c5616cb20": {
"Timestamp": "2020-06-09T12:03:09Z",
"SyncStatus": "SERVING",
"Status": "GOOD",
"Host": "c424ee3654814288904d1f31c257e038",
"ShortName": "Coordinator0019",
"Engine": "rocksdb",
"Version": "3.6.3-1",
"SyncTime": "2020-06-09T12:03:08Z",
"LastAckedTime": "2020-06-09T12:03:09Z",
"Endpoint": "tcp://203.255.92.193:8529",
"Role": "Coordinator",
"CanBeDeleted": false
我试过了,但没有定义。
const url = require('url');
const address = 'http://localhost:8529/_admin/cluster/health';
const parsedData= url.parse(address, true);
console.log(parsedData.Health);
console.log(parsedData.Status);
console.log(parsedData.search);
const queryData = parsedData.query;
console.log(queryData.Health);
我不知道怎么做。有没有一个库函数可以用javascript得到“http://localhost:8529/_admin/cluster/health
1条答案
按热度按时间5t7ly7z51#
url.parse()
仅解析您传递给它的URL字符串:您需要向服务器发出实际请求,例如:
该示例假定协调器节点在端口8529上本地运行,并且群集的身份验证已禁用。