<?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 can I get the max volume per day for the license stack used using the REST API in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-the-max-volume-per-day-for-the-license-stack-used/m-p/87547#M18174</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;
I can get information about the license stacks via the CLI:&lt;BR /&gt;
splunk list licenser-stacks&lt;/P&gt;

&lt;P&gt;I would like to get the same via a rest API call. Is this possible?&lt;/P&gt;

&lt;P&gt;Thanks in advance,&lt;BR /&gt;
Alex&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jan 2013 13:19:52 GMT</pubDate>
    <dc:creator>SunDance</dc:creator>
    <dc:date>2013-01-15T13:19:52Z</dc:date>
    <item>
      <title>How can I get the max volume per day for the license stack used using the REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-the-max-volume-per-day-for-the-license-stack-used/m-p/87547#M18174</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I can get information about the license stacks via the CLI:&lt;BR /&gt;
splunk list licenser-stacks&lt;/P&gt;

&lt;P&gt;I would like to get the same via a rest API call. Is this possible?&lt;/P&gt;

&lt;P&gt;Thanks in advance,&lt;BR /&gt;
Alex&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2013 13:19:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-the-max-volume-per-day-for-the-license-stack-used/m-p/87547#M18174</guid>
      <dc:creator>SunDance</dc:creator>
      <dc:date>2013-01-15T13:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the max volume per day for the license stack used using the REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-the-max-volume-per-day-for-the-license-stack-used/m-p/87548#M18175</link>
      <description>&lt;P&gt;&lt;A href="https://yoursplunkserver:8089/services/licenser/stacks"&gt;https://yoursplunkserver:8089/services/licenser/stacks&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2013 16:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-the-max-volume-per-day-for-the-license-stack-used/m-p/87548#M18175</guid>
      <dc:creator>mloven_splunk</dc:creator>
      <dc:date>2013-01-15T16:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the max volume per day for the license stack used using the REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-the-max-volume-per-day-for-the-license-stack-used/m-p/87549#M18176</link>
      <description>&lt;P&gt;Here's a little bit of python (2.x) code that uses the &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEBB"&gt;Splunk Python SDK&lt;/A&gt; to extract license values from the "&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTlicense#licenser.2Fstacks"&gt;licenser/stacks&lt;/A&gt;" RESTful endpoint that &lt;A href="http://splunk-base.splunk.com/users/130492/mloven_splunk"&gt;@mloven_splunk&lt;/A&gt; mentioned above. The output is &lt;EM&gt;equivalent&lt;/EM&gt; to the output from &lt;CODE&gt;splunk list licenser-stacks&lt;/CODE&gt;. You'll have to have the Splunk Python SDK already &lt;A href="http://dev.splunk.com/view/SP-CAAAEC3"&gt;installed&lt;/A&gt; on your system and you should probably add it to your &lt;A href="http://www.stereoplex.com/blog/understanding-imports-and-pythonpath"&gt;PYTHONPATH&lt;/A&gt;. YMMV.&lt;/P&gt;

&lt;P&gt;Here's what the output looks like on one of my forwarders:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;$ python endpoint_license_stack.py&lt;BR /&gt;
License Label Name                                Quota (Bytes)        License Type&lt;BR /&gt;
Splunk Forwarder                              ==&amp;gt; 1048576          ==&amp;gt; forwarder &lt;BR /&gt;
Splunk Free                                   ==&amp;gt; 524288000        ==&amp;gt; free&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The code is really crappy because...well, just look at that for loop. Yuck.&lt;/P&gt;

&lt;P&gt;Also, I always try to stick with libraries that are provided by most default Python installations, so I cannot use any of the cool output-formatting libraries that I've found and, frankly, I'm working with xml.etree...which is not a very friendly library...but I'll work with XML over JSON any day of the week so I cannot complain too much.&lt;/P&gt;

&lt;P&gt;Don't forget to change the USERNAME and PASSWORD variables to something appropriate for your system.&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client
import xml.etree.ElementTree as etree
import sys

HOST = "localhost"
PORT = 8089
USERNAME = "username"   # this username requires the "license_edit" capability
PASSWORD = "password"

def main(args):
    try:
        service = client.connect(host=HOST,
                             port=PORT,
                             username=USERNAME,
                             password=PASSWORD)
        htmlout = service.get('licenser/stacks')     # Here's your REST endpoint
        tree = etree.parse(htmlout.body)             # "body" contains the XML output from the endpoint
        labels = tree.findall('.//{http://dev.splunk.com/ns/rest}key[@name="label"]')
        quotas = tree.findall('.//{http://dev.splunk.com/ns/rest}key[@name="quota"]')
        types = tree.findall('.//{http://dev.splunk.com/ns/rest}key[@name="type"]')

        print '%-45s     %-16s     %-50s' % ("License Label Name",
                                             "Quota (Bytes)",
                                             "License Type")
        x=0
        for j in labels:
            print '%-45s ==&amp;gt; %-16s ==&amp;gt; %-50s' % (labels[x].text,
                                                 quotas[x].text,
                                                 types[x].text)
            x += 1
        service.logout()
    except:
        # error handling code here
        print "Main loop: We failed."
        return 1 # exit on error
    else:
        #print "Main loop: Perfect execution."
        return 0 # exit errorlessly

if __name__ == '__main__':
        sys.exit(main(sys.argv))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jan 2013 05:02:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-get-the-max-volume-per-day-for-the-license-stack-used/m-p/87549#M18176</guid>
      <dc:creator>sspencer_splunk</dc:creator>
      <dc:date>2013-01-16T05:02:28Z</dc:date>
    </item>
  </channel>
</rss>

