如果进程在windows上

内置key

proc.num[<name>,<user>,<state>,<cmdline><zone>]

监控进程数量

system.uptime

系统运行时间()

proc_info[process,<attribute>,<type>]

特定进程的各种信息 Windows 特定项键

perf_counter[counter,<interval>]

对于windows上的进程,任然推荐使用性能监视器perf_counter

Windows performance counters (zabbix.com)

perf_counter[\Process(wps)\Elapsed Time]
扩展key

User parameters,添加powershell脚本

powershell脚本需要

UserParameter=wps.runtime,powershell -ExecutionPolicy Bypass -File "D:\test\zabbix\script1.ps1"

# 获取WPS进程
$wpsProcess = Get-Process -Name "wps" -ErrorAction SilentlyContinue

if ($wpsProcess) {
    # 获取进程的启动时间
    $startTime = $wpsProcess.StartTime
    # 获取当前时间
    $currentTime = Get-Date
    # 计算存活时间
    $uptime = $currentTime - $startTime

    # 输出存活时间
    Write-Output "$($uptime.Days) days $($uptime.Hours) hours $($uptime.Minutes) minutes $($uptime.Seconds) seconds"
} else {
    Write-Output "0 days 0 hours 0 minutes 0 seconds"
}

如果进程在linux上