romainsi / zabbix-VEEAM_B-R

52 stars 40 forks source link

"ResultBackup" not working #42

Closed dubenaex closed 5 years ago

dubenaex commented 5 years ago

Hello, I had the felling that your script is quite popular and used so I'm kind of surprised that basic things are not working for me so I'm expecting that issue is on my side however I'm not able to find out what is wrong.

For the moment I'm running only PS script (no zabbix interaction).

I'm able to create XML files and get list of jobs, even jobs per VM. If I check result of Job I'm getting always 4. For example ;

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "zabbix_vbr_job.ps1" DiscoveryBackupJobs
{"data":[{"{#JOBID}":"ba779c2f-fbaf-4f7e-8d6a-1c21adf2892f","{#JOBNAME}":"vmwin-nas"},{"{#JOBID}":"39b7d35f-b0af-4bd0-8817-3d037cddfc9a","{#JOBNAME}":"vmlx-nas"},{"{#JOBID}":"

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "zabbix_vbr_job.ps1" ResultBackup "ba779c2f-fbaf-4f7e-8d6a-1c21adf2892f"
4

It is same for jobs even they all have last result success in Veeam GUI. In your code result should provide this part :

    "ResultBackup"  {
        $xml = ImportXml -item backuptaskswithretry
        $query1 = $xml | Where-Object { $_.jobId -like "$ID" } | Sort-Object JobStart -Descending | Select-Object -First 1
        $query2 = $query1.JobResult
        if (!$query2.value)
        {
            write-output "4" # If empty Send 4 : First Backup (or no history)
        }
        else
        {
            $query3 = $query2.value
            $query4 = "$query3" | veeam-replace
            write-output "$query4"
        }
    }

XML backuptaskswithretry is empty in my case. What exactly should be stored here ?

Thanks,

Martin

dubenaex commented 5 years ago

Ok sorry, stupid mistake. I had $days = '2' instead of $days = '-2'