Moin,
sorry for late reply. Also nein, nen Template gibts da nicht und ich bin auch ehrlich gesagt nicht so fit in Zabbix dass ich daraus eins erstellen könnte.
Aber vom Prinzip her habe ich ein Userscript im Installationsverzeichnis des Zabbix Agents erstellt und abgelegt welches Zyklisch die Statistikdaten via NSP PowerShell Modul abfragt. Der Inhalt der Variablen wird dann einfach nur an Zabbix übergeben.
Die PS Scripte hänge ich mal an.
Im Internet gibts auch genug HowTos wie man ein PS Script via Zabbix Agent ausführt und Daten übergibt.
Bei den Replikationsartefakten ist es im Prinzip ähnlich gelöst, nur dass ich hier via PowerShell ne SQL Verbindung aufrufe pro Rolle. Heisst dass dieses PS Script zyklisch auf allen GW Rollen und der Intranetrolle läuft und die Daten an Zabbix übergibt. Möglicherweise geht das auch von der GW Rolle aus und von dort dann nen Connect zu allen Rollen, aber Firewalltechnisch war das bei uns nicht gewollt!
Die Parameter am Anfang kann man ebenfalls via Zabbix an das PS Script übergeben!
Code:
Param
(
[Parameter(Mandatory = $true,Position=0)][string]$userName,
[Parameter(Mandatory = $true,Position=1)][string]$password
)
$ErrorActionPreference = 'Stop'
$1hour = New-TimeSpan -Minutes 1
$password = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($password))
$userName = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($userName))
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
$session = New-PSSession -ComputerName localhost -Credential $Credentials
$incoming = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Age $USING:1hour -Directions FromExternal -CountOnly})
$outgoing = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Age $USING:1hour -Directions FromLocal -CountOnly})
$DeliveryPending = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Age $USING:1hour -Status DeliveryPending -CountOnly})
$inboundRejects = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Age $USING:1hour -Directions FromExternal -Status PermanentlyBlocked, TemporarilyBlocked -CountOnly})
$localRejects = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Age $USING:1hour -Directions FromLocal -Status PermanentlyBlocked, TemporarilyBlocked -CountOnly})
$inboundDeliveryFailure = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Age $USING:1hour -Directions FromExternal -Status DispatcherError -CountOnly})
$outboundDeliveryFailure = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Age $USING:1hour -Directions FromLocal -Status DispatcherError -CountOnly})
$NDRsSendTotalDE = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Subject "unzustellbar:*" -CountOnly})
$NDRsSendTotalEN = [int](Invoke-Command -Session $session -ScriptBlock {Get-NspMessageTrack -Subject "undeliverable:*" -CountOnly})
Remove-PSSession -Session $session
$totalTraffic = $incoming + $outgoing
$totalRejects = $inboundRejects + $localRejects
$NDRsSendReceived = $NDRsSendTotalDE + $NDRsSendTotalEN
$totalDeliveryFailed = $inboundDeliveryFailure + $outboundDeliveryFailure
#$totalDeliveryFailed = 307
$totalRejectRate = 0
$inboundRejectRate = 0
$localRejectRate = 0
if($totalTraffic -ne 0) {
$totalRejectRate = [Math]::Round($totalRejects / $totalTraffic * 100,0)
if($incoming -ne 0) {
$inboundRejectRate = [Math]::Round($inboundRejects / $incoming * 100,0)
}
if($outgoing -ne 0) {
$localRejectRate = [Math]::Round($localRejects / $outgoing * 100,0)
}
}
$Data = @{
# TotalMailTraffic = $totalTraffic
IncomingMailTraffic = $incoming
OutgoingMailTraffic = $outgoing
DeliveryPendingTotal = $DeliveryPending
# TotalRejectedMails = $totalRejects
IncomingRejectedMails = $inboundRejects
InboundDeliveryFailed = $inboundDeliveryFailure
# TotalDeliveryFailed = $totalDeliveryFailed
OutboundDeliveryFailed = $outboundDeliveryFailure
NDRsSendReceivedTotal = $NDRsSendReceived
OutgoingRejectedMails = $localRejects
# TotalRejectRate = $totalRejectRate
# IncomingRejectRate = $inboundRejectRate
# OutgoingRejectRate = $localRejectRate
}
$Data | ConvertTo-Json -Compress
$Data | ConvertTo-Json | out-file C:\temp\test.json
Code:
function Invoke-SQL {
Param(
[string]$DataSource,
[string]$Database,
[string]$SqlCommand,
[string]$User,
[string]$Password
)
if (($User) -and ($Password)) {
$connectionString = "Data Source=$dataSource;User ID=$User;Password=$Password;Initial Catalog=$Database"
} else {
$connectionString = "Data Source=$dataSource; " + "Integrated Security=SSPI; " + "Initial Catalog=$database"
}
$connection = new-object system.data.SqlClient.SQLConnection($connectionString)
$command = new-object system.data.sqlclient.sqlcommand($sqlCommand,$connection)
$connection.Open()
$adapter = New-Object System.Data.sqlclient.sqlDataAdapter $command
$dataset = New-Object System.Data.DataSet
$adapter.Fill($dataSet) | Out-Null
$connection.Close()
$dataSet.Tables
}
# Example usage (sql auth):
$Artefacts = Invoke-SQL -dataSource SQLServer -database NoSpamProxyAddressSynchronization -user sqlreadinguser -password 12345 -sqlCommand 'SELECT count (*) FROM [DataReplication].[Artefact]'
$Artefacts | select -ExpandProperty Column1