Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aix-pm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
aix-pm
Commits
cdf49679
Commit
cdf49679
authored
6 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
parametrize auto-enlagred filesystems
parent
e9a2d562
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/util/Util/Monitoring.pm
+90
-22
90 additions, 22 deletions
modules/util/Util/Monitoring.pm
with
90 additions
and
22 deletions
modules/util/Util/Monitoring.pm
+
90
−
22
View file @
cdf49679
...
...
@@ -129,12 +129,14 @@ sub read_config
my
$n_mon
=
setup_default_collection
(
$paf
,
'
monitoring
');
my
$n_events
=
setup_default_collection
(
$paf
,
'
events
');
my
$n_msg
=
setup_default_collection
(
$paf
,
'
messages
');
# print "paf: ", Dumper ($paf);
# print "n_mon=[$n_mon] n_events=[$n_events]\n";
my
(
$mdb
,
$c_moni
)
=
Util::MongoDB::
connect
(
$paf
,
$n_mon
);
my
$c_events
=
$mdb
->
get_collection
(
$n_events
);
my
$c_msg
=
$mdb
->
get_collection
(
$n_msg
);
# print "mdb: ", Dumper ($mdb);
# print "c_moni: ", Dumper ($c_moni);
# print "c_events: ", Dumper ($c_events);
...
...
@@ -142,7 +144,17 @@ sub read_config
$obj
->
{'
_mdb
'}
=
$mdb
;
$obj
->
{'
_moni
'}
=
$c_moni
;
$obj
->
{'
_events
'}
=
$c_events
;
$obj
->
{'
_messages
'}
=
$c_msg
;
# END connect to MongoDB collection
my
$machine
=
$mon_cfg
->
{
machine
};
unless
(
defined
(
$machine
))
{
my
@uname
=
split
('
',
`
uname -a
`);
$machine
=
$uname
[
1
];
}
$obj
->
{
_machine
}
=
$machine
;
1
;
}
...
...
@@ -156,39 +168,28 @@ sub setup_ref
{
my
$obj
=
shift
;
# 2018-12-21: hmm... why is _ref not always initialized as a fresh empty hash ref?
my
$ref
=
$obj
->
{'
_ref
'};
$ref
=
$obj
->
{'
_ref
'}
=
{}
unless
(
defined
(
$ref
));
my
@ai
;
$obj
->
{'
_auto_increment
'}
=
\
@ai
;
my
$fs_list
=
$obj
->
{'
mon_cfg
'}
->
{'
filesystems
'};
foreach
my
$fs
(
@$fs_list
)
{
my
$mp
=
$fs
->
{'
mount_point
'};
$ref
->
{
$mp
}
=
$fs
;
push
(
@ai
,
$fs
)
if
(
exists
(
$fs
->
{
auto_increment
}));
}
# print __LINE__, " ref: ", Dumper ($ref);
$ref
;
}
sub
setup_default_collection
{
my
$cfg
=
shift
;
my
$name
=
shift
;
# print __LINE__, " cfg: ", Dumper ($cfg);
my
$colls
=
$cfg
->
{'
collections
'};
$colls
=
$cfg
->
{'
collections
'}
=
{}
unless
(
defined
(
$colls
));
my
$col
=
$colls
->
{
$name
};
$col
=
$colls
->
{
$name
}
=
$name
unless
(
defined
(
$col
));
# print __LINE__, " cfg: ", Dumper ($cfg);
# print "col=[$col]\n";
$col
;
}
=head1 FILE SYSTEM FUNCTIONS
=head1 FILE SYSTEM METHODS
=cut
...
...
@@ -281,6 +282,77 @@ sub mon_fs
(
wantarray
)
?
(
$ev
,
$fs_hash
)
:
$ev
;
}
sub
get_auto_increment_filesystems
{
my
$mon
=
shift
;
my
$ai
=
$mon
->
{
_auto_increment
};
$ai
=
[]
unless
(
defined
(
$ai
));
(
wantarray
)
?
@$ai
:
$ai
;
}
sub
get_machine
{
my
$mon
=
shift
;
$mon
->
{
_machine
};
}
sub
send_message
{
my
$mon
=
shift
;
my
$message
=
shift
;
my
$priority
=
shift
||
'
low
';
my
$msg_cnt
=
0
;
my
$c_msg
=
$mon
->
{
_messages
};
my
$notify
=
$mon
->
{
mon_cfg
}
->
{
notify
};
if
(
defined
(
$c_msg
)
&&
defined
(
$notify
))
{
my
@notify
=
(
ref
(
$notify
)
eq
'
ARRAY
')
?
@$notify
:
$notify
;
foreach
my
$to
(
@notify
)
{
$c_msg
->
insert
({
message
=>
$message
,
to
=>
$to
,
priority
=>
$priority
,
state
=>
'
new
'
});
$msg_cnt
;
}
}
$mon
->
{
_events
}
->
insert
({
event
=>
'
messages
',
message
=>
$message
,
priority
=>
$priority
,
count
=>
$msg_cnt
});
}
=head1 SETUP FUNCTIONS
=head2 $col= setup_default_collecton ($name)
Find the collection named for a specific purpose in the configuration.
If there is no collection name in the configuration, it uses the default
name $name. E.g. setup_default_collection ('events') returns 'events',
if there is nothing configured.
=cut
sub
setup_default_collection
{
my
$cfg
=
shift
;
my
$name
=
shift
;
# print __LINE__, " cfg: ", Dumper ($cfg);
my
$colls
=
$cfg
->
{'
collections
'};
$colls
=
$cfg
->
{'
collections
'}
=
{}
unless
(
defined
(
$colls
));
my
$col
=
$colls
->
{
$name
};
$col
=
$colls
->
{
$name
}
=
$name
unless
(
defined
(
$col
));
# print __LINE__, " cfg: ", Dumper ($cfg);
# print "col=[$col]\n";
$col
;
}
=head1 GENERIC STATUS FUNCTIONS
=cut
sub
get_fs_level
{
my
$x
=
shift
;
...
...
@@ -298,10 +370,6 @@ sub get_fs_level
(
$pct_used1
>
$pct_used2
)
?
$pct_used1
:
$pct_used2
;
}
=head1 GENERIC STATUS FUNCTIONS
=cut
sub
compare_levels
{
my
@observations
=
@_
;
...
...
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