--=-vdIlD8gvh2D9Oaf8pkgZ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hello List,
For a customer I have written a 'top10' cgi for Nagios 3.0.3. What it
basically does is sort services based on the status output, filtered
through a regexp.
It adds the following new configuration parameters for services:
show_top10 Show this service in the top10 screen?
regmatch_sort The regexp to sort the plugin output to
sort_reverse Sort them in reverse
An example config would look like this:
define service{
use generic-cisco-service-always
servicegroups PING
hostgroup_name alle-cisco-devices
service_description PING
check_command check_ping!100.0,20%!500.0,60%
show_top10 1
regmatch_sort \([0-9]\+.\?[0-9]\+\)\ ms
}
The current implementation is fairly naive, and most certainly full of
holes, consider this to be a 'proof of concept'. I have a screenshot up
here:
http://www.tmm.cx/~hp/top10.png
Is there any interest in such a feature for nagios proper? if so, I'll
gladly clean up the code and submit a proper patch.
Attached you'll also find the patch to the current version. Not very
pretty, like I said
--=-vdIlD8gvh2D9Oaf8pkgZ
Content-Disposition: attachment; filename=top.patch
Content-Type: text/x-patch; name=top.patch; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
diff -ruN ../nagios-3.0.3/cgi/top.c nagios-3.0.3/cgi/top.c
--- ../nagios-3.0.3/cgi/top.c 1970-01-01 01:00:00.000000000 +0100
+++ nagios-3.0.3/cgi/top.c 2008-08-21 14:26:08.594277291 +0200
@@ -0,0 +1,619 @@
+/*************************************************************************=
*
+ *
+ * TOP.C - Nagios top10 CGI
+ *
+ * Copyright (c) 1999-2008 Ethan Galstad ([email protected])
+ * Copyright (c) 2008 Hein-Pieter van Braam ([email protected])
+ * Last Modified: 06-23-2008
+ *
+ * License:
+ *=20
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *************************************************************************=
/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/objects.h"
+#include "../include/comments.h"
+#include "../include/macros.h"
+#include "../include/statusdata.h"
+
+#include "../include/cgiutils.h"
+#include "../include/getcgi.h"
+#include "../include/cgiauth.h"
+
+extern int refresh_rate;
+extern time_t program_start;
+
+extern char main_config_file[MAX_FILENAME_LENGTH];
+extern char url_html_path[MAX_FILENAME_LENGTH];
+extern char url_docs_path[MAX_FILENAME_LENGTH];
+extern char url_images_path[MAX_FILENAME_LENGTH];
+extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
+extern char url_logo_images_path[MAX_FILENAME_LENGTH];
+extern char url_media_path[MAX_FILENAME_LENGTH];
+extern char log_file[MAX_FILENAME_LENGTH];
+
+extern char *service_critical_sound;
+extern char *service_warning_sound;
+extern char *service_unknown_sound;
+extern char *host_down_sound;
+extern char *host_unreachable_sound;
+extern char *normal_sound;
+
+extern char *notes_url_target;
+extern char *action_url_target;
+
+extern int suppress_alert_window;
+
+extern int enable_splunk_integration;
+
+extern host *host_list;
+extern service *service_list;
+extern hostgroup *hostgroup_list;
+extern servicegroup *servicegroup_list;
+extern hoststatus *hoststatus_list;
+extern servicestatus *servicestatus_list;
+
+
+#define MAX_MESSAGE_BUFFER 4096
+
+#define DISPLAY_HOSTS 0
+#define DISPLAY_HOSTGROUPS 1
+#define DISPLAY_SERVICEGROUPS
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]