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
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.
Hi Michael,
I ran into this issue a few times before (hopefully this fix works for you..)
You need to ensure that the output file is written in ASCII mode otherwise the Xymon cannot understand the format (to my limited knowledge..)
Add "-Encoding ASCII" as shown here with your example
$sAlarm,$datetime | Out-File -Encoding ASCII -FilePath "C:\Program Files (x86)\BBWin\tmp\exchqueues"
regards
- Padraig Lennon
-----Original Message----- From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Shea, Graeme A Sent: Wednesday, August 06, 2014 10:49 PM To: Michael Schultheiss; xymon at xymon.com Subject: Re: [Xymon] External Powershell script not working
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.
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
Lennon, Padraig wrote:
Hi Michael,
I ran into this issue a few times before (hopefully this fix works for you..)
You need to ensure that the output file is written in ASCII mode otherwise the Xymon cannot understand the format (to my limited knowledge..)
Add "-Encoding ASCII" as shown here with your example
$sAlarm,$datetime | Out-File -Encoding ASCII -FilePath "C:\Program Files (x86)\BBWin\tmp\exchqueues"
Thank you! Adding -Encoding ASCII made the added check show up on the Xymon page. We were baffled why older VBscript externals were working yet the Powershell external was failing with similar output being generated. Forcing ASCII output did the trick!
--
Michael Schultheiss, RHCSA, RHCE OIT Administration Sr. Unix Systems Engineer Ivy Tech Community College schultmc at ivytech.edu
participants (3)
-
Padraig.Lennon@pioneerinvestments.com
-
schultmc@ivytech.edu
-
Shea.Graeme.A@edumail.vic.gov.au