Page 1 of 1

Graphing a two state value

Posted: Wed Jun 07, 2023 5:39 am
by Chris Hardick
Hi

We are developing a powershell plugin script for use with ncpa that checks a value is set in the windows registry:


$FWStatus = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\" | Select-Object EnableFirewall
#$FWStatus.EnableFirewall
#$FWStatus.EnableFirewall
if ($FWStatus.EnableFirewall -eq 1)
{
Write-Output "OK: Firewall Enabled"
exit 0
}
else
{
Write-Output "CRITICAL: Firewall Disabled"
exit 2
}

Is there any special graph for a two state service eg Boolean, or will I need to return the "EnableFirewall" value which will be 1 or 0 and simply graph those states?

Thanks for your help

Re: Graphing a two state value

Posted: Wed Jul 26, 2023 1:47 am
by bennycavitt
Hi Chris,
I think you can use a boolean graph in NCPA to represent the status of the service.

In your PowerShell script, you can modify the output to return a boolean value instead of a text message. For example, you could modify the script as follows:

$FWStatus = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile" | Select-Object EnableFirewall

if ($FWStatus.EnableFirewall -eq 1)
{
Write-Output "True"
exit 0
}
else
{
Write-Output "False"
exit 2
}

This script will output "True" if the firewall is enabled and "False" if the firewall is disabled.

In NCPA, you can create a boolean graph for this service by selecting "Boolean" as the graph type and setting the "True" and "False" states to display as "Firewall Enabled" and "Firewall Disabled", respectively. The graph will display a green icon for "Firewall Enabled" and a red icon for "Firewall Disabled".pizza tower

Alternatively, you could also create a graph that displays the "EnableFirewall" value as a line graph with two states (0 and 1). This would show the status of the firewall over time and allow you to monitor changes in the firewall status.