[240] | 1 | #!/usr/bin/env perl |
---|
| 2 | # |
---|
| 3 | # 2014/05/15 Gabriel Moreau <Gabriel.Moreau@univ-grenoble-alpes.fr> |
---|
| 4 | # 2017/06/22 Gabriel Moreau - big update |
---|
[256] | 5 | # 2018/06/25 Gabriel Moreau - make velvice generic |
---|
[240] | 6 | # |
---|
| 7 | # velvice.cgi |
---|
| 8 | # Copyright (C) 2014-2018, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
| 9 | # |
---|
| 10 | # Need NagiosStatus http://exchange.nagios.org/directory/Addons/APIs/Perl/NagiosStatus-2Epm/details |
---|
| 11 | # Possible command http://old.nagios.org/developerinfo/externalcommands/commandlist.php |
---|
| 12 | # |
---|
[250] | 13 | # apt-get install perl-modules libnagios-object-perl libhtml-parser-perl liburi-encode-perl libcolor-calc-perl libyaml-syck-perl |
---|
[240] | 14 | |
---|
| 15 | use strict; |
---|
| 16 | use warnings; |
---|
[270] | 17 | use version; our $VERSION = version->declare('0.7.6'); |
---|
[240] | 18 | |
---|
| 19 | use CGI; |
---|
| 20 | use HTML::Entities (); |
---|
| 21 | use Nagios::StatusLog; |
---|
| 22 | use URI::Encode qw(uri_encode uri_decode); |
---|
| 23 | use Color::Calc (); |
---|
| 24 | use YAML::Syck; |
---|
| 25 | |
---|
[257] | 26 | my $query = CGI->new(); |
---|
| 27 | my $cgi_check = uri_decode($query->param('check')); |
---|
| 28 | my $cgi_script_name = $query->script_name(); |
---|
[260] | 29 | my $cgi_path = $cgi_script_name =~ s{/[^/]+\.cgi$}{}r; |
---|
[263] | 30 | undef $query; |
---|
[256] | 31 | |
---|
[240] | 32 | my $config = {}; |
---|
| 33 | $config = YAML::Syck::LoadFile('/etc/nagios3/velvice.yml') if -e '/etc/nagios3/velvice.yml'; |
---|
[256] | 34 | $config->{'nagios-server'} ||= {}; |
---|
| 35 | $config->{'nagios-server'}{'status-file'} ||= '/var/cache/nagios3/status.dat'; |
---|
| 36 | $config->{'nagios-server'}{'nagios-cmd'} ||= '/var/lib/nagios3/rw/nagios.cmd'; |
---|
[260] | 37 | $config->{'nagios-server'}{'portal-url'} ||= $cgi_path =~ s{/cgi-bin/}{/}r . '/'; |
---|
[258] | 38 | $config->{'nagios-server'}{'status-cgi'} ||= "$cgi_path/status.cgi"; |
---|
[263] | 39 | $config->{'nagios-server'}{'stylesheets'} ||= $config->{'nagios-server'}{'portal-url'} =~ s{/?$}{/stylesheets}r; |
---|
[256] | 40 | $config->{'host-mapping'} ||= {}; |
---|
| 41 | $config->{'color-downtime'} ||= {}; |
---|
[261] | 42 | $config->{'color-downtime'}{'day-min'} ||= 3; |
---|
| 43 | $config->{'color-downtime'}{'day-max'} ||= 50; |
---|
| 44 | $config->{'color-downtime'}{'factor'} ||= 0.7; |
---|
[256] | 45 | $config->{'remote-action'} ||= {}; |
---|
[240] | 46 | |
---|
| 47 | my $log = Nagios::StatusLog->new( |
---|
[256] | 48 | Filename => $config->{'nagios-server'}{'status-file'}, |
---|
[240] | 49 | Version => 3.0 |
---|
| 50 | ); |
---|
| 51 | |
---|
| 52 | sub hostmapping { |
---|
| 53 | my $host = shift; |
---|
| 54 | |
---|
[256] | 55 | return exists $config->{'host-mapping'}{$host} ? $config->{'host-mapping'}{$host} : $host; |
---|
[240] | 56 | } |
---|
| 57 | |
---|
| 58 | sub downtime { |
---|
| 59 | my ($time_change) = @_; |
---|
| 60 | |
---|
| 61 | my $now = time; |
---|
| 62 | return sprintf '%.1f', ($now - $time_change) / (60 * 3600); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | sub alertcolor { |
---|
| 66 | my ($color, $downtime) = @_; |
---|
| 67 | |
---|
[261] | 68 | $downtime = $downtime - $config->{'color-downtime'}{'day-min'}; # same color first days |
---|
| 69 | $downtime = $config->{'color-downtime'}{'day-max'} if $downtime > $config->{'color-downtime'}{'day-max'}; # max 50 days for color |
---|
[240] | 70 | $downtime = 0 if $downtime < 0; |
---|
| 71 | |
---|
[261] | 72 | my $factor = ($downtime * $config->{'color-downtime'}{'factor'}) / $config->{'color-downtime'}{'day-max'}; |
---|
[240] | 73 | return Color::Calc::color_light_html($color, $factor); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | my %hostdown; |
---|
| 77 | my @serviceproblems; |
---|
| 78 | my %hostcount; |
---|
| 79 | my @futurecheck; |
---|
| 80 | HOST: |
---|
| 81 | for my $host (sort $log->list_hosts()) { |
---|
| 82 | my $host_stat = $log->host($host); |
---|
| 83 | |
---|
| 84 | if ($host_stat->status eq 'DOWN') {TESTIF:{ |
---|
| 85 | for my $srv ($log->list_services_on_host($host)) { |
---|
| 86 | last TESTIF if $log->service($host, $srv)->status eq 'OK' or $log->service($host, $srv)->status eq 'PENDING'; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | $hostdown{$host} = $host_stat; |
---|
| 90 | next HOST; |
---|
| 91 | }} |
---|
| 92 | |
---|
| 93 | for my $srv ($log->list_services_on_host($host)) { |
---|
| 94 | if ($log->service($host, $srv)->status ne 'OK') { |
---|
| 95 | push @serviceproblems, $log->service($host, $srv); |
---|
| 96 | $hostcount{$host}++; |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | my $now = time; |
---|
| 102 | my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime $now; |
---|
| 103 | $year += 1900; |
---|
| 104 | $mon++; |
---|
| 105 | my $date = sprintf '%04i-%02i-%02i %02i:%02i', $year, $mon, $mday, $hour, $min; |
---|
| 106 | |
---|
| 107 | my $htmlpage = <<"ENDH"; |
---|
| 108 | Content-Type: text/html |
---|
| 109 | |
---|
| 110 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
---|
| 111 | <html lang="en"> |
---|
| 112 | <head> |
---|
| 113 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
---|
| 114 | <title>Nagios Velvice</title> |
---|
[264] | 115 | <link rel="stylesheet" type="text/css" href="$config->{'nagios-server'}{'stylesheets'}/velvice.css"> |
---|
[240] | 116 | </head> |
---|
| 117 | <body> |
---|
| 118 | <h1> |
---|
| 119 | <ul> |
---|
[256] | 120 | <li>Nagios Velvice Alert Panel : <a href="$config->{'nagios-server'}{'portal-url'}">Core Server</a></li> |
---|
[257] | 121 | <li><small>(<a href="$cgi_script_name">UPDATE</a> - $date)</small></li> |
---|
[240] | 122 | </ul> |
---|
| 123 | </h1> |
---|
| 124 | ENDH |
---|
| 125 | |
---|
[254] | 126 | my %service_name = (); |
---|
| 127 | my %service_status = (); |
---|
[240] | 128 | for my $srv (@serviceproblems) { |
---|
| 129 | $service_name{$srv->service_description}++; |
---|
[254] | 130 | $service_status{$srv->status}++; |
---|
[240] | 131 | } |
---|
| 132 | |
---|
| 133 | if (scalar @serviceproblems == 0) { |
---|
| 134 | $htmlpage .= "<p>No alert to recheck.</p>\n"; |
---|
| 135 | } |
---|
| 136 | else { |
---|
| 137 | |
---|
| 138 | $htmlpage .= "<p>Alert to recheck - Level:\n"; |
---|
| 139 | $htmlpage .= join ",\n", |
---|
[257] | 140 | " <a href='$cgi_script_name?check=all'>ALL</a><small>(" . scalar(@serviceproblems) . ')</small>', |
---|
| 141 | map(" <a href='$cgi_script_name?check=" . lc(uri_encode($_)) . "'>$_</a>($service_status{$_})", sort keys %service_status); |
---|
[240] | 142 | $htmlpage .= ".\n"; |
---|
| 143 | $htmlpage .= " <br />\n"; |
---|
| 144 | $htmlpage .= " Service:\n"; |
---|
[257] | 145 | $htmlpage .= join ",\n", map(" <a href='$cgi_script_name?check=" . lc(uri_encode($_)) . "'>$_</a><small>($service_name{$_})</small>", sort keys %service_name); |
---|
[240] | 146 | $htmlpage .= ".\n"; |
---|
| 147 | $htmlpage .= "</p>\n"; |
---|
| 148 | |
---|
| 149 | my $nagios_cmd; |
---|
[256] | 150 | open $nagios_cmd, '>>', $config->{'nagios-server'}{'nagios-cmd'} or die "Can't open file filename: $!"; |
---|
[240] | 151 | |
---|
[254] | 152 | my %remote_sshdown = (); |
---|
| 153 | my %remote_db = (); |
---|
| 154 | my $remote_flag; |
---|
[245] | 155 | |
---|
[240] | 156 | my $current_host = ''; |
---|
| 157 | $htmlpage .= "<table border=\"1\">\n"; |
---|
[254] | 158 | SERVICE_PROBLEMS: |
---|
[240] | 159 | for my $srv (@serviceproblems) { |
---|
| 160 | my $hostname = $srv->host_name; |
---|
| 161 | my $service = $srv->service_description; |
---|
[245] | 162 | my $status = $srv->status; |
---|
[240] | 163 | my $downtime = downtime($srv->last_state_change); |
---|
[257] | 164 | my $output = HTML::Entities::encode($srv->plugin_output) =~ s/^[A-Z_\s]+?[:-]//r; |
---|
[240] | 165 | |
---|
[245] | 166 | my $color = $status eq 'CRITICAL' ? '#F88888' : '#FFFF00'; |
---|
[240] | 167 | $color = alertcolor($color, $downtime); |
---|
| 168 | $htmlpage .= " <tr style='background:$color;'>\n"; |
---|
| 169 | if ($hostname ne $current_host) { |
---|
| 170 | $current_host = $hostname; |
---|
[256] | 171 | $htmlpage .= " <td rowspan='$hostcount{$hostname}' style='vertical-align:middle;'><a href=\"$config->{'nagios-server'}{'status-cgi'}?host=$hostname\">$hostname</a></td>\n"; |
---|
[240] | 172 | } |
---|
[245] | 173 | |
---|
| 174 | my $bold; |
---|
[254] | 175 | ACTION_STYLE: |
---|
[256] | 176 | for my $act_name (keys %{$config->{'remote-action'}}) { |
---|
| 177 | my $act_regex = $config->{'remote-action'}{$act_name}{'regex'}; |
---|
| 178 | $bold++ if $service =~ m/$act_regex/ and $config->{'remote-action'}{$act_name}{'style'} eq 'bold'; |
---|
[240] | 179 | } |
---|
[246] | 180 | $htmlpage .= $bold ? ' <td class="bold">' : ' <td>'; |
---|
| 181 | $htmlpage .= "$service</td>\n"; |
---|
[245] | 182 | |
---|
| 183 | $htmlpage .= " <td>$status</td>\n"; |
---|
[240] | 184 | $htmlpage .= " <td style='max-width:60%;'><small>$output"; |
---|
| 185 | |
---|
[257] | 186 | if (($cgi_check =~ m/all/i) |
---|
| 187 | or ($cgi_check =~ m/^$service$/i) |
---|
| 188 | or ($cgi_check =~ m/critical/i and $status eq 'CRITICAL') |
---|
| 189 | or ($cgi_check =~ m/warning/i and $status eq 'WARNING') |
---|
| 190 | or ($cgi_check =~ m/pending/i and $status eq 'PENDING') |
---|
[240] | 191 | ) { |
---|
| 192 | $now++; |
---|
| 193 | my $interval = $srv->next_check() - $srv->last_check() || 300; |
---|
| 194 | $interval = 240 if $interval < 240; |
---|
| 195 | $interval = 3000 if $interval > 3000; |
---|
[261] | 196 | my $future = $now + 20 + int(rand($interval - 20)); # 5 * 60 = 300 |
---|
[240] | 197 | |
---|
| 198 | $htmlpage .= " -- <b>CHECK</b> [$now/" . ($future - $now) . "]"; |
---|
| 199 | printf $nagios_cmd "[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%lu\n", $now, $hostname, $service, $now; |
---|
| 200 | # delay future command |
---|
| 201 | push @futurecheck, sprintf "[%lu] SCHEDULE_FORCED_SVC_CHECK;%s;%s;%lu", $future, $hostname, $service, $future; |
---|
| 202 | } |
---|
| 203 | |
---|
[254] | 204 | ACTION_PUSH_AND_DEPEND: |
---|
[256] | 205 | for my $act_name (keys %{$config->{'remote-action'}}) { |
---|
| 206 | my $act_regex = $config->{'remote-action'}{$act_name}{'regex'}; |
---|
| 207 | my $act_status = $config->{'remote-action'}{$act_name}{'status'} || 'ALL'; |
---|
| 208 | my $act_depend = $config->{'remote-action'}{$act_name}{'depend'} || 'SSH'; |
---|
[254] | 209 | |
---|
| 210 | if ($service =~ m/$act_regex/ and ($act_status eq 'ALL' or $status =~ m/$act_status/)) { |
---|
| 211 | $remote_db{$act_name} ||= []; |
---|
| 212 | push @{$remote_db{$act_name}}, $hostname; |
---|
| 213 | $remote_flag++; |
---|
[245] | 214 | } |
---|
[254] | 215 | |
---|
| 216 | # check depend service otherwise |
---|
| 217 | $remote_sshdown{$act_depend} ||= {}; |
---|
| 218 | $remote_sshdown{$act_depend}->{$hostname}++ if $service =~ m/$act_depend/; |
---|
[245] | 219 | } |
---|
[240] | 220 | |
---|
| 221 | $htmlpage .= "</small></td>\n"; |
---|
| 222 | $htmlpage .= " <td style='text-align:right;'>$downtime days</td>\n"; |
---|
| 223 | $htmlpage .= " </tr>\n"; |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | $htmlpage .= "</table>\n"; |
---|
| 227 | close $nagios_cmd; |
---|
| 228 | |
---|
[254] | 229 | # host down |
---|
[240] | 230 | if (%hostdown) { |
---|
| 231 | $htmlpage .= "<br />\n"; |
---|
| 232 | $htmlpage .= "<table border='1'>\n"; |
---|
[254] | 233 | HOST_DOWN: |
---|
[240] | 234 | for my $host (sort keys %hostdown) { |
---|
| 235 | my $host_stat = $hostdown{$host}; |
---|
| 236 | my $hostname = $host_stat->host_name; |
---|
| 237 | my $downtime = downtime($host_stat->last_state_change); |
---|
| 238 | my $color = alertcolor('#F88888', $downtime); |
---|
| 239 | $htmlpage .= " <tr style='background:$color'>\n"; |
---|
[256] | 240 | $htmlpage .= " <td><a href=\"$config->{'nagios-server'}{'status-cgi'}?host=$hostname\">$hostname</a></td>\n"; |
---|
[240] | 241 | my @host_service; |
---|
| 242 | for my $srv ($log->list_services_on_host($host)) { |
---|
| 243 | push @host_service, $log->service($host, $srv)->service_description; |
---|
| 244 | } |
---|
| 245 | $htmlpage .= " <td><small>" . join(', ', @host_service) . "</small></td>\n"; |
---|
| 246 | $htmlpage .= " <td style='text-align:right;'>$downtime days</td>\n"; |
---|
| 247 | $htmlpage .= " </tr>\n"; |
---|
| 248 | } |
---|
| 249 | $htmlpage .= "</table>\n"; |
---|
| 250 | } |
---|
| 251 | |
---|
[254] | 252 | # remote action |
---|
| 253 | if ($remote_flag) { |
---|
[240] | 254 | require Nagios::Object::Config; |
---|
| 255 | my $parser = Nagios::Object::Config->new(); |
---|
| 256 | $parser->parse("/var/cache/nagios3/objects.cache"); |
---|
| 257 | |
---|
[254] | 258 | REMOTE_ACTION: |
---|
| 259 | for my $act_name (keys %remote_db) { |
---|
[256] | 260 | my $act_depend = $config->{'remote-action'}{$act_name}{'depend'} || 'SSH'; |
---|
[254] | 261 | |
---|
| 262 | my @action = grep !exists $remote_sshdown{$act_depend}->{$_}, @{$remote_db{$act_name}}; |
---|
[245] | 263 | if (@action) { |
---|
[256] | 264 | my $srv_title = $config->{'remote-action'}{$act_name}{'title'} || "Action: $act_name"; |
---|
[247] | 265 | $htmlpage .= "<h2>$srv_title</h2>\n"; |
---|
[245] | 266 | $htmlpage .= "<pre>\n"; |
---|
[256] | 267 | my $remote_action = $config->{'remote-action'}{$act_name}{'command'}; |
---|
| 268 | $remote_action = $config->{'remote-action'}{$act_name}{'command-one'} |
---|
| 269 | if @action == 1 and exists $config->{'remote-action'}{$act_name}{'command-one'}; |
---|
[245] | 270 | my @hosts; |
---|
| 271 | for my $host (@action) { |
---|
| 272 | my $object = $parser->find_object("$host", "Nagios::Host"); |
---|
| 273 | push @hosts, hostmapping($object->address =~ s/\..*$//r); |
---|
| 274 | } |
---|
| 275 | my $hosts_list = join ' ', @hosts; |
---|
[246] | 276 | $htmlpage .= ' ' . $remote_action =~ s{\%m}{$hosts_list}r; |
---|
[245] | 277 | $htmlpage .= "</pre>\n"; |
---|
| 278 | } |
---|
| 279 | } |
---|
[240] | 280 | } |
---|
| 281 | } |
---|
| 282 | |
---|
[269] | 283 | $htmlpage .= <<"ENDH"; |
---|
| 284 | <hr clear="all"> |
---|
| 285 | <a href="http://servforge.legi.grenoble-inp.fr/projects/soft-trokata/wiki/SoftWare/NagiosVelvice">Velvice</a> version: $VERSION |
---|
| 286 | <ul> |
---|
| 287 | <li>Written by Gabriel Moreau</li> |
---|
| 288 | <li>Licence GNU GPL version 2 or later and Perl equivalent</li> |
---|
| 289 | <li>Copyright (C) 2014-2018, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France</li> |
---|
| 290 | </ul> |
---|
[240] | 291 | </body> |
---|
| 292 | </html> |
---|
| 293 | ENDH |
---|
| 294 | |
---|
| 295 | print $htmlpage; |
---|
| 296 | |
---|
[254] | 297 | # delayed future check |
---|
[240] | 298 | if (@futurecheck) { |
---|
| 299 | sleep 2; |
---|
| 300 | my $nagios_cmd; |
---|
[256] | 301 | open $nagios_cmd, '>>', $config->{'nagios-server'}{'nagios-cmd'} or die "Can't open file filename: $!"; |
---|
[240] | 302 | print $nagios_cmd "$_\n" for @futurecheck; |
---|
| 303 | close $nagios_cmd; |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | __END__ |
---|
| 307 | |
---|
| 308 | |
---|
[241] | 309 | =head1 NAME |
---|
| 310 | |
---|
| 311 | velvice.cgi - nagios velvice alert panel |
---|
| 312 | |
---|
[265] | 313 | =head1 USAGE |
---|
[241] | 314 | |
---|
[265] | 315 | velvice.cgi |
---|
| 316 | velvice.cgi?check=XXX |
---|
| 317 | |
---|
| 318 | |
---|
[241] | 319 | =head1 DESCRIPTION |
---|
| 320 | |
---|
| 321 | Nagios VELVICE is an acronym for "Nagios leVEL serVICE status". |
---|
| 322 | |
---|
[265] | 323 | The Nagios web page is sometimes very graphically charged |
---|
| 324 | and does not necessarily contain the information you need at a glance. |
---|
| 325 | For example, it is quite complicated to restart controls on multiple hosts in one click. |
---|
[241] | 326 | |
---|
[265] | 327 | For example, a server that is down should take only one line and not one per service... |
---|
| 328 | Similarly, a service that has been down for 5 minutes or since yesterday |
---|
| 329 | has more weight than a service that has fallen for 15 days. |
---|
[241] | 330 | |
---|
[265] | 331 | With Velvice Panel, a broken down server takes only one line. |
---|
| 332 | Services that have been falling for a long time gradually lose their color and become pastel colors. |
---|
[241] | 333 | |
---|
[265] | 334 | With Velvice Panel, it is possible through a single click |
---|
| 335 | to redo a check of all services that are in the CRITICAL state. |
---|
| 336 | Similarly, it is possible to restart a check on all SSH services in breakdowns ... |
---|
| 337 | In order not to clog the Nagios server, checks are shifted by 2 seconds in time. |
---|
| 338 | |
---|
| 339 | There is also a link to the web page of the main Nagios server. |
---|
| 340 | For each computer, you have a direct link to its dedicated web page on this server. |
---|
| 341 | |
---|
| 342 | |
---|
| 343 | =head1 CONFIGURATION FILE SPECIFICATION |
---|
| 344 | |
---|
| 345 | The configuration file must be F</etc/nagios3/velvice.yml>. |
---|
| 346 | This is not a required file. |
---|
| 347 | The file is in YAML format because this is a human-readable text file style. |
---|
| 348 | Other formats could have been Plain XML, RDF, JSON... but they are much less readable. |
---|
| 349 | |
---|
| 350 | You can find in the software nagios-velvice an example of configuration: |
---|
| 351 | L<velvice.sample.yml|http://servforge.legi.grenoble-inp.fr/pub/soft-trokata/nagios-velvice/velvice.sample.yml>. |
---|
| 352 | This one is in fact the master reference specification! |
---|
| 353 | |
---|
| 354 | The main keys C<nagios-server> and C<color-downtime> have good default values. |
---|
| 355 | No secondary key is required... |
---|
[268] | 356 | The Velvice script try hard to replace ~ by the good value automatically. |
---|
[265] | 357 | |
---|
[268] | 358 | nagios-server: |
---|
| 359 | status-file: /var/cache/nagios3/status.dat |
---|
| 360 | nagios-cmd: /var/lib/nagios3/rw/nagios.cmd |
---|
| 361 | portal-url: ~/nagios3/ |
---|
| 362 | status-cgi: ~/cgi-bin/nagios3/status.cgi |
---|
| 363 | stylesheets: ~/nagios3/stylesheets |
---|
| 364 | |
---|
| 365 | The background color of the faulty service line display remains stable with a bright color for at least 3 days. |
---|
| 366 | Then, it decreases and becomes pastel after 53 days with an intensity of 70% (100% is white and 0% is black). |
---|
| 367 | |
---|
| 368 | color-downtime: |
---|
| 369 | day-min: 3 |
---|
| 370 | day-max: 50 |
---|
| 371 | factor: 0.7 |
---|
| 372 | |
---|
[265] | 373 | With key C<host-mapping>, |
---|
| 374 | it's good to map C<localhost> to the real name of the computer (hostname). |
---|
| 375 | |
---|
[268] | 376 | host-mapping: |
---|
| 377 | localhost: srv-nagios |
---|
| 378 | toto: titi |
---|
| 379 | |
---|
[265] | 380 | The only important key is C<remote-action>. |
---|
| 381 | You can affiliate as many subkeys as you want. |
---|
| 382 | Let's take an example: |
---|
| 383 | |
---|
| 384 | remote-action: |
---|
| 385 | oom-killer: |
---|
| 386 | regex: ^OOM Killer |
---|
| 387 | title: OOM Killer |
---|
| 388 | command: tssh -c 'sudo rm /var/lib/nagios3/nagios_oom_killer.log' %m |
---|
| 389 | command-one: ssh %m 'sudo rm /var/lib/nagios3/nagios_oom_killer.log' |
---|
| 390 | depend: ^SSH |
---|
| 391 | status: ALL |
---|
| 392 | style: bold |
---|
| 393 | |
---|
| 394 | C<oom-killer> is just a key for your remote action. |
---|
| 395 | The regex is used to find which service has a problem... |
---|
| 396 | The title is use in the result web page (not mandatory - otherwise, it will be C<Action: oom-killer>). |
---|
| 397 | The C<command> is just written on this web page. |
---|
| 398 | You have the responsibility to copy / cut it on a terminal. |
---|
| 399 | For security reasons, the nagios server does not have the right to launch the command on the remote host. |
---|
| 400 | The wildcard C<%m> is replaced by the list of the host (separated by the space). |
---|
| 401 | Sometime, the command could be different if there is only one computer (just SSH and no parallel SSH). |
---|
| 402 | If your command is based on SSH, |
---|
| 403 | you can have an SSH action only if the remote SSH is running. |
---|
| 404 | So you can make the remote action depend on the SSH service through a regular expression of your choice. |
---|
| 405 | |
---|
| 406 | The last two keys. |
---|
| 407 | The C<status> key is for CRITICAL or WARNING (or ALL). |
---|
| 408 | The key C<style> is there to mark in bold the service in error on the web page. |
---|
| 409 | |
---|
| 410 | =head1 SEE ALSO |
---|
| 411 | |
---|
| 412 | yamllint(1), ysh(1), YAML, Nagios::StatusLog, Color::Calc |
---|
| 413 | |
---|
| 414 | In Debian GNU/Linux distribution, packages for C<yamllint> and C<ysh> are: |
---|
| 415 | |
---|
| 416 | =over |
---|
| 417 | |
---|
| 418 | =item * C<yamllint> - Linter for YAML files (Python) |
---|
| 419 | |
---|
| 420 | =item * C<libyaml-shell-perl> - YAML test shell (Perl) |
---|
| 421 | |
---|
| 422 | =back |
---|
| 423 | |
---|
| 424 | |
---|
| 425 | Own project ressources: |
---|
| 426 | |
---|
| 427 | =over |
---|
| 428 | |
---|
| 429 | =item * L<Web site|http://servforge.legi.grenoble-inp.fr/projects/soft-trokata/wiki/SoftWare/NagiosVelvice> |
---|
| 430 | |
---|
| 431 | =item * L<Online Manual|http://servforge.legi.grenoble-inp.fr/pub/soft-trokata/nagios-velvice/velvice.html> |
---|
| 432 | |
---|
| 433 | =item * L<SVN repository|http://servforge.legi.grenoble-inp.fr/svn/soft-trokata/trunk/nagios-velvice> |
---|
| 434 | |
---|
| 435 | =back |
---|
| 436 | |
---|
| 437 | |
---|
| 438 | =head1 VERSION |
---|
| 439 | |
---|
[266] | 440 | $Id: velvice.cgi 270 2018-06-26 17:55:02Z g7moreau $ |
---|
[265] | 441 | |
---|
| 442 | |
---|
| 443 | =head1 AUTHOR |
---|
| 444 | |
---|
| 445 | Written by Gabriel Moreau <Gabriel.Moreau(A)univ-grenoble-alpes.fr>, LEGI UMR 5519, CNRS, Grenoble - France |
---|
| 446 | |
---|
| 447 | |
---|
[241] | 448 | =head1 LICENSE AND COPYRIGHT |
---|
| 449 | |
---|
| 450 | Licence GNU GPL version 2 or later and Perl equivalent |
---|
| 451 | |
---|
[265] | 452 | Copyright (C) 2014-2018, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|