Xymon Mailing List Archive search

custom scripts for windows servers

12 messages in this thread

list Chris Pretorius · Fri, 18 May 2018 12:10:33 +0000 ·
Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file "test.txt" is not created.
There's no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. "C:\groovy-2.4.15\bin\groovy"
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com - this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.

If this were saved as "google-dns.ps1", and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg - you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{
    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<http://www.google.com>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com<http://www.accenture.com>;
list Zak Beck · Fri, 18 May 2018 12:56:57 +0000 ·
Hi

I'm no BBWin expert - have you tried supplying the full path to the groovy executable?

e.g.

<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />

Cheers

Zak
quoted from Chris Pretorius

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid>; xymon at xymon.com
Subject: [External] RE: custom scripts for windows servers

Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file "test.txt" is not created.
There's no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. "C:\groovy-2.4.15\bin\groovy"
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com - this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.

If this were saved as "google-dns.ps1", and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg - you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{
    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;
quoted from Chris Pretorius

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com<http://www.accenture.com>;
list Chris Pretorius · Mon, 21 May 2018 07:02:11 +0000 ·
Hi Zak

Yes I did. Made no difference.
quoted from Zak Beck

Regards

From: Beck, Zak <user-aada0fa38bf8@xymon.invalid>
Sent: Friday, May 18, 2018 2:57 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
Subject: RE: custom scripts for windows servers

Hi

I'm no BBWin expert - have you tried supplying the full path to the groovy executable?

e.g.

<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />

Cheers

Zak

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: custom scripts for windows servers

Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file "test.txt" is not created.
There's no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. "C:\groovy-2.4.15\bin\groovy"
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com - this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.

If this were saved as "google-dns.ps1", and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg - you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{
    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com<http://www.accenture.com>;
list Robert Herron · Tue, 22 May 2018 17:42:02 -0400 ·
What is loglevel set to in the bbwin section of bbwin.cfg?  The
documentation says the default is 0 for no log. 1 = errors, 2 = warnings, 3
= info, 4 = debug.

<configuration>
<bbwin>
<setting name="loglevel" value="3">
<setting name="logpath" value="c:\program files\bbwin\logs\bbwin.log"
...
</bbwin>
...
</configuration>


On May 18, 2018 8:26 AM, "Chris Pretorius" <user-832aac18b2a8@xymon.invalid>
quoted from Chris Pretorius
wrote:

Hi


Our dev decided to create a groovy script since the tests it needs to do is
complex.


He created a small test script which I copied to the ext folder:

test.groovy

def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')

file1.write 'Test message'


Added to externals block:


<externals>

                <setting name="timer" value="3m" />

                <setting name="logstimer" value="60s" />

                <load value="groovy test.groovy" timer="1m" />

                <!-- externals launch examples

                <load value="cscript mybbscript.vbs" />

                <load value="myexternal.exe" />

                <load value="cscript wlbs.vbs" timer="15m" />

                <load value="cluster.exe" timer="90s" /> -->

</externals>


I Also tried the full path to test.groovy.

Restarted the client, I even set the log on as from Local system to
Administrator.


The file “test.txt” is not created.

There’s no errors logged in the BBWin.log


How can I be sure BBwin is executing the script?

Groovy is installed. “C:\groovy-2.4.15\bin\groovy”

I am able to run the script from command prompt and the test.txt file is
created.


Kind regards

*From:* Beck, Zak <user-aada0fa38bf8@xymon.invalid>
*Sent:* Friday, May 4, 2018 12:37 PM
*To:* Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
*Subject:* RE: custome scripts for windows servers


Hi Chris


BBWin or WinPSClient do not have a built in scripting language, they only
support scripts that the OS already knows how to run. This will depend on
what tools you have installed on your servers.


By default, Windows servers will definitely run VBScript (VBS) and most
newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run
Powershell.


There are a number of script samples in BBWin in the externals folder and
for WinPSClient, the documentation is fairly complete in this area.


Both BBWin and WinPSClient can return data from any script if that script
writes a text file to the tmp folder (which is a subfolder of BBWin or
WinPSClient).


Below is a Powershell example of testing DNS lookup for google.com – this
is not necessarily the best way to test DNS, it is provided as a simple
example of an external script.


If this were saved as “google-dns.ps1”, and a SHA1 hash of the file
generated, it can be used with the WinPSClient by adding a line like this
to client-local.cfg – you do not need to replace the {script} with
anything, the client will do that:


external:everyscan:sync:http://<xymon
server>/PS_Updates/google-dns.ps1|SHA1|<sha1
value>|powershell.exe|-executionpolicy remotesigned -noprofile -file
"{script}"


Cheers


Zak


param(

    [string] $TestName = 'googledns'

    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition

$datadir = join-path $scriptdir '..\tmp' -Resolve


$groupColour = 'green'


try

{

    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')

}

catch

{

    $groupColour = 'red'

    $message = "Error performing DNS query: $_"

}


if ($groupColour -eq 'green')

{

    $ips = $results | foreach { $_.IPAddressToString }

    $message = "Result of DNS query:`r`n"

    $message += ($ips -join "`r`n")

}


$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'

$output = `

@"

$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5
minutes)


DNS query for www.google.com


$message


<br><p>Information from $($Env:computername)</p>


"@


$dataFile = Join-Path $datadir $TestName

$output | Set-Content $datafile


*From:* Xymon [mailto:xymon-bounces at xymon.com <xymon-bounces at xymon.com>] *On
quoted from Chris Pretorius
Behalf Of *Chris Pretorius
*Sent:* Friday, 4 May 2018 10:32
*To:* xymon at xymon.com
*Subject:* [External] [Xymon] custome scripts for windows servers


Good day all


Can someone please send links to example custom scripts for windows server.


We are mostly a Linux shop but have a few Windows servers. They are
monitored on xymon and it is currently a mix of BBwin and winpsclients.


My google skills has let me down as I could not find examples except for
bash script examples..


Does BBwin or winpsclient support groovy script or can I only use VBscript?


Kind regards


[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


*Chris Pretorius*

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za
<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer
<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;
quoted from Chris Pretorius


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise confidential information. If you have
received it in error, please notify the sender immediately and delete the
original. Any other use of the e-mail by you is prohibited. Where allowed
by local law, electronic communications with Accenture and its affiliates,
including e-mail and instant messaging (including content), may be scanned
by our systems for the purposes of information security and assessment of
internal compliance with Accenture policy. Your privacy is important to us.
Accenture uses your personal data only in compliance with data protection
laws. For further information on how Accenture processes your personal
data, please see our privacy statement at
https://www.accenture.com/us-en/privacy-policy.
list Robert Herron · Tue, 22 May 2018 17:44:49 -0400 ·
Also, do you have an externals line in the bbwin section?  Do you have
other external tests on this host that work?

On Fri, May 18, 2018, 8:26 AM Chris Pretorius <user-832aac18b2a8@xymon.invalid>
quoted from Robert Herron
wrote:
Hi


Our dev decided to create a groovy script since the tests it needs to do
is complex.


He created a small test script which I copied to the ext folder:

test.groovy

def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')

file1.write 'Test message'


Added to externals block:


<externals>

                <setting name="timer" value="3m" />

                <setting name="logstimer" value="60s" />

                <load value="groovy test.groovy" timer="1m" />

                <!-- externals launch examples

                <load value="cscript mybbscript.vbs" />

                <load value="myexternal.exe" />

                <load value="cscript wlbs.vbs" timer="15m" />

                <load value="cluster.exe" timer="90s" /> -->

</externals>


I Also tried the full path to test.groovy.

Restarted the client, I even set the log on as from Local system to
Administrator.


The file “test.txt” is not created.

There’s no errors logged in the BBWin.log


How can I be sure BBwin is executing the script?

Groovy is installed. “C:\groovy-2.4.15\bin\groovy”

I am able to run the script from command prompt and the test.txt file is
created.


Kind regards

*From:* Beck, Zak <user-aada0fa38bf8@xymon.invalid>
*Sent:* Friday, May 4, 2018 12:37 PM
*To:* Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
*Subject:* RE: custome scripts for windows servers


Hi Chris


BBWin or WinPSClient do not have a built in scripting language, they only
support scripts that the OS already knows how to run. This will depend on
what tools you have installed on your servers.


By default, Windows servers will definitely run VBScript (VBS) and most
newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run
Powershell.


There are a number of script samples in BBWin in the externals folder and
for WinPSClient, the documentation is fairly complete in this area.


Both BBWin and WinPSClient can return data from any script if that script
writes a text file to the tmp folder (which is a subfolder of BBWin or
WinPSClient).


Below is a Powershell example of testing DNS lookup for google.com – this
is not necessarily the best way to test DNS, it is provided as a simple
example of an external script.


If this were saved as “google-dns.ps1”, and a SHA1 hash of the file
generated, it can be used with the WinPSClient by adding a line like this
to client-local.cfg – you do not need to replace the {script} with
anything, the client will do that:


external:everyscan:sync:http://<xymon
server>/PS_Updates/google-dns.ps1|SHA1|<sha1
value>|powershell.exe|-executionpolicy remotesigned -noprofile -file
"{script}"


Cheers


Zak


param(

    [string] $TestName = 'googledns'

    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition

$datadir = join-path $scriptdir '..\tmp' -Resolve


$groupColour = 'green'


try

{

    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')

}

catch

{

    $groupColour = 'red'

    $message = "Error performing DNS query: $_"

}


if ($groupColour -eq 'green')

{

    $ips = $results | foreach { $_.IPAddressToString }

    $message = "Result of DNS query:`r`n"

    $message += ($ips -join "`r`n")

}


$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'

$output = `

@"

$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5
minutes)


DNS query for www.google.com


$message


<br><p>Information from $($Env:computername)</p>


"@


$dataFile = Join-Path $datadir $TestName

$output | Set-Content $datafile


*From:* Xymon [mailto:xymon-bounces at xymon.com <xymon-bounces at xymon.com>] *On
Behalf Of *Chris Pretorius
*Sent:* Friday, 4 May 2018 10:32
*To:* xymon at xymon.com
*Subject:* [External] [Xymon] custome scripts for windows servers


Good day all


Can someone please send links to example custom scripts for windows server.


We are mostly a Linux shop but have a few Windows servers. They are
monitored on xymon and it is currently a mix of BBwin and winpsclients.


My google skills has let me down as I could not find examples except for
bash script examples..


Does BBwin or winpsclient support groovy script or can I only use VBscript?


Kind regards


[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


*Chris Pretorius*

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za
<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer
<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise confidential information. If you have
received it in error, please notify the sender immediately and delete the
original. Any other use of the e-mail by you is prohibited. Where allowed
by local law, electronic communications with Accenture and its affiliates,
including e-mail and instant messaging (including content), may be scanned
by our systems for the purposes of information security and assessment of
internal compliance with Accenture policy. Your privacy is important to us.
Accenture uses your personal data only in compliance with data protection
laws. For further information on how Accenture processes your personal
data, please see our privacy statement at
https://www.accenture.com/us-en/privacy-policy.


www.accenture.com

list Chris Pretorius · Wed, 23 May 2018 12:49:29 +0000 ·
Hi Robert

Thanx for your input.

I don’t have access to the server now as they are busy with critical dev work.

I will set the loglevel as soon as I get a gap.

Regards
quoted from Robert Herron

From: Robert Herron <user-8b27ea4290da@xymon.invalid>
Sent: Tuesday, May 22, 2018 11:42 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid>
Cc: Beck, Zak <user-aada0fa38bf8@xymon.invalid>; xymon Mailing List <xymon at xymon.com>
Subject: Re: [Xymon] custom scripts for windows servers

What is loglevel set to in the bbwin section of bbwin.cfg?  The documentation says the default is 0 for no log. 1 = errors, 2 = warnings, 3 = info, 4 = debug.

<configuration>
<bbwin>
<setting name="loglevel" value="3">
<setting name="logpath" value="c:\program files\bbwin\logs\bbwin.log"
...
</bbwin>
...
</configuration>


On May 18, 2018 8:26 AM, "Chris Pretorius" <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>> wrote:
Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file “test.txt” is not created.
There’s no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. “C:\groovy-2.4.15\bin\groovy”
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com<http://google.com>; – this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.
quoted from Robert Herron

If this were saved as “google-dns.ps1”, and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg – you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{

    $results = [System.Net.DNS]::GetHostAddresses('www.google.com<http://www.google.com>';)
quoted from Robert Herron
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<http://www.google.com>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.
list Alfred Lerch · Thu, 24 May 2018 08:15:03 +0000 ·
Hi,

I found the hard way that BBwin is running in a 32.bit context and that bbwin.cfg requires 8.3 file notation and a full path for the script as well
You might try
<load value=" C:\groovy~1\bin\groovy C:\Progra~2\BBwin\ext\test.groovy" timer="1m" />

Use dir /x to find out how the ~ strings are on your system

Regards

Alfred

PS: I'd rather recommend WinPSClient and PowerShell - well supported and 64-bit proof :)
quoted from Chris Pretorius

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Beck, Zak
Sent: Freitag, 18. Mai 2018 14:57
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
Subject: Re: [Xymon] custom scripts for windows servers

Hi

I'm no BBWin expert - have you tried supplying the full path to the groovy executable?

e.g.

<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />

Cheers

Zak

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: custom scripts for windows servers

Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file "test.txt" is not created.
There's no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. "C:\groovy-2.4.15\bin\groovy"
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com - this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.

If this were saved as "google-dns.ps1", and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg - you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{
    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com<http://www.accenture.com>;
list Chris Pretorius · Thu, 24 May 2018 08:30:42 +0000 ·
Awesome, thanx. Will give it a try.
quoted from Alfred Lerch

From: Lerch, Alfred <user-d5fb06881473@xymon.invalid>
Sent: Thursday, May 24, 2018 10:15 AM
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid>; Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
Subject: RE: custom scripts for windows servers

Hi,

I found the hard way that BBwin is running in a 32.bit context and that bbwin.cfg requires 8.3 file notation and a full path for the script as well
You might try
<load value=" C:\groovy~1\bin\groovy C:\Progra~2\BBwin\ext\test.groovy" timer="1m" />

Use dir /x to find out how the ~ strings are on your system

Regards

Alfred

PS: I'd rather recommend WinPSClient and PowerShell - well supported and 64-bit proof :)

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Beck, Zak
Sent: Freitag, 18. Mai 2018 14:57
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] custom scripts for windows servers

Hi

I'm no BBWin expert - have you tried supplying the full path to the groovy executable?

e.g.

<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />

Cheers

Zak

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: custom scripts for windows servers

Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file "test.txt" is not created.
There's no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. "C:\groovy-2.4.15\bin\groovy"
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com - this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.

If this were saved as "google-dns.ps1", and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg - you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{
    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com<http://www.accenture.com>;
list Chris Pretorius · Thu, 24 May 2018 08:53:30 +0000 ·
Hi

Made the following changes.

C:\>dir /x
Volume in drive C has no label.
Volume Serial Number is A869-53E2

Directory of C:\

2018-05-04  11:13 AM    <DIR>          GROOVY~1.15  groovy-2.4.15
2018-05-10  11:48 AM    <DIR>          PROGRA~1     Program Files
2018-05-17  12:11 PM    <DIR>          PROGRA~2     Program Files (x86)

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="C:\GROOVY~1.15\bin\groovy C:\PROGRA~2\BBWin\ext\test.groovy" timer="1m" />
</externals>

I also changed the test groovy script. test.groovy
def file1 = new File('C:\PROGRA~2\BBWin\tmp\test.txt')
file1.write 'Test message'

The test.txt file is not created

BBWin logs:
2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent started
2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent ended
2018/05/24 10:44:49 [DEBUG]: [disk]: init disk agent AgentDisk::Init
2018/05/24 10:44:49 [INFO]: [filesystem]: failed to save logfetch status C:\Program Files (x86)\BBWin\tmp\logfetch.status : The system cannot find the file specified.
2018/05/24 10:44:49 [DEBUG]: [msgs]: Begin Msgs Initialization AgentMsgs::Init
2018/05/24 10:44:49 [DEBUG]: [msgs]: Ending Msgs Initialization
2018/05/24 10:44:49 [DEBUG]: Starting hobbit client agent.
2018/05/24 10:44:49 [DEBUG]: [externals]: starting external 'C:\GROOVY~1.15\bin\groovy C:\PROGRA~2\BBWin\ext\test.groovy'
2018/05/24 10:44:49 [INFO]: bbwin is started.

Regards
quoted from Chris Pretorius

From: Lerch, Alfred <user-d5fb06881473@xymon.invalid>
Sent: Thursday, May 24, 2018 10:15 AM
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid>; Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
Subject: RE: custom scripts for windows servers

Hi,

I found the hard way that BBwin is running in a 32.bit context and that bbwin.cfg requires 8.3 file notation and a full path for the script as well
You might try
<load value=" C:\groovy~1\bin\groovy C:\Progra~2\BBwin\ext\test.groovy" timer="1m" />

Use dir /x to find out how the ~ strings are on your system

Regards

Alfred

PS: I'd rather recommend WinPSClient and PowerShell - well supported and 64-bit proof :)

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Beck, Zak
Sent: Freitag, 18. Mai 2018 14:57
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] custom scripts for windows servers

Hi

I'm no BBWin expert - have you tried supplying the full path to the groovy executable?

e.g.

<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />

Cheers

Zak

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: custom scripts for windows servers

Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file "test.txt" is not created.
There's no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. "C:\groovy-2.4.15\bin\groovy"
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com - this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.

If this were saved as "google-dns.ps1", and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg - you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{
    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.

www.accenture.com<http://www.accenture.com>;
list Robert Herron · Thu, 24 May 2018 05:51:52 -0400 ·
Test.groovy isn't an 8.3 filename but that doesn't seem to matter. If bbwin
had a problem, I would expect something in the log about file not found --
similar to the logfetch message.

Have you checked Task Manager to seee if there a orphanned groovy
processes?  The bbwin.log says it started groovy so maybe it's not fully
initializing, can't open the groovy script, etc.  I know you said you can
manually run the script so maybe the user/context bbwin runs under doesn't
have permissions to the groovy executable.

Also, may create a simple "hello world" BAT or CMD file and add it as an
external test.  This should help prove bbwin can run externals and
hopefully better narrow the problem.

On Thu, May 24, 2018, 4:53 AM Chris Pretorius <user-832aac18b2a8@xymon.invalid>
quoted from Chris Pretorius
wrote:
Hi


Made the following changes.


C:\>dir /x

Volume in drive C has no label.

Volume Serial Number is A869-53E2


Directory of C:\


2018-05-04  11:13 AM    <DIR>          GROOVY~1.15  groovy-2.4.15

2018-05-10  11:48 AM    <DIR>          PROGRA~1     Program Files

2018-05-17  12:11 PM    <DIR>          PROGRA~2     Program Files (x86)


<externals>

                <setting name="timer" value="3m" />

                <setting name="logstimer" value="60s" />

                <load value="C:\GROOVY~1.15\bin\groovy
C:\PROGRA~2\BBWin\ext\test.groovy" timer="1m" />

</externals>


I also changed the test groovy script. test.groovy

def file1 = new File('C:\PROGRA~2\BBWin\tmp\test.txt')

file1.write 'Test message'


The test.txt file is not created


BBWin logs:

2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent started

2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent ended

2018/05/24 10:44:49 [DEBUG]: [disk]: init disk agent AgentDisk::Init

2018/05/24 10:44:49 [INFO]: [filesystem]: failed to save logfetch status
C:\Program Files (x86)\BBWin\tmp\logfetch.status : The system cannot find
the file specified.

2018/05/24 10:44:49 [DEBUG]: [msgs]: Begin Msgs Initialization
AgentMsgs::Init

2018/05/24 10:44:49 [DEBUG]: [msgs]: Ending Msgs Initialization

2018/05/24 10:44:49 [DEBUG]: Starting hobbit client agent.

2018/05/24 10:44:49 [DEBUG]: [externals]: starting external
'C:\GROOVY~1.15\bin\groovy C:\PROGRA~2\BBWin\ext\test.groovy'

2018/05/24 10:44:49 [INFO]: bbwin is started.


Regards


*From:* Lerch, Alfred <user-d5fb06881473@xymon.invalid>
*Sent:* Thursday, May 24, 2018 10:15 AM
*To:* Beck, Zak <user-aada0fa38bf8@xymon.invalid>; Chris Pretorius <
user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
*Subject:* RE: custom scripts for windows servers


Hi,


I found the hard way that BBwin is running in a 32.bit context and that
bbwin.cfg requires 8.3 file notation and a full path for the script as well

You might try

<load value=" C:\groovy~1\bin\groovy C:\Progra~2\BBwin\ext\test.groovy"
timer="1m" />


Use dir /x to find out how the ~ strings are on your system


Regards


Alfred


PS: I’d rather recommend WinPSClient and PowerShell – well supported and

64-bit proof J
quoted from Chris Pretorius


*From:* Xymon [mailto:xymon-bounces at xymon.com <xymon-bounces at xymon.com>] *On
Behalf Of *Beck, Zak
*Sent:* Freitag, 18. Mai 2018 14:57
*To:* Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
*Subject:* Re: [Xymon] custom scripts for windows servers


Hi


I’m no BBWin expert – have you tried supplying the full path to the groovy
executable?


e.g.


<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />


Cheers


Zak


*From:* Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid

<user-832aac18b2a8@xymon.invalid>]
quoted from Chris Pretorius
*Sent:* Friday, 18 May 2018 13:11
*To:* Beck, Zak <user-aada0fa38bf8@xymon.invalid>; xymon at xymon.com
*Subject:* [External] RE: custom scripts for windows servers


Hi


Our dev decided to create a groovy script since the tests it needs to do
is complex.


He created a small test script which I copied to the ext folder:

test.groovy

def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')

file1.write 'Test message'


Added to externals block:


<externals>

                <setting name="timer" value="3m" />

                <setting name="logstimer" value="60s" />

                <load value="groovy test.groovy" timer="1m" />

                <!-- externals launch examples

                <load value="cscript mybbscript.vbs" />

                <load value="myexternal.exe" />

                <load value="cscript wlbs.vbs" timer="15m" />

                <load value="cluster.exe" timer="90s" /> -->

</externals>


I Also tried the full path to test.groovy.

Restarted the client, I even set the log on as from Local system to
Administrator.


The file “test.txt” is not created.

There’s no errors logged in the BBWin.log


How can I be sure BBwin is executing the script?

Groovy is installed. “C:\groovy-2.4.15\bin\groovy”

I am able to run the script from command prompt and the test.txt file is
created.


Kind regards

*From:* Beck, Zak <user-aada0fa38bf8@xymon.invalid>
*Sent:* Friday, May 4, 2018 12:37 PM
*To:* Chris Pretorius <user-832aac18b2a8@xymon.invalid>; xymon at xymon.com
*Subject:* RE: custome scripts for windows servers


Hi Chris


BBWin or WinPSClient do not have a built in scripting language, they only
support scripts that the OS already knows how to run. This will depend on
what tools you have installed on your servers.


By default, Windows servers will definitely run VBScript (VBS) and most
newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run
Powershell.


There are a number of script samples in BBWin in the externals folder and
for WinPSClient, the documentation is fairly complete in this area.


Both BBWin and WinPSClient can return data from any script if that script
writes a text file to the tmp folder (which is a subfolder of BBWin or
WinPSClient).


Below is a Powershell example of testing DNS lookup for google.com – this
is not necessarily the best way to test DNS, it is provided as a simple
example of an external script.


If this were saved as “google-dns.ps1”, and a SHA1 hash of the file
generated, it can be used with the WinPSClient by adding a line like this
to client-local.cfg – you do not need to replace the {script} with
anything, the client will do that:


external:everyscan:sync:http://<xymon
server>/PS_Updates/google-dns.ps1|SHA1|<sha1
value>|powershell.exe|-executionpolicy remotesigned -noprofile -file
"{script}"


Cheers


Zak


param(

    [string] $TestName = 'googledns'

    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition

$datadir = join-path $scriptdir '..\tmp' -Resolve


$groupColour = 'green'


try

{

    $results = [System.Net.DNS]::GetHostAddresses('www.google.com')

}

catch

{

    $groupColour = 'red'

    $message = "Error performing DNS query: $_"

}


if ($groupColour -eq 'green')

{

    $ips = $results | foreach { $_.IPAddressToString }

    $message = "Result of DNS query:`r`n"

    $message += ($ips -join "`r`n")

}


$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'

$output = `

@"

$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5
minutes)


DNS query for www.google.com

<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;
quoted from Chris Pretorius


$message


<br><p>Information from $($Env:computername)</p>


"@


$dataFile = Join-Path $datadir $TestName

$output | Set-Content $datafile


*From:* Xymon [mailto:xymon-bounces at xymon.com <xymon-bounces at xymon.com>] *On
Behalf Of *Chris Pretorius
*Sent:* Friday, 4 May 2018 10:32
*To:* xymon at xymon.com
*Subject:* [External] [Xymon] custome scripts for windows servers


Good day all


Can someone please send links to example custom scripts for windows server.


We are mostly a Linux shop but have a few Windows servers. They are
monitored on xymon and it is currently a mix of BBwin and winpsclients.


My google skills has let me down as I could not find examples except for
bash script examples..


Does BBwin or winpsclient support groovy script or can I only use VBscript?


Kind regards


[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


*Chris Pretorius*

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za
<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[image: https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer
<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise confidential information. If you have
received it in error, please notify the sender immediately and delete the
original. Any other use of the e-mail by you is prohibited. Where allowed
by local law, electronic communications with Accenture and its affiliates,
including e-mail and instant messaging (including content), may be scanned
by our systems for the purposes of information security and assessment of
internal compliance with Accenture policy. Your privacy is important to us.
Accenture uses your personal data only in compliance with data protection
laws. For further information on how Accenture processes your personal
data, please see our privacy statement at
https://www.accenture.com/us-en/privacy-policy.


www.accenture.com

list Chris Pretorius · Thu, 7 Jun 2018 12:14:12 +0000 ·
Good day

I gave up with BBWin and ended installing xymonpsclient.

It configured and reporting to the xymon server.

How do I configure XymonPSClient to run my test script?
Can you please send links with examples so I can see where I went wrong.
quoted from Robert Herron


Regards

From: Robert Herron <user-8b27ea4290da@xymon.invalid>
Sent: Thursday, May 24, 2018 11:52 AM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid>
Cc: Lerch, Alfred <user-d5fb06881473@xymon.invalid>; Beck, Zak <user-aada0fa38bf8@xymon.invalid>; xymon at xymon.com
Subject: Re: [Xymon] custom scripts for windows servers

Test.groovy isn't an 8.3 filename but that doesn't seem to matter. If bbwin had a problem, I would expect something in the log about file not found -- similar to the logfetch message.

Have you checked Task Manager to seee if there a orphanned groovy processes?  The bbwin.log says it started groovy so maybe it's not fully initializing, can't open the groovy script, etc.  I know you said you can manually run the script so maybe the user/context bbwin runs under doesn't have permissions to the groovy executable.

Also, may create a simple "hello world" BAT or CMD file and add it as an external test.  This should help prove bbwin can run externals and hopefully better narrow the problem.
On Thu, May 24, 2018, 4:53 AM Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>> wrote:
Hi

Made the following changes.

C:\>dir /x
Volume in drive C has no label.
Volume Serial Number is A869-53E2

Directory of C:\

2018-05-04  11:13 AM    <DIR>          GROOVY~1.15  groovy-2.4.15
2018-05-10  11:48 AM    <DIR>          PROGRA~1     Program Files
2018-05-17  12:11 PM    <DIR>          PROGRA~2     Program Files (x86)

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="C:\GROOVY~1.15\bin\groovy C:\PROGRA~2\BBWin\ext\test.groovy" timer="1m" />
</externals>

I also changed the test groovy script. test.groovy
def file1 = new File('C:\PROGRA~2\BBWin\tmp\test.txt')
file1.write 'Test message'

The test.txt file is not created

BBWin logs:
2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent started
2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent ended
2018/05/24 10:44:49 [DEBUG]: [disk]: init disk agent AgentDisk::Init
2018/05/24 10:44:49 [INFO]: [filesystem]: failed to save logfetch status C:\Program Files (x86)\BBWin\tmp\logfetch.status : The system cannot find the file specified.
2018/05/24 10:44:49 [DEBUG]: [msgs]: Begin Msgs Initialization AgentMsgs::Init
2018/05/24 10:44:49 [DEBUG]: [msgs]: Ending Msgs Initialization
2018/05/24 10:44:49 [DEBUG]: Starting hobbit client agent.
2018/05/24 10:44:49 [DEBUG]: [externals]: starting external 'C:\GROOVY~1.15\bin\groovy C:\PROGRA~2\BBWin\ext\test.groovy'
2018/05/24 10:44:49 [INFO]: bbwin is started.

Regards

From: Lerch, Alfred <user-d5fb06881473@xymon.invalid<mailto:user-d5fb06881473@xymon.invalid>>
Sent: Thursday, May 24, 2018 10:15 AM
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custom scripts for windows servers

Hi,

I found the hard way that BBwin is running in a 32.bit context and that bbwin.cfg requires 8.3 file notation and a full path for the script as well
You might try
<load value=" C:\groovy~1\bin\groovy C:\Progra~2\BBwin\ext\test.groovy" timer="1m" />

Use dir /x to find out how the ~ strings are on your system

Regards

Alfred

PS: I’d rather recommend WinPSClient and PowerShell – well supported and 64-bit proof ☺

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Beck, Zak
Sent: Freitag, 18. Mai 2018 14:57
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] custom scripts for windows servers

Hi

I’m no BBWin expert – have you tried supplying the full path to the groovy executable?

e.g.

<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />

Cheers

Zak

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: custom scripts for windows servers

Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file “test.txt” is not created.
There’s no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. “C:\groovy-2.4.15\bin\groovy”
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com<http://google.com>; – this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.

If this were saved as “google-dns.ps1”, and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg – you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{
    $results = [System.Net.DNS]::GetHostAddresses('www.google.com<http://www.google.com>';)
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.
list Zak Beck · Fri, 8 Jun 2018 14:35:16 +0000 ·
Hi Chris

There’s a couple of sections on this with examples in the documentation (https://sourceforge.net/p/xymon/code/HEAD/tree/sandbox/WinPSClient/, XymonPSClient.doc). Could you take a look and then show us what you have configured?

Thanks
quoted from Chris Pretorius

Zak

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Thursday, 7 June 2018 13:14
To: xymon at xymon.com
Cc: Lerch, Alfred <user-d5fb06881473@xymon.invalid>; Beck, Zak <user-aada0fa38bf8@xymon.invalid>; Robert Herron <user-8b27ea4290da@xymon.invalid>
Subject: [External] RE: [Xymon] custom scripts for windows servers

Good day

I gave up with BBWin and ended installing xymonpsclient.

It configured and reporting to the xymon server.

How do I configure XymonPSClient to run my test script?
Can you please send links with examples so I can see where I went wrong.


Regards

From: Robert Herron <user-8b27ea4290da@xymon.invalid<mailto:user-8b27ea4290da@xymon.invalid>>
Sent: Thursday, May 24, 2018 11:52 AM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>
Cc: Lerch, Alfred <user-d5fb06881473@xymon.invalid<mailto:user-d5fb06881473@xymon.invalid>>; Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] custom scripts for windows servers

Test.groovy isn't an 8.3 filename but that doesn't seem to matter. If bbwin had a problem, I would expect something in the log about file not found -- similar to the logfetch message.

Have you checked Task Manager to seee if there a orphanned groovy processes?  The bbwin.log says it started groovy so maybe it's not fully initializing, can't open the groovy script, etc.  I know you said you can manually run the script so maybe the user/context bbwin runs under doesn't have permissions to the groovy executable.

Also, may create a simple "hello world" BAT or CMD file and add it as an external test.  This should help prove bbwin can run externals and hopefully better narrow the problem.
On Thu, May 24, 2018, 4:53 AM Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>> wrote:
Hi

Made the following changes.

C:\>dir /x
Volume in drive C has no label.
Volume Serial Number is A869-53E2

Directory of C:\

2018-05-04  11:13 AM    <DIR>          GROOVY~1.15  groovy-2.4.15
2018-05-10  11:48 AM    <DIR>          PROGRA~1     Program Files
2018-05-17  12:11 PM    <DIR>          PROGRA~2     Program Files (x86)

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="C:\GROOVY~1.15\bin\groovy C:\PROGRA~2\BBWin\ext\test.groovy" timer="1m" />
</externals>

I also changed the test groovy script. test.groovy
def file1 = new File('C:\PROGRA~2\BBWin\tmp\test.txt')
file1.write 'Test message'

The test.txt file is not created

BBWin logs:
2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent started
2018/05/24 10:44:49 [DEBUG]: [cpu]: initialization cpu agent ended
2018/05/24 10:44:49 [DEBUG]: [disk]: init disk agent AgentDisk::Init
2018/05/24 10:44:49 [INFO]: [filesystem]: failed to save logfetch status C:\Program Files (x86)\BBWin\tmp\logfetch.status : The system cannot find the file specified.
2018/05/24 10:44:49 [DEBUG]: [msgs]: Begin Msgs Initialization AgentMsgs::Init
2018/05/24 10:44:49 [DEBUG]: [msgs]: Ending Msgs Initialization
2018/05/24 10:44:49 [DEBUG]: Starting hobbit client agent.
2018/05/24 10:44:49 [DEBUG]: [externals]: starting external 'C:\GROOVY~1.15\bin\groovy C:\PROGRA~2\BBWin\ext\test.groovy'
2018/05/24 10:44:49 [INFO]: bbwin is started.

Regards

From: Lerch, Alfred <user-d5fb06881473@xymon.invalid<mailto:user-d5fb06881473@xymon.invalid>>
Sent: Thursday, May 24, 2018 10:15 AM
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custom scripts for windows servers

Hi,

I found the hard way that BBwin is running in a 32.bit context and that bbwin.cfg requires 8.3 file notation and a full path for the script as well
You might try
<load value=" C:\groovy~1\bin\groovy C:\Progra~2\BBwin\ext\test.groovy" timer="1m" />

Use dir /x to find out how the ~ strings are on your system

Regards

Alfred

PS: I’d rather recommend WinPSClient and PowerShell – well supported and 64-bit proof ☺

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Beck, Zak
Sent: Freitag, 18. Mai 2018 14:57
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] custom scripts for windows servers

Hi

I’m no BBWin expert – have you tried supplying the full path to the groovy executable?

e.g.

<load value=" C:\groovy-2.4.15\bin\groovy test.groovy" timer="1m" />

Cheers

Zak

From: Chris Pretorius [mailto:user-832aac18b2a8@xymon.invalid]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: custom scripts for windows servers

Hi

Our dev decided to create a groovy script since the tests it needs to do is complex.

He created a small test script which I copied to the ext folder:
test.groovy
def file1 = new File('C:/Program Files (x86)/BBWin/tmp/test.txt')
file1.write 'Test message'

Added to externals block:

<externals>
                <setting name="timer" value="3m" />
                <setting name="logstimer" value="60s" />
                <load value="groovy test.groovy" timer="1m" />
                <!-- externals launch examples
                <load value="cscript mybbscript.vbs" />
                <load value="myexternal.exe" />
                <load value="cscript wlbs.vbs" timer="15m" />
                <load value="cluster.exe" timer="90s" /> -->
</externals>

I Also tried the full path to test.groovy.
Restarted the client, I even set the log on as from Local system to Administrator.

The file “test.txt” is not created.
There’s no errors logged in the BBWin.log

How can I be sure BBwin is executing the script?
Groovy is installed. “C:\groovy-2.4.15\bin\groovy”
I am able to run the script from command prompt and the test.txt file is created.

Kind regards
From: Beck, Zak <user-aada0fa38bf8@xymon.invalid<mailto:user-aada0fa38bf8@xymon.invalid>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <user-832aac18b2a8@xymon.invalid<mailto:user-832aac18b2a8@xymon.invalid>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: custome scripts for windows servers

Hi Chris

BBWin or WinPSClient do not have a built in scripting language, they only support scripts that the OS already knows how to run. This will depend on what tools you have installed on your servers.

By default, Windows servers will definitely run VBScript (VBS) and most newer versions (Windows Server 2008 onwards, Windows 7 onwards) will run Powershell.

There are a number of script samples in BBWin in the externals folder and for WinPSClient, the documentation is fairly complete in this area.

Both BBWin and WinPSClient can return data from any script if that script writes a text file to the tmp folder (which is a subfolder of BBWin or WinPSClient).

Below is a Powershell example of testing DNS lookup for google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__google.com&d=DwMGaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=9EnjlE3SqvvjaWqH6OgBdXOFtgfd6IaS5xr1J4qIfJM&s=-390mJ2uQ4ZpDhAf7A0dhaPEv8x6KupTpOoc7XwQWp0&e=>; – this is not necessarily the best way to test DNS, it is provided as a simple example of an external script.
quoted from Chris Pretorius

If this were saved as “google-dns.ps1”, and a SHA1 hash of the file generated, it can be used with the WinPSClient by adding a line like this to client-local.cfg – you do not need to replace the {script} with anything, the client will do that:

external:everyscan:sync:http://<xymon server>/PS_Updates/google-dns.ps1|SHA1|<sha1 value>|powershell.exe|-executionpolicy remotesigned -noprofile -file "{script}"

Cheers

Zak

param(
    [string] $TestName = 'googledns'
    )


$scriptdir = split-path -parent $MyInvocation.MyCommand.Definition
$datadir = join-path $scriptdir '..\tmp' -Resolve

$groupColour = 'green'

try
{

    $results = [System.Net.DNS]::GetHostAddresses('www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMGaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=9EnjlE3SqvvjaWqH6OgBdXOFtgfd6IaS5xr1J4qIfJM&s=pKL3_aRmNrvMmn-mmHg41R92k10htJKCQH9MIGAMj7Q&e=>';)
quoted from Chris Pretorius
}
catch
{
    $groupColour = 'red'
    $message = "Error performing DNS query: $_"
}

if ($groupColour -eq 'green')
{
    $ips = $results | foreach { $_.IPAddressToString }
    $message = "Result of DNS query:`r`n"
    $message += ($ips -join "`r`n")
}

$timeFormatted = Get-Date -Format 'dd-MMM-yyyy HH:mm'
$output = `
@"
$($groupColour)+10m $TestName as at $timeFormatted (updated approx every 5 minutes)

DNS query for www.google.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.google.com&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=ehH4bK0KVKjrTOWMKx0blROIXhuYtKDkAY-5Dx33TAY&s=MQyttX_Krv5ePOOct2Oj-hvX5UZfhfvJCIir9vTbnEo&e=>;

$message

<br><p>Information from $($Env:computername)</p>

"@

$dataFile = Join-Path $datadir $TestName
$output | Set-Content $datafile


From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Chris Pretorius
Sent: Friday, 4 May 2018 10:32
To: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] [Xymon] custome scripts for windows servers

Good day all

Can someone please send links to example custom scripts for windows server.

We are mostly a Linux shop but have a few Windows servers. They are monitored on xymon and it is currently a mix of BBwin and winpsclients.

My google skills has let me down as I could not find examples except for bash script examples..

Does BBwin or winpsclient support groovy script or can I only use VBscript?

Kind regards

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/AUTOlogoW.png]


Chris Pretorius

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/phone.png]

0872367740

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/email.png]

user-3fef1df92e88@xymon.invalid<mailto:user-3fef1df92e88@xymon.invalid>

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/web.png]

www.signio.co.za<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.signio.co.za&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=r79tHecFmkZS4Rbtj5kLMAraNByFoS72NbMZKxd1RA0&e=>;

[https://lsc-assets.scdn1.secure.raxcdn.com/lssig/address.png]

Centurion Square, 3rd Floor, cnr Heuwel and Gordon Hood rd, Centurion


This communication is subject to Lightstone's email disclaimer<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.lightstone.co.za_portal_content_email-2Ddisclaimer.aspx&d=DwMFAg&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=pSAlFEj4hRKElAZwLvHsRfWzfQja9_NJ4QDJTay2kjA&s=WjjJGAqyaTDuEZEXWKI9C5QN006jNlgDG-2MU9-IWoA&e=>;


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.