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
f93eacd7
Commit
f93eacd7
authored
12 years ago
by
Clinton Wolfe
Browse files
Options
Downloads
Patches
Plain Diff
First pass at an Resmon reporter for CLGR
parent
ed903e97
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/ChefLastGoodRun.pm
+93
-0
93 additions, 0 deletions
lib/Core/ChefLastGoodRun.pm
with
93 additions
and
0 deletions
lib/Core/ChefLastGoodRun.pm
0 → 100644
+
93
−
0
View file @
f93eacd7
package
Core::
ChefLastGoodRun
;
use
strict
;
use
warnings
;
use
base
'
Resmon::Module
';
=pod
=head1 NAME
Core::ChefLastGoodRun
=head1 SYNOPSIS
Core::ChefLastGoodRun {
local : report_path => /var/chef/reports/last_good_run.json
}
=head1 DESCRIPTION
This module reads a JSON file deposited whenever chef-solo runs to successful completion.
=head1 CONFIGURATION
=over
=item check_name
Arbitrary name of the check.
=item report_path
Optional path to the report JSON file.
=back
=head1 METRICS
=over
=item age (integer, seconds since last run)
=back
=head1 METRICS AVAILABLE WITH REPORT PARSING
If you have the JSON and File::Slurp perl modules installed, the following are also provided:
=over
=item elapsed (float, time last run took)
=item change_count (integer, number of changes)
=back
=cut
my
$MODS_LOADED
;
sub
handler
{
my
$self
=
shift
;
my
$config
=
$self
->
{'
config
'};
my
$report_path
=
$config
->
{'
report_path
'}
||
'
/var/chef/reports/last_good_run.json
';
unless
(
-
e
$report_path
)
{
return
{}
}
# Age metric
my
%metrics
;
$metrics
{
age
}
=
[
time
()
-
(
stat
(
$report_path
))[
9
],
'
I
'
];
# Try to load JSON module
unless
(
$MODS_LOADED
)
{
eval
"
use JSON; use File::Slurp;
";
if
(
$@
)
{
return
\
%metrics
;
}
else
{
$MODS_LOADED
=
1
;
}
}
my
$report
=
File::Slurp::
readfile
(
$report_path
);
$report
=
decode_json
(
$report
);
$metrics
{
elapsed
}
=
[
$report
->
{
elapsed_time
},
'
F
'
];
$metrics
{
change_count
}
=
[
scalar
(
@
{
$report
->
{
updated_resources
}}),
'
I
'
];
return
\
%metrics
;
};
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