aboutsummaryrefslogtreecommitdiffstats
path: root/stats.pl
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2015-02-11 23:44:50 +0100
committerMarius Halden <marius.h@lden.org>2015-02-11 23:44:50 +0100
commit82174ec3583dfb8102677c6ed29251a99a28499d (patch)
treec6be18c747bd148aa995d8d7fc3adc10c76611e4 /stats.pl
parent59227c420dfe7f0c12e952679cabfc7acb87f311 (diff)
downloadappdrift-stats-82174ec3583dfb8102677c6ed29251a99a28499d.tar.gz
appdrift-stats-82174ec3583dfb8102677c6ed29251a99a28499d.tar.bz2
appdrift-stats-82174ec3583dfb8102677c6ed29251a99a28499d.tar.xz
Some cleanup
Diffstat (limited to 'stats.pl')
-rwxr-xr-xstats.pl56
1 files changed, 18 insertions, 38 deletions
diff --git a/stats.pl b/stats.pl
index ef4442e..ef1261b 100755
--- a/stats.pl
+++ b/stats.pl
@@ -103,13 +103,12 @@ for my $group (sort keys %$groups) {
}
}
- $groups->{$group}->{'users'} = $users; #defined($users) ? $users : 0;
- $groups->{$group}->{'posts'} = $posts; #defined($posts) ? $posts : 0;
- $groups->{$group}->{'comments'} = $comments; #defined($comments) ? $comments : 0;
+ $groups->{$group}->{'users'} = $users;
+ $groups->{$group}->{'posts'} = $posts;
+ $groups->{$group}->{'comments'} = $comments;
}
my $group_info = {};
-
my %g_rrd_info = (
destination => "$rrd_path/graph",
periods => [ qw(day week month) ],
@@ -125,21 +124,13 @@ for my $group (sort keys %$groups) {
my $uptime_rrd = RRD::Simple->new( file => "$rrd_path/rrd/$group-uptime.rrd" );
my $users_rrd = RRD::Simple->new( file => "$rrd_path/rrd/$group-users.rrd" );
- unless ( -f "$rrd_path/rrd/$group-uptime.rrd" ) {
- $uptime_rrd->create(
- uptime => "GAUGE",
- maintenance => "GAUGE",
- downtime => "GAUGE",
- );
- }
+ mkdir "$rrd_path/graph/$group" unless ( -d "$rrd_path/graph/$group" );
- unless ( -f "$rrd_path/rrd/$group-users.rrd" ) {
- $users_rrd->create(
- users => "GAUGE",
- maintenance => "GAUGE",
- downtime => "GAUGE",
- );
- }
+ $uptime_rrd->create(uptime => "GAUGE", maintenance => "GAUGE", downtime => "GAUGE")
+ unless ( -f "$rrd_path/rrd/$group-uptime.rrd" );
+
+ $users_rrd->create(users => "GAUGE", maintenance => "GAUGE", downtime => "GAUGE")
+ unless ( -f "$rrd_path/rrd/$group-users.rrd" );
$uptime_rrd->update(
uptime => $groups->{$group}->{'time_up'},
@@ -152,8 +143,6 @@ for my $group (sort keys %$groups) {
posts => $groups->{$group}->{'posts'},
comments => $groups->{$group}->{'comments'},
);
-
- mkdir "$rrd_path/graph/$group" unless ( -d "$rrd_path/graph/$group" );
$uptime_rrd->graph(
%rrd_info,
@@ -238,44 +227,38 @@ for my $group (sort keys %$groups) {
$group_info->{'comments'}->{$group} = $groups->{$group}->{'comments'};
}
-## Score related
my $pos_rrd = "$rrd_path/rrd/positions.rrd";
my $bal_rrd = "$rrd_path/rrd/balance.rrd";
my $upt_rrd = "$rrd_path/rrd/uptime.rrd";
my $dwn_rrd = "$rrd_path/rrd/downtime.rrd";
my $mnt_rrd = "$rrd_path/rrd/maintenance.rrd";
+my $usr_rrd = "$rrd_path/rrd/users.rrd";
+my $pst_rrd = "$rrd_path/rrd/posts.rrd";
+my $cmt_rrd = "$rrd_path/rrd/comments.rrd";
my $position_rrd = RRD::Simple->new( file => "$pos_rrd" );
my $balance_rrd = RRD::Simple->new( file => "$bal_rrd" );
my $uptime_rrd = RRD::Simple->new( file => "$upt_rrd" );
my $downtime_rrd = RRD::Simple->new( file => "$dwn_rrd" );
my $maint_rrd = RRD::Simple->new( file => "$mnt_rrd" );
+my $user_rrd = RRD::Simple->new( file => "$usr_rrd" );
+my $post_rrd = RRD::Simple->new( file => "$pst_rrd" );
+my $comment_rrd = RRD::Simple->new( file => "$cmt_rrd" );
$position_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$pos_rrd" );
$balance_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$bal_rrd" );
$uptime_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$upt_rrd" );
$downtime_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$dwn_rrd" );
$maint_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$mnt_rrd" );
+$user_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$usr_rrd" );
+$post_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$pst_rrd" );
+$comment_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$cmt_rrd" );
my @pos_sources = $position_rrd->sources("$pos_rrd");
my @bal_sources = $balance_rrd->sources("$bal_rrd");
my @upt_sources = $uptime_rrd->sources("$upt_rrd");
my @dwn_sources = $downtime_rrd->sources("$dwn_rrd");
my @mnt_sources = $maint_rrd->sources("$mnt_rrd");
-
-## User related
-my $usr_rrd = "$rrd_path/rrd/users.rrd";
-my $pst_rrd = "$rrd_path/rrd/posts.rrd";
-my $cmt_rrd = "$rrd_path/rrd/comments.rrd";
-
-my $user_rrd = RRD::Simple->new( file => "$usr_rrd" );
-my $post_rrd = RRD::Simple->new( file => "$pst_rrd" );
-my $comment_rrd = RRD::Simple->new( file => "$cmt_rrd" );
-
-$user_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$usr_rrd" );
-$post_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$pst_rrd" );
-$comment_rrd->create(%{$group_info->{'rrd_groups'}}) unless ( -f "$cmt_rrd" );
-
my @usr_sources = $user_rrd->sources("$usr_rrd");
my @pst_sources = $user_rrd->sources("$pst_rrd");
my @cmt_sources = $comment_rrd->sources("$cmt_rrd");
@@ -286,7 +269,6 @@ for my $group (keys %{$group_info->{'rrd_groups'}}) {
$uptime_rrd->add_source("$upt_rrd", $group => $group_info->{'rrd_groups'}->{$group}) unless (in_array($group, \@upt_sources));
$downtime_rrd->add_source("$dwn_rrd", $group => $group_info->{'rrd_groups'}->{$group}) unless (in_array($group, \@dwn_sources));
$maint_rrd->add_source("$mnt_rrd", $group => $group_info->{'rrd_groups'}->{$group}) unless (in_array($group, \@mnt_sources));
-
$user_rrd->add_source("$usr_rrd", $group => $group_info->{'rrd_groups'}->{$group}) unless (in_array($group, \@usr_sources));
$post_rrd->add_source("$pst_rrd", $group => $group_info->{'rrd_groups'}->{$group}) unless (in_array($group, \@pst_sources));
$comment_rrd->add_source("$cmt_rrd", $group => $group_info->{'rrd_groups'}->{$group}) unless (in_array($group, \@cmt_sources));
@@ -297,7 +279,6 @@ $balance_rrd->update(%{$group_info->{'balance'}});
$uptime_rrd->update(%{$group_info->{'uptime'}});
$downtime_rrd->update(%{$group_info->{'downtime'}});
$maint_rrd->update(%{$group_info->{'maintenance'}});
-
$user_rrd->update(%{$group_info->{'users'}});
$post_rrd->update(%{$group_info->{'posts'}});
$comment_rrd->update(%{$group_info->{'comments'}});
@@ -350,7 +331,6 @@ $uptime_rrd->graph(
vertical_label => "Uptime/seconds",
);
-
$user_rrd->graph(
%g_rrd_info,
basename => "users",