<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I pull service status for Windows in an efficient manner? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-pull-service-status-for-Windows-in-an-efficient-manner/m-p/290598#M55428</link>
    <description>&lt;P&gt;The below powershell script will use the commandline tool "sc.exe" to output the service name and status, and then format the results with a simple echo output so Splunk can read it as an input.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$output = sc.exe query state= all
$formatted = new-object PSObject
for ($i=0; $i -lt $output.Length; $i++) {
    if ($output[$i] -like "SERVICE_NAME:*") {
        $service = $output[$i] -replace 'SERVICE_NAME: ',''
        $status = $output[$i+3] -replace '        STATE              : ',''
        $status = $status -replace '  ',','
        $newout = $service + "," + $status
        echo $newout
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample results:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;smphost,1,STOPPED&lt;BR /&gt;
SmsRouter,1,STOPPED&lt;BR /&gt;
smstsmgr,1,STOPPED&lt;BR /&gt;
SNMPTRAP,1,STOPPED&lt;BR /&gt;
SplunkForwarder,4,RUNNING&lt;BR /&gt;
Spooler,4,RUNNING&lt;BR /&gt;
sppsvc,4,RUNNING&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Fri, 12 May 2017 15:24:51 GMT</pubDate>
    <dc:creator>fairje</dc:creator>
    <dc:date>2017-05-12T15:24:51Z</dc:date>
    <item>
      <title>How do I pull service status for Windows in an efficient manner?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-pull-service-status-for-Windows-in-an-efficient-manner/m-p/290597#M55427</link>
      <description>&lt;P&gt;I know the WinHostMon input can be used to poll the status of all the services on a host, but it also outputs a lot of extra information which adds a lot of bloat to the data stream. Running that at 1 or 5 minute intervals across multiple servers adds a substantial (and unnecessary) hit to your index volume.&lt;/P&gt;

&lt;P&gt;The other common input manner is to use WMI to poll for that information, but WMI is notoriously hard hitting on the system, and at a frequent polling interval is likely to just crush the systems you are trying to run it on.&lt;/P&gt;

&lt;P&gt;Is there another way to get this information to just return back the service name and it's state without all the extra informaiton and without causing a major hit on CPU load on the servers you are trying to monitor?&lt;/P&gt;

&lt;P&gt;e.g.&lt;BR /&gt;
    splunkforwarder,running&lt;BR /&gt;
    Spooler,running&lt;BR /&gt;
    Schedule,stopped&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 15:20:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-pull-service-status-for-Windows-in-an-efficient-manner/m-p/290597#M55427</guid>
      <dc:creator>fairje</dc:creator>
      <dc:date>2017-05-12T15:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pull service status for Windows in an efficient manner?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-pull-service-status-for-Windows-in-an-efficient-manner/m-p/290598#M55428</link>
      <description>&lt;P&gt;The below powershell script will use the commandline tool "sc.exe" to output the service name and status, and then format the results with a simple echo output so Splunk can read it as an input.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$output = sc.exe query state= all
$formatted = new-object PSObject
for ($i=0; $i -lt $output.Length; $i++) {
    if ($output[$i] -like "SERVICE_NAME:*") {
        $service = $output[$i] -replace 'SERVICE_NAME: ',''
        $status = $output[$i+3] -replace '        STATE              : ',''
        $status = $status -replace '  ',','
        $newout = $service + "," + $status
        echo $newout
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample results:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;smphost,1,STOPPED&lt;BR /&gt;
SmsRouter,1,STOPPED&lt;BR /&gt;
smstsmgr,1,STOPPED&lt;BR /&gt;
SNMPTRAP,1,STOPPED&lt;BR /&gt;
SplunkForwarder,4,RUNNING&lt;BR /&gt;
Spooler,4,RUNNING&lt;BR /&gt;
sppsvc,4,RUNNING&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 12 May 2017 15:24:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-pull-service-status-for-Windows-in-an-efficient-manner/m-p/290598#M55428</guid>
      <dc:creator>fairje</dc:creator>
      <dc:date>2017-05-12T15:24:51Z</dc:date>
    </item>
  </channel>
</rss>

