如何解决在 REACT (JS) 上制作计数器或检查服务器停机时间的方法事件
我正在尝试使用 UpTimeRobot 的 API 来监控 2 个云提供商,Locaweb 和 AWS,所以我使用了一个名为“nocodeapi/status”(https://github.com/nocodeapi/status)的 git,它是一个 React 程序,从这里提取数据 例如 https://v1.nocodeapi.com/hugonh/uptime/XPBjzmgSBPYqMCNj?monitors=785820041-785820037-787326309-787325770 并在 localhost:3000 上转换为图形界面,如图像所示
SMTP Monitor Example of HTTP monitor
如何获得向下标志(红色箭头;类型===1)发生的次数或停机时间最长、持续时间更长?
我第一次使用 React (JS)
const statusComp = type => {
let status = "";
if (type === 1)
status = (
<>
<ArrowDown color="red" size={14} /> Down
</>
);
if (type === 2)
status = (
<>
<ArrowUp color="green" size={14} /> Up
</>
);
if (type === 98)
status = (
<>
<Play color="blue" size={14} /> Started
</>
);
return status;
};
function getLastDown(logs){
const downLogIndex = logs.findIndex(log => log.type === 1)
let message;
if(downLogIndex === -1){
message = "No down time"
}else {
message = `${moment
.unix(logs[downLogIndex].datetime)
.format("YYYY-MM-DD,h:mm:ss")} (${secondsToHms(logs[downLogIndex].duration)})`
}
return message
}
//else 在它下降时发生,并在正确的彩色图表上显示时间和持续时间。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。