<?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 Script/AWK help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413792#M861324</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to work out a script but not getting the result I want. Maybe you guys can help:&lt;BR /&gt;&lt;BR /&gt;I have a list that contains:&lt;BR /&gt;Start month, Start day, Start Hour, Stop Month, Stop day, Stop Hour.&lt;BR /&gt;&lt;BR /&gt;Like next example:&lt;BR /&gt;3 29 6 3 29 6&lt;BR /&gt;3 29 15 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 18&lt;BR /&gt;3 29 17 3 31 18&lt;BR /&gt;3 29 18 3 29 18&lt;BR /&gt;3 29 18 3 29 18&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 2 0&lt;BR /&gt;4 2 0 4 2 0&lt;BR /&gt;4 2 0 4 2 0&lt;BR /&gt;&lt;BR /&gt;Al these timing represent the start and stop of an application.&lt;BR /&gt;I like to figure out how many concurent users I have on an hourly basis on each day i have. So if a user runs the application for 2 day's it will be counted for 1 user per hour during run day's:&lt;BR /&gt;The result must look like:&lt;BR /&gt;&lt;BR /&gt;"Month" "day" "hour" "count of concurent users"&lt;BR /&gt;3         29     6      2&lt;BR /&gt;3         29     7      4&lt;BR /&gt;3         29     8      1&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;4         1      0      4&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope you can help out.&lt;BR /&gt;Regards,&lt;BR /&gt;Peter</description>
    <pubDate>Wed, 03 Nov 2004 07:12:40 GMT</pubDate>
    <dc:creator>Hoefnix</dc:creator>
    <dc:date>2004-11-03T07:12:40Z</dc:date>
    <item>
      <title>Script/AWK help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413792#M861324</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to work out a script but not getting the result I want. Maybe you guys can help:&lt;BR /&gt;&lt;BR /&gt;I have a list that contains:&lt;BR /&gt;Start month, Start day, Start Hour, Stop Month, Stop day, Stop Hour.&lt;BR /&gt;&lt;BR /&gt;Like next example:&lt;BR /&gt;3 29 6 3 29 6&lt;BR /&gt;3 29 15 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 17&lt;BR /&gt;3 29 17 3 29 18&lt;BR /&gt;3 29 17 3 31 18&lt;BR /&gt;3 29 18 3 29 18&lt;BR /&gt;3 29 18 3 29 18&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 1 23&lt;BR /&gt;4 1 23 4 2 0&lt;BR /&gt;4 2 0 4 2 0&lt;BR /&gt;4 2 0 4 2 0&lt;BR /&gt;&lt;BR /&gt;Al these timing represent the start and stop of an application.&lt;BR /&gt;I like to figure out how many concurent users I have on an hourly basis on each day i have. So if a user runs the application for 2 day's it will be counted for 1 user per hour during run day's:&lt;BR /&gt;The result must look like:&lt;BR /&gt;&lt;BR /&gt;"Month" "day" "hour" "count of concurent users"&lt;BR /&gt;3         29     6      2&lt;BR /&gt;3         29     7      4&lt;BR /&gt;3         29     8      1&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;4         1      0      4&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope you can help out.&lt;BR /&gt;Regards,&lt;BR /&gt;Peter</description>
      <pubDate>Wed, 03 Nov 2004 07:12:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413792#M861324</guid>
      <dc:creator>Hoefnix</dc:creator>
      <dc:date>2004-11-03T07:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script/AWK help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413793#M861325</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;could you be more precise about getting your desired output&lt;BR /&gt;How do you get to your "3 29 8 1" output for example ?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Franky</description>
      <pubDate>Wed, 03 Nov 2004 09:12:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413793#M861325</guid>
      <dc:creator>Franky_1</dc:creator>
      <dc:date>2004-11-03T09:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script/AWK help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413794#M861326</link>
      <description>Peter,&lt;BR /&gt;&lt;BR /&gt; Your input data's are dealing with starting / stopping time of application. No user details there.&lt;BR /&gt;&lt;BR /&gt; Can your elaborate on your result more.&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
      <pubDate>Wed, 03 Nov 2004 09:57:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413794#M861326</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-11-03T09:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Script/AWK help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413795#M861327</link>
      <description>Hey Peter, With all due respect, it looks to me you gave a lousy input example!&lt;BR /&gt;I think you are looking for something like this perl script:&lt;BR /&gt;&lt;BR /&gt;use Time::Local;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt; ($bm, $bd, $bh, $em, $ed, $eh) = split;&lt;BR /&gt; $time = timelocal(0,0,$bh,$bd,$bm-1,2004);&lt;BR /&gt; $end  = timelocal(0,0,$eh,$ed,$em-1,2004);&lt;BR /&gt; while ($time &amp;lt; $end) {&lt;BR /&gt;    ($sec,$min,$hour,$mday,$mon,$year) = localtime $time;&lt;BR /&gt;    $key = sprintf ("%02d %02d %02d", $mon+1, $mday, $hour);&lt;BR /&gt;    $usage{$key}++;&lt;BR /&gt;    $time +=3600;&lt;BR /&gt;    }&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;foreach $time (sort keys %usage) {&lt;BR /&gt;  print "$time $usage{$time}\n";&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;For each data line it takes each begin and end time and converts it to seconds. &lt;BR /&gt;Then it adds one to the array entry for the start second for each hour in the range.&lt;BR /&gt;When all lines are doen it reports the accumulate users for each start hour it ever touched.&lt;BR /&gt;&lt;BR /&gt;With this input:&lt;BR /&gt;&lt;BR /&gt;3 30 6 3 30 16&lt;BR /&gt;3 30 14 3 30 17&lt;BR /&gt;3 30 18 3 30 19&lt;BR /&gt;3 30 13 4 01 18&lt;BR /&gt;4 1 10 4 1 23&lt;BR /&gt;4 1 20 4 1 21&lt;BR /&gt;&lt;BR /&gt;The output becomes:&lt;BR /&gt;&lt;BR /&gt;03 30 06 1&lt;BR /&gt;03 30 07 1&lt;BR /&gt;03 30 08 1&lt;BR /&gt;03 30 09 1&lt;BR /&gt;03 30 10 1&lt;BR /&gt;03 30 11 1&lt;BR /&gt;03 30 12 1&lt;BR /&gt;03 30 13 2&lt;BR /&gt;03 30 14 3&lt;BR /&gt;03 30 15 3&lt;BR /&gt;03 30 16 2&lt;BR /&gt;03 30 17 1&lt;BR /&gt;03 30 18 2&lt;BR /&gt;03 30 19 1&lt;BR /&gt;03 30 20 1&lt;BR /&gt; :&lt;BR /&gt;04 01 09 1&lt;BR /&gt;04 01 10 2&lt;BR /&gt;04 01 11 2&lt;BR /&gt;04 01 12 2&lt;BR /&gt;04 01 13 2&lt;BR /&gt;04 01 14 2&lt;BR /&gt;04 01 15 2&lt;BR /&gt;04 01 16 2&lt;BR /&gt;04 01 17 2&lt;BR /&gt;04 01 18 1&lt;BR /&gt;04 01 19 1&lt;BR /&gt;04 01 20 2&lt;BR /&gt;04 01 21 1&lt;BR /&gt;04 01 22 1&lt;BR /&gt;&lt;BR /&gt;Met vriendelijke groetjes,&lt;BR /&gt;En veel geluk er mee!&lt;BR /&gt;:-).&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Nov 2004 10:13:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413795#M861327</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-11-03T10:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script/AWK help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413796#M861328</link>
      <description>Hein,&lt;BR /&gt;&lt;BR /&gt;It looks to me that you got the correct output from my lousy input. The input file I've got is very large so I just cut and pasted some small part. I will test your solution tomorrow because I am in a meeting right now. Thanks anyway.&lt;BR /&gt;&lt;BR /&gt;Franky,&lt;BR /&gt;The output have to name the number of runs of an application within that hour of a day.&lt;BR /&gt;&lt;BR /&gt;Muthukumar,&lt;BR /&gt;I have user data in this file, but it does not interest me at the moment because the same user can run multiple session of this application. The stats show them per session as one row.&lt;BR /&gt;&lt;BR /&gt;Thanks all and I report back tomorrow,&lt;BR /&gt;Peter</description>
      <pubDate>Wed, 03 Nov 2004 10:37:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413796#M861328</guid>
      <dc:creator>Hoefnix</dc:creator>
      <dc:date>2004-11-03T10:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script/AWK help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413797#M861329</link>
      <description>&amp;gt;&amp;gt; It looks to me that you got the correct output from my lousy input. &lt;BR /&gt;&lt;BR /&gt;:-)&lt;BR /&gt;&lt;BR /&gt;My biggest problem was that the suggested output did not line up with the suggested input. That, plus the fact that the sample input consisted mostly of 'null' records (usage less than 1 full hour?).&lt;BR /&gt;&lt;BR /&gt;btw....&lt;BR /&gt;&lt;BR /&gt;Just in case anyone ever needs a thing smilar to this being year-end resilient...&lt;BR /&gt;Here is a tweak that will make that happen.&lt;BR /&gt;(Also, it should really use the actual year ,not my hardcoded 2004, to deal with leap years properly :-)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-------------------- perl script ----------&lt;BR /&gt;use Time::Local;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt; ($bm, $bd, $bh, $em, $ed, $eh) = split;&lt;BR /&gt; $time = timelocal(0,0,$bh,$bd,$bm-1,2004);&lt;BR /&gt; $end  = timelocal(0,0,$eh,$ed,$em-1,($em&amp;lt;$bm)? 2005: 2004);&lt;BR /&gt; while ($time &amp;lt; $end) {&lt;BR /&gt;    ($sec,$min,$hour,$mday,$mon,$year) = localtime $time;&lt;BR /&gt;    $key = sprintf ("%1d %02d %02d %02d", $year-104,$mon+1, $mday, $hour);&lt;BR /&gt;    $usage{$key}++;&lt;BR /&gt;    $time +=3600;&lt;BR /&gt;    }&lt;BR /&gt; }&lt;BR /&gt;foreach $time (sort keys %usage) {&lt;BR /&gt;  print "$time $usage{$time}\n";&lt;BR /&gt;  }&lt;BR /&gt;---------------------- sample input --------&lt;BR /&gt;3 31 20 3 31 23&lt;BR /&gt;3 31 18 3 31 22&lt;BR /&gt;3 31 21 4 01 6&lt;BR /&gt;12 31 21 01 01 01&lt;BR /&gt;12 31 22 12 31 23&lt;BR /&gt;------output for that  sample input --------&lt;BR /&gt;0 03 31 18 1&lt;BR /&gt;0 03 31 19 1&lt;BR /&gt;0 03 31 20 2&lt;BR /&gt;0 03 31 21 3&lt;BR /&gt;0 03 31 22 2&lt;BR /&gt;0 03 31 23 1&lt;BR /&gt;0 04 01 00 1&lt;BR /&gt;0 04 01 01 1&lt;BR /&gt;0 04 01 02 1&lt;BR /&gt;0 04 01 03 1&lt;BR /&gt;0 04 01 04 1&lt;BR /&gt;0 04 01 05 1&lt;BR /&gt;0 12 31 21 1&lt;BR /&gt;0 12 31 22 2&lt;BR /&gt;0 12 31 23 1&lt;BR /&gt;1 01 01 00 1&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Nov 2004 14:01:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413797#M861329</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-11-03T14:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script/AWK help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413798#M861330</link>
      <description>Hein,&lt;BR /&gt;&lt;BR /&gt;Your scripts work fine. There is one remark. You already mentioned it in the second post, but the times that an application runs within the same hour needs also be counted for that hour.&lt;BR /&gt;With this script these stats are not comming back in the output.&lt;BR /&gt;&lt;BR /&gt;Thanks anyway because I would not have been succesful writing this myself. I will try to fix the counts of less then 1 hour runs.&lt;BR /&gt;&lt;BR /&gt;Regards(vriendelijke groet),&lt;BR /&gt;Peter</description>
      <pubDate>Fri, 05 Nov 2004 03:23:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-awk-help/m-p/3413798#M861330</guid>
      <dc:creator>Hoefnix</dc:creator>
      <dc:date>2004-11-05T03:23:47Z</dc:date>
    </item>
  </channel>
</rss>

