Xymon Mailing List Archive search

Windows Powershell client v2.15

7 messages in this thread

list Zak Beck · Thu, 28 Apr 2016 09:08:45 +0000 ·
Hi

 
I have today committed v2.15. This has a big, new feature that we've been
working on internally for some time and testing in our environment, that is,
external scripts and external data.

 
As far as is possible, I have replicated the BBWin functionality for
external data. Data files in the 'externaldatalocation' directory
(installdir\tmp by default) with the correct file format will be uploaded to
Xymon. You can therefore run external scripts, have them produce status data
files in the correct format and that will be uploaded. The format is the
same as BBWin and that described in 'Xymon Message Syntax' on this page:
http://xymon.sourceforge.net/xymon/help/manpages/man1/xymon.1.html. The
sample scripts supplied with BBWin, e.g. fsmon.vbs, should work without
material changes (fsmon for example looks in the registry for a couple of
locations of folders, this may need changing if you have never installed
BBWin).

 
You can now also specify external scripts in client-local.cfg to be run
either every scan or every "slow" scan, and they can be sent to run
synchronously or asynchronously - therefore a relatively simple external
script scheduler. The scripts can either pre-exist on the target or they can
be downloaded from a central web server or file share (like client updates).
Script versioning is controlled via hashes - this has also been extended to
client updates (optionally).

 
Obviously the use of external scripts requires some care - for example, if
you specify synchronous execution and your script never completes,
XymonPSClient will be left waiting forever. If you specify asynchronous and
your script never completes, you can end up with multiple processes building
up over time. It's quite difficult to work out what may be happening with
external scripts if you do not have any form of logging in your script, just
as it would be with BBWin - therefore if you're having trouble, I recommend
logging to file at various points in your script and the start and end of
execution.

 
Note that external scripts will be run as the same user as XymonPSClient,
which would usually be the LOCAL SYSTEM user. You can test whether your
script works as LOCAL SYSTEM interactively using psexec (e.g. psexec -i -s
cmd.exe), from the sysinternals process utilities
(https://technet.microsoft.com/en-gb/sysinternals/psexec).

 
I have updated the XymonPSClient.doc which has a section on external scripts
and data - please read this carefully first as there are a number of options
associated with these new features. I will try and answer any questions
about scheduling and external data configuration, but I can't commit to
answering questions about or debugging your individual scripts.

Zak
list Colin Coe · Thu, 28 Apr 2016 19:33:24 +0800 ·
This is awesome news, thanks!
quoted from Zak Beck


On Thu, Apr 28, 2016 at 5:08 PM, <user-aada0fa38bf8@xymon.invalid> wrote:
Hi


I have today committed v2.15. This has a big, new feature that we've been
working on internally for some time and testing in our environment, that
is, external scripts and external data.


As far as is possible, I have replicated the BBWin functionality for
external data. Data files in the 'externaldatalocation' directory
(installdir\tmp by default) with the correct file format will be uploaded
to Xymon. You can therefore run external scripts, have them produce status
data files in the correct format and that will be uploaded. The format is
the same as BBWin and that described in 'Xymon Message Syntax' on this
page: http://xymon.sourceforge.net/xymon/help/manpages/man1/xymon.1.html.
The sample scripts supplied with BBWin, e.g. fsmon.vbs, should work without
material changes (fsmon for example looks in the registry for a couple of
locations of folders, this may need changing if you have never installed
BBWin).


You can now also specify external scripts in client-local.cfg to be run
either every scan or every "slow" scan, and they can be sent to run
synchronously or asynchronously - therefore a relatively simple external
script scheduler. The scripts can either pre-exist on the target or they
can be downloaded from a central web server or file share (like client
updates). Script versioning is controlled via hashes – this has also been
extended to client updates (optionally).


Obviously the use of external scripts requires some care – for example, if
you specify synchronous execution and your script never completes,
XymonPSClient will be left waiting forever. If you specify asynchronous and
your script never completes, you can end up with multiple processes
building up over time. It's quite difficult to work out what may be
happening with external scripts if you do not have any form of logging in
your script, just as it would be with BBWin – therefore if you're having
trouble, I recommend logging to file at various points in your script and
the start and end of execution.


Note that external scripts will be run as the same user as XymonPSClient,
which would usually be the LOCAL SYSTEM user. You can test whether your
script works as LOCAL SYSTEM interactively using psexec (e.g. psexec -i -s
cmd.exe), from the sysinternals process utilities (
https://technet.microsoft.com/en-gb/sysinternals/psexec).


I have updated the XymonPSClient.doc which has a section on external
scripts and data – please read this carefully first as there are a number
of options associated with these new features. I will try and answer any
questions about scheduling and external data configuration, but I can't
commit to answering questions about or debugging your individual scripts.

Zak

list Brandon Dale · Sat, 30 Apr 2016 09:15:16 +0000 ·
Hi Zak,

Just wanted to say the new externals functionality is awesome and makes everything easier, I have converted one of my PowerShell scripts to write the file in the expected format using the HASH and HASHVALUE and it all works as expected - very cool.

I wanted to see if I could get a PowerShell script to run without specify HASH and HASHVALUE, the example in the documentation of external:everyscan:sync:fsmon.vbs doesn't seem to work for .ps1 scripts, I assume because you need to use the powershell.exe process to call the script.

In the documentation it says this "If PROCESS is used, HASH, HASHVALUE and ARGUMENTS must be specified. " but I decided to try it anyway without specifying them and it seems to work fine, here is an example:

external:everyscan:sync:test.ps1|powershell.exe|-file "{script}"

So the documentation doesn't seem to be completely clear on how you run a PowerShell script without the HASH and HASHVALUE specified.

Regards,

Brandon.
list Zak Beck · Tue, 3 May 2016 08:30:05 +0000 ·
Hi

 
Thanks for the feedback :), pleased to see it works for you.
quoted from Brandon Dale

 
I wanted to see if I could get a PowerShell script to run without specify
HASH and HASHVALUE, the example in the documentation of
external:everyscan:sync:fsmon.vbs doesn't seem to work for .ps1 scripts, I
assume because you need to use the powershell.exe process to call the
script.

 

Correct - if there's no default handler, you need to specify the process.

 
I had a lot of trouble with the optional arguments and settled for
documenting the guaranteed way it works! I'll have another look and see if I
can make it clearer.

 
Longer term, I'd like to make the hashes mandatory - it makes sense when
deploying stuff to many servers to use them, in case the web server is
compromised or returning error pages.

 
Zak 
quoted from Brandon Dale

 
From: Brandon Dale [mailto:user-bf8ff8e1cedb@xymon.invalid] 
Sent: 30 April 2016 10:15
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid>; xymon at xymon.com
Subject: RE: Windows PowerShell client v2.15

 
Hi Zak,

 
Just wanted to say the new externals functionality is awesome and makes
everything easier, I have converted one of my PowerShell scripts to write
the file in the expected format using the HASH and HASHVALUE and it all
works as expected - very cool.

 
I wanted to see if I could get a PowerShell script to run without specify
HASH and HASHVALUE, the example in the documentation of
external:everyscan:sync:fsmon.vbs doesn't seem to work for .ps1 scripts, I
assume because you need to use the powershell.exe process to call the
script.

 
In the documentation it says this "If PROCESS is used, HASH, HASHVALUE and
ARGUMENTS must be specified. " but I decided to try it anyway without
specifying them and it seems to work fine, here is an example:

 
external:everyscan:sync:test.ps1|powershell.exe|-file "{script}"

 
So the documentation doesn't seem to be completely clear on how you run a
PowerShell script without the HASH and HASHVALUE specified.

 
Regards,

 
Brandon.
list Sven de Vilder · Tue, 3 May 2016 17:15:59 +0200 ·
Hello Zak,

Thanks for this excellent script. I haven't tested the externals 
function yet, but I will soon. And maybe then I'll finally be able to 
remove BBwin everywhere...

Is it possible to add this line (or something similar) to the 
XymonClientInstall section :

     & "$xymondir\nssm.exe" set `"$xymonsvcname`" Description 
`"XymonPSClient Version $Version`"

This way the service will have a description with the version in it 
(instead of nothing). This will benefit me greatly in deploying the 
client. I've tested it on one of my servers and it seems to be working 
as expected.

Kind regards,

Sven De Vilder
quoted from Colin Coe

user-aada0fa38bf8@xymon.invalid wrote:
Hi

I have today committed v2.15. This has a big, new feature that we've
been working on internally for some time and testing in our environment,
that is, external scripts and external data.

As far as is possible, I have replicated the BBWin functionality for
external data. Data files in the 'externaldatalocation' directory
(installdir\tmp by default) with the correct file format will be
uploaded to Xymon. You can therefore run external scripts, have them
produce status data files in the correct format and that will be
uploaded. The format is the same as BBWin and that described in 'Xymon
Message Syntax' on this page:
http://xymon.sourceforge.net/xymon/help/manpages/man1/xymon.1.html. The
sample scripts supplied with BBWin, e.g. fsmon.vbs, should work without
material changes (fsmon for example looks in the registry for a couple
of locations of folders, this may need changing if you have never
installed BBWin).

You can now also specify external scripts in client-local.cfg to be run
either every scan or every "slow" scan, and they can be sent to run
synchronously or asynchronously - therefore a relatively simple external
script scheduler. The scripts can either pre-exist on the target or they
can be downloaded from a central web server or file share (like client
updates). Script versioning is controlled via hashes – this has also
been extended to client updates (optionally).

Obviously the use of external scripts requires some care – for example,
if you specify synchronous execution and your script never completes,
XymonPSClient will be left waiting forever. If you specify asynchronous
and your script never completes, you can end up with multiple processes
building up over time. It's quite difficult to work out what may be
happening with external scripts if you do not have any form of logging
in your script, just as it would be with BBWin – therefore if you're
having trouble, I recommend logging to file at various points in your
script and the start and end of execution.

Note that external scripts will be run as the same user as
XymonPSClient, which would usually be the LOCAL SYSTEM user. You can
test whether your script works as LOCAL SYSTEM interactively using
psexec (e.g. psexec -i -s cmd.exe), from the sysinternals process
utilities (https://technet.microsoft.com/en-gb/sysinternals/psexec).

I have updated the XymonPSClient.doc which has a section on external
scripts and data – please read this carefully first as there are a
number of options associated with these new features. I will try and
answer any questions about scheduling and external data configuration,
but I can't commit to answering questions about or debugging your
individual scripts.

Zak

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij
de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.


This message may contain confidential information and is intended exclusively
for the addressee. If you receive this message unintentionally, please do not
use the contents but notify the sender immediately by return e-mail. University
Medical Center Utrecht is a legal person by public law and is registered at
the Chamber of Commerce for Midden-Nederland under no. 30244197.

Please consider the environment before printing this e-mail.
list Zak Beck · Tue, 3 May 2016 16:09:34 +0000 ·
Hi

Yes, I can look at that - however, I'm not sure about adding the version as
the client can self-update. I'll see if there's a way to update the version
at the same time.

Cheers

Zak
quoted from Sven de Vilder

-----Original Message-----
From: Sven De Vilder [mailto:user-3a7f76b871fc@xymon.invalid] Sent: 03 May 2016 16:16
To: Beck, Zak <user-aada0fa38bf8@xymon.invalid>
Cc: xymon at xymon.com
Subject: Re: [Xymon] Windows Powershell client v2.15

Hello Zak,

Thanks for this excellent script. I haven't tested the externals function
yet, but I will soon. And maybe then I'll finally be able to remove BBwin
everywhere...

Is it possible to add this line (or something similar) to the
XymonClientInstall section :

     & "$xymondir\nssm.exe" set `"$xymonsvcname`" Description
`"XymonPSClient Version $Version`"

This way the service will have a description with the version in it (instead
of nothing). This will benefit me greatly in deploying the client. I've
tested it on one of my servers and it seems to be working as expected.

Kind regards,

Sven De Vilder

user-aada0fa38bf8@xymon.invalid wrote:
Hi

I have today committed v2.15. This has a big, new feature that we've been working on internally for some time and testing in our environment, that is, external scripts and external data.

As far as is possible, I have replicated the BBWin functionality for external data. Data files in the 'externaldatalocation' directory (installdir\tmp by default) with the correct file format will be uploaded to Xymon. You can therefore run external scripts, have them produce status data files in the correct format and that will be uploaded. The format is the same as BBWin and that described in 'Xymon Message Syntax' on this page:
http://xymon.sourceforge.net/xymon/help/manpages/man1/xymon.1.html. The sample scripts supplied with BBWin, e.g. fsmon.vbs, should work without material changes (fsmon for example looks in the registry for a couple of locations of folders, this may need changing if you have never installed BBWin).

You can now also specify external scripts in client-local.cfg to be run either every scan or every "slow" scan, and they can be sent to run synchronously or asynchronously - therefore a relatively simple external script scheduler. The scripts can either pre-exist on the target or they can be downloaded from a central web server or file share (like client updates). Script versioning is controlled via hashes - this has also been extended to client updates (optionally).

Obviously the use of external scripts requires some care - for example, if you specify synchronous execution and your script never completes, XymonPSClient will be left waiting forever. If you specify asynchronous and your script never completes, you can end up with multiple processes building up over time. It's quite difficult to work out what may be happening with external scripts if you do not have any form of logging in your script, just as it would be with BBWin - therefore if you're having trouble, I recommend logging to file at various points in your script and the start and end of execution.

Note that external scripts will be run as the same user as XymonPSClient, which would usually be the LOCAL SYSTEM user. You can test whether your script works as LOCAL SYSTEM interactively using psexec (e.g. psexec -i -s cmd.exe), from the sysinternals process utilities (https://technet.microsoft.com/en-gb/sysinternals/psexec).

I have updated the XymonPSClient.doc which has a section on external scripts and data - please read this carefully first as there are a number of options associated with these new features. I will try and answer any questions about scheduling and external data configuration, but I can't commit to answering questions about or debugging your individual scripts.

Zak

--

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de
W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd
bij de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.

--

This message may contain confidential information and is intended
exclusively for the addressee. If you receive this message unintentionally,
please do not use the contents but notify the sender immediately by return
e-mail. University Medical Center Utrecht is a legal person by public law
and is registered at the Chamber of Commerce for Midden-Nederland under no.
30244197.

Please consider the environment before printing this e-mail.
list Sven de Vilder · Wed, 4 May 2016 10:29:58 +0200 ·
Okay, great. I didn't think about the self-update mechanism. It seems to 
be possible to update the description without reregistering the service.

Thanks,

Sven
quoted from Zak Beck


user-aada0fa38bf8@xymon.invalid wrote:
Hi

Yes, I can look at that - however, I'm not sure about adding the version as
the client can self-update. I'll see if there's a way to update the version
at the same time.

Cheers

Zak

-----Original Message-----
From: Sven De Vilder [mailto:user-3a7f76b871fc@xymon.invalid]
Sent: 03 May 2016 16:16
To: Beck, Zak<user-aada0fa38bf8@xymon.invalid>
Cc: xymon at xymon.com
Subject: Re: [Xymon] Windows Powershell client v2.15

Hello Zak,

Thanks for this excellent script. I haven't tested the externals function
yet, but I will soon. And maybe then I'll finally be able to remove BBwin
everywhere...

Is it possible to add this line (or something similar) to the
XymonClientInstall section :

      &  "$xymondir\nssm.exe" set `"$xymonsvcname`" Description
`"XymonPSClient Version $Version`"

This way the service will have a description with the version in it (instead
of nothing). This will benefit me greatly in deploying the client. I've
tested it on one of my servers and it seems to be working as expected.

Kind regards,

Sven De Vilder

user-aada0fa38bf8@xymon.invalid wrote:
Hi

I have today committed v2.15. This has a big, new feature that we've
been working on internally for some time and testing in our
environment, that is, external scripts and external data.

As far as is possible, I have replicated the BBWin functionality for
external data. Data files in the 'externaldatalocation' directory
(installdir\tmp by default) with the correct file format will be
uploaded to Xymon. You can therefore run external scripts, have them
produce status data files in the correct format and that will be
uploaded. The format is the same as BBWin and that described in 'Xymon
Message Syntax' on this page:
http://xymon.sourceforge.net/xymon/help/manpages/man1/xymon.1.html.
The sample scripts supplied with BBWin, e.g. fsmon.vbs, should work
without material changes (fsmon for example looks in the registry for
a couple of locations of folders, this may need changing if you have
never installed BBWin).

You can now also specify external scripts in client-local.cfg to be
run either every scan or every "slow" scan, and they can be sent to
run synchronously or asynchronously - therefore a relatively simple
external script scheduler. The scripts can either pre-exist on the
target or they can be downloaded from a central web server or file
share (like client updates). Script versioning is controlled via
hashes - this has also been extended to client updates (optionally).

Obviously the use of external scripts requires some care - for
example, if you specify synchronous execution and your script never
completes, XymonPSClient will be left waiting forever. If you specify
asynchronous and your script never completes, you can end up with
multiple processes building up over time. It's quite difficult to work
out what may be happening with external scripts if you do not have any
form of logging in your script, just as it would be with BBWin -
therefore if you're having trouble, I recommend logging to file at
various points in your script and the start and end of execution.

Note that external scripts will be run as the same user as
XymonPSClient, which would usually be the LOCAL SYSTEM user. You can
test whether your script works as LOCAL SYSTEM interactively using
psexec (e.g. psexec -i -s cmd.exe), from the sysinternals process
utilities (https://technet.microsoft.com/en-gb/sysinternals/psexec).

I have updated the XymonPSClient.doc which has a section on external
scripts and data - please read this carefully first as there are a
number of options associated with these new features. I will try and
answer any questions about scheduling and external data configuration,
but I can't commit to answering questions about or debugging your
individual scripts.

Zak

--

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de
W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd
bij de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.

--

This message may contain confidential information and is intended
exclusively for the addressee. If you receive this message unintentionally,
please do not use the contents but notify the sender immediately by return
e-mail. University Medical Center Utrecht is a legal person by public law
and is registered at the Chamber of Commerce for Midden-Nederland under no.
30244197.

Please consider the environment before printing this e-mail.