<?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 How to query the deployment server to get the serverclasses for a hostname? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250341#M74760</link>
    <description>&lt;P&gt;We have a chef recipe, that people are using and loving.  Now, they want the ability to find out their serverclasses on servers without involving us.  Unfortunately, I don't see anyway of doing this by hostname, only by clientname, which, by default, is the GUID.&lt;/P&gt;

&lt;P&gt;Anyone? &lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2016 16:41:53 GMT</pubDate>
    <dc:creator>a212830</dc:creator>
    <dc:date>2016-08-25T16:41:53Z</dc:date>
    <item>
      <title>How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250341#M74760</link>
      <description>&lt;P&gt;We have a chef recipe, that people are using and loving.  Now, they want the ability to find out their serverclasses on servers without involving us.  Unfortunately, I don't see anyway of doing this by hostname, only by clientname, which, by default, is the GUID.&lt;/P&gt;

&lt;P&gt;Anyone? &lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 16:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250341#M74760</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-08-25T16:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250342#M74761</link>
      <description>&lt;P&gt;This search will give you a mapping of hostnames/IPs/GUIDs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" (sourcetype="splunkd_access" root="services" user="-" phonehome) OR ((source=*/metrics.log* OR source=*\\metrics.log*) group=tcpin_connections NOT statusee=TcpInputProcessor)
| rex field=uri "connection_(?&amp;lt;clientipPH&amp;gt;\d+\.\d+\.\d+\.\d+)_(?&amp;lt;portPH&amp;gt;\d+)_(?&amp;lt;hostnamePH&amp;gt;(?:\d+\.\d+\.\d+\.\d+)|(?:[^\s]+\.[A-Za-z]{2,3})|[^_]+)_(?&amp;lt;clientnamePH&amp;gt;[^\s]+)_(?&amp;lt;GUIDPH&amp;gt;[^\s_]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 17:12:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250342#M74761</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-08-25T17:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250343#M74762</link>
      <description>&lt;P&gt;Was hoping for a REST call, not a Splunk search.  &lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 17:28:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250343#M74762</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-08-25T17:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250344#M74763</link>
      <description>&lt;P&gt;My search gives you the GUID, then you can use the REST API.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 18:54:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250344#M74763</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-08-25T18:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250345#M74764</link>
      <description>&lt;P&gt;To add color: I believe @212830 wants it as a REST call so the folks interfacing with the CHEF recipes can continue to use that interface.&lt;/P&gt;

&lt;P&gt;Conversely, they can use a REST call to run a search that provides the answer.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 16:41:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250345#M74764</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-08-26T16:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250346#M74765</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| REST /services/deployment/server/clients 
 | search name="$host$"
 | fields + applications.*.serverclasses
 | rename "applications.*.serverclasses" AS "*"
 | transpose
 | rename column AS app, "row 1" AS serverclass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, save it as a search and have the end users run a REST call to a search which runs &lt;CODE&gt;| savedsearch search_above(cool)&lt;/CODE&gt; where the token (in this case "cool") is the hostname they are interrogating.&lt;/P&gt;

&lt;P&gt;But, to be honest, I think this would work best as a dashboard if they are willing to go to a page:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Splunk Deployment Audit&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false" autoRun="true"&amp;gt;&amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;input type="dropdown" token="name" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;Select a deployment client:&amp;lt;/label&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| REST /services/deployment/server/clients&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;name&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;name&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| REST /services/deployment/server/clients 
 | search name="$name$"
 | fields + applications.*.serverclasses
 | rename "applications.*.serverclasses" AS "*"
 | transpose
 | rename column AS app, "row 1" AS serverclass&amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Aug 2016 17:02:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250346#M74765</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-08-26T17:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250347#M74766</link>
      <description>&lt;P&gt;since I was running on a deployment server which is not a search peer, I had to specify splunk_server=mydeployhostnamehere&lt;/P&gt;

&lt;P&gt;i.e.&lt;BR /&gt;
    | REST /services/deployment/server/clients splunk_server=mydeployhostnamehere&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 00:39:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250347#M74766</guid>
      <dc:creator>bandit</dc:creator>
      <dc:date>2017-05-11T00:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250348#M74767</link>
      <description>&lt;P&gt;Absolutely - good catch!&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 12:11:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250348#M74767</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2017-05-11T12:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250349#M74768</link>
      <description>&lt;P&gt;Here is a search that provides a bit more information on all the forwarders and provides the apps and serverClasses side-by-side:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest /services/deployment/server/clients  splunk_server=local
