[Xymon] A simple xymon client in Powershell
Neil Simmonds
Neil.Simmonds at express-gifts.co.uk
Thu Jan 16 10:42:16 CET 2014
Hi Jeremy,
You are my saviour!
I've been banging my head against an issue for about 3 days now. I've been trying to get MQ monitoring working on a BBWin client, however, despite having written a powershell script that works perfectly as an external script when I run it from command line it doesn't work properly when I add it to BBWin.cfg (it extracts the data from mq but one of the commands further in the script doesn't work).
I've just changed the output from my script so all it does is pull the data from MQ, write a header line to a file (client hostname.mqcollect mqcollect) then append the MQ data. If I drop that file in the BBWin tmp directory, BBWin changes it before it sends it to the server however, if I drop it in /ext and I then use your script to send that file to Xymon "Xymonsend.ps1" server @ "C:\Program Files (x86)\BBWin\ext\mq..result", it works perfectly. The server correctly sees it as client data and I can add Queues to monitor into analysis.cfg.
Thank you very, very much.
Neil Simmonds
Senior Operations Analyst (Operations Support Group)
Express Gifts Limited
Express House
Clayton Business Park
Accrington
Lancashire
BB5 5JY
T: 01254 303092 | E: neil.simmonds at Express-Gifts.co.uk<mailto:neil.simmonds at Express-Gifts.co.uk>
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Jeremy Laidman
Sent: 15 January 2014 07:15
To: xymon at xymon.com
Subject: [Xymon] A simple xymon client in Powershell
Guys
I thought some of you might find this useful. It's an implementation of the "xymon" client program written in 6 lines of Powershell, It lacks the ability to wait for data returned by the Xymon server, but it's fine for sending status and data messages.
param($xymsrv=$(throw "ERROR: Specify xymon server and message lines"))
$socket=(new-object System.Net.Sockets.TcpClient($xymsrv,1984))
$writer=new-object System.IO.StreamWriter $socket.GetStream()
if ($args[0] -eq "@") { foreach ($line in Get-Content $args[1]) {$writer.Write($line+"`n")} }
else { foreach ($line in $args) {$writer.Write($line+"`n")} }
$writer.close()
You could run it like this:
C:\>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"
or if you have the status/data message in a file:
C:\>powershell -file xymon-powershell.ps1 %XYMSRV% @ statusfile.txt
Cheers
Jeremy
Name & Registered Office: EXPRESS GIFTS LIMITED, 2 GREGORY ST, HYDE, CHESHIRE, ENGLAND, SK14 4TH, Company No. 00718151.
Express Gifts Limited is authorised and regulated by the Financial Services Authority
--------------
NOTE: This email and any information contained within or attached in a separate file is confidential and intended solely for the
Individual to whom it is addressed. The information or data included is solely for the purpose indicated or previously agreed. Any
information or data included with this e-mail remains the property of Findel PLC and the recipient will refrain from utilising the
information for any purpose other than that indicated and upon request will destroy the information and remove it from their records.
Any views or opinions presented are solely those of the author and do not necessarily represent those of Findel PLC. If you are not
the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing,
or copying of this email is strictly prohibited. No warranties or assurances are made in relation to the safety and content of this
e-mail and any attachments. No liability is accepted for any consequences arising from it. Findel Plc reserves the right to monitor
all e-mail communications through its internal and external networks. If you have received this email in error please notify our IT
helpdesk on +44(0) 1254 303030
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20140116/62011c35/attachment.html>
More information about the Xymon
mailing list