├── Example.png ├── zabbix3.0_addconf.txt ├── Zabbix v3.4 ├── Readme.md ├── DiscoverScheduledTasks.ps1 └── zbx3.4_export_templates.xml ├── README.md ├── DiscoverScheduledTasks.ps1 └── zbx_export_templates.xml /Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/romainsi/zabbix-scheduledtask/HEAD/Example.png -------------------------------------------------------------------------------- /zabbix3.0_addconf.txt: -------------------------------------------------------------------------------- 1 | ####### USER-DEFINED MONITORED PARAMETERS ####### 2 | 3 | ### Option: UnsafeUserParameters 4 | # Allow all characters to be passed in arguments to user-defined parameters. 5 | # The following characters are not allowed: 6 | # \ ' " ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @ 7 | # Additionally, newline characters are not allowed. 8 | # 0 - do not allow 9 | # 1 - allow 10 | # 11 | # Mandatory: no 12 | # Range: 0-1 13 | # Default: 14 | # UnsafeUserParameters=0 15 | UnsafeUserParameters=1 16 | 17 | ### Option: UserParameter 18 | # User-defined parameter to monitor. There can be several user-defined parameters. 19 | # Format: UserParameter=, 20 | # 21 | # Mandatory: no 22 | # Default: 23 | # UserParameter= 24 | UserParameter=TaskSchedulerMonitoring[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\DiscoverScheduledTasks.ps1" "$1" "$2" 25 | -------------------------------------------------------------------------------- /Zabbix v3.4/Readme.md: -------------------------------------------------------------------------------- 1 | ================DiscoverScheduledTasks ================ 2 | 3 | This template use PowerShell Cmdlets to discover and manage Windows Tasks Scheduled. 4 | 5 | Default French translation. 6 | 7 | Items : Task Last Result (Status for each tasks), Task Last Run Time, Task Next Run time 8 | 9 | Discovery : All tasks Active or Running 10 | 11 | Triggers : [HIGH] => Last Result of tasks FAILED
12 | Triggers : [HIGH] => State of tasks Disabled 13 | 14 | Install : 15 | 16 | Import template, 17 | 18 | Install the Zabbix agent on your host, 19 | 20 | Copy DiscoverScheduledTasks.ps1 in your zabbix agent directory, 21 | 22 | In powershell script change $path variable for subsfolders, 23 | 24 | Add the following line to your Zabbix agent configuration file : 25 | 26 | EnableRemoteCommands=1 27 | 28 | UnsafeUserParameters=1 29 | 30 | UserParameter=TaskSchedulerMonitoring[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\DiscoverScheduledTasks.ps1" "$1" "$2" 31 | 32 | Value mapping 'scheduledtask' is in french for error ID of tasks. 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ================DiscoverScheduledTasks ================ 2 | 3 | 4 | This template use PowerShell Cmdlets to discover and manage Windows Tasks Scheduled. 5 | 6 | Default French translation. 7 | 8 | Items : Task Last Result (Status for each tasks), Task Last Run Time, Task Next Run time 9 | 10 | Discovery : All tasks Active or Running 11 | 12 | Triggers : [HIGH] => Last Result of tasks FAILED 13 | 14 | 15 | 16 | Install : 17 | 18 | - Import template, 19 | 20 | - Install the Zabbix agent on your host, 21 | 22 | - Copy DiscoverScheduledTasks.ps1 in your zabbix agent directory, 23 | 24 | - In powershell script change $path variable for subsfolders, 25 | 26 | - Add the following line to your Zabbix agent configuration file : 27 | 28 | EnableRemoteCommands=1 29 | 30 | UnsafeUserParameters=1 31 | 32 | UserParameter=TaskSchedulerMonitoring[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\DiscoverScheduledTasks.ps1" "$1" "$2" 33 | 34 | Value mapping 'scheduledtask' is in french for error ID of tasks. 35 | 36 | Timeout=(3-30) Ajust with your server performance (and don't forget in server.conf on zabbix server : timeout specifies how long we wait for agent, SNMP device or external check (in seconds) so ajust too) 37 | 38 | -------------------------------------------------------------------------------- /DiscoverScheduledTasks.ps1: -------------------------------------------------------------------------------- 1 | # Script: DiscoverSchelduledTasks 2 | # Author: Romain Si 3 | # 4 | # This script is intended for use with Zabbix > 3.x 5 | # 6 | # 7 | # Add to Zabbix Agent 8 | # UserParameter=TaskSchedulerMonitoring[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\DiscoverScheduledTasks.ps1" "$1" "$2" 9 | # 10 | ## Modifier la variable $path pour indiquer les sous dossiers de Tâches Planifiées à traiter sous la forme "\nomDossier\","\nomdossier2\sousdossier\" voir (Get-ScheduledTask -TaskPath ) 11 | ## Change the $path variable to indicate the Scheduled Tasks subfolder to be processed as "\nameFolder\","\nameFolder2\subfolder\" see (Get-ScheduledTask -TaskPath ) 12 | ## Pour la découverte des tâches à la racine utiliser "\" 13 | ## For discovery task to the root folder use "\" 14 | 15 | 16 | $path = "\examplefolder\" 17 | 18 | 19 | Function Convert-ToUnixDate ($PSdate) { 20 | $epoch = [timezone]::CurrentTimeZone.ToLocalTime([datetime]'1/1/1970') 21 | (New-TimeSpan -Start $epoch -End $PSdate).TotalSeconds 22 | } 23 | 24 | $ITEM = [string]$args[0] 25 | $ID = [string]$args[1] 26 | 27 | switch ($ITEM) { 28 | "DiscoverTasks" { 29 | $apptasks = Get-ScheduledTask -TaskPath $path | where {$_.state -like "Ready" -or "Running"} 30 | $apptasksok1 = $apptasks.TaskName 31 | $apptasksok = $apptasksok1.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 32 | $idx = 1 33 | write-host "{" 34 | write-host " `"data`":[`n" 35 | foreach ($currentapptasks in $apptasksok) 36 | { 37 | if ($idx -lt $apptasksok.count) 38 | { 39 | 40 | $line= "{ `"{#APPTASKS}`" : `"" + $currentapptasks + "`" }," 41 | write-host $line 42 | } 43 | elseif ($idx -ge $apptasksok.count) 44 | { 45 | $line= "{ `"{#APPTASKS}`" : `"" + $currentapptasks + "`" }" 46 | write-host $line 47 | } 48 | $idx++; 49 | } 50 | write-host 51 | write-host " ]" 52 | write-host "}"}} 53 | 54 | 55 | switch ($ITEM) { 56 | "TaskLastResult" { 57 | [string] $name = $ID 58 | $name1 = $name.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 59 | $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1" 60 | $pathtask1 = $pathtask.Taskpath 61 | $taskResult = Get-ScheduledTaskInfo -TaskPath "$pathtask1" -TaskName "$name1" 62 | Write-Output ($taskResult.LastTaskResult) 63 | }} 64 | 65 | switch ($ITEM) { 66 | "TaskLastRunTime" { 67 | [string] $name = $ID 68 | $name1 = $name.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 69 | $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1" 70 | $pathtask1 = $pathtask.Taskpath 71 | $taskResult = Get-ScheduledTaskInfo -TaskPath "$pathtask1" -TaskName "$name1" 72 | $taskResult1 = $taskResult.LastRunTime 73 | $date = get-date -date "01/01/1970" 74 | $taskResult2 = (New-TimeSpan -Start $date -end $taskresult1).TotalSeconds 75 | Write-Output ($taskResult2) 76 | }} 77 | 78 | switch ($ITEM) { 79 | "TaskNextRunTime" { 80 | [string] $name = $ID 81 | $name1 = $name.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 82 | $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1" 83 | $pathtask1 = $pathtask.Taskpath 84 | $taskResult = Get-ScheduledTaskInfo -TaskPath "$pathtask1" -TaskName "$name1" 85 | $taskResult1 = $taskResult.NextRunTime 86 | $date = get-date -date "01/01/1970" 87 | $taskResult2 = (New-TimeSpan -Start $date -end $taskresult1).TotalSeconds 88 | Write-Output ($taskResult2) 89 | }} 90 | -------------------------------------------------------------------------------- /Zabbix v3.4/DiscoverScheduledTasks.ps1: -------------------------------------------------------------------------------- 1 | # Script: DiscoverSchelduledTasks 2 | # Author: Romain Si 3 | # 4 | # This script is intended for use with Zabbix > 3.x 5 | # 6 | # 7 | # Add to Zabbix Agent 8 | # UserParameter=TaskSchedulerMonitoring[*],powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\DiscoverScheduledTasks.ps1" "$1" "$2" 9 | # 10 | ## Modifier la variable $path pour indiquer les sous dossiers de Tâches Planifiées à traiter sous la forme "\nomDossier\" ou "\nomdossier2\sousdossier\" voir (Get-ScheduledTask -TaskPath ) 11 | ## Change the $path variable to indicate the Scheduled Tasks subfolder to be processed as "\nameFolder\" or "\nameFolder2\subfolder\" see (Get-ScheduledTask -TaskPath ) 12 | 13 | 14 | $path = "\example\" 15 | 16 | 17 | Function Convert-ToUnixDate ($PSdate) { 18 | $epoch = [timezone]::CurrentTimeZone.ToLocalTime([datetime]'1/1/1970') 19 | (New-TimeSpan -Start $epoch -End $PSdate).TotalSeconds 20 | } 21 | 22 | $ITEM = [string]$args[0] 23 | $ID = [string]$args[1] 24 | 25 | switch ($ITEM) { 26 | "DiscoverTasks" { 27 | $apptasks = Get-ScheduledTask -TaskPath $path | where {$_.state -like "Ready" -or "Running"} 28 | $apptasksok1 = $apptasks.TaskName 29 | $apptasksok = $apptasksok1.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 30 | $idx = 1 31 | write-host "{" 32 | write-host " `"data`":[`n" 33 | foreach ($currentapptasks in $apptasksok) 34 | { 35 | if ($idx -lt $apptasksok.count) 36 | { 37 | 38 | $line= "{ `"{#APPTASKS}`" : `"" + $currentapptasks + "`" }," 39 | write-host $line 40 | } 41 | elseif ($idx -ge $apptasksok.count) 42 | { 43 | $line= "{ `"{#APPTASKS}`" : `"" + $currentapptasks + "`" }" 44 | write-host $line 45 | } 46 | $idx++; 47 | } 48 | write-host 49 | write-host " ]" 50 | write-host "}"}} 51 | 52 | 53 | switch ($ITEM) { 54 | "TaskLastResult" { 55 | [string] $name = $ID 56 | $name1 = $name.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 57 | $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1" 58 | $pathtask1 = $pathtask.Taskpath 59 | $taskResult = Get-ScheduledTaskInfo -TaskPath "$pathtask1" -TaskName "$name1" 60 | Write-Output ($taskResult.LastTaskResult) 61 | }} 62 | 63 | switch ($ITEM) { 64 | "TaskLastRunTime" { 65 | [string] $name = $ID 66 | $name1 = $name.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 67 | $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1" 68 | $pathtask1 = $pathtask.Taskpath 69 | $taskResult = Get-ScheduledTaskInfo -TaskPath "$pathtask1" -TaskName "$name1" 70 | $taskResult1 = $taskResult.LastRunTime 71 | $date = get-date -date "01/01/1970" 72 | $taskResult2 = (New-TimeSpan -Start $date -end $taskresult1).TotalSeconds 73 | Write-Output ($taskResult2) 74 | }} 75 | 76 | switch ($ITEM) { 77 | "TaskNextRunTime" { 78 | [string] $name = $ID 79 | $name1 = $name.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 80 | $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1" 81 | $pathtask1 = $pathtask.Taskpath 82 | $taskResult = Get-ScheduledTaskInfo -TaskPath "$pathtask1" -TaskName "$name1" 83 | $taskResult1 = $taskResult.NextRunTime 84 | $date = get-date -date "01/01/1970" 85 | $taskResult2 = (New-TimeSpan -Start $date -end $taskresult1).TotalSeconds 86 | Write-Output ($taskResult2) 87 | }} 88 | 89 | switch ($ITEM) { 90 | "TaskState" { 91 | [string] $name = $ID 92 | $name1 = $name.replace('â','â').replace('à','à').replace('ç','ç').replace('é','é').replace('è','è').replace('ê','ê') 93 | $pathtask = Get-ScheduledTask -TaskPath "*" -TaskName "$name1" 94 | $pathtask1 = $pathtask.State 95 | Write-Output ($pathtask1) 96 | }} 97 | -------------------------------------------------------------------------------- /zbx_export_templates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.0 4 | 2017-10-26T15:02:29Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 216 | 217 | 218 | 219 | scheduledtask 220 | 221 | 222 | 0 223 | Succès 224 | 225 | 226 | 267008 227 | La tâche est prête à fonctionner à l'heure prévue suivante 228 | 229 | 230 | 267009 231 | La tâche est en cours d'exécution 232 | 233 | 234 | 267011 235 | La tâche n'est pas encore terminée 236 | 237 | 238 | 267012 239 | Il n'y a plus d'opérations programmées pour cette tâche 240 | 241 | 242 | 267014 243 | La tâche est terminée 244 | 245 | 246 | 2147943645 247 | Le service n'est pas disponible 248 | 249 | 250 | 2147750671 251 | Identifiants corrompus 252 | 253 | 254 | 2147750687 255 | Une instance de cette tâche est déjà en cours d'exécution 256 | 257 | 258 | 2147942667 259 | Le répertoire «démarrer dans» ne peut être trouvé 260 | 261 | 262 | 2147942402 263 | Un des fichiers n'est pas disponible 264 | 265 | 266 | 3228369022 267 | Exception logicielle inconnue 268 | 269 | 270 | 1 271 | Fonction incorrecte ou inconnue appelée 272 | 273 | 274 | 2 275 | Fichier non trouvé 276 | 277 | 278 | 10 279 | Environnement Incorrect 280 | 281 | 282 | 283 | 284 | 285 | -------------------------------------------------------------------------------- /Zabbix v3.4/zbx3.4_export_templates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.4 4 | 2018-01-05T12:48:06Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 275 | 276 | 277 | 278 | scheduledtask 279 | 280 | 281 | 0 282 | Succès 283 | 284 | 285 | 1 286 | Fonction incorrecte ou inconnue appelée 287 | 288 | 289 | 2 290 | Fichier non trouvé 291 | 292 | 293 | 10 294 | Environnement Incorrect 295 | 296 | 297 | 267008 298 | La tâche est prête à fonctionner à l'heure prévue suivante 299 | 300 | 301 | 267009 302 | La tâche est en cours d'exécution 303 | 304 | 305 | 267011 306 | La tâche n'est pas encore terminée 307 | 308 | 309 | 267012 310 | Il n'y a plus d'opérations programmées pour cette tâche 311 | 312 | 313 | 267014 314 | La tâche est terminée 315 | 316 | 317 | 2147750671 318 | Identifiants corrompus 319 | 320 | 321 | 2147750687 322 | Une instance de cette tâche est déjà en cours d'exécution 323 | 324 | 325 | 2147942401 326 | Fonction incorrecte ou inconnue appelée 327 | 328 | 329 | 2147942402 330 | Un des fichiers n'est pas disponible 331 | 332 | 333 | 2147942667 334 | Le répertoire «démarrer dans» ne peut être trouvé 335 | 336 | 337 | 2147943645 338 | Le service n'est pas disponible 339 | 340 | 341 | 3228369022 342 | Exception logicielle inconnue 343 | 344 | 345 | 346 | 347 | 348 | --------------------------------------------------------------------------------