<?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 to create a table of availabilities of a given service for a set of hosts in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590294#M205517</link>
    <description>&lt;P&gt;Thanks!&amp;nbsp; After fixing the malformed if-statement it worked!&amp;nbsp; If you correct yours I can Accept as Solution:&lt;/P&gt;&lt;P&gt;if(count&amp;gt;=(info_max_time-info_min_time)/1800,100,count/((info_max_time-info_min_time)/1800)*100)&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2022 19:36:52 GMT</pubDate>
    <dc:creator>bsg273</dc:creator>
    <dc:date>2022-03-22T19:36:52Z</dc:date>
    <item>
      <title>How to create a table of availabilities of a given service for a set of hosts?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590081#M205442</link>
      <description>&lt;P&gt;I'm trying to create a table of availabilities (percent uptime) for a given service for a set of hosts.&amp;nbsp; My desired output is a simple 2-column table of "Host" and "Availability (%)", like the one below:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;Host&lt;/TD&gt;
&lt;TD width="50%"&gt;Availability&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;my-db-1&lt;/TD&gt;
&lt;TD width="50%"&gt;100%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;my-db-2&lt;/TD&gt;
&lt;TD width="50%"&gt;97.5%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;my-db-3&lt;/TD&gt;
&lt;TD width="50%"&gt;100%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;my-db-4&lt;/TD&gt;
&lt;TD width="50%"&gt;72.2%&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P class="lia-align-center"&gt;rhnsd Availabilities&lt;/P&gt;
&lt;P class="lia-align-left"&gt;I have a query I currently use to get just availability of a service for a single host, but I'd like to scale it larger to create the above output.&amp;nbsp; It assumes ps.sh is running every 1800 seconds and uses the number of events it finds over a give time period (info_max_time-info_min_time) and divides that by the total number of 1800 second intervals that can fit in the given time period, along with some conditions if no host matches or if the availability is &amp;gt;100.&amp;nbsp; That query is as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=os host="my-db-1.mydomain.net" sourcetype=ps rhnsd  | stats count, distinct_count(host) as hostcount | addinfo | eval availability=if(hostcount=0,0,if(count&amp;gt;=(info_max_time-info_min_time)/1800,100,count/((info_max_time-info_min_time)/1800))*100) | table availability&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Or if there's a much easier way to accomplish this that I don't know about, I'm all ears.&amp;nbsp; Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 04:11:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590081#M205442</guid>
      <dc:creator>bsg273</dc:creator>
      <dc:date>2022-03-23T04:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table of availabilities of a given service for a set of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590107#M205446</link>
      <description>&lt;P&gt;index=os host IN ("my-db-1.mydomain.net","my-db-2.mydomain.net","my-db-3.mydomain.net","my-db-4.mydomain.net") sourcetype=ps rhnsd&lt;BR /&gt;| stats count, distinct_count(host) as hostcount&lt;BR /&gt;| addinfo&lt;BR /&gt;| eval availability=if(hostcount=0,0,if(count&amp;gt;=(info_max_time-info_min_time)/1800,100,count/((info_max_time-info_min_time)/1800))*100)&lt;BR /&gt;| table host, availability&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 05:24:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590107#M205446</guid>
      <dc:creator>thatsabhijeet</dc:creator>
      <dc:date>2022-03-22T05:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table of availabilities of a given service for a set of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590234#M205485</link>
      <description>&lt;P&gt;Hmmm, this isn't working for me.&amp;nbsp; It's giving me a single row output in Statistics, whereby the host is blank and the availability is a single incorrect value.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 15:08:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590234#M205485</guid>
      <dc:creator>bsg273</dc:creator>
      <dc:date>2022-03-22T15:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table of availabilities of a given service for a set of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590276#M205507</link>
      <description>&lt;P&gt;Give this a try:&lt;/P&gt;&lt;P&gt;**Fixed malformed if condition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=os host IN ("my-db-1.mydomain.net",..other hosts..) sourcetype=ps rhnsd  | stats count by host | addinfo | eval availability=if(count&amp;gt;=(info_max_time-info_min_time)/1800,100,count/((info_max_time-info_min_time)/1800)*100) | table host availability&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that any host that is not reporting data will not appear in the result, not even with 0 as availability. To report availability of hosts that may not be reporting at all, you should create a lookup table with list of those hosts (just single column with name "host" will do) and use something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=os [| inputlookup yourhostlookup.csv | table host ] sourcetype=ps rhnsd  | stats count by host | addinfo | eval availability=if(count&amp;gt;=(info_max_time-info_min_time)/1800,100,count/((info_max_time-info_min_time)/1800)*100) | table host availability
| append [| inputlookup yourhostlookup.csv | table host | eval availability=0]
| stats max(availability) as availability by host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 19:47:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590276#M205507</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2022-03-22T19:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table of availabilities of a given service for a set of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590294#M205517</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; After fixing the malformed if-statement it worked!&amp;nbsp; If you correct yours I can Accept as Solution:&lt;/P&gt;&lt;P&gt;if(count&amp;gt;=(info_max_time-info_min_time)/1800,100,count/((info_max_time-info_min_time)/1800)*100)&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 19:36:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590294#M205517</guid>
      <dc:creator>bsg273</dc:creator>
      <dc:date>2022-03-22T19:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table of availabilities of a given service for a set of hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590297#M205518</link>
      <description>&lt;P&gt;Correction made to the answer.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 19:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-table-of-availabilities-of-a-given-service-for-a/m-p/590297#M205518</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2022-03-22T19:47:25Z</dc:date>
    </item>
  </channel>
</rss>

