influxdb: per-backend stats
This commit is contained in:
parent
5354a6f6c5
commit
f1ef2e472a
1 changed files with 48 additions and 53 deletions
|
@ -29,7 +29,7 @@ sub run {
|
||||||
my $active = $now->clone->subtract( months => 1 );
|
my $active = $now->clone->subtract( months => 1 );
|
||||||
|
|
||||||
my @stats;
|
my @stats;
|
||||||
my @stations;
|
my @backend_stats;
|
||||||
my @traewelling;
|
my @traewelling;
|
||||||
|
|
||||||
push(
|
push(
|
||||||
|
@ -85,50 +85,31 @@ sub run {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
push(
|
my @backends = $self->app->stations->get_backends;
|
||||||
@stations,
|
|
||||||
query_to_influx(
|
for my $backend (@backends) {
|
||||||
'iris',
|
push(
|
||||||
$db->select(
|
@backend_stats,
|
||||||
'stations',
|
[
|
||||||
'count(*) as count',
|
$backend->{iris} ? 'IRIS' : $backend->{name},
|
||||||
{
|
$db->select(
|
||||||
source => 0,
|
'stations',
|
||||||
archived => 0
|
'count(*) as count',
|
||||||
}
|
{
|
||||||
)->hash->{count}
|
source => $backend->{id},
|
||||||
)
|
archived => 0
|
||||||
);
|
}
|
||||||
push(
|
)->hash->{count},
|
||||||
@stations,
|
$db->select(
|
||||||
query_to_influx(
|
'related_stations',
|
||||||
'hafas',
|
'count(*) as count',
|
||||||
$db->select(
|
{
|
||||||
'stations',
|
backend_id => $backend->{id},
|
||||||
'count(*) as count',
|
}
|
||||||
{
|
)->hash->{count}
|
||||||
source => 1,
|
]
|
||||||
archived => 0
|
);
|
||||||
}
|
}
|
||||||
)->hash->{count}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
push(
|
|
||||||
@stations,
|
|
||||||
query_to_influx(
|
|
||||||
'archived',
|
|
||||||
$db->select( 'stations', 'count(*) as count', { archived => 1 } )
|
|
||||||
->hash->{count}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
push(
|
|
||||||
@stations,
|
|
||||||
query_to_influx(
|
|
||||||
'meta',
|
|
||||||
$db->select( 'related_stations', 'count(*) as count' )
|
|
||||||
->hash->{count}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
push(
|
push(
|
||||||
@traewelling,
|
@traewelling,
|
||||||
|
@ -167,10 +148,18 @@ sub run {
|
||||||
. $self->app->config->{influxdb}->{url}
|
. $self->app->config->{influxdb}->{url}
|
||||||
. ' stats '
|
. ' stats '
|
||||||
. join( ',', @stats ) );
|
. join( ',', @stats ) );
|
||||||
$self->app->log->debug( 'POST '
|
for my $backend_entry (@backend_stats) {
|
||||||
. $self->app->config->{influxdb}->{url}
|
$self->app->log->debug(
|
||||||
. ' stations '
|
'POST '
|
||||||
. join( ',', @stations ) );
|
. $self->app->config->{influxdb}->{url}
|
||||||
|
. ' stations,backend='
|
||||||
|
. $backend_entry->[0]
|
||||||
|
. sprintf(
|
||||||
|
' count=%d,meta=%d',
|
||||||
|
$backend_entry->[1], $backend_entry->[2]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
$self->app->log->debug( 'POST '
|
$self->app->log->debug( 'POST '
|
||||||
. $self->app->config->{influxdb}->{url}
|
. $self->app->config->{influxdb}->{url}
|
||||||
. ' traewelling '
|
. ' traewelling '
|
||||||
|
@ -181,10 +170,16 @@ sub run {
|
||||||
$self->app->config->{influxdb}->{url},
|
$self->app->config->{influxdb}->{url},
|
||||||
'stats ' . join( ',', @stats )
|
'stats ' . join( ',', @stats )
|
||||||
)->wait;
|
)->wait;
|
||||||
$self->app->ua->post_p(
|
my $buf = q{};
|
||||||
$self->app->config->{influxdb}->{url},
|
for my $backend_entry (@backend_stats) {
|
||||||
'stations ' . join( ',', @stations )
|
$buf
|
||||||
)->wait;
|
.= "\nstations,backend="
|
||||||
|
. $backend_entry->[0]
|
||||||
|
. sprintf( ' count=%d,meta=%d',
|
||||||
|
$backend_entry->[1], $backend_entry->[2] );
|
||||||
|
}
|
||||||
|
$self->app->ua->post_p( $self->app->config->{influxdb}->{url}, $buf )
|
||||||
|
->wait;
|
||||||
$self->app->ua->post_p(
|
$self->app->ua->post_p(
|
||||||
$self->app->config->{influxdb}->{url},
|
$self->app->config->{influxdb}->{url},
|
||||||
'traewelling ' . join( ',', @traewelling )
|
'traewelling ' . join( ',', @traewelling )
|
||||||
|
|
Loading…
Reference in a new issue