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
f1f2d3f0
Commit
f1f2d3f0
authored
6 years ago
by
Sergey Joseph Ivanov
Browse files
Options
Downloads
Patches
Plain Diff
monitor how many DSes failed in Cacti last run
parent
297cced3
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/Site/Cacti.pm
+84
-0
84 additions, 0 deletions
lib/Site/Cacti.pm
with
84 additions
and
0 deletions
lib/Site/Cacti.pm
0 → 100644
+
84
−
0
View file @
f1f2d3f0
package
Site::
Cacti
;
use
strict
;
use
warnings
;
use
base
'
Resmon::Module
';
use
Resmon::
ExtComm
qw(run_command cache_command)
;
=pod
=head1 Site::Cacti
Site::Cacti is a Cacti log parser to summarize failed datasets number
=head1 SYNOPSIS
Site::Command {
some_check_name: noop;
}
=head1 DESCRIPTION
This module parses Cacti Log and gets total numbers of Datasets and
how many of them failed during last cacti run.
=head1 CONFIGURATION
=over
=item check_name
=back
=cut
my
$DEBUG
=
0
;
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
$SPAN
=
(
5
*
60
);
# seconds
my
$LOG
=
'
/var/log/cacti/cacti.log
';
my
$END
=
`
tail -1
$LOG
`;
chomp
$END
;
$END
=
$END
=~
m<^(\d{4}/\d{1,2}/\d{1,2} \d\d:\d\d)>
?
$
1
:
die
"
problem with tail
$LOG
: strange date/time in the line
\n
$END
";
my
$M
=
substr
$END
,
-
1
;
$M
=
$M
<
5
?
0
:
5
;
my
$START
=
$END
;
$START
=~
s/.$/$M/
;
open
(
my
$log
,
"
<
$LOG
")
or
die
"
can't open <
$LOG
: $!
";
=pod example of the log line:
2018/11/02 14:45:05 - SPINE: Poller[1] Device[14] TH[1] DS[1341] SNMP: v2: 172.26.69.124, dsname: traffic_out, oid: .1.3.6.1.2.1.31.1.1.1.10.669, value: 93577117
=cut
while
(
<
$log
>
)
{
last
if
(
$_
=~
m<^$START>
);
}
my
(
$errors
,
$datasets
)
=
(
0
,
0
);
while
(
<
$log
>
)
{
=pod example of errors reported:
2018/11/02 17:00:05 - SPINE: Poller[1] WARNING: Invalid Response(s), Errors[1] Device[9] Thread[1] DS[903]
=cut
if
(
/SPINE:\s+Poller\[\d+\]\s+WARNING:.*Errors\[(\d+)\]\s+Device\[(\d+)\].*\s+DS\[([ 0-9,]+)\]/
)
{
print
STDERR
"
errors: num=$1, Device
\
[$2], DSes=$3
\n
"
if
$DEBUG
;
$errors
+=
$
2
;
}
=pod example of DSes reported:
2018/11/05 15:00:05 - SPINE: Poller[1] Device[32] TH[1] NOTE: There are '398' Polling Items for this Device
=cut
elsif
(
/SPINE:\s+Poller\[\d+\]\s+Device\[(\d+)\]\s+TH\[\d+\]\s+NOTE: There are '(\d+)' Polling Items for this Device/
)
{
$datasets
+=
$
2
;
print
STDERR
"
There are $2 datasets for Device
\
[$1
\
]
\n
"
if
$DEBUG
;
}
}
close
$log
;
return
{
"
datasets
"
=>
[
$datasets
,"
i
"],
"
errors
"
=>
[
$errors
,
"
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