| foreach applications.*.restartSplunkd [eval Apps=if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), mvappend(Apps, "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"), Apps)]
| foreach serverClasses.*.restartSplunkd [eval ServerClasses=if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), mvappend(ServerClasses, "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"), ServerClasses)]
| eval Forwarder = lower(dns)
| rex field=utsname "(?&amp;lt;os&amp;gt;[^\-]+)\-(?&amp;lt;arch&amp;gt;.+)"
| eval os = case(os == "linux", "Linux", os == "windows", "Windows", arch == "sun4u", "Solaris", arch == "sun4v", "Solaris")
| fields - utsname
| lookup version2build.csv build
| rename dns AS Forwarder, averagePhoneHomeInterval AS PHI
| stats values(Apps) AS Apps, values(ServerClasses) AS ServerClasses count by Forwarder ip os arch version build clientName splunk_server PHI lastPhoneHomeTime
| fieldformat lastPhoneHomeTime=strftime(lastPhoneHomeTime, "%F %T")
| eval missing=now()-lastPhoneHomeTime-PHI | eval missing=if(missing&amp;lt;0, 0, missing)
| eval Missing=case (missing==0, "No", missing==1, "Yes")
| fields - missing
| addtotals count col=t row=f
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here is that search modified to look for one host inside an XML search form like the one above (same search modified for one host lookup and xml-ified (changed &amp;lt;, &amp;gt;, and " to &amp;lt;, &amp;gt;, and ^quot;). It uses $name$ for the host variable --  you can just drop it into the XML Sloshburch showed, above, replacing what is there between  and :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest /services/deployment/server/clients  splunk_server=local
| foreach applications.*.restartSplunkd [eval Apps=if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), mvappend(Apps, &amp;amp;quot;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&amp;amp;quot;), Apps)]
| foreach serverClasses.*.restartSplunkd [eval ServerClasses=if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), mvappend(ServerClasses, &amp;amp;quot;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&amp;amp;quot;), ServerClasses)]
| eval Forwarder = lower(dns)
| search Forwarder = $name$
| rex field=utsname &amp;amp;quot;(?&amp;lt;os&amp;gt;[^\-]+)\-(?&amp;lt;arch&amp;gt;.+)&amp;amp;quot;
| eval os = case(os == &amp;amp;quot;linux&amp;amp;quot;, &amp;amp;quot;Linux&amp;amp;quot;, os == &amp;amp;quot;windows&amp;amp;quot;, &amp;amp;quot;Windows&amp;amp;quot;, arch == &amp;amp;quot;sun4u&amp;amp;quot;, &amp;amp;quot;Solaris&amp;amp;quot;, arch == &amp;amp;quot;sun4v&amp;amp;quot;, &amp;amp;quot;Solaris&amp;amp;quot;)
| fields - utsname
| lookup version2build.csv build
| rename dns AS Forwarder, averagePhoneHomeInterval AS PHI
| stats values(Apps) AS Apps, values(ServerClasses) AS ServerClasses count by Forwarder ip os arch version build clientName splunk_server PHI lastPhoneHomeTime
| fieldformat lastPhoneHomeTime=strftime(lastPhoneHomeTime, &amp;amp;quot;%F %T&amp;amp;quot;)
| eval missing=now()-lastPhoneHomeTime-PHI | eval missing=if(missing&amp;lt;0, 0, missing)
| eval Missing=case (missing==0, &amp;amp;quot;No&amp;amp;quot;, missing==1, &amp;amp;quot;Yes&amp;amp;quot;)
| fields - missing, count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2017 18:07:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250349#M74768</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2017-06-13T18:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250350#M74769</link>
      <description>&lt;P&gt;So this worked for you right?  If so, be sure to click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 14:39:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/250350#M74769</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-12T14:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to query the deployment server to get the serverclasses for a hostname?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/606551#M210958</link>
      <description>&lt;P&gt;Of all the searches I've done, this REST search was the only one that worked for me in 9.0.0.&amp;nbsp; I tweaked it to give me client per server class so that I could export a csv of my environment.&amp;nbsp; The only caveat is that it won't include any server classes that don't have any clients phoned home, which is a minor issue.&amp;nbsp; Note: this must be run from Deployment Server (DS).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rest /services/deployment/server/clients count=0 splunk_server=local  | table hostname serverClasses.*.stateOnClient 
| untable hostname ServerClassNames dummy 
| rex field=ServerClassNames "serverClasses\.(?&amp;lt;ServerClassNames&amp;gt;[^\.]+)\.stateOnClient$" 
| stats values(hostname) as hostname dc(hostname) by ServerClassNames 
| rename hostname as clientName
| table ServerClassNames, clientName&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 17:22:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-the-deployment-server-to-get-the-serverclasses-for/m-p/606551#M210958</guid>
      <dc:creator>jasonwagner</dc:creator>
      <dc:date>2022-07-21T17:22:03Z</dc:date>
    </item>
  </channel>
</rss>

