Hi
I have created a Trigger in Zabbix that is supposed to be fired if a host's CPU Usage is more than 90% for 5 continuous minutes.
Here is the Trigger Expression:
avg(/Chat1/system.run[powershell -ExecutionPolicy Bypass -File \\192.168.4.211\PS_Scripts\CPU_Usage.ps1],5m)>90
And here is the CPU_Usage.ps1 script:
try {
# Attempt to fetch the total CPU usage percentage
$cpuUsage = Get-WmiObject -Query "SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name='_Total'" |
Select-Object -ExpandProperty PercentProcessorTime
# Check if the CPU usage was successfully retrieved
if ($cpuUsage -ne $null) {
# Output the CPU usage percentage with formatting for readability
Write-Output $cpuUsage
}
else {
Write-Output "Failed to retrieve CPU usage information."
}
} catch {
# Handle errors gracefully
Write-Output "An error occurred while trying to retrieve CPU usage information: $_"
}
I created a python script that could spike the CPU Usage to 100% (Verified in Task Manager's 'Performance' Tab as well).
But though this python script spikes the CPU Usage to 100% for more than 5 minutes, The trigger is not being fired.
I need help!
I have created a Trigger in Zabbix that is supposed to be fired if a host's CPU Usage is more than 90% for 5 continuous minutes.
Here is the Trigger Expression:
avg(/Chat1/system.run[powershell -ExecutionPolicy Bypass -File \\192.168.4.211\PS_Scripts\CPU_Usage.ps1],5m)>90
And here is the CPU_Usage.ps1 script:
try {
# Attempt to fetch the total CPU usage percentage
$cpuUsage = Get-WmiObject -Query "SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name='_Total'" |
Select-Object -ExpandProperty PercentProcessorTime
# Check if the CPU usage was successfully retrieved
if ($cpuUsage -ne $null) {
# Output the CPU usage percentage with formatting for readability
Write-Output $cpuUsage
}
else {
Write-Output "Failed to retrieve CPU usage information."
}
} catch {
# Handle errors gracefully
Write-Output "An error occurred while trying to retrieve CPU usage information: $_"
}
I created a python script that could spike the CPU Usage to 100% (Verified in Task Manager's 'Performance' Tab as well).
But though this python script spikes the CPU Usage to 100% for more than 5 minutes, The trigger is not being fired.
I need help!
Comment