Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Plot Your Nodes by Hour

by blakem (Monsignor)
on Nov 30, 2001 at 02:54 UTC ( #128488=sourcecode: print w/replies, xml ) Need Help??
Category: Perlmonks Related Scripts
Author/Contact Info blakem .... uh, /msg blakem
Description: Displays a bargraph of *your* nodes per hour. Similiar to the previous one, but parses a different XML feed and shows data about all the nodes you have personally posted.

(telling observation: I have yet to post a node during the 9am-10am slot....)

#!/usr/bin/perl -wT
use strict;
use LWP::Simple;
use XML::Simple;
use Time::Local;
use Text::BarGraph;

my $xmlurl       = "http://perlmonks.org/index.pl?node_id=32704";
my $user         = 'blakem';
my $pass         = 'yeahright';

## Ask the perlmonks XML engine about my nodes
my $queryurl = $xmlurl . "&user=$user&passwd=$pass&op=login";
my $xml = get $queryurl;
$xml =~  tr [\200-\377] [\000-\177];  # kludge to zero out high-bit as
+cii
my $nodeinfo = XMLin($xml);

## Tally what hour they were posted in %nodecount
my %nodecount = map {$_=>0} ('00' .. '23');
for my $node (values %{$nodeinfo->{NODE}}) {
  my ($year,$mon,$mday,$hours,$min,$sec) = split(/\D+/,$node->{createt
+ime});
  $year -= 1900;
  $mon--;
  my $time = timegm($sec,$min,$hours,$mday,$mon,$year);
  my $hour = (localtime($time))[2];
  # print $node->{id} .": ". localtime($time) . " => $hour\n";
  $nodecount{sprintf("%02d",$hour)}++;
}

# print out a bargraph
my $g = Text::BarGraph->new();
$g->{num} = 1;
print $g->graph(\%nodecount);

=head1 OUTPUT ( blakems nodes by the hour they were posted )
 00 (43) ###################################################
 01 (39) ##############################################
 02 (26) ##############################
 03 (26) ##############################
 04 ( 7) ########
 05 (11) #############
 06 ( 4) ####
 07 ( 2) ##
 08 ( 1) #
 09 ( 0) 
 10 (30) ###################################
 11 (51) ############################################################
 12 (54) #############################################################
+###
 13 (35) #########################################
 14 (42) #################################################
 15 (58) #############################################################
+########
 16 (58) #############################################################
+########
 17 (41) ################################################
 18 (15) #################
 19 ( 4) ####
 20 (10) ###########
 21 (18) #####################
 22 (23) ###########################
 23 (30) ###################################

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://128488]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2020-12-05 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (63 votes). Check out past polls.

    Notices?