
zabbix 监控可能会用到的key
如果进程在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上
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 程序员小航
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果