#!/opt/lnxall_app/bin/lua local invoker = require "invoker" local module = {} local MIN_VALID_TIME = 1770087731 function module.checkplat() local osr = invoker.readfile("/etc/os-release") if not osr then return false end return string.find(osr, "debian", 1, true) ~= nil or string.find(osr, "Debian", 1, true) ~= nil end function module.category() return "系统资源" end function module.description() return "检查时间同步" end function module.detailed() return "检查系统时间是否明显异常, 并确认 timesyncd 或 ntpd 时间同步服务是否正在运行." end function module.suggestion() return nil end function module.step() local now = os.time() if now < MIN_VALID_TIME then return { type = "incorrect UTC", now = os.date(nil, now), }, true end local timesyncd = invoker.invoke(invoker.NOSTDIO, "pidof", "timesyncd") local ntpd = invoker.invoke(invoker.NOSTDIO, "pidof", "ntpd") if timesyncd ~= 0 and ntpd ~= 0 then return { type = "NTP service NOT found", now = os.date(nil, now), }, true end return { type = "NTP service found", now = os.date(nil, now), }, false end return module