[Xymon] A simple xymon client in Powershell

Ribeiro, Glauber glauber.ribeiro at experian.com
Wed Jan 15 16:16:50 CET 2014


Check this out!
https://sourceforge.net/p/xymon/code/HEAD/tree/sandbox/WinPSClient/


g

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Jeremy Laidman
Sent: Wednesday, January 15, 2014 01: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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20140115/914835ac/attachment.html>


More information about the Xymon mailing list