How to Monitor Hyper-V Checkpoints with the Script Sensor

Discover how to configure NetCrunch to monitor Hyper-V checkpoints remotely and set up alerts based on the output.

Monitoring Hyper-V checkpoints is essential to ensuring that your virtual environment remains healthy and efficient. With NetCrunch, you can easily execute PowerShell scripts on any Windows machine, such as a Hyper-V host, and use the script results to generate alerts and take action when needed.

Why Use NetCrunch for PowerShell Script Execution?

NetCrunch allows you to automate the execution of PowerShell scripts across your network, leveraging its monitoring capabilities to run scripts on any Windows machine. This flexibility means you can monitor various metrics, including Hyper-V checkpoints, without logging into each machine manually. NetCrunch can execute scripts on remote computers, collect the output, and generate alerts based on predefined conditions, helping you to maintain optimal performance and security in your IT environment.

Step-by-Step Guide to Monitoring Hyper-V Checkpoints with NetCrunch

To monitor Hyper-V checkpoints with NetCrunch, ensure that the Hyper-V host allows remote PowerShell script execution from the NetCrunch server and that the Script Sensor is correctly configured to run the script.

Configure the Hyper-V Host to Accept Remote Scripts from the NetCrunch Server

To securely monitor Hyper-V checkpoints, the Hyper-V host must be configured to accept PowerShell commands remotely, specifically from the NetCrunch server:

1. Enable PowerShell Remoting:

On the Hyper-V host (the Windows machine running Hyper-V), open PowerShell as an administrator and run the following command to enable PowerShell Remoting:

powershell Enable-PSRemoting -Force

This command configures the necessary settings and starts the WinRM service, allowing remote PowerShell commands to be executed.

2. Set Trusted Hosts to Allow Only NetCrunch Server:

Limit remote script execution to only the NetCrunch server by setting the WinRM TrustedHosts list to include only the NetCrunch server's Fully Qualified Domain Name (FQDN). On the Hyper-V host, run the following command in PowerShell:

powershell Set-Item WSMan:\localhost\Client\TrustedHosts -Value "netcrunch.example.local"

Replace netcrunch.example.local with the actual FQDN of your NetCrunch server. This ensures that only the NetCrunch server can execute remote PowerShell scripts on the Hyper-V host.

3. Restart the WinRM Service:

After setting the trusted hosts, restart the WinRM service to apply the changes:

powershell Restart-Service WinRM

4. Adjust Firewall Settings:

Ensure the firewall on the Hyper-V host allows incoming WinRM traffic only from the NetCrunch server - create a firewall rule that permits traffic from the NetCrunch server's IP address or FQDN.

You can use the Windows Defender Firewall with Advanced Security to create a custom rule:

  1. Open Windows Defender Firewall with Advanced Security.
  2. Navigate to Inbound Rules and click New Rule.
  3. Select Custom and click Next.
  4. Choose All programs and click Next.
  5. Select TCP and specify Local port as 5985 (HTTP) or 5986 (HTTPS), then click Next.
  6. Under Which remote IP addresses does this rule apply to?, select These IP addresses and add the IP address of the NetCrunch server.
  7. Complete the wizard to apply the rule.

2. Configure the NetCrunch Script Sensor

Once the Hyper-V host is configured to accept remote scripts only from the NetCrunch server, you need to set up the Script Sensor in NetCrunch to monitor the checkpoints.

Add a Script Sensor in NetCrunch:

Open the NetCrunch administration console and navigate to the node where you want to add the Script Sensor. Click on "Add Sensor" and select "Script Sensor".

Set Up the Script Sensor:

  1. Script Type: Choose “PowerShell” to indicate that the script to be executed is a PowerShell script.
  2. Script File: Provide the full path to the PowerShell script file on the NetCrunch server. Make sure this path is accessible and that the script has the necessary permissions to be executed.
  3. Pass Credentials Through PSCredential Object: Check this option to ensure the credentials required to execute the script remotely are securely passed to the PowerShell session.
  4. Credentials: Enter the credentials that have permission to execute the script on the Hyper-V host. These should be credentials with administrative access to the Hyper-V host to allow the script to retrieve checkpoint information.
  5. Script Output Data Format: Set this to “Auto-detect”. NetCrunch will automatically determine the format of the output returned by the script and process it accordingly. Script sensor configuration
  6. Save and Apply the Sensor Configuration
  7. Use the Test button to check the Sensor configuration
  8. Save the configuration settings and apply them to the selected node. The Script Sensor will now be configured to remotely execute the PowerShell script on the Hyper-V host and collect the output. Script sensor test result

3. Set Up Alerts Based on the Script Output

NetCrunch can use the script output to trigger alerts and actions. For example, you can set up an alert if the number of checkpoints older than 24 hours exceeds a certain threshold.

Configure Alerting:

  1. Click Alert
  2. Select New Event for Monitoring Sensor Counter
  3. Name Alert and choose Alert Severity
  4. in the Event Condition section choose Select Counter
  5. Select the name of your counter and then click OK
  6. Select the value instead of average value and set trigger (e.g. >0)
  7. Select reset conditions and then click OK
  8. Don't forget to assign Alerting Script

That's all. As a result, you will receive an alert if on the selected Hyper-V host anu Checkpoints older than 24h are detected. Add alert to sensor Add event to script Add sensor monitor counter Alerting rule

Conclusion

By implementing the NetCrunch Script Sensor, you can automate the monitoring of Hyper-V checkpoints across your environment. This approach ensures that you have real-time visibility into the status of your checkpoints, allowing you to proactively manage your virtual infrastructure and prevent potential issues before they affect your operations. By configuring PowerShell Remoting to accept scripts only from the NetCrunch server, you maintain a secure monitoring setup, minimizing the risk of unauthorized script execution.

checkpointhyper vscriptsensor

NetCrunch. Answers not just pictures

Maps → Alerts → Automation → Intelligence