Page 1 of 1

check_veeam_repo.ps1 Returns Parameter Errors

Posted: Thu Apr 11, 2024 2:17 am
by rj-admin2
Hi All,

New here and just trying to find my feet. So, I am trying to use Nagios XI to monitor used space on our Veeam backup repositories. I downloaded the Powershell script: "check_veeam_repo.ps1" from Nagios Exchange. I'm trying to run it remotely on the Veeam server using NCPA (this is already working as I monitor CPU, Memory Disk etc). However when I add the service for VEAAM Repositories, I get the following error:

C:\Program Files (x86)\Nagios\NCPA\plugins\check_veeam_repo.ps1 : Cannot process command because of one or more
missing mandatory parameters: warningPercent criticalPercent.
+ CategoryInfo : InvalidArgument: (:) [check_veeam_repo.ps1], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingMandatoryParameter,check_veeam_repo.ps1

The command looks like:

Check command: check_xi_ncpa
Command view: $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
$ARG1$: -t 'NCPA Password' -P 5693 -M 'plugins/check_veeam_repo.ps1' -w '85' -c '90'

Like I've already said, I know the NCPA setup is correct as it's already in use, and this service definition is a copy/clone of another one that is working correctly.

I'm kind of stumped. Can anyone help?

TIA.

Re: check_veeam_repo.ps1 Returns Parameter Errors

Posted: Tue Apr 16, 2024 1:47 pm
by bbahn
Hello @rj-admin2,

Have you checked whether it works in NCPA? Try visiting https://[your_ncpa_ip_address]:5693/api/ and test your plugin in the interface to narrow down where the failure is coming from.

Re: check_veeam_repo.ps1 Returns Parameter Errors

Posted: Wed Apr 17, 2024 2:10 am
by rj-admin2
Many thanks for the suggestion.

Having run through this and rejigged the expected parameters, I'm now presented with the following output:

"returncode": 3,
"stdout": "Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.\nAt C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_veeam_repo.ps1:33 char:1\n+ Add-PSSnapin VeeamPSSnapin\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : InvalidArgument: (VeeamPSSnapin:String) [Add-PSSnapin], PSArgumentException\n + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand\n \nUNKNOWN - Missing VeeamPSSnaping"

As far as I know, the PS "extensions" for Veeam are installed already, by default. So really not sure what is going on here?

TIA.

Re: check_veeam_repo.ps1 Returns Parameter Errors

Posted: Wed Apr 17, 2024 10:25 am
by bbahn
@rj-admin2,

Even if the extensions are installed, if they aren't registered properly, they may not work. Try running

Code: Select all

Get-PSSnapin -Registered
and see if the Veeam snap-in is listed.

If not, the Veeam snap-in is not registered nad you will need to manually register it. You can typically find the PowerShell snap-in file (a .psd1 or .dll file) in the Veeam installation directory. Once located, you can register it using the Install-Util command or via the Add-PSSnapin command if you find the specific .dll.

If that doesn't work, you may need to reinstall Veeam, try again and/or contact Veeam support.

Re: check_veeam_repo.ps1 Returns Parameter Errors

Posted: Fri Apr 19, 2024 12:43 am
by rj-admin2
Many thanks for this.

I was playing about yesterday and upgraded NCPA to v3.0.2. I can now run the script locally within PS. So, I have to assume everything I need is installed and working. Although the "Get-PSSnapin -Registered" command still shows nothing.

When I run the script from the NCPA gui/api browser page, I get:

"returncode": -1,
"stdout": "Error: Plugin command (powershell -ExecutionPolicy Bypass -File C:\\Program Files\\Nagios\\NCPA\\plugins\\check_veeam_repo - orig.ps1 '-w=90 -c=95') timed out. (59 sec)",
"cmd": "powershell -ExecutionPolicy Bypass -File C:\\Program Files\\Nagios\\NCPA\\plugins\\check_veeam_repo - orig.ps1 '-w=90 -c=95'"

TIA.

Re: check_veeam_repo.ps1 Returns Parameter Errors

Posted: Fri Apr 19, 2024 10:41 am
by bbahn
It looks like you're running into a timeout. If you update your [plugin directives] plugin_timeout in C:\Program Files\Nagios\NCPA\etc\ncpa.cfg to something higher than 59 seconds, that may fix the problem.

Re: check_veeam_repo.ps1 Returns Parameter Errors

Posted: Wed May 01, 2024 5:47 am
by rj-admin2
Many thanks for this.

I now have the script generating output. However my problem is that Nagios is not displaying the whole text. I get a truncated single line output: "WARNING: The names of some imported commands from the module 'Veeam.Backup.PowerShell' include unapproved verbs that".

Is there a limit I need to adjust to enable Nagios to display the complete output?

TIA.

Re: check_veeam_repo.ps1 Returns Parameter Errors

Posted: Wed May 01, 2024 10:14 am
by bbahn
@rj-admin2,

It looks like Veeam on Powershell 7 requires the use of -UseWindowsPowerShell as a parameter when importing the Veeam PowerShell module
Actually, I just discovered that using the -UseWindowsPowerShell parameter when importing the Veeam PS module that it will actually work on PowerShell 7.3.

Import-Module Veeam.Backup.PowerShell -UseWindowsPowerShell
How to load the modules for Veeam in PowerShell