Skip to content

Commit a249aa3

Browse files
committed
OMD-Top: added as core module
1 parent ab6397b commit a249aa3

31 files changed

+2757
-3
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ t/scenarios/*/panorama/
7474
tmp_*
7575
action_menus/*
7676
plugins/plugins-enabled/editor
77-
plugins/plugins-available/omd
7877
plugins/plugins-available/pansnaps
7978
plugins/plugins-available/status-dashboard
8079
plugins/plugins-available/woshsh

Changes

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ next:
1818
- prevent running multiple updates from cron in parallel
1919
- Reports:
2020
- fix creating grafana reports from url report
21+
- OMD-Top:
22+
- added as core module
2123

2224
3.20.2 Wed Dec 18 17:43:10 CET 2024
2325
- unescape escaped characters in expanded command

MANIFEST

+24
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,30 @@ plugins/plugins-available/node-control/templates/node_control_facts.tt
423423
plugins/plugins-available/node-control/templates/node_control_logs.tt
424424
plugins/plugins-available/node-control/templates/node_control_omd_status.tt
425425
plugins/plugins-available/node-control/templates/node_control_peer_status.tt
426+
plugins/plugins-available/omd/cron
427+
plugins/plugins-available/omd/description.txt
428+
plugins/plugins-available/omd/lib/Thruk/Controller/omd.pm
429+
plugins/plugins-available/omd/lib/Thruk/OMD/Top/Parser/LinuxTop.pm
430+
plugins/plugins-available/omd/preview.png
431+
plugins/plugins-available/omd/root/asc.gif
432+
plugins/plugins-available/omd/root/bg.gif
433+
plugins/plugins-available/omd/root/desc.gif
434+
plugins/plugins-available/omd/root/style.css
435+
plugins/plugins-available/omd/root/vendor/jquery.flot.crosshair.js
436+
plugins/plugins-available/omd/root/vendor/jquery.flot.selection.js
437+
plugins/plugins-available/omd/root/vendor/jquery.flot.stack.js
438+
plugins/plugins-available/omd/root/vendor/jquery.tablesorter.min.js
439+
plugins/plugins-available/omd/root/vendor/theme.default.min.css
440+
plugins/plugins-available/omd/routes
441+
plugins/plugins-available/omd/scripts/save_top_data
442+
plugins/plugins-available/omd/t/controller_omd.t
443+
plugins/plugins-available/omd/t/data/1421945063.debian6.txt
444+
plugins/plugins-available/omd/t/data/1421945063.rhel7.txt
445+
plugins/plugins-available/omd/t/data/1421945063.ubuntu14-04.txt
446+
plugins/plugins-available/omd/t/data/1660200901.debian11.txt
447+
plugins/plugins-available/omd/t/top_data.t
448+
plugins/plugins-available/omd/templates/omd_top.tt
449+
plugins/plugins-available/omd/templates/omd_top_details.tt
426450
plugins/plugins-available/panorama/0.tab
427451
plugins/plugins-available/panorama/description.txt
428452
plugins/plugins-available/panorama/DEV.txt

MANIFEST.SKIP

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ t/scenarios/pentest_arachni/results/
107107
^.ci/
108108
.github/
109109
^continue$
110-
plugins/plugins-available/omd
111110
plugins/plugins-available/pansnaps
112111
plugins/plugins-available/status-dashboard
113112
plugins/plugins-available/woshsh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
layout: docs
3+
title: OMD Top Plugin
4+
breadcrumb: [ "plugins.html", "Plugins" ]
5+
lightbox: true
6+
---
7+
8+
## OMD Top Thruk Plugin
9+
10+
This plugin saves top data every minute and renders nice graphs to drill down
11+
performance problems on your monitoring host.
12+
13+
![Thruk OMD Top Plugin](omd-top.png "Thruk OMD Top Plugin")
14+
15+
## Installation
16+
17+
Assuming you are using OMD (link:https://omd.consol.de[omd.consol.de]).
18+
19+
This is a core plugin, so it is shipped with Thruk and can simply
20+
be enabled by running: `thruk plugins enable omd` or
21+
from the plugins section in the config tool.
22+
23+
It worked if you have a new menu item under `System` -> `OMD Top`.
24+
25+
### Configuration
26+
27+
In order to put processes into groups, you can define those groups in ex.:
28+
29+
`~/etc/thruk/thruk_local.d/omd_top.conf
30+
31+
or
32+
33+
`~/etc/thruk/thruk_local.conf`
34+
35+
For example:
36+
37+
omd_top = squid = squid
38+
omd_top = /sbin/httpd2 = apache2
39+
omd_top = /usr/sbin/mysqld = mysql
40+
omd_top = /bin/mod_gearman_worker = mod-gearman
41+
42+
You shouldn't define more than 10 groups, otherwise they won't fit onto
43+
the resulting graph. You have to reload the apache to activate changes.
44+
45+
## Usage
46+
47+
The cronjob will collect top data for the last 3 days. On the start page you can
48+
select a time range you want to examine in detail.
49+
50+
On the second page, you can select datapoints to fetch the detailed top data
51+
which then can be sorted by clicking on the table header.
52+
53+
## Extending by own Parsers
54+
55+
The default parser uses linux top data as input source, but it is possible to
56+
write own parser. Just add a new input source to your `thruk_local.conf`:
57+
58+
omd_top_extra_dir = WinCPU=var/cputop
59+
60+
Then implement ex.: a OMD/Top/Parser/WinCPU.pm based on the existing LinuxTop.pm.
412 KB
Loading

plugins/plugins-available/omd/cron

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# save top data every minute
2+
* * * * * $OMD_ROOT/etc/thruk/plugins-enabled/omd/scripts/save_top_data >/dev/null 2>&1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The 'OMD' plugin saves top data every minute and renders nice graphs to drill
2+
down performance problems on your monitoring host.
3+
4+
Url: omd.cgi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package Thruk::Controller::omd;
2+
3+
use warnings;
4+
use strict;
5+
6+
use Thruk ();
7+
use Thruk::Backend::Manager ();
8+
use Thruk::Utils ();
9+
10+
#use Thruk::Timer qw/timing_breakpoint/;
11+
12+
=head1 NAME
13+
14+
Thruk::Controller::omd - Thruk Controller
15+
16+
=head1 DESCRIPTION
17+
18+
Thruk Controller.
19+
20+
=head1 METHODS
21+
22+
=cut
23+
24+
my $top_dir = defined $ENV{'OMD_ROOT'} ? $ENV{'OMD_ROOT'}.'/var/top' : 'var/top';
25+
my $pluginname = Thruk::Utils::get_plugin_name(__FILE__, __PACKAGE__);
26+
27+
##########################################################
28+
29+
=head2 index
30+
31+
=cut
32+
sub index {
33+
my($c) = @_;
34+
35+
return unless Thruk::Action::AddDefaults::add_defaults($c, Thruk::ADD_SAFE_DEFAULTS);
36+
37+
$c->stash->{title} = 'Top Statistics';
38+
$c->stash->{page} = 'status';
39+
$c->stash->{hide_backends_chooser} = 1;
40+
$c->stash->{no_auto_reload} = 1;
41+
$c->stash->{plugin} = $pluginname;
42+
43+
our $hosts_list = undef;
44+
45+
# check permissions
46+
unless( $c->check_user_roles( "authorized_for_configuration_information")
47+
and $c->check_user_roles( "authorized_for_system_commands")) {
48+
return $c->detach('/error/index/8');
49+
}
50+
51+
# get input folders
52+
my $default_parser = 'LinuxTop';
53+
my $folder_hash = {};
54+
my $folders = [];
55+
if(-d $top_dir.'/.') {
56+
$folder_hash->{$top_dir} = $default_parser;
57+
}
58+
if($c->config->{'omd_top_extra_dir'}) {
59+
for my $dir (@{Thruk::Utils::list($c->config->{'omd_top_extra_dir'})}) {
60+
my($parser, $folder) = split/\s*=\s*/mx, $dir;
61+
if(!$folder) { $folder = $parser; $parser = $default_parser; }
62+
next unless -d $folder.'/.';
63+
my @subdirs = glob($folder.'/*');
64+
for my $sub (sort @subdirs) {
65+
my $display = $sub;
66+
$display =~ s|.*/||mx;
67+
push @{$folders}, { parser => $parser, 'dir' => $sub, display => $display };
68+
$folder_hash->{$sub} = $parser;
69+
}
70+
}
71+
}
72+
$folders = Thruk::Backend::Manager->_sort($folders, 'display');
73+
if(-d $top_dir.'/.') {
74+
unshift @{$folders}, { parser => $default_parser, 'dir' => $top_dir, 'display' => 'Monitoring Server' };
75+
}
76+
$c->stash->{folders} = $folders;
77+
$c->stash->{folder} = $c->req->parameters->{'folder'} || $top_dir;
78+
if(!$folder_hash->{$c->stash->{folder}}) { $c->stash->{folder} = $top_dir; }
79+
if(!$folder_hash->{$c->stash->{folder}} && scalar @{$folders} > 0) { $c->stash->{folder} = $folders->[0]->{dir}; }
80+
$c->stash->{parser} = $folder_hash->{$c->stash->{folder}};
81+
82+
if(scalar @{$folders} == 0 || !$c->stash->{parser}) {
83+
$c->stash->{folders} = [];
84+
$c->stash->{template} = 'omd_top.tt';
85+
return;
86+
}
87+
88+
my $parser = _parser($c);
89+
my $action = $c->req->parameters->{'action'} || '';
90+
if($action eq 'top_details') {
91+
return $parser->top_graph_details($c);
92+
}
93+
elsif($action eq 'top_data') {
94+
return $parser->top_graph_data($c);
95+
}
96+
97+
return $parser->top_graph($c);
98+
}
99+
100+
##########################################################
101+
sub _parser {
102+
my($c) = @_;
103+
my $class = 'Thruk::OMD::Top::Parser::'.$c->stash->{parser};
104+
my $require = $class;
105+
$require =~ s/::/\//gmx;
106+
require $require . ".pm";
107+
$class->import;
108+
my $parser = $class->new($c->stash->{folder});
109+
return($parser);
110+
}
111+
112+
##########################################################
113+
114+
=head1 AUTHOR
115+
116+
Sven Nierlein, 2009-2014, <[email protected]>
117+
118+
=head1 LICENSE
119+
120+
This library is free software, you can redistribute it and/or modify
121+
it under the same terms as Perl itself.
122+
123+
=cut
124+
125+
1;

0 commit comments

Comments
 (0)