Fortinet black logo

User Guide

template.ps1 file

24.2.0
Copy Link
Copy Doc ID af1daa65-c273-11ec-9fd1-fa163e15d75b:408125
Download PDF

template.ps1 file

function Plugin-Configuration

{

return @{

textKey = "systemp"

category = "Get System Temperature"

};

}

function Discover

{

return @(

@{

resource_textkey = "temp_in_F"

label = "Temperature Fahrenheit"

unit="degrees F"

options = @("fan", "intakeFan", "exitFan")

},

@{

resource_textkey = "temp_in_C"

label = "Temperature Celsius"

unit="degrees C"

options = @("fan", "intakeFan", "exitFan")

}

)

}

function Collect-Metric($resource_textkey, $option)

{

return Get-Temperature $resource_textkey;

}

function Get-Temperature($scale)

{

$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"

$currentTempKelvin = $t.CurrentTemperature / 10;

$currentTempCelsius = $currentTempKelvin - 273.15;

if($scale -eq "temp_in_F") {

return (9/5) * $currentTempCelsius + 32;

}

if($scale -eq "temp_in_C") {

return $currentTempCelsius;

}

return $currentTempKelvin;

}

template.ps1 file

function Plugin-Configuration

{

return @{

textKey = "systemp"

category = "Get System Temperature"

};

}

function Discover

{

return @(

@{

resource_textkey = "temp_in_F"

label = "Temperature Fahrenheit"

unit="degrees F"

options = @("fan", "intakeFan", "exitFan")

},

@{

resource_textkey = "temp_in_C"

label = "Temperature Celsius"

unit="degrees C"

options = @("fan", "intakeFan", "exitFan")

}

)

}

function Collect-Metric($resource_textkey, $option)

{

return Get-Temperature $resource_textkey;

}

function Get-Temperature($scale)

{

$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"

$currentTempKelvin = $t.CurrentTemperature / 10;

$currentTempCelsius = $currentTempKelvin - 273.15;

if($scale -eq "temp_in_F") {

return (9/5) * $currentTempCelsius + 32;

}

if($scale -eq "temp_in_C") {

return $currentTempCelsius;

}

return $currentTempKelvin;

}