Submit a ticketCall us

Training ClassSign up for Network Performance Monitor (NPM) and Scalability instructor-led classes

Attend our instructor-led classes, provided by SolarWinds® Academy, to discuss the more advanced monitoring mechanisms available in NPM as well as how to tune your equipment to optimize its polling capabilities. NPM classes offered:
NPM Custom Monitoring and Polling
Orion Platform Scalability

Reserve your seat.

Home > Success Center > Server & Application Monitor (SAM) > SAM - Knowledgebase Articles > Python-based Windows Script Monitor does not return data (SAM)

Python-based Windows Script Monitor does not return data (SAM)

Updated June 22, 2018


You can use Windows scripting languages to gather metrics and other information that you wish to monitor in SAM. For details, see Configure a Windows Script Monitor and also  

This article describes how a Python-based Windows Script Monitor cannot return data when characters are truncated due to a full buffer that is not flushed.

Here is an example of what may appear in log files when this issue occurs:

Engine: python 
Script: ==================================================== 
print ("Statistic: 100") 
print ("Message: Things are working as expected") 
Output: ====================================================
Errors: ====================================================
Result: ====================================================
Component Evidence 
Type: DynamicEvidence 
Component Type: WindowsScript 
Actual Outcome: Undefined


The default location for SAM logs is c:\ProgramData\SolarWinds\Logs\APM.


  • SAM 6.6.1 and later
  • Python 3.x
  • Python extensions for Windows (pywin32) versions that match the Python version


SAM's Windows Script Monitor use CScript, a front-end application for the Windows Script Host, but does not get data back from the CScript process. If you run CScript manually from the command line (for example, cscript //E:python, output appears. But if you redirect standard output to a file (cscript //E:python > result.txt), no data appears unless you print enough (about 8 KB) characters from the Python script. Any data that exceeds the buffer size will be truncated when the buffer is full again. This occurs because Pywin32 replaces sys.stdout with its own structure, which does not support flushing.


Use the script structure shown in the following example:  

# Restore stdout
import sys 
sys.stdout = sys.__stdout__ 

# Your script here
print("Statistic: 100") 
print("Message: Test") 

# Flush stdout


Last modified