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
2835049b
Commit
2835049b
authored
8 years ago
by
Sergey Joseph Ivanov
Browse files
Options
Downloads
Patches
Plain Diff
resmon can run any command defined in resmon.conf
parent
83a6035e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Site/Command.pm
+94
-0
94 additions, 0 deletions
lib/Site/Command.pm
with
94 additions
and
0 deletions
lib/Site/Command.pm
0 → 100644
+
94
−
0
View file @
2835049b
package
Site::
Command
;
use
strict
;
use
warnings
;
use
base
'
Resmon::Module
';
use
Resmon::
ExtComm
qw(run_command cache_command)
;
=pod
=head1 Site::Command
Site::Command - a sample/template resmon module
=head1 SYNOPSIS
Site::Command {
some_check_name: run => command
}
=head1 DESCRIPTION
This module runs the command and returns output of it along with numbers of chars,
lines, and words in it
=head1 CONFIGURATION
=over
=item check_name
The check name is descriptive only in this check. It is not used for anything.
Some checks use the check_name as part of the configuration, such as
free space checks that specify the filesystem to use.
=item run
Command to run
=back
=head1 METRICS
=over
=item run
The command to run
=item lines
The number of lines in the output
=item words
The number of words in the output
=item chars
The length of the output
=item output
The output of the command
=back
=cut
sub
handler
{
my
$self
=
shift
;
my
$config
=
$self
->
{
config
};
# All configuration is in here
my
$check_name
=
$self
->
{
check_name
};
# The check name is in here
my
$run
=
$config
->
{
run
};
# The "run" parameter
my
$output
=
cache_command
(
$run
,
600
);
my
$chars
=
length
(
$output
);
my
$words
=
scalar
(
split
('
',
$output
));
my
$lines
=
scalar
(
split
(
/^/
,
$output
));
$output
=~
s/\n/;/mg
;
return
{
"
run
"
=>
[
$run
,
"
s
"],
"
output
"
=>
[
$output
,
"
s
"],
"
chars
"
=>
[
$chars
,
"
i
"],
"
words
"
=>
[
$words
,
"
i
"],
"
lines
"
=>
[
$lines
,
"
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