Hi Alexander

Thank you very much for the quick reply.
I’ll give this a look.


Kind regards
Roel

From: Gruber Alexander [mailto:alexander.gru...@az-druck.de]
Sent: donderdag 10 december 2015 15:27
To: zenloadbalancer-support@lists.sourceforge.net
Subject: Re: [Zenloadbalancer-support] 3th party monitoring

HI,

We use PRTG to monitor ZEN with a powershell Script:




$username = 'admin'
$password = 'XXXX'
$zen1 = "192.168.20.111"
$zen2 = "192.168.20.112"
$farm = "FARMNAME"
$checktyp = "master"

if($args.Length -eq 2){
     $farm           = $args[0]
     $checktyp       = $args[1]
}

if($checktyp -ne "session" -and $checktyp -ne "server" -and $checktyp -ne 
"master") {
     $x = [string]-1 + ":Falscher checktyp!"
     write-host $x
     exit 2
}

# SSL Zertifikatsfehler ignorieren, bis powershell console geschlossen wird
function AllowUntrustetSSL(){
     [System.Net.ServicePointManager]::ServerCertificateValidationCallback = 
{$true}
     $netAssembly = 
[Reflection.Assembly]::GetAssembly([System.Net.Configuration.SettingsSection])
     if($netAssembly)
     {
          $bindingFlags = [Reflection.BindingFlags] 
"Static,GetProperty,NonPublic"
          $settingsType = 
$netAssembly.GetType("System.Net.Configuration.SettingsSectionInternal")

          $instance = $settingsType.InvokeMember("Section", $bindingFlags, 
$null, $null, @())

          if($instance)
          {
               $bindingFlags = "NonPublic","Instance"
               $useUnsafeHeaderParsingField = 
$settingsType.GetField("useUnsafeHeaderParsing", $bindingFlags)

               if($useUnsafeHeaderParsingField)
               {
                 $useUnsafeHeaderParsingField.SetValue($instance, $true)
               }
          }
     }
}

function DownloadWithAuth{
    Param (
         [string]$user,
         [string]$pw,
         [string]$url
    )
    AllowUntrustetSSL
    $auth = 'Basic ' + 
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($user+":"+$pw
 ))
    $req = New-Object System.Net.WebClient
    $req.Headers.Add('Content-Type', 'application/xml')
    $req.Headers.Add('Accept', 'application/xml')
    $req.Headers.Add('Authorization', $auth )
    #write-host $url
    try {
        $Result = $req.DownloadString($url)
    }
    catch{
        $Result = ""
    }
    return $Result
}

function FindInFarmStatus{
     Param (
          [string]$farm,
          [string]$suche,
          [string]$master
     )
     $url = "https://"+ $master 
+":444/index.cgi?id=1-2&action=managefarm&farmname=" + $farm
     $check = DownloadWithAuth $username $password $url

     if($check.Contains($suche)){
          return 0
     }
     else{
          return 1
     }
}

function GetMaster(){
     $master      = ""
     $url           = "https://"; + $zen1 + ":444/index.cgi?id=1-2"
     $check           = DownloadWithAuth $username $password $url
     if($check.Contains("this node is master")){
          $master = $zen1
     }
     else{
          $url = "https://"+$zen2+":444/index.cgi?id=1-2";
          $check = DownloadWithAuth $username $password $url
          if($check.Contains("this node is master")){
                 $master = $zen2
          }
     }
     return $master
}

function GetServerZahlen(){
    Param (
        [string]$master,
        [string]$farm
    )

     $url           = "https://"; + $master + 
":444/index.cgi?id=1-2&action=managefarm&farmname=" + $farm
     $check           = DownloadWithAuth $username $password $url

     $treffer = $check | select-string -pattern "(\d)*( servers, )(\d)*( 
active)" -AllMatches | % { $_.Matches } | % { $_.Value }
     $anz = $treffer.split(" ")
     $server = @($anz[2],$anz[0])
     return $server
}

function GetSessionZahlen(){
    Param (
        [string]$master,
        [string]$farm
    )

     $url           = "https://"; + $master + 
":444/index.cgi?id=1-2&action=managefarm&farmname=" + $farm
     $check           = DownloadWithAuth $username $password $url

     $treffer = $check | select-string -pattern "(\d)*( active sessions)" 
-AllMatches | % { $_.Matches } | % { $_.Value }
     $anz = $treffer.split(" ")
     return $anz[0]
}

$master = GetMaster

if($master -eq ""){
     $x = [string]-1 + ":Kein ZEN Master!"
     write-host $x
     exit 2
}
elseif($checktyp -eq "session"){
     $anz = GetSessionZahlen $master $farm
    $x = [string] + $anz + ":Sessions"
    write-host $x
    exit 0
}
elseif($checktyp -eq "server"){
     $anz = GetServerZahlen $master $farm
    $x = [string] + $anz[0] + ":Server von " + $anz[1]
    write-host $x
    exit 0
}
elseif($checktyp -eq "master"){
     if($master -eq $zen1){ $x = [string] 1 + ":Master " + $zen1 }
     elseif($master -eq $zen2){ $x = [string] 2 + ":Master " + $zen2 }
    else{ $x = [string] 0 + ":Master " + $master }
    write-host $x
    exit 0
}






Regards
Alex


Von: Roel van Daal [mailto:roel.vand...@cheops.be]
Gesendet: Donnerstag, 10. Dezember 2015 15:07
An: 
zenloadbalancer-support@lists.sourceforge.net<mailto:zenloadbalancer-support@lists.sourceforge.net>
Betreff: [Zenloadbalancer-support] 3th party monitoring

Hi

I’m testing the zen loadbalancer and I’m looking for a way to monitor some 
things with 3th party software.
Is there a way to do this for example with snmp or something?
Anyone any idea’s

I’m specifically looking on how to monitor the connections on a farm.

Kind regards
roel

Roel van Daal

Support Engineer



T +32 3 880 23 00

[cid:image001.jpg@01D1336D.CF7DE040]<http://www.cheops.be>
------------------------------------------------------------------------------
_______________________________________________
Zenloadbalancer-support mailing list
Zenloadbalancer-support@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/zenloadbalancer-support

Reply via email to