Custom Log Type Name. Will be displayed as Custom Log 'LogType_CL' in OMS.
SkipWindowsServer
bool
$Config/SkipWindowsServer$
Skip Windows Server
If set to true, Fujitsu PRIMERGY Windows Server Health will not be included in the data sent to the OMS workspace
SkipLinuxServer
bool
$Config/SkipLinuxServer$
Skip Linux Server
If set to true, Fujitsu PRIMERGY Linux Server Health will not be included in the data sent to the OMS workspace
SkipESXiServer
bool
$Config/SkipESXiServer$
Skip ESXi Server
If set to true, Fujitsu PRIMERGY ESXi Server Health will not be included in the data sent to the OMS workspace
SkipOobServer
bool
$Config/SkipOobServer$
Skip Out-Of-Band Server
If set to true, Fujitsu PRIMERGY Out-Of-Band Server Health will not be included in the data sent to the OMS workspace
TimeoutSeconds
int
$Config/TimeoutSeconds$
Timeout Seconds
Timeout in Seconds for the Collect Health State to OMS Write Action Script
Source Code:
<WriteActionModuleType ID="Fujitsu.ServerView.Monitoring.OMS.IngestHealthStatusWriteAction" Accessibility="Internal" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ScriptName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Certificate" type="xsd:string"/>
<!-- Will be displayed as Custom Log 'LogType_CL' in OMS -->
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="LogType" type="xsd:string"/>
<!-- Allow filtering of included Fujitsu Classes -->
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="SkipWindowsServer" type="xsd:boolean" default="false"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="SkipLinuxServer" type="xsd:boolean" default="false"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="SkipESXiServer" type="xsd:boolean" default="false"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="SkipOobServer" type="xsd:boolean" default="false"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="StrictErrorHandling" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="LogType" Selector="$Config/LogType$" ParameterType="string"/>
<OverrideableParameter ID="SkipWindowsServer" Selector="$Config/SkipWindowsServer$" ParameterType="bool"/>
<OverrideableParameter ID="SkipLinuxServer" Selector="$Config/SkipLinuxServer$" ParameterType="bool"/>
<OverrideableParameter ID="SkipESXiServer" Selector="$Config/SkipESXiServer$" ParameterType="bool"/>
<OverrideableParameter ID="SkipOobServer" Selector="$Config/SkipOobServer$" ParameterType="bool"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="WA" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<ScriptName>$Config/ScriptName$</ScriptName>
<ScriptBody><Script>
##################################################################################
# #
# NOTICE #
# #
# COPYRIGHT 2015 - 2017 FUJITSU LIMITED #
# ALL RIGHTS RESERVED #
# #
# This computer program is CONFIDENTIAL and contains TRADE SECRETS of #
# FUJITSU LIMITED. The receipt or possession of this program does #
# not convey any rights to reproduce or disclose its contents, or to #
# manufacture, use, or sell anything that it may describe, in whole or #
# in part, without the specific written consent of FUJITSU LIMITED. #
# Any reproduction of this program without the express written consent #
# of FUJITSU LIMITED is a violation of the copyright laws and may #
# subject you to civil liability and criminal prosecution. #
# #
##################################################################################
<#
This Script sends health state together with basic Server data to an OMS workspace as JSON Data
where it can be analyzed as custom log type. For technical details see:
https://azure.microsoft.com/en-us/documentation/articles/log-analytics-data-collector-api/
# --------------------------------------------------------------------------
# Defaults
#
[string]$MP_NAME = "Fujitsu.ServerView.Monitoring.Cloud"
[string]$SCRIPT_NAME = "IngestHealthStatus.ps1"
[int] $SCRIPT_EVENT_NUMBER = 8969 # is a prime
[int] $ERROR_BAD_CERT_DATA = 8971 # is a prime
[int] $ERROR_BAD_JSON_DATA = 8941 # is a prime
[int] $ERROR_SENDING_DATA = 8951 # is a prime
[string] $API_VERSION = "2016-04-01"
[bool] $SendSingleRecords = $False
# overwrite with passed in parameters
if ($ScriptName -ne '') { $SCRIPT_NAME = $ScriptName}
# set CONSTANT variables (can not be changed):
set-variable -name PoShScriptName -value "$SCRIPT_NAME" -option constant
# Note: Sending JSON from SCOM with cert based authorization uses different API Endpoint
$uri = "https://$($customerId).ods.opinsights.azure.com/OperationalData.svc/PostJsonDataItems?api-version=$($API_VERSION)"
# Note: We do not use/have a dedicated time-stamp field
$headers = @{
"Log-Type" = $logType;
"x-ms-date" = $rfc1123date;
}
if ( ($response.StatusCode -eq [System.Net.HttpStatusCode]::Accepted) -or ($response.StatusCode -eq [System.Net.HttpStatusCode]::OK) ) {
DebugOut "SUCCESS sending Health State of Fujitsu ServerView Servers to Microsoft OMS..."
} else {
LogScriptEventWithEventSource -EventSource $SCRIPT_NAME -EventLevel $WARNING_LEVEL -EventNumber $ERROR_SENDING_DATA -Message ("Error sending Fujitsu ServerView Server Health Data to Microsoft OMS: Response='$($response)'")
DebugWarn "WARNING: Could not send Fujitsu ServerView Servers Health Data to Microsoft OMS: Response='$($response)'"
}
} catch {
DebugErr $ERROR_SENDING_DATA "ERROR sending Fujitsu ServerView Servers Health Data to Microsoft OMS:`nException=$_"
}
}
} catch {
# Generic Exception ...
LogScriptEventWithEventSource -EventSource $SCRIPT_NAME -EventLevel $ERROR_LEVEL -EventNumber $SCRIPT_EVENT_NUMBER -Message ("Collect Health State of Fujitsu ServerView Servers to OMS: Exception=$_")
Exit -1
}
DebugOut "Collect Health State of Fujitsu ServerView Servers to OMS - END"
}
# This script part contains helper functions to perform various logging activities
# and is embedded into the final script via Visual Studio Authoring Extensions
# Log an event into the registry, Source will be 'Health Service Script'
# See https://msdn.microsoft.com/en-us/library/bb437630.aspx
[int]$WARNING_LEVEL = 2
[int]$ERROR_LEVEL = 1
[int]$INFO_LEVEL = 0
$LOGFILE_VERSION = 8.3.0.0
# Generic version
Function RaiseEvent {
Param (
[parameter(Mandatory=$true)]
[string]$EventSource = "Fujitsu ServerView",
[parameter(Mandatory=$true)]
[int]$EventLevel,
[parameter(Mandatory=$true)]
[int]$EventNumber,
[parameter(Mandatory=$true)]
[string]$Message
)
# Backwards compatible wrapper
Function LogScriptEvent {
Param (
[parameter(Mandatory=$true)]
[ValidateRange(0,2)]
[int]$EventLevel,
[parameter(Mandatory=$true)]
[int]$EventNumber,
[parameter(Mandatory=$true)]
[string]$Message
)
# Note: Log will be written always with Event Source 'Health Service Script'
if ($ScriptApi -ne $Null) {
# Note: do not use actual script name to consolidate Alert Suppression from parallel scripts
$ScriptApi.LogScriptEvent("Fujitsu ServerView", $EventNumber, $EventLevel, $Message)
# $ScriptApi.LogScriptEvent($PoShScriptName, $EventNumber, $EventLevel, $Message)
}
}
# --------------------------------------------------------------------------
# Global variables = variables, which are changed in different functions ...
# ... and the changed value shall be available in the calling function
# --------------------------------------------------------------------------
$global:DebugMode = $False
$global:DebugFile = $False
$global:OverWrite = $True
$global:DebugHosts = ""
$global:DebugForHost = "$False"
$global:ErrFilePrefix = "ERRORTrace"
$global:WarnFilePrefix = "WARNINGTrace"
$global:LogTargetName = ""
$global:LogFilePrefix = ""
# Note: do not mix with Custom Log update directory for the time being
$global:LogFilePath = "$Env:TEMP\SVISCOM\SVISCOM-Cloud"
$global:LogFileName = "$LogFilePath\$($LogFilePrefix).log"
# create the target directory, if it does not exist
if ( ! (Test-Path -Path $global:LogFilePath)) {
New-Item -ItemType directory -Path $global:LogFilePath | Out-Null
}
if (Test-Path -Path $global:LogFilePath) {
$pathOK = $True
}
if (Test-Path -Path $Xm_FileName) {
$txt = get-content $Xm_FileName
foreach ($line in $txt) {
if ($line.contains($LOGFILE_VERSION)) {
$fileOK = $True
break
}
}
}
if (($pathOK -eq $True) -and ($fileOK -eq $False)) {
# we write a new SVISCOM-OutOfBand.xm_ file every time the MP is changed to make sure all
# INI-Values are documented for use by the customer if anything changes.
if (Test-Path -Path $Xm_FileName) {
Remove-Item -Path $Xm_FileName -Force | Out-Null
}
#Create xm_ file
New-Item -Path $Xm_FileName -ItemType File | Out-Null
Add-Content -Path $Xm_FileName -Value @"
<$SectionRoot>
<!--
$SVISCOMLogXmlName Debug XML file Version $LOGFILE_VERSION
With this file logging for PowerShell scripts within the
- Fujitsu ServerView Integration Management Pack and
- Optional Extension Management Packs for the Fujitsu ServerView Integration Management Pack
can be enabled.
Rename the file type from '.xm_' to '.xml' to enable reading this file.
Note: You have to enable debug for a script and also select the server in
the '<$TagHostsDiscovery>' or '<$TagHostsMonitoring>' section to generate traces (see below).
The following sections specify for which PowerShell scripts the traces will be generated;
Each of the sections represents a single PowerShell script.
'<$TagDebugMode>' enables logging (yes) or disables logging (no)
'<$TagOverWrite>' defines continuous logging (no) or single script run logging (yes)
-->
<!-- DISCOVERIES -->
<!-- currently none -->
<!-- MONITORS -->
<!-- The following section enables trace files for the Health monitoring script -->
<$SectionHealthMonitor>
<$TagDebugMode>yes</$TagDebugMode>
<$TagOverWrite>no</$TagOverWrite>
</$SectionHealthMonitor>
<!--
The following sections specify for which servers the traces will be generated:
In the '<$TagHostsDiscovery>' and '<$TagHostsMonitoring>' sections
single or multiple servers can be specified for verbose debug output
during the discovery and/or during monitoring.
Use '<$TagHostsDiscovery>' for selecting hosts for the discovery trace.
Use '<$TagHostsMonitoring>' for selecting hosts for the monitoring trace.
Use 'all' (without quote signs) for all Fujitsu Out-Of-Band Servers monitored by SCOM.
Use a single IP address or a comma separated list to select multiple single servers
Example:
<$TagHostsDiscovery>all</$TagHostsDiscovery>
<$TagHostsMonitoring>192.168.1.100,192.168.1.101,192.168.1.102</$TagHostsMonitoring>
will generate discovery traces for all Fujitsu Out-Of-Band Servers and
will generate monitoring traces only for servers with the IP address
192.168.1.100 192.168.1.101 and 192.168.1.102
-->
<$TagHostsDiscovery>all</$TagHostsDiscovery>
<$TagHostsMonitoring>all</$TagHostsMonitoring>
</$SectionRoot>
"@
}
}
if (Test-Path -Path $global:LogFilePath) {
if (Test-Path -Path $XmlFileName) {
[xml]$xmlfile = Get-Content $XmlFileName
if ($xmlfile.$SectionRoot.$section.$TagDebugMode -ne $null) {
if ($($xmlfile.$SectionRoot.$Section.$TagDebugMode).ToUpper() -eq "YES") {
$global:DebugMode = $True
$global:DebugFile = $True
}
}
if ($xmlfile.$SectionRoot.$section.$TagOverWrite -ne $null) {
if ($($xmlfile.$SectionRoot.$Section.$TagOverWrite).ToUpper() -eq "NO") {
$global:OverWrite = $False
}
}
if ($xmlfile.$SectionRoot.$HostTag -ne $null) {
$global:DebugHosts = $($xmlfile.$SectionRoot.$HostTag).ToLower()
}
# Check if DEBUG shall run for this server.
# There are two possibilities to check: "all" server DEBUG is on or this server is in the list.
if ($global:DebugHosts -eq "all") {
$global:DebugForHost = $True
} else {
# Check if this host is in the list of DebugHosts
$ListOfHosts = $($global:DebugHosts).split(',')
DebugOut "Searching for host: $ServerName"
DebugOut "in list of DebugHosts: $global:DebugHosts"
if ($ServerName.ToLower() -in $ListOfHosts) {
$global:DebugForHost = $True
}
}
} # else file does not exist
} # else directory does not exist
}
Function CreateLogFile
{
# For some reason checking for "$True" with "if ($global:a -and $global:b)" is not evaluated correctly!!!
# It works OK in a test with a simple PS script ... no idea why ... Thus we use:
if ($global:DebugForHost -eq $True) {
if ($global:DebugFile -eq $True) {
# Create the target directory, if it does not exist
if (!(Test-Path -Path $global:LogFilePath)) {
New-Item -ItemType directory -Path $global:LogFilePath | Out-Null
}
# Check if file exists and delete if it does and OverWrite is set to TRUE
if (Test-Path -Path $global:LogFileName) {
DebugOut ""
DebugOut "Log file already exists at: $global:LogFileName"
if ($global:OverWrite -eq $True) {
Remove-Item -Path $global:LogFileName -Force | Out-Null
}
}
# If the file has just been removed (OverWrite = YES) or the file does not exist: create it
if (!(Test-Path -Path $global:LogFileName)) {
#Create log file
New-Item -Path $global:LogFileName -ItemType File | Out-Null
}