擅长:python、mysql、java
<ol>
<li>从存储和查询中断数据的角度定义您最喜欢的数据库模式。(基于间隔。)</li>
<li>从记录Pindom事件的角度定义您最喜欢的存储过程签名(参数)。(基于事件)一定要同时记录成功的ping,这样您就可以区分长时间的中断和短时间的中断。你知道吗</li>
<li>按规定执行程序。你知道吗</li>
<li>每次ping后调用过程。你知道吗</li>
</ol>
<p>过程的主体大致如下(伪代码):</p>
<pre><code> First, select the last interval as o1, and update it if the status is unchanged
UPDATE Interval SET ended = CURRENT_TIMESTAMP
FROM Interval AS o1 LEFT JOIN Interval o2 ON o2.ended > o1.ended
WHERE o2 IS NULL AND o1.status = @currentStatus
If the status changed, insert a new interval with the current status
IF ROW_COUNT() = 0 THEN
INSERT INTO Interval VALUES (...)
END IF
</code></pre>