[Xymon] External Powershell script not working

Shea, Graeme A Shea.Graeme.A at edumail.vic.gov.au
Wed Aug 6 23:49:06 CEST 2014


Hello Michael,

if you concatenate the strings with a space between them follow by a blank line rather than having separate lines it may work. Early versions of BBWin needed the first line to contain the date (or at least more information) after the "green", don't know if this has been fixed in the later versions. 

Regards
Graeme

-----Original Message-----
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Michael Schultheiss
Sent: Thursday, 7 August 2014 12:40 AM
To: xymon at xymon.com
Subject: [Xymon] External Powershell script not working

We've created an external powershell script for monitoring one of our
Exchange servers. The script has been listed in the externals section of
BBwin.cfg and we've verified the script is outputing to 
C:\Program Files (x86)\BBWin\tmp

but the results aren't showing up on the xymon server page.

We have other servers running external scripts but haven't been able to
determine the difference between the working external script and the
non-working one.

Powershell script:


Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Support -ErrorAction SilentlyContinue

$count = Get-TransportServer | Get-Message | Measure-Object | Select-Object Count -ExpandProperty Count
$sAlarm = "green"
$datetime = (Get-Date).ToString()

If ($count -gt 150) {
    $sAlarm = "yellow"
}    

$sAlarm,$datetime | Out-File -FilePath "C:\Program Files (x86)\BBWin\tmp\exchqueues"

Output:

green
8/6/2014 10:32:22 AM

BBwin.cfg snippet:


<externals>
	<setting name="timer" value="5m" />
	<setting name="logstimer" value="60" />
	<load value="C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -nologo -ExecutionPolicy Unrestricted -File 'C:\Program Files(x86)\BBWin\ext\exchqueues.ps1'" />
	<!-- externals launch examples
	<load value="cscript mybbscript.vbs" />
	<load value="myexternal.exe" />
	<load value="cscript wlbs.vbs" timer="15m" />
	<load value="cluster.exe" timer="90s" /> -->
</externals>

-- 
-------------------------------------------------------------
Michael Schultheiss, RHCSA, RHCE   OIT Administration
Sr. Unix Systems Engineer          Ivy Tech Community College
schultmc at ivytech.edu
_______________________________________________
Xymon mailing list
Xymon at xymon.com
http://lists.xymon.com/mailman/listinfo/xymon

Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.



More information about the Xymon mailing list