Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrors
resmon
Commits
bf8bc6d4
Commit
bf8bc6d4
authored
13 years ago
by
Mark Harrison
Browse files
Options
Downloads
Patches
Plain Diff
Convert old resmon 1 WALFILES module to resmon2
parent
194d789e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Core/PostgresReplayLag.pm
+83
-0
83 additions, 0 deletions
lib/Core/PostgresReplayLag.pm
with
83 additions
and
0 deletions
lib/Core/PostgresReplayLag.pm
0 → 100644
+
83
−
0
View file @
bf8bc6d4
package
Core::
PostgresReplayLag
;
use
strict
;
use
warnings
;
use
base
'
Resmon::Module
';
use
Time::
Local
;
=pod
=head1 NAME
Core::PostgresReplayLag - Monitor postgres replay lag
=head1 SYNOPSIS
Core::PostgresReplayLag {
pg : logdir => /data/set/foo/pgdata/82/pg_log
}
=head1 DESCRIPTION
This module monitors how long it's been since a postgres replay log was
restored.
=head1 CONFIGURATION
=over
=item check_name
The check name is descriptive only in this check. It is not used for anything.
=item logdir
Postgres log directory
=back
=head1 METRICS
=over
=item lag
The number of seconds since the last restore.
=back
=cut
sub
handler
{
my
$self
=
shift
;
my
$config
=
$self
->
{
config
};
# All configuration is in here
opendir
(
my
$dh
,
$config
->
{
logdir
});
my
@files
=
sort
grep
/^postgresql-[\d-]+_?\d*\.log$/
,
readdir
(
$dh
);
closedir
(
$dh
);
my
$wallog
=
$files
[
-
1
];
open
(
my
$fh
,
"
<
",
"
$config
->{logdir}/
$wallog
");
my
@lines
=
grep
(
/LOG: restored log file/
,
<
$fh
>
);
close
(
$fh
);
if
(
$#lines
<
0
)
{
return
{
"
error
"
=>
["
Nothing restored
",
"
s
"]
}
}
my
(
$year
,
$month
,
$day
,
$hour
,
$min
)
=
(
$lines
[
-
1
]
=~
/^(\d\d\d\d)-(\d\d)-(\d\d)\s(\d+):(\d+)/
);
my
$restoretime
=
timelocal
(
0
,
$min
,
$hour
,
$day
,
$month
-
1
,
$year
);
my
$now
=
time
();
my
$lag
=
$now
-
$restoretime
;
return
{
"
lag
"
=>
[
$lag
,
"
i
"]
};
};
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment