<?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: system uptime calculation in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290251#M175678</link>
    <description>&lt;P&gt;Thanks morley, this query works for events starting with uptime 0 to some value, if server restarts, uptime starts from 0.  for this scenario, the uptime calculation doesn't workout!&lt;/P&gt;

&lt;P&gt;[2017-02-09 04:53:27,006]: host="infor-gtnalpq-msa1-1" , uptime="327"&lt;BR /&gt;
[2017-02-09 04:53:28,006]: host="infor-gtnalpq-msa1-1" , uptime="328"&lt;BR /&gt;
[2017-02-09 04:53:29,006]: host="infor-gtnalpq-msa1-1" , uptime="329"&lt;BR /&gt;
[2017-02-09 04:53:30,006]: host="infor-gtnalpq-msa1-1" , uptime="330"&lt;BR /&gt;
[2017-02-09 04:53:34,006]: host="infor-gtnalpq-msa1-1" , uptime="0"&lt;BR /&gt;
[2017-02-09 04:53:35,006]: host="infor-gtnalpq-msa1-1" , uptime="1"&lt;BR /&gt;
[2017-02-09 04:53:36,006]: host="infor-gtnalpq-msa1-1" , uptime="2"&lt;BR /&gt;
[2017-02-09 04:53:37,006]: host="infor-gtnalpq-msa1-1" , uptime="3"&lt;BR /&gt;
[2017-02-09 04:53:38,006]: host="infor-gtnalpq-msa1-1" , uptime="4"&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 09:41:19 GMT</pubDate>
    <dc:creator>pprakash2</dc:creator>
    <dc:date>2017-02-09T09:41:19Z</dc:date>
    <item>
      <title>system uptime calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290248#M175675</link>
      <description>&lt;P&gt;I have a field uptime which is being forwarded from one of the server i want to monitor its uptime. This field has accumulated value of time in seconds. How do i calculate uptime of server in percentage given the date range.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 09:34:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290248#M175675</guid>
      <dc:creator>pprakash2</dc:creator>
      <dc:date>2017-02-08T09:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: system uptime calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290249#M175676</link>
      <description>&lt;P&gt;It would help if you will post some examples to the uptime and date range fields&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 23:17:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290249#M175676</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-02-08T23:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: system uptime calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290250#M175677</link>
      <description>&lt;P&gt;example splunk events below: &lt;/P&gt;

&lt;P&gt;timestamp=15-01-2016 02:05:34.00, uptime=1231&lt;BR /&gt;
timestamp=15-01-2016 04:07:22.00, uptime=2398&lt;BR /&gt;
timestamp=16-01-2016 06:03:15.00, uptime=198792&lt;/P&gt;

&lt;P&gt;if the servecr is restarted the uptime counter starts from 0.  Based on these events, i need to calculate the % uptime , % downtime for the server. Could you please assist.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 04:04:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290250#M175677</guid>
      <dc:creator>pprakash2</dc:creator>
      <dc:date>2017-02-09T04:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: system uptime calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290251#M175678</link>
      <description>&lt;P&gt;Thanks morley, this query works for events starting with uptime 0 to some value, if server restarts, uptime starts from 0.  for this scenario, the uptime calculation doesn't workout!&lt;/P&gt;

&lt;P&gt;[2017-02-09 04:53:27,006]: host="infor-gtnalpq-msa1-1" , uptime="327"&lt;BR /&gt;
[2017-02-09 04:53:28,006]: host="infor-gtnalpq-msa1-1" , uptime="328"&lt;BR /&gt;
[2017-02-09 04:53:29,006]: host="infor-gtnalpq-msa1-1" , uptime="329"&lt;BR /&gt;
[2017-02-09 04:53:30,006]: host="infor-gtnalpq-msa1-1" , uptime="330"&lt;BR /&gt;
[2017-02-09 04:53:34,006]: host="infor-gtnalpq-msa1-1" , uptime="0"&lt;BR /&gt;
[2017-02-09 04:53:35,006]: host="infor-gtnalpq-msa1-1" , uptime="1"&lt;BR /&gt;
[2017-02-09 04:53:36,006]: host="infor-gtnalpq-msa1-1" , uptime="2"&lt;BR /&gt;
[2017-02-09 04:53:37,006]: host="infor-gtnalpq-msa1-1" , uptime="3"&lt;BR /&gt;
[2017-02-09 04:53:38,006]: host="infor-gtnalpq-msa1-1" , uptime="4"&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 09:41:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290251#M175678</guid>
      <dc:creator>pprakash2</dc:creator>
      <dc:date>2017-02-09T09:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: system uptime calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290252#M175679</link>
      <description>&lt;P&gt;Assuming uptime values makes sense: for this example first two lines have the same starting time.&lt;BR /&gt;
And timestamp is recognized as _time field,&lt;/P&gt;

&lt;P&gt;If the source looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults |eval a="time=15-01-2016 02:05:34.00, uptime=1231 BR
time=15-01-2016 02:45:32.00, uptime=3629 BR
time=16-01-2016 06:03:15.00, uptime=93253" |table a
|makemv delim="BR" a |mvexpand a |rename a as _raw |extract |eval _time=strptime(time,"%d-%m-%Y %H:%M:%S") |table _time uptime 



_time                 uptime
--------------------------------
2016-01-15 02:05:34 1231
2016-01-15 02:45:32 3629
2016-01-16 06:03:15 93253
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then the following query will calculate the precentage of uptime and downtime&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults |eval a="time=15-01-2016 02:05:34.00, uptime=1231 BR
time=15-01-2016 02:45:32.00, uptime=3629 BR
time=16-01-2016 06:03:15.00, uptime=93253" |table a
|makemv delim="BR" a |mvexpand a |rename a as _raw |extract |eval _time=strptime(time,"%d-%m-%Y %H:%M:%S") |table _time uptime 


|eval start=_time-uptime,end=_time |eval startc=start,endc=end  
|convert ctime(*c) |sort - _time |dedup start |reverse | streamstats values(end) as before_end window=1 current=f |eval downtime=start-before_end |stats sum(uptime) as uptime sum(downtime) as downtime
|eval overall=uptime+downtime |eval uptime=(uptime/overall)*100,downtime=(downtime/overall)*100 |table uptime downtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;uptime  downtime
95.08   4.92
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 11:11:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290252#M175679</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-02-09T11:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: system uptime calculation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290253#M175680</link>
      <description>&lt;P&gt;Thanks Ehud, this was helpful!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 06:10:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/system-uptime-calculation/m-p/290253#M175680</guid>
      <dc:creator>pprakash2</dc:creator>
      <dc:date>2017-02-23T06:10:14Z</dc:date>
    </item>
  </channel>
</rss>

