[Xymon] A simple xymon client in Powershell
Jeremy Laidman
jlaidman at rebel-it.com.au
Wed Jan 15 08:15:15 CET 2014
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/52b3a1f7/attachment.html>
More information about the Xymon
mailing list