The execs at my company want a similar 'snapshot'. Essentially I create a graph showing usage in 15 minute intervals. For every log entry I parse the session and date. I convert the date like below:
for($date){ ($h,$m,$s)=split/:/; s/\:\d\d$//; #throw out the seconds, we don't need them $m="00" if ($m<15); $m="15" if (($m>=15) && ($m<30)); $m="30" if (($m>=30) && ($m<45)); $m="45" if ($m>=45); s/\:\d\d\/\:$m/; #replace the minutes with the generalized value }
Now I create a hash with the key values equal to a the generalized timestamp. This lets me see how many unique sessions were active during a given 15 minute interval:
$parseddata{$date}++ unless grep{$_ eq "$date|$session"}@seen; push @seen,"$date|$session";
Now I have a hash with keys equal to 15 minute interval timestamps and values equal to the number of unique sessions active during the interval. I then create the graph:
my @keys = sort keys %parseddata; my @values; for(@keys){ push @values,$parseddata{$_}; } my @data=([@keys],[@values]); my $graph=GD::Graph::area->new(1000,600); #set all the graph options(labels, colors etc...) my $gd = $graph->plot(\@data); open(GRAPH, ">/graphs/$datestamp.png) or die "Can't open output file f +or graph: $!"; binmode GRAPH; print GRAPH $gd->png;

In reply to Re: How to do session times The Right Way by insensate
in thread How to do session times The Right Way by strider corinth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.