| 238 | } |
| 239 | |
| 240 | static string GetSystemInfo() { |
| 241 | struct sysinfo info; |
| 242 | sysinfo(&info); |
| 243 | |
| 244 | struct statvfs fsinfo; |
| 245 | statvfs("/", &fsinfo); |
| 246 | |
| 247 | struct utsname utsName; |
| 248 | uname(&utsName); |
| 249 | |
| 250 | struct NodeInfo nodeinfo; |
| 251 | getnodeinfo(&nodeinfo); |
| 252 | |
| 253 | string vcpus = std::to_string(std::thread::hardware_concurrency()); |
| 254 | string memory = std::to_string(info.totalram * info.mem_unit / 1024 / 1024); // Unit: MB |
| 255 | string totalHDD = std::to_string(fsinfo.f_frsize * fsinfo.f_blocks / 1024 / 1024); // Unit: MB |
| 256 | string freeHDD = std::to_string(fsinfo.f_bsize * fsinfo.f_bfree / 1024 / 1024); // Unit: MB |
| 257 | string osType = string(utsName.sysname); |
| 258 | string osVer = string(utsName.release); |
| 259 | string nv = nodeinfo.nv; |
| 260 | string nfp = nodeinfo.nfp; |
| 261 | string synh = std::to_string(nodeinfo.synh); |
| 262 | string tiph = std::to_string(nodeinfo.tiph); |
| 263 | string finh = std::to_string(nodeinfo.finh); |
| 264 | |
| 265 | string json; |
| 266 | |
| 267 | json += "{"; |
| 268 | json += "\"vcpus\":" + vcpus + ","; |
| 269 | json += "\"mem\":" + memory + ","; |
| 270 | json += "\"diskt\":" + totalHDD + ","; |
| 271 | json += "\"diskf\":" + freeHDD + ","; |
| 272 | json += "\"ost\":\"" + osType + "\","; |
| 273 | json += "\"osv\":\"" + osVer + "\","; |
| 274 | json += "\"nv\":\"" + nv + "\","; |
| 275 | json += "\"nfp\":\"" + nfp + "\","; |
| 276 | json += "\"synh\":" + synh + ","; |
| 277 | json += "\"tiph\":" + tiph + ","; |
| 278 | json += "\"finh\":" + finh ; //finalized height |
| 279 | json += "}"; |
| 280 | |
| 281 | return json; |
| 282 | } |
| 283 | |
| 284 | bool GetMyPublicIP(CNetAddr& ipRet) { |
| 285 | ipHost = SysCfg().GetArg("-ipserver", ""); |
no test coverage detected