Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Perlmonks Nodes Per Hour

by blakem (Monsignor)
on Nov 29, 2001 at 13:49 UTC ( [id://128308]=sourcecode: print w/replies, xml ) Need Help??
Category: PerlMonks Related Scripts
Author/Contact Info blakem .... uh, /msg blakem
Description: Displays new nodes per hour as a bargraph (see the sample output in the code below). Its quick and dirty, so there isn't much thats customizable. It will need your user/pass combo to make the XML feeds work, though. The sample output is in Pacific time but the script will recognize your own localtime settings.

Update: slight pod tweak for the podmaster
Update2: added second sample output based on a full month of data

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

my $startid  = shift || 128020;
my $endid    = shift || 128303;
my $xmlurl   = "http://perlmonks.org/index.pl?node_id=37150";
my $user     = 'blakem';
my $pass     = 'yeahright';

## Ask the perlmonks XML engine about the nodes
my $queryurl = $xmlurl . '&nodes=' . join(',',$startid .. $endid) .
               "&user=$user&passwd=$pass&op=login";
my $nodeinfo = XMLin(get $queryurl);

## Tally what hour they were posted in %nodecount
my %nodecount;
for my $node (@{$nodeinfo->{NODE}}) {
  my ($year,$mon,$mday,$hours,$min,$sec) =
    $node->{createtime} =~ /(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
  $year -= 1900;
  $mon--;
  my $time = timegm($sec,$min,$hours,$mday,$mon,$year);
  my $hour = (localtime($time))[2];
  # print $node->{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   ( New nodes per hour for 11/28 in PST )
 00 ( 7) ################
 01 ( 3) #######
 02 ( 7) ################
 03 ( 6) ##############
 04 ( 3) #######
 05 ( 7) ################
 06 (17) ########################################
 07 (29) #############################################################
+########
 08 (16) ######################################
 09 (28) #############################################################
+#####
 10 (16) ######################################
 11 (23) ######################################################
 12 (19) #############################################
 13 (26) #############################################################
 14 (25) ###########################################################
 15 (17) ########################################
 16 ( 2) ####
 17 ( 5) ###########
 18 ( 3) #######
 19 ( 4) #########
 20 (10) #######################
 21 ( 7) ################
 22 ( 1) ##
 23 ( 3) #######


=head2  Output for a one-month sampling period... 
 00 (122) ##################
 01 (173) ##########################
 02 (176) ##########################
 03 (187) ############################
 04 (160) ########################
 05 (241) ####################################
 06 (307) ###############################################
 07 (440) ############################################################
+#######
 08 (399) ############################################################
+#
 09 (439) ############################################################
+#######
 10 (408) ############################################################
+##
 11 (411) ############################################################
+##
 12 (444) ############################################################
+########
 13 (368) ########################################################
 14 (347) #####################################################
 15 (281) ###########################################
 16 (256) #######################################
 17 (243) #####################################
 18 (207) ###############################
 19 (177) ###########################
 20 (188) ############################
 21 (149) ######################
 22 (127) ###################
 23 (112) #################

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2025-06-17 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.