lordmilko / PrtgSensors

Miscellaneous sensors for PRTG Network Monitor
MIT License
9 stars 3 forks source link

Get-ClusterStatus.ps1 getting prtg is not recognized as the name of a cmdlet .... #8

Closed lukaszkarbownik closed 2 months ago

lukaszkarbownik commented 3 months ago

After following the setup and compiling the file with VS and having PS policy set to bypass I still get this error.

Prtg : The term 'Prtg' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\Get-ClusterStatus.ps1:61 char:5

Please advice what I might be doing wrong

lukaszkarbownik commented 3 months ago

and PowerShell module is already installed on the server

lordmilko commented 3 months ago

When PRTG runs PowerShell scripts, historically it has run them in the 32-bit version of PowerShell

You may need to open Windows PowerShell (x86) from the start menu and do Install-Module PrtgXml there too

lordmilko commented 3 months ago

Alternatively, add the following to the top of the script and let PRTG install it for you when it runs it

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

if(!(Get-Module -ListAvailable PrtgXml))
{
    Install-Package PrtgXml -ForceBootstrap -Force | Out-Null
}
lukaszkarbownik commented 3 months ago

thanks for the reply

is there anything else needed ? now I can run it and configure sensor in PRTG but I get this response on every resource

0 (configured lookup prtg.customsensors.onlineoffline is empty or not available)

tried to follow this kb to reload them but had no success :

https://kb.paessler.com/en/topic/91470-several-standard-lookups-not-found

And all the required lookup files have been copied per step 5 :

Copy prtg.customlookups.onlineoffline.ovl and prtg.customlookups.sql.nodestate.ovl to C:\Program Files (x86)\PRTG Network Monitor\lookups\custom

lordmilko commented 3 months ago

Did you install the lookup on the master PRTG server, or on the probe? I believe it needs to be installed on the master server

lukaszkarbownik commented 3 months ago

Yes on the Master server , working in PRTG support as well and they asked me to change sensor settings to store results and send them logs

lukaszkarbownik commented 3 months ago

output of the Powershell is also not working, so not sure if this is PRTG issue at this point

PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\Get-ClusterStatus.ps1 HTVP-DRCLS

<Prtg>
    <Result>
        <Channel>HTVP-DRCLS-N1</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.sql.nodestate</ValueLookup>
    </Result>
    <Result>
        <Channel>HTVP-DRCLS-N2</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.sql.nodestate</ValueLookup>
    </Result>
    <Result>
        <Channel>Cluster Disk 2</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>Cluster Disk 3</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>Cluster IP Address</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>Cluster Name</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>SQL IP Address 1 (HTVP-DRSQLCLS)</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>SQL Network Name (HTVP-DRSQLCLS)</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>SQL Server (DRSQL)</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>SQL Server Agent (DRSQL)</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>SQL Server CEIP (DRSQL)</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>SQL Server FILESTREAM share (DRSQL)</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
    <Result>
        <Channel>Storage Qos Resource</Channel>
        <Value>0</Value>
        <ValueLookup>prtg.customsensors.onlineoffline</ValueLookup>
    </Result>
</Prtg>
lordmilko commented 3 months ago

This is the expected output. Each node and resource in the cluster gets its own channel.

I've had issues with getting PRTG to recognize new custom lookups before; it's been a few years so I can't remember the issues. Maybe try restart the PRTG Core Server, or run Process Monitor while requesting to do a refresh of the lookups on the system and see if it sees the new one we've added?

lukaszkarbownik commented 3 months ago

ok, thanks for the info. I'll press Paessler support more on this; they were hesitant to look at this initially since this is custom, but now that the error is gone and gives a clear output, they are trying to help.

lukaszkarbownik commented 2 months ago

@lordmilko I just want to provide the update. PRTG found the issue with the script expecting different values

"The issue is that the lookup names and content have: customlookups in the name and the content While your script is expecting "customsensors" So either change the lookup files to use "customer sensors" instead or adjust the script to use "custom lookups. "

I ended up going with updating script and lookup files content to use customlookups and it worked

Screenshot 2024-08-08 105651

lordmilko commented 2 months ago

Hi @lukaszkarbownik,

Thanks for reporting this. I have updated the script accordingly