Displaying: e84cf01b7daa6145a33ad8ef4dbbb14a [new Paste]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#/usr/bin/perl
use strict;
use RRD::Simple ();
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use URI::Escape;
require Data::Dumper;
 
$RRD::Simple::DEBUG=1;	 
 
my $rrd = RRD::Simple->new( file => "devrandom.rrd" );
print Data::Dumper::Dumper($rrd);
my @players=("mute", "matt_", "heeen");
 
if(!-e "devrandom.rrd")
{
$rrd->create(
		 timeplayed_mute => "COUNTER",
		 timeplayed_matt_ => "COUNTER",
		 timeplayed_heeen => "COUNTER"
	 )
}
my %data;
 
my $ua = LWP::UserAgent->new(agent => 'Mozilla/5.0');
 
foreach(@players)
{
	my $response = $ua->get( "http://stats.enemyterritory.com/profile/$_?xml=true");
 
	if ( $response->is_error() ) {
		print "Error-Code    : ".$response->code()."Fehlermeldung: ".$response->message();
	}
	else 
	{
		my $content=$response->content();
		my ( $time_played ) = $content =~ /time_played="(\d+)"/;
		#print $_,$time_played,"\n";
		if ( $time_played ) 
		{
			$data{"timeplayed_$_"}=time;
 
		}
	}
}
 
$rrd->update(%data);
 
 
my %rtn = $rrd->graph(
		 destination => "/var/www/heeen.de/htdocs/graph/",
		 title => "devrandom",
		 vertical_label => "ETQW Time spent",
		 interlaced => "",
		 width=>"800",
		 height=>"400"
		 );
 
 
Highlighting: perl