I have made a script that will give back the freespace on a quorumdisk for a cluster if the node you supplied as a parameter is active and if it is not active will return 0 with the text that it is not active.
This script is in the exe folder of main prtg server and it works fine if I run it from the powershell prompt but it wont give me back anything when it is executed from prtg itself. It does see the parameter but doesn't seem to be able to get anything from the get-wmiobject.
Any ideas?
This is the code :
param([string]$MACHINE) if ($MACHINE -eq "") { write-host "0:ERROR NO PARAMETER GIVEN" exit 2 } clear-host # Define variables # $MACHINE="zlm-webprd1" # Get the currently active clusternode [string]$CLUSTERNODE=Get-WmiObject -ComputerName $MACHINE -namespace "root/MSCluster" MSCluster_NodeToActiveGroup|%{$_.GroupComponent} [string]$CLUSTERNODE = [string]$CLUSTERNODE.Substring(20) $CLUSTERNODE = $CLUSTERNODE -replace "`"","" # Get the hostname from the currently connected system. [string]$HOSTNAME=Get-Wmiobject -computername $MACHINE Win32_ComputerSYstem|%{$_.Name} # Get the Quorum Disk [string]$QUORUMDISK=Get-Wmiobject -computername $MACHINE -namespace "root/MSCLuster" MSCluster_ClusterToQuorumResource|%{$_.PartComponent} [string]$QUORUMDISK = [string]$QUORUMDISK.Substring(30) $QUORUMDISK = $QUORUMDISK -replace "`"","" if ($CLUSTERNODE -eq $HOSTNAME) { # Get the size and freespace of disk partitions and only select quorum disk $dsk= Get-WmiObject -computername $MACHINE Win32_LogicalDisk foreach ( $drive in $dsk ) { if ($drive.name -eq $QUORUMDISK) { [string]$TEMP1 = (($drive.Freespace)/($drive.size))*100 [string]$TEMP1 = [string]$TEMP1 -replace " ","" write-host $TEMP1":ACTIVE" } } } else { write-host "0:NOT ACTIVE" exit 1 }
Add comment