[Xymon] custom scripts for windows servers

Robert Herron robert.herron at gmail.com
Thu May 24 11:51:52 CEST 2018


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 <chrisp at lightstoneauto.co.za>
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 <alfred_lerch at mentor.com>
> *Sent:* Thursday, May 24, 2018 10:15 AM
> *To:* Beck, Zak <zak.beck at accenture.com>; Chris Pretorius <
> chrisp at lightstoneauto.co.za>; 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
>
>
>
> *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 <chrisp at lightstoneauto.co.za>; 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:chrisp at lightstoneauto.co.za
> <chrisp at lightstoneauto.co.za>]
> *Sent:* Friday, 18 May 2018 13:11
> *To:* Beck, Zak <zak.beck at accenture.com>; 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>
> *Sent:* Friday, May 4, 2018 12:37 PM
> *To:* Chris Pretorius <chrisp at lightstoneauto.co.za>; 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 <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]
>
> chrisp at lightstone.co.za
>
> [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
> _______________________________________________
> Xymon mailing list
> Xymon at xymon.com
> http://lists.xymon.com/mailman/listinfo/xymon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180524/488186bc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4816 bytes
Desc: not available
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20180524/488186bc/attachment.png>


More information about the Xymon mailing list