From 89a67770e66d11740948e90a41db6cee0482cf8e Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Wed, 13 Apr 2011 17:03:16 +0100 Subject: new version. --- .hgignore | 4 + CHANGELOG | 21 + README | 164 + TODO | 146 + bin/jconsole | 23 + bin/jmauveserver | 65 + bin/mauveclient | 172 + bin/mauveconsole | 23 + bin/mauveserver | 71 + bytemark_example_alerts.sh | 45 + bytemark_policy.txt | 125 + debian/changelog | 11 + debian/compat | 1 + debian/control | 57 + debian/copyright | 19 + debian/mauvealert-client.install | 3 + debian/mauvealert-common.install | 3 + debian/mauvealert-server.install | 31 + debian/rules | 9 + lib/canary.rb | 55 + lib/dm-sqlite-adapter-with-mutex.rb | 28 + lib/mauve/alert.rb | 399 ++ lib/mauve/alert_changed.rb | 144 + lib/mauve/alert_group.rb | 104 + lib/mauve/auth_bytemark.rb | 47 + lib/mauve/calendar_interface.rb | 146 + lib/mauve/configuration.rb | 484 ++ lib/mauve/datamapper.rb | 13 + lib/mauve/http_server.rb | 106 + lib/mauve/mauve_thread.rb | 133 + lib/mauve/mauve_time.rb | 16 + lib/mauve/notification.rb | 165 + lib/mauve/notifier.rb | 66 + lib/mauve/notifiers.rb | 6 + lib/mauve/notifiers/debug.rb | 68 + lib/mauve/notifiers/email.rb | 138 + lib/mauve/notifiers/sms_aql.rb | 90 + lib/mauve/notifiers/sms_default.rb | 12 + lib/mauve/notifiers/templates/email.html.erb | 0 lib/mauve/notifiers/templates/email.txt.erb | 0 lib/mauve/notifiers/templates/sms.txt.erb | 0 lib/mauve/notifiers/templates/xmpp.html.erb | 0 lib/mauve/notifiers/templates/xmpp.txt.erb | 1 + lib/mauve/notifiers/xmpp-smack.rb | 395 ++ lib/mauve/notifiers/xmpp.rb | 296 ++ lib/mauve/people_list.rb | 44 + lib/mauve/person.rb | 230 + lib/mauve/processor.rb | 109 + lib/mauve/proto.rb | 116 + lib/mauve/sender.rb | 94 + lib/mauve/server.rb | 142 + lib/mauve/source_list.rb | 105 + lib/mauve/timer.rb | 86 + lib/mauve/udp_server.rb | 109 + lib/mauve/web_interface.rb | 334 ++ lib/object_builder.rb | 113 + lib/rack-flash.rb | 171 + lib/sinatra-partials.rb | 25 + mauve.proto | 85 + mauveserver.conf | 136 + static/alerts-mobil.css | 0 static/alerts.css | 223 + static/alerts2.css | 523 +++ static/datadumper.js | 204 + static/images/acknowledge_acknowledged.png | Bin 0 -> 1575 bytes static/images/acknowledge_acknowledged_hover.png | Bin 0 -> 1575 bytes static/images/acknowledge_unacknowledged.png | Bin 0 -> 1576 bytes static/images/acknowledge_unacknowledged_hover.png | Bin 0 -> 1576 bytes static/images/alarm_alert_seen.xcf | Bin 0 -> 43298 bytes static/images/arrow-down.gif | Bin 0 -> 156 bytes static/images/arrow-up.gif | Bin 0 -> 145 bytes static/images/arrow_down.png | Bin 0 -> 379 bytes static/images/arrow_up.png | Bin 0 -> 372 bytes static/images/broken_window.jpg | Bin 0 -> 3938 bytes static/images/detail_show.png | Bin 0 -> 413 bytes static/images/error.png | Bin 0 -> 666 bytes static/images/hourglass.png | Bin 0 -> 744 bytes static/images/logo.png | Bin 0 -> 1696 bytes static/images/minus.png | Bin 0 -> 254 bytes static/images/plus.png | Bin 0 -> 262 bytes static/images/resize.png | Bin 0 -> 284 bytes static/images/toggle.png | Bin 0 -> 218 bytes static/images/toggle_alerts.png | Bin 0 -> 3875 bytes static/images/treeview-black-line.png | Bin 0 -> 432 bytes static/images/treeview-black.png | Bin 0 -> 613 bytes static/images/treeview-default-line.png | Bin 0 -> 454 bytes static/images/treeview-default.gif | Bin 0 -> 1222 bytes static/images/treeview-default.png | Bin 0 -> 617 bytes static/images/zoom.png | Bin 0 -> 692 bytes static/jquery-1.4.2.min.js | 154 + static/jquery.cookie.js | 92 + static/jquery.countdown.js | 759 +++ static/jquery.pop.js | 63 + static/jquery.treeview.pack.js | 16 + static/mauve.js | 211 + static/mauve_utils.js | 150 + static/prototype.js | 4874 ++++++++++++++++++++ test/alert_and_notification_logic.rb | 391 ++ test/mauve_test_helper.rb | 104 + test/mauve_time.rb | 38 + test/notification.rb | 57 + utils/buffer_size.sh | 32 + utils/clear_wrong_reminder.sql | 4 + utils/get_last_test_db.sh | 3 + utils/get_last_test_log.sh | 3 + utils/get_live_db.sh | 3 + utils/init_jmauve.sh | 80 + utils/init_mauve.sh | 83 + utils/packet_processing.sh | 32 + utils/run_android.sh | 2 + utils/supportbot-mauve | 73 + utils/test-smack.rb | 101 + views/_acknowledge.haml | 6 + views/_alert_counts.haml | 16 + views/_alert_strips_group.haml | 37 + views/_alert_summary.haml | 7 + views/_event_list.haml | 22 + views/_get_alerts.haml | 43 + views/_get_list.haml | 40 + views/_head.haml | 22 + views/_head2.haml | 20 + views/_head3.haml | 17 + views/_jqChangeStatus.haml | 21 + views/_jqModalScript.haml | 22 + views/_navigation.haml | 14 + views/_treecontrol.haml | 9 + views/_unacknowledged.haml | 6 + views/alert.haml | 56 + views/alerts.haml | 24 + views/alerts2.haml | 18 + views/events.haml | 22 + views/please_authenticate.haml | 25 + views/preferences.haml | 24 + 133 files changed, 14550 insertions(+) create mode 100644 .hgignore create mode 100644 CHANGELOG create mode 100644 README create mode 100644 TODO create mode 100755 bin/jconsole create mode 100755 bin/jmauveserver create mode 100755 bin/mauveclient create mode 100755 bin/mauveconsole create mode 100755 bin/mauveserver create mode 100755 bytemark_example_alerts.sh create mode 100644 bytemark_policy.txt create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/mauvealert-client.install create mode 100644 debian/mauvealert-common.install create mode 100644 debian/mauvealert-server.install create mode 100755 debian/rules create mode 100644 lib/canary.rb create mode 100644 lib/dm-sqlite-adapter-with-mutex.rb create mode 100644 lib/mauve/alert.rb create mode 100644 lib/mauve/alert_changed.rb create mode 100644 lib/mauve/alert_group.rb create mode 100644 lib/mauve/auth_bytemark.rb create mode 100644 lib/mauve/calendar_interface.rb create mode 100644 lib/mauve/configuration.rb create mode 100644 lib/mauve/datamapper.rb create mode 100644 lib/mauve/http_server.rb create mode 100644 lib/mauve/mauve_thread.rb create mode 100644 lib/mauve/mauve_time.rb create mode 100644 lib/mauve/notification.rb create mode 100644 lib/mauve/notifier.rb create mode 100644 lib/mauve/notifiers.rb create mode 100644 lib/mauve/notifiers/debug.rb create mode 100644 lib/mauve/notifiers/email.rb create mode 100644 lib/mauve/notifiers/sms_aql.rb create mode 100644 lib/mauve/notifiers/sms_default.rb create mode 100644 lib/mauve/notifiers/templates/email.html.erb create mode 100644 lib/mauve/notifiers/templates/email.txt.erb create mode 100644 lib/mauve/notifiers/templates/sms.txt.erb create mode 100644 lib/mauve/notifiers/templates/xmpp.html.erb create mode 100644 lib/mauve/notifiers/templates/xmpp.txt.erb create mode 100644 lib/mauve/notifiers/xmpp-smack.rb create mode 100644 lib/mauve/notifiers/xmpp.rb create mode 100644 lib/mauve/people_list.rb create mode 100644 lib/mauve/person.rb create mode 100644 lib/mauve/processor.rb create mode 100644 lib/mauve/proto.rb create mode 100644 lib/mauve/sender.rb create mode 100644 lib/mauve/server.rb create mode 100644 lib/mauve/source_list.rb create mode 100644 lib/mauve/timer.rb create mode 100644 lib/mauve/udp_server.rb create mode 100644 lib/mauve/web_interface.rb create mode 100644 lib/object_builder.rb create mode 100644 lib/rack-flash.rb create mode 100644 lib/sinatra-partials.rb create mode 100644 mauve.proto create mode 100644 mauveserver.conf create mode 100644 static/alerts-mobil.css create mode 100644 static/alerts.css create mode 100644 static/alerts2.css create mode 100644 static/datadumper.js create mode 100644 static/images/acknowledge_acknowledged.png create mode 100644 static/images/acknowledge_acknowledged_hover.png create mode 100644 static/images/acknowledge_unacknowledged.png create mode 100644 static/images/acknowledge_unacknowledged_hover.png create mode 100644 static/images/alarm_alert_seen.xcf create mode 100644 static/images/arrow-down.gif create mode 100644 static/images/arrow-up.gif create mode 100644 static/images/arrow_down.png create mode 100644 static/images/arrow_up.png create mode 100644 static/images/broken_window.jpg create mode 100644 static/images/detail_show.png create mode 100644 static/images/error.png create mode 100644 static/images/hourglass.png create mode 100644 static/images/logo.png create mode 100644 static/images/minus.png create mode 100644 static/images/plus.png create mode 100644 static/images/resize.png create mode 100644 static/images/toggle.png create mode 100644 static/images/toggle_alerts.png create mode 100644 static/images/treeview-black-line.png create mode 100644 static/images/treeview-black.png create mode 100644 static/images/treeview-default-line.png create mode 100644 static/images/treeview-default.gif create mode 100644 static/images/treeview-default.png create mode 100644 static/images/zoom.png create mode 100644 static/jquery-1.4.2.min.js create mode 100644 static/jquery.cookie.js create mode 100644 static/jquery.countdown.js create mode 100644 static/jquery.pop.js create mode 100644 static/jquery.treeview.pack.js create mode 100644 static/mauve.js create mode 100644 static/mauve_utils.js create mode 100644 static/prototype.js create mode 100644 test/alert_and_notification_logic.rb create mode 100644 test/mauve_test_helper.rb create mode 100644 test/mauve_time.rb create mode 100644 test/notification.rb create mode 100755 utils/buffer_size.sh create mode 100644 utils/clear_wrong_reminder.sql create mode 100755 utils/get_last_test_db.sh create mode 100755 utils/get_last_test_log.sh create mode 100755 utils/get_live_db.sh create mode 100755 utils/init_jmauve.sh create mode 100755 utils/init_mauve.sh create mode 100755 utils/packet_processing.sh create mode 100755 utils/run_android.sh create mode 100755 utils/supportbot-mauve create mode 100755 utils/test-smack.rb create mode 100644 views/_acknowledge.haml create mode 100644 views/_alert_counts.haml create mode 100644 views/_alert_strips_group.haml create mode 100644 views/_alert_summary.haml create mode 100644 views/_event_list.haml create mode 100644 views/_get_alerts.haml create mode 100644 views/_get_list.haml create mode 100644 views/_head.haml create mode 100644 views/_head2.haml create mode 100644 views/_head3.haml create mode 100644 views/_jqChangeStatus.haml create mode 100644 views/_jqModalScript.haml create mode 100644 views/_navigation.haml create mode 100644 views/_treecontrol.haml create mode 100644 views/_unacknowledged.haml create mode 100644 views/alert.haml create mode 100644 views/alerts.haml create mode 100644 views/alerts2.haml create mode 100644 views/events.haml create mode 100644 views/please_authenticate.haml create mode 100644 views/preferences.haml diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..5afd643 --- /dev/null +++ b/.hgignore @@ -0,0 +1,4 @@ +~$ +test.log$ +test.db$ +test.conf$ diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..2b04e22 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,21 @@ +... Because it is needed. + +Version 1.0.13 + * Buttons now appear in a line. + * Function were called in wrong order on buttons. + * Alerts no longer sorted by source, just by subject. + * Alerts sorted by subject then summary. + * Page no longer needs to reload on status changes. No new conglomerate created. + * Bug #1111 fix: Alerts do not acknowledge for longer than maximum time. + * Bug #1116 fix: Ajax requests take too long, now spawn a new thread -- + see feature 1131 for full fix. + + +Version 1.0.12 + * Added time scales to bulk alerts acknowledgement. + * Change the web page header to be simpler and nicer. + * Added link to alert history. + + +Version 1.0.11 and below. + * Nothing documented. diff --git a/README b/README new file mode 100644 index 0000000..be83da3 --- /dev/null +++ b/README @@ -0,0 +1,164 @@ +** Mauve Alert + + a messaging system for system and network administrators to help you sleep + better, and be attentive to your computers. + + Holly: Purple alert! Purple alert! + + Lister: What's a 'Purple Alert'? + + Holly: Well, it's sort of like, not as bad as a red alert, but a bit worse + than a blue alert. Kind of like a mauve alert, don't want to say + 'mauve alert.' + + Rimmer: Holly, wipe the rabid foam from your chin and start again. + +** Introduction + +If you run a network where too many scripts know your mobile phone number, +or you run up huge text messaging bills, your inbox is filled with +wall-to-wall red alerts of questionable urgency, or you want to be able +to make use of SNMP without a huge effort up-front, mauve may be for you. + +Mauve is not a network monitoring system, but it makes it very easy to +construct a reliable one from only shell scripts and cron. If you have a +network monitoring system (or more likely, several), mauve lets you consolidate +or reorganise how it alerts you and your team. + +Many monitoring systems only deal in red alerts, and put a lot of design +effort into screaming like a baby. The result of having multiple monitoring +systems all screaming at once, is that it's difficult to keep on top of what +alerts are actually important. The weary sysadmin learns to ignore their +text message noise in certain patterns, at certain times of day, filters their +email and so on, at the risk of ignoring something critical. + +Mauve is intended to be a bucket into which the sysadmin can easily throw +alerts. He can then decide on a central policy for distribution to his team, +saving the screaming red lights for really urgent problems. + +Many controls are built into mauve to ensure alerts are responded to by team +members. If it doesn't know any better, the system will send SMS messages to +a mobile phone, emails, or instant messages, and wait for the user to +acknowledge its alert(s), reminding the user at configured intervals. + +The user can also run a special client which suppresses the normal alerts +clogging up her email or phone. This mode of operation is intended for users +with 24/7 connected devices with richer alerting functions than a simple +text message beep or email chime. They are by their desks running a particular +program. Mauve comes with a simple prototype for Linux, and a smartphone +client for Android phones. [TODO] + +** Important data in mauve + +An alert is an event signalled by a system in your network, and it suggests +that something needs attention within a timeframe of a few minutes to a few +days. Alerts are not intended to be useful for helping you organise jobs +that can take longer than this, and are not intended to organise multi-stage +complicated jobs. + +Alerts are raised and cleared only by the system, and acknowledged by people. + +An acknowledgement is a message to the server that someone is attending to +the alert, and that it can expect the alert to be cleared within a particular +time frame. mauveserver provides a web interface through which users can +acknowledge alerts. + +Alerts are sent in a group, in a single packet called an "alert update". +Individual alert systems can send a complete update, specifying all the current +alerts that they are aware of - or they can send updates consisting of alert/ +clear messages as each change occurs. + +The information flow looks like this: + + (single UDP packets) + alert notifi (SMS/email etc.) + updates cations +[alert source 1] ------> [ ] -------> [person 1] +[alert source 2] ------> [alert station] -------> [person 2] +[alert source 3] ------> [ ] ... | + ... | | + \-----------<<--------+ + acknowledgements + (web interface) + +** Alert updates + +The alert update is the most important data structure and is described fully +in the mauve.proto file. See later on in this document for how these fields +are use to implement various monitoring patterns in Bytemark's network. + +Alert updates are not intended to span more than a single UDP packet, and +are therefore limited to 64KB. Their format is a packed binary defined by +Google's protobuf tools, and a single alert describing typical network events +will be in the order of 100s or even 10s of bytes. + +** Alert transmission and network architecture [NOT IMPLEMENTED, BAD IDEA?] + +Alert Updates are intended to be transmitted several times simultaneously +through a network of relays, each of which will forward to the intended +destination (the Alert Station), i.e. + + --------> relay ----\ + / \ +Alert source ---------> relay ----\ \ + \ \ \ + \ \ \ + --------------------v v v + Alert station + + +The canny administrator of a multi-homed mauve network is anticipating total +network failure and/or heavily congested links. Relay stations should be +positioned such that simultaneous transmission from a single source in the +network will result in different paths being taken to relays and/or final +destination. + +Alerts signal often fleeting events, and may not be of any significance if +they do not arrive at the alert station within a minute of transmission. +Transmission of an alert should be a "fire and forget" event, and the onus +of reliability of transmission lies with the network designer rather than +any protocol or queuing. + +Therefore we allow simple proxying of alerts, and the alert sender should +send alerts to all proxies and the final destination at once. The +destination will only process the same update once, so it's safe to try to +transmit through many different paths. + +As currently implemented, the alert station in a mauve system cannot be +duplicated or replicated reliably, and I'm not keen to try. A failover alert +station must be part of your planning! + +** Alert stations [TO REVISE] + +Alert stations are the central point in mauve's alert system. They are the +destinations for devices to send their alerts. It is a feature of the mauve +alert protocols that many alert stations can be configured, and they should +all contain the same information. + +Devices send their alerts to every configured alert station. + +Monitors can connect to multiple alert stations to find out which is the most +up-to-date. + + send/clear alerts copy alerts + devices --------------------> alert station -------------> alert monitor + <------------- + acknowledge alerts + +** Software components of mauve + +Mauve is a set of tools to construct an alert system that suits your network. +It has several front-end tools: + + mauvesend - a command line tool to send alert updates to a server + + mauveserver - the alert receiver, which stores incoming alerts in a database, + consults a configuration to decide who needs to know about which alerts, + and sends out texts, emails or jabber messages. + + mauveclient - a prototype client program allowing a person to acknowledge + alerts. + +** Installation + + diff --git a/TODO b/TODO new file mode 100644 index 0000000..a1b70e8 --- /dev/null +++ b/TODO @@ -0,0 +1,146 @@ + TODO list for mauve + ---=== o O o ===--- + + +1 Unit test. +------------- + +We need a lot more. Currently, the testing is woefully inadequate. In +specific: + +1.1 test_cases.rb + + This needs a little work so that the tests in there run faster. The +test currently run in nearly four minutes which is too long. The +main problem appears to be the starting and stopping of the server. +Using a server for all the tests should work provided that we remove the +fake alert created by each test in the database in the teardown method. + + This could be linked to 2.3 + +1.2 The rest... + + Too many classes have no unit tests. This has to change. + + Everything new must have unit test associated with it. + + +2 Code refactor. +----------------- + + The idea here is to have a mauve server that receive new Alerts and +process them as state machines. A brain within this should determine +which Person gets a notification. This brain needs to be accessible via +the UI since events within the UI will impact the Alert -- such as +acknowledge events. + + The UI should be separate from the mauve server. The UI either needs +a hook into the backend database or send updated alerts. I prefer the +latter. + + +2.1 Timers class. + + This needs ripping out and replacing with event machine. + + +2.2 Alert class. + + This needs ripping out and replacing with a state machine. Something +like http://slagyr.github.com/statemachine/ maybe useful. + + A brain need creating as well. + + Mauvesend may need to be refactored to conform to the state machine +model. It should not be much work but will require major work to deploy +on all systems. + + This is lots of work. + + +2.3 Configuration class. + + Nothing here is essential but would be nice to have. + + This is fine but needs more error checking of the loaded configuration +file. + + A method to reload the configuration file gracefully -- aka without a +restart. This could be linked to 1.1. + + +2.4 UI, the web interface. + + This needs ripping out and separated as a new process. We can have a +thread in the main mauve server process write the date to a file every X +seconds. The UI can display this date and thus any check can be done on +that date. If it is older than X, then the main server has stopped and +we should alert everybody. + + + +3 General work. +---------------- + +3.1 Move to apt-ruby. + + We must get ride of the external directories and move fully to +apt-ruby. This should lead to better deployment on Debian. + + +3.2 Rubinius. + + Make sure we can run the code in Rubinius. Not urgent until the GIL +is fixed. Note that this may entails some new code for the XMPP +notification class. + + I tried to do this on Tue Jan 18 with rbx-head hydra (no GIL devel +branch) and it did not work well at all. The unit test ran slower than +with mri and failed on multiple occations (140 tests, 248 assertions, 0 +failures, 122 errors, 0 pendings, 0 omissions, 0 notifications 47.8571% +passed). I suspect rr mock and log4r gems are not playing well with +rbx as most errors were due to interactions between those two. It could +be that the rbx-head version is really not ready to be used in +production. + + +3.3 Documentation. + + We need some more in code documentation although it is now adequate. + + User documentation, especially with regards to the configuration file, +need a lot of work. Not sure where is the best: Redmine wiki, Bytemark +wiki, text file in repository... + + + + +4 New features. +--------------- + +4.1 XMPP/email interface. + + The ability to manipulate Alerts via XMPP and eamil. + + +4.2 Suppress Alerts. + + The ability to suppress alerts for a short time. + + +4.3 Notes for Alerts. + + The ability to create notes on alerts. + + +4.4 Better alert history. + + Either just cosmetic or require code changes to have a better timeline +of alerts status. + + +4.5 Really SMTP + + Move new smtp code so that we do not use the local mailer but send the +email directly. The code (with documentation and tests) is written but +not incorporated yet. diff --git a/bin/jconsole b/bin/jconsole new file mode 100755 index 0000000..6e638ad --- /dev/null +++ b/bin/jconsole @@ -0,0 +1,23 @@ +#!/usr/bin/env jruby + +require 'pp' +pp $: + +Thread.abort_on_exception = true +require 'irb' +require 'thread' + +# hack for delving into test-generated configurations +class AlertAndNotificationLogic; Alerts = Queue.new; end + +require 'mauve/configuration' +include Mauve +#raise "must specify config file" unless ARGV.length > 0 +unless ARGV.length > 0 + STDERR.print("You must specify a configuration file as $arg[1]\n") + STDERR.print(" eg: ./mauve_starter ./bin/console ./test/local.conf\n") + exit 1 +end +Configuration.current = ConfigurationBuilder.load(ARGV.shift) +IRB.start + diff --git a/bin/jmauveserver b/bin/jmauveserver new file mode 100755 index 0000000..9cdd26f --- /dev/null +++ b/bin/jmauveserver @@ -0,0 +1,65 @@ +#!/usr/bin/env jruby + +begin + eval "Proc.new { |a,&b| }" +rescue SyntaxError => no_blocks_with_procs + STDERR.print "mauveserver must have Ruby 1.8.7 or later, sorry (if you "+ + "try, you'll get a SyntaxError trying to load one of its libraries)\n" + exit 1 +end + +require 'mauve/configuration' +include Mauve + +configuration_file = ARGV[0] +if !configuration_file + if File.exists?("/etc/mauvealert/mauveserver.conf") + configuration_file = "/etc/mauvealert/mauveserver.conf" + else + STDERR.print "Syntax: #{$0} \n" + exit 1 + end +end +Configuration.current = ConfigurationBuilder.load(configuration_file) + +class RestartSignalReceived < Exception; end +trap("HUP") do + # this blows up if you do it twice in quick succession, but don't really + # care about that case as it's only for log rotation. + Thread.main.raise(RestartSignalReceived.new) +end + +# Start canary thread. +#require 'canary' +#Canary.start(1, Log) + +# Main loop +@logger = Log4r::Logger.new "mauve::server<#{Process.pid}>" +loop do + begin + Configuration.current.server.run + rescue Interrupt + @logger.info "Interrupted by user, exiting" + Configuration.current.close + exit 0 + rescue RestartSignalReceived => ex + @logger.info "Restart signal received, reloading the configuration" + begin + new_configuration = ConfigurationBuilder.load(configuration_file) + rescue Exception => ex + @logger.error "Error reloading configuration, reusing old one: #{ex}" + @logger.debug ex.backtrace.join("\n") + end + + Configuration.current.close + Configuration.current = new_configuration + rescue Exception => ex + @logger.fatal("Uncaught #{ex.class} exception, will try to log") + @logger.fatal("Class: #{ex.class} "+ + "Message: #{ex.message} "+ + "Backtrace: #{ex.backtrace.join("\n")}") + exit 9 + end +end + + diff --git a/bin/mauveclient b/bin/mauveclient new file mode 100755 index 0000000..d513926 --- /dev/null +++ b/bin/mauveclient @@ -0,0 +1,172 @@ +#! /usr/bin/ruby1.8 +# == Synopsis +# +# mauvesend: send alert(s) to a given alert station +# +# == Usage +# +# mauvesend [destination] +# [--source | -o ] [--replace | -p] [--verbose | -v] +# [--id [alert options] ... ] +# +# : +# where the alert should go, can be one of: +# SRV record from DNS (we add _mauvealert._udp to record name) +# normal hostname (i.e. A record) +# IP address:port number +# +# if no destination is supplied, reads parameter from file +# /etc/mauvealert/mauvesend.destination (otherwise throws an error). +# +# --source | -o : +# identify the source of the alert (defaults to hostname, but you might +# want to name your monitoring systems more explicitly). +# +# --replace | -p: +# Send an update replacing all other alerts for this source - any previous +# alerts not specified in this update are assumed to be cleared. If you +# specify this option, you don't have to supply *any* alerts to raise or +# clear (in which case all alerts from that source will be cleared). +# +# --verbose | -v: +# If you specify this option once, it will print the transmission ID +# of the packet for debugging. If you specify it twice, it will print +# the entire data structure. +# +# You can specify any number of alerts in an update - every time you specify +# --id starts a new alert. +# +# --id | -i : +# alert ID; unique specified for each alert raised. +# +# --summary | -s : +# text for humans describing the nature of the alert, first 100 characters +# are only ones guaranteed to make it to pagers, twitter, SMS etc. +# +# --detail | -d : +# HTML fragment describing the alert in more detail, no limit on length. +# +# --subject | -u : +# set the subject of the alert (i.e. the server/entity that this alert +# concerns). +# +# --clear | -c