[Xymon] xymon-powershell.ps1

Beck, Zak zak.beck at accenture.com
Thu Jun 29 16:54:36 CEST 2017


Hi Steve

Here’s an example from one of my scripts. I’ve changed the names, nothing else. As I said, there is no requirement for any quoting, special spacing etc.

Everything after “green+30m” constitutes the message and is displayed on the page in Xymon. Note that Xymon builds the page using this as the content so no need for html, body etc tags. If you want to see roughly what it looks like, copy the below from “green” up to “Zak” to a file e.g. test.html and browse it (the main difference is that this is intended for use on a black background so the colours may look odd on white).

green+30m XIO status as at 14-Jul-2016 14:53 (updated approx every 10 minutes)

</pre>
<style type="text/css">
.datagrid table { border-collapse: collapse; text-align: left; width: 100%; }
.datagrid {font: normal 12px/150% Times New Roman, Times, serif; overflow: hidden; border: 1px solid #949494; }
.datagrid table td, .datagrid table th { padding: 4px 10px; }
.datagrid table tbody th { background-color:#000000; color:#d8d8bf; font-size: 15px; font-weight: bold; border-left: 1px solid #949494;border-bottom: 1px solid #949494; }
.datagrid table tbody td { color: #d8d8bf; border-left: 1px solid #949494;font-size: 14px;border-bottom: 1px solid #949494;font-weight: normal; }
.datagrid table tbody .alt td { background: #525252; color: #d8d8bf; }
.datagrid table tbody td:first-child { border-left: none; }
.datagrid table tbody tr:last-child td { border-bottom: none; }
</style>
<h3>Clusters</h3>
<div class="datagrid"><table> <colgroup><col/><col/><col/><col/><col/><col/><col/><col/><col/></colgroup> <tr><th>Status</th><th>name</th><th>Reduction Ratio</th><th>Compression Factor</th><th>Dedupe Ratio</th><th>Total Memory in use</th><th>Phys Space TB</th><th>Phys Used TB</th><th>UsedPct</th></tr> <tr><td><img src="/gifs/green.gif"></td><td>CLUSTER1</td><td>1.0:1</td><td>1.0:1</td><td>1.0:1</td><td>0%</td><td>15.24</td><td>0</td><td>0</td></tr> </table></div><h3>Volumes</h3>
<div class="datagrid"><table> <colgroup><col/><col/><col/><col/></colgroup> <tr><th>Cluster Name</th><th>Name</th><th>Average Latency</th><th>Provisioned Size GB</th></tr> <tr><td>CLUSTER1</td><td>NAME1</td><td>0</td><td>10</td></tr> <tr><td>CLUSTER1</td><td>NAME2</td><td>0</td><td>2</td></tr> <tr><td>CLUSTER1</td><td>NAME3</td><td>0</td><td>10</td></tr> </table></div><p>Script was run on REDACTED. Script took 0.02 minutes to run.

Zak

From: Steve Brown [mailto:sgb at pics.com]
Sent: 29 June 2017 14:36
To: Beck, Zak <zak.beck at accenture.com>; David Boyer <davieb at gmail.com>
Cc: xymon at xymon.com
Subject: [External] RE: [Xymon] xymon-powershell.ps1

Hi,
I saw the example file in the documentation but don’t find it helpful. It is far too simple and what I have is much more complex. I was hoping to see an example to show the quoting, spacing, and special characters associated with an html table.
Thanks anyway
Steve

From: Beck, Zak [mailto:zak.beck at accenture.com]
Sent: Thursday, June 29, 2017 8:16 AM
To: Steve Brown <sgb at pics.com<mailto:sgb at pics.com>>; David Boyer <davieb at gmail.com<mailto:davieb at gmail.com>>
Cc: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: [Xymon] xymon-powershell.ps1

Hi

Group colour is the overall status of the test.

For example, I may have a test that contains multiple tests, like checking the size of two or three directories. Each of those directories may have a red / yellow / green status. The group colour is the overall outer status, for example, if any one of the directory tests has a red status, I may want the group colour to be red.

This is the example of the content of the file, between the markers ---8<---

---8<---

green 14/01/2016 14:37:07 SERVER1



&green checking directory extdirtest 'c:\temp' - Rules are <50 and <100 - Actually 5 file(s)
---8<---

In this case:

GROUPCOLOUR = green
MESSAGE = 14/01/2016 14:37:07 SERVER1… all the way to the end.

Because it’s a file, the MESSAGE content is taken verbatim – there is no escaping or quoting necessary. The date and time and server name seen in the example are just part of the message, they are not parsed and are not mandatory – they will be displayed on the test’s page.

The name of the test is the name of the file.

Zak

From: Steve Brown [mailto:sgb at pics.com]
Sent: 29 June 2017 14:02
To: Beck, Zak <zak.beck at accenture.com<mailto:zak.beck at accenture.com>>; David Boyer <davieb at gmail.com<mailto:davieb at gmail.com>>
Cc: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: [Xymon] xymon-powershell.ps1

Hi,
Thanks. I reviewed that yesterday but I didn’t see an example that would be useful. I don’t know what <GROUPCOLOUR> represents. The documentation shows GROUPCOLOUR – red, yellow or green – the colour for the group  But that doesn’t tell me what it represents either.  I don’t know what group it refers to. Does it just mean the status of the test? I’m not using BBWin and have never used it. I was trying to use the xymon-powershell.ps1 script but it seems limited. I’m not a windows person. I’m a Linux guy and was hoping to see an example of this file that would be useful. I was hoping to see the criteria for quoting and different lines. I’ll need to create an example to submit to get permissions to install the Powershell Client and to write files on the server.
Steve

From: Beck, Zak [mailto:zak.beck at accenture.com]
Sent: Thursday, June 29, 2017 7:50 AM
To: Steve Brown <sgb at pics.com<mailto:sgb at pics.com>>; David Boyer <davieb at gmail.com<mailto:davieb at gmail.com>>
Cc: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: RE: [Xymon] xymon-powershell.ps1

Hi

There’s a section in the doc file for XymonPSClient headed “External data” which describes the file in detail.

Here’s a copy / paste of the format from that section:


<GROUPCOLOUR>[+LIFETIME] <MESSAGE>


GROUPCOLOUR – red, yellow or green – the colour for the group

+LIFETIME – optional – how long before Xymon should turn the status purple if no further results are received, specified in minutes (but supports 'h', 'd' or 'w' suffix e.g. 5h for 5 hours)

MESSAGE  - the message to be displayed. This message can span multiple lines and can include “&colour” e.g. &green / &yellow / &red to display a subtest with the corresponding coloured GIF.

For example, the external script fsmon supplied with the BBWin source writes external files with the following contents:


green 14/01/2016 14:37:07 [SERVER1]



&green checking directory extdirtest 'c:\temp' - Rules are <50 and <100 - Actually 5 file(s)

Here the group colour is green and the subtest colour is also green, no lifetime has been specified so the result will turn purple after the default interval if no more test results are sent.


Note that you can also do this with BBWin if that’s what you’re using, and the message can include html as per your requirement.

Thanks

Zak

From: Steve Brown [mailto:sgb at pics.com]
Sent: 29 June 2017 13:22
To: David Boyer <davieb at gmail.com<mailto:davieb at gmail.com>>; Beck, Zak <zak.beck at accenture.com<mailto:zak.beck at accenture.com>>
Cc: xymon at xymon.com<mailto:xymon at xymon.com>
Subject: [External] RE: [Xymon] xymon-powershell.ps1

Thanks I’ll see if I can get permission to install the PowerShell client and create files on the client machine.  Can you send me an example of the file you place in c:\..\..\tmp ?

From: David Boyer [mailto:davieb at gmail.com]
Sent: Wednesday, June 28, 2017 10:24 PM
To: Beck, Zak <zak.beck at accenture.com<mailto:zak.beck at accenture.com>>
Cc: Steve Brown <sgb at pics.com<mailto:sgb at pics.com>>; xymon at xymon.com<mailto:xymon at xymon.com>
Subject: Re: [Xymon] xymon-powershell.ps1

Hi,
Like Zak said, just write your HTML page to a file then place it in the c:\..\..\tmp and it should be picked up within 5mins. The filename will reflect the test name on the xymon web page. I have a couple of sched tasks that work this way.
Dave

On Wed, Jun 28, 2017 at 5:06 AM, Beck, Zak <zak.beck at accenture.com<mailto:zak.beck at accenture.com>> wrote:
Hi

I’m not familiar with xymon-powershell.ps1, but I don’t see why not, the server certainly supports it (we do it all the time in the Powershell client).

Bear in mind for powershell, the escape character for those double-quotes is backtick (`), as in:

"<table width=`"100%`">"

You may want to switch to the Windows Powershell client, it allows you to schedule and run external scripts or pick up data from external text files, so whatever is calling xymon-powershell.ps1 could just write a text file in the correct format to c:\program files\xymon\tmp and it would get sent…

https://sourceforge.net/p/xymon/code/HEAD/tree/sandbox/WinPSClient/<https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceforge.net_p_xymon_code_HEAD_tree_sandbox_WinPSClient_&d=DwMGaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=txMYPUEjcG94O3HCuRXTGdsKRhVt6Nx1haus2hd2GIU&s=kMea6StIUZTOmvEo98JnLbx0tSHFtZ5Tal_e5M6y6-U&e=>

Cheers

Zak

From: Xymon [mailto:xymon-bounces at xymon.com<mailto:xymon-bounces at xymon.com>] On Behalf Of Steve Brown
Sent: 27 June 2017 17:16
To: 'xymon at xymon.com<mailto:xymon at xymon.com>' <xymon at xymon.com<mailto:xymon at xymon.com>>
Subject: [External] [Xymon] xymon-powershell.ps1

Hi
Is there a way to send an html table through the xymon-powershell.ps1 script?

I currently use bb-central where I have a Linux script that runs on the xymon server. I’m able to send the html table with the following


OBJFILE="<iframe name=\"locktbl\" src=\"/hobbit/dba/${RHOST}/${MNAME}-lock.html\" frameborder=\"no\" height=\"600\" width=\"1200\"></iframe>"
LINE="status $MACHINE.$TEST $COLOR
        ${OBJFILE} "
$BB $BBDISP "$LINE"               #SEND IT TO BBDISPLAY

The status line is very similar to the xymon-powershell.ps1 input

powershell -file xymon-powershell.ps1 %XYMSRV% "status %COMPUTERNAME%.mytest green %DATE% %TIME%" "The status of 'mytest' is 'satisfactory' at %DATE% %TIME%" "" "here's the last line"

I basically want to replace the "The status of 'mytest' is 'satisfactory' at %DATE% %TIME%" with an html table.

Thank you for your help
Steve

________________________________

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.
______________________________________________________________________________________

www.accenture.com<http://www.accenture.com>

_______________________________________________
Xymon mailing list
Xymon at xymon.com<mailto:Xymon at xymon.com>
http://lists.xymon.com/mailman/listinfo/xymon<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.xymon.com_mailman_listinfo_xymon&d=DwMGaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=S-aLwpx-PHBTBMIG_c2JczRC0SfuZCmsiH9Iams25FI&m=txMYPUEjcG94O3HCuRXTGdsKRhVt6Nx1haus2hd2GIU&s=NyK8zOPW_on_G4lGWF_-KLLKezCrJAZSHc9PRHabZLc&e=>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20170629/3c45d907/attachment.html>


More information about the Xymon mailing list