[Xymon] custom scripts for windows servers

Chris Pretorius chrisp at lightstoneauto.co.za
Mon May 21 09:02:11 CEST 2018


Hi Zak

Yes I did. Made no difference.

Regards

From: Beck, Zak <zak.beck at accenture.com>
Sent: Friday, May 18, 2018 2:57 PM
To: Chris Pretorius <chrisp at lightstoneauto.co.za>; 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:chrisp at lightstoneauto.co.za]
Sent: Friday, 18 May 2018 13:11
To: Beck, Zak <zak.beck at accenture.com<mailto:zak.beck at accenture.com>>; 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 <zak.beck at accenture.com<mailto:zak.beck at accenture.com>>
Sent: Friday, May 4, 2018 12:37 PM
To: Chris Pretorius <chrisp at lightstoneauto.co.za<mailto:chrisp at lightstoneauto.co.za>>; 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]

chrisp at lightstone.co.za<mailto:chrisp at lightstone.co.za>

[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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180521/a9f0f475/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4816 bytes
Desc: image001.png
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180521/a9f0f475/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 503 bytes
Desc: image002.png
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180521/a9f0f475/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 589 bytes
Desc: image003.png
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180521/a9f0f475/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 574 bytes
Desc: image004.png
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180521/a9f0f475/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 505 bytes
Desc: image005.png
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180521/a9f0f475/attachment-0004.png>


More information about the Xymon mailing list