-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcounter
102 lines (85 loc) · 2.46 KB
/
counter
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
######################################################################
#
# Show the number of eprints currently in the repository
#
# Used for remote monitoring of repository growth. eg. by
# software.eprints.org
#
######################################################################
#
# __COPYRIGHT__
#
# Copyright 2000-2015 University of Southampton. All Rights Reserved.
#
# __LICENSE__
#
######################################################################
use EPrints;
use strict;
my $eprints = EPrints->new;
my $repo = $eprints->current_repository;
exit( 0 ) unless( defined $repo );
$repo->send_http_header( content_type=>"text/plain; charset=UTF-8" );
my %counts;
foreach my $ds_id ($repo->get_sql_dataset_ids)
{
my $ds = $repo->dataset( $ds_id );
my $table = $ds->get_sql_table_name;
$counts{$ds_id} = $repo->get_database->count_table( $table );
}
{
my $ds = $repo->dataset( "eprint" );
my $search = $ds->prepare_search;
my @counts = $search->perform_groupby( $ds->field( "eprint_status" ) );
foreach my $i (0..$#{$counts[0]})
{
$counts{$counts[0]->[$i]} = $counts[1]->[$i];
}
for(qw( inbox buffer archive deletion ))
{
$counts{$_} ||= 0;
}
}
foreach my $ds_id ( sort keys %counts )
{
print sprintf("%s: %i\n",
$ds_id,
$counts{$ds_id}
);
}
# version
print "Version: " . $repo->config( "version_description" ) . "\n";
print "Base EPrints version: " . EPrints->human_version . " " . $repo->config( "base_vendor_short" ) . "\n";
foreach my $key ( qw / base_version_long base_version_alias base_vendor_long base_vendor_short/ )
{
print $key . ": " . $repo->config( $key ) . "\n";
}
print "Platform version: " . $repo->config( "version_short" ) . " " . $repo->config( "vendor_short" ) . "\n";
foreach my $key ( qw / version_long version_alias vendor_long vendor_short version_tag/ )
{
print $key . ": " . $repo->config( $key ) . "\n";
}
# Indexer Status
my $daemon = EPrints::Index::Daemon->new(
session => $repo,
logfile => EPrints::Index::logfile(),
noise => ($repo->{noise}||1),
);
my $status = "not-running";
$status = "running" if $daemon->is_running();
$status = "stalled" if $daemon->has_stalled();
print "indexer: $status\n";
print "epm: ";
{
my $first = 1;
$repo->dataset( 'epm' )->dataobj_class->map($repo, sub {
my( undef, undef, $epm ) = @_;
print "; " if !$first;
$first = 0;
print $epm->value( "epmid" ) . "=" . $epm->value( "version" );
});
}
print "\n";
# ULCC version
printf( "ulcc_version: %s\n", $repo->config( "ulcc_version" ) );
exit;