diff --git a/.gitignore b/.gitignore index d2fc8b1f4..74513102b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ features/support/etc/netsaint/* log/* vendor .bundle -etc/*.yaml +etc/*.toml coverage tmp/* flapjack-*.gem diff --git a/Gemfile.lock b/Gemfile.lock index 4f81bf3bb..a2d2cd253 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,6 +23,7 @@ PATH redis (~> 3.0.6) sinatra terminal-table + toml tzinfo tzinfo-data xmpp4r (>= 0.5.5) @@ -41,6 +42,7 @@ GEM tzinfo (~> 1.1) addressable (2.3.6) awesome_print (1.2.0) + blankslate (2.1.2.4) builder (3.2.2) chronic (0.10.2) chronic_duration (0.10.6) @@ -58,7 +60,7 @@ GEM chronic diff-lcs (1.2.5) docile (1.1.5) - ffi (1.9.5) + ffi (1.9.6) find_a_port (1.0.1) fuubar (2.0.0) rspec (~> 3.0) @@ -72,13 +74,13 @@ GEM json (1.8.1) mail (2.6.1) mime-types (>= 1.16, < 3) - mime-types (2.3) + mime-types (2.4.3) minitest (5.4.2) - msgpack (0.5.8) + msgpack (0.5.9) multi_json (1.10.1) multi_test (0.1.1) numerizer (0.1.1) - oj (2.10.2) + oj (2.10.4) pact (1.3.3) awesome_print (~> 1.1) find_a_port (~> 1.0.1) @@ -89,6 +91,8 @@ GEM term-ansicolor (~> 1.0) thor webrick + parslet (1.5.0) + blankslate (~> 2.0) rack (1.5.2) rack-protection (1.5.3) rack @@ -132,10 +136,12 @@ GEM thread_safe (0.3.4) tilt (1.4.1) tins (1.3.3) + toml (0.1.2) + parslet (~> 1.5.0) trollop (2.0) tzinfo (1.2.2) thread_safe (~> 0.1) - tzinfo-data (1.2014.8) + tzinfo-data (1.2014.9) tzinfo (>= 1.0.0) webmock (1.18.0) addressable (>= 2.3.6) diff --git a/README.md b/README.md index 4fcbb849d..27a8f664c 100644 --- a/README.md +++ b/README.md @@ -87,11 +87,11 @@ You'll also need Redis >= 2.6.12. ## Configuring -Have a look at the [default config file](https://github.com/flapjack/flapjack/blob/master/etc/flapjack_config.yaml.example) and modify things as required. The package installer copies this to `/etc/flapjack/flapjack_config.yaml` if it doesn't already exist. +Have a look at the [default config file](https://github.com/flapjack/flapjack/blob/master/etc/flapjack_config.toml.example) and modify things as required. The package installer copies this to `/etc/flapjack/flapjack_config.toml` if it doesn't already exist. ``` bash # edit the config -sudo vi /etc/flapjack/flapjack_config.yaml +sudo vi /etc/flapjack/flapjack_config.toml # reload the config sudo /etc/init.d/flapjack reload diff --git a/bin/flapjack b/bin/flapjack index 37051d3f1..39ed2efeb 100755 --- a/bin/flapjack +++ b/bin/flapjack @@ -12,8 +12,8 @@ program_desc 'Flexible monitoring notification routing system' version Flapjack::VERSION desc 'Configuration file to use' -default_value '/etc/flapjack/flapjack_config.yaml' -arg_name '/path/to/flapjack.yaml' +default_value '/etc/flapjack/flapjack_config.toml' +arg_name '/path/to/flapjack.toml' flag [:c,:config] desc 'Environment to boot' diff --git a/etc/flapjack_config.toml.example b/etc/flapjack_config.toml.example new file mode 100644 index 000000000..a28ac1d33 --- /dev/null +++ b/etc/flapjack_config.toml.example @@ -0,0 +1,209 @@ +pid_dir = "/var/run/flapjack/" +log_dir = "/var/log/flapjack/" +daemonize = "yes" +[logger] + level = "INFO" + syslog_errors = "yes" +[redis] + host = "127.0.0.1" + port = 6380 + db = 0 +# Processes monitoring events off the *events* queue (a redis list) and decides +# what actions to take (generate notification event, record state changes, etc) +[processor] + enabled = "yes" + queue = "events" + notifier_queue = "notifications" + archive_events = true + events_archive_maxage = 10800 + # Flapjack sets scheduled maintenance on new check results so contacts aren't + # notified as soon as Flapjack becomes aware of an entity to notify on. + # This is useful is cases where your monitoring starts checking something + # before it is completely provisioned + # Value parsed by https://github.com/hpoydar/chronic_duration + # You can disable this setting by specifying "0 seconds". + new_check_scheduled_maintenance_duration = "100 years" + new_check_scheduled_maintenance_ignore_tags = ["bypass_ncsm"] + [processor.logger] + level = "INFO" + syslog_errors = "yes" +# Processes notification events off the *notifications* queue (a redis list) and +# works out who to notify, and on which media, and with what kind of notification +# message. It then creates jobs for the various notification gateways below. +[notifier] + enabled = "yes" + queue = "notifications" + email_queue = "email_notifications" + sms_queue = "sms_notifications" + sms_twilio_queue = "sms_twilio_notifications" + sns_queue = "sns_notifications" + jabber_queue = "jabber_notifications" + pagerduty_queue = "pagerduty_notifications" + notification_log_file = "/var/log/flapjack/notification.log" + default_contact_timezone = "UTC" + [notifier.logger] + level = "INFO" + syslog_errors = "yes" +[nagios-receiver] + fifo = "/var/cache/nagios3/event_stream.fifo" + pid_dir = "/var/run/flapjack/" + log_dir = "/var/log/flapjack/" +[nsca-receiver] + fifo = "/var/lib/nagios3/rw/nagios.cmd" + pid_dir = "/var/run/flapjack/" + log_dir = "/var/log/flapjack/" +[gateways] + # Generates email notifications + [gateways.email] + enabled = "no" + # the redis queue this pikelet will look for notifications on + queue = "email_notifications" + [gateways.email.logger] + level = "INFO" + syslog_errors = "yes" + # these values are passed directly through to EventMachine::Protocols::SmtpClient configuration, + # and can be omitted if the defaults are acceptable + [gateways.email.smtp_config] + # from = "Flapjack Example " + # reply_to = "flapjack@support.example" + host = "127.0.0.1" + # 1025 is the default port for http://mailcatcher.me + port = 1025 + starttls = false + #[gateways.email.smtp_config.auth] + # type = + # username = + # password = + # location of custom alert templates + #[gateways.email.templates] + # rollup_subject_text = "/etc/flapjack/templates/email/rollup_subject.text.erb" + # alert_subject_text = "/etc/flapjack/templates/email/alert_subject.text.erb" + # rollup_text = "/etc/flapjack/templates/email/rollup.text.erb" + # alert_text = "/etc/flapjack/templates/email/alert.text.erb" + # rollup.html = "/etc/flapjack/templates/email/rollup.html.erb" + # alert.html = "/etc/flapjack/templates/email/alert.html.erb" + # Sends SMS notifications via MessageNet (Australia only) + [gateways.sms] + enabled = "no" + # the redis queue this pikelet will look for notifications on + queue = "sms_notifications" + endpoint = "https://www.messagenet.com.au/dotnet/Lodge.asmx/LodgeSMSMessage" + username = "ermahgerd" + password = "xxxx" + [gateways.sms.logger] + level = "INFO" + syslog_errors = "yes" + # location of custom alert templates + #templates: + # rollup_text = "/etc/flapjack/templates/sms/rollup.text.erb" + # alert_text = "/etc/flapjack/templates/sms/alert.text.erb" + # Sends SMS notifications via Twilio + [gateways.sms_twilio] + enabled = "no" + queue = "sms_twilio_notifications" + account_sid = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + auth_token = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + from = "+1xxxxxxxxxx" + [gateways.sms_twilio.logger] + level = "INFO" + syslog_errors = "yes" + # location of custom alert templates + #[gateways.sms_twilio.templates] + # rollup_text = "/etc/flapjack/templates/sms_twilio/rollup.text.erb" + # alert_text = "/etc/flapjack/templates/sms_twilio/alert.text.erb" + # Generates SNS notifications + [gateways.sns] + enabled = "no" + queue = "sns_notifications" + #region_name = "us-east-1" + # Don't forget to use an IAM user's credentials here so revocation is easy! + access_key = "AKIAIOSFODNN7EXAMPLE" + secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + # Connects to an XMPP (jabber) server, sends notifications (to rooms and individuals), + # handles acknowledgements from jabber users and other commands. + [gateways.jabber] + enabled = "no" + # the redis queue this pikelet will look for notifications on + queue = "jabber_notifications" + server = "jabber.example.com" + port = 5222 + jabberid = "flapjack@jabber.example.com" + password = "good-password" + alias = "flapjack" + # List of strings that this pikelet user will respond to + identifiers = ["@flapjack"] + # the Multi-User Chats the pikelet should join and announce to + rooms = [ + "gimp@conference.jabber.example.com", + "log@conference.jabber.example.com" + ] + [gateways.jabber.logger] + level = "INFO" + syslog_errors = "yes" + # location of custom alert templates + #[gateways.jabber.templates] + # rollup_text = "/etc/flapjack/templates/jabber/rollup.text.erb" + # alert_text = "/etc/flapjack/templates/jabber/alert.text.erb" + # Sends notifications to and accepts acknowledgements from [PagerDuty](http://www.pagerduty.com/) + # (NB = "contacts will need to have a registered PagerDuty account to use this)" + [gateways.pagerduty] + enabled = "no" + # the redis queue this pikelet will look for notifications on + queue = "pagerduty_notifications" + [gateways.pagerduty.logger] + level = "INFO" + syslog_errors = "yes" + # location of custom alert templates + #[gateways.pagerduty.templates] + # alert_text = "/etc/flapjack/templates/pagerduty/alert.text.erb" + # Browsable web interface + [gateways.web] + enabled = "yes" + port = 3080 + timeout = 300 + # Seconds between auto_refresh of entities/checks pages. Set to 0 to disable + auto_refresh = 120 + access_log = "/var/log/flapjack/web_access.log" + api_url = "http://localhost:3081/" + # Full path to location of logo file, e.g. /etc/flapjack/custom_logo.png + #logo_image_path = "/etc/flapjack/web/custom_logo/flapjack-2013-notext-transparent-300-300.png" + [gateways.web.logger] + level = "INFO" + syslog_errors = "yes" + # HTTP API server + [gateways.jsonapi] + enabled = "yes" + port = 3081 + timeout = 300 + access_log = "/var/log/flapjack/jsonapi_access.log" + base_url = "http://localhost:3081/" + [gateways.jsonapi.logger] + level = "INFO" + syslog_errors = "yes" + # "out-of-band" end-to-end testing, used for monitoring other instances of + # flapjack to ensure that they are running correctly + [gateways.oobetet] + enabled = "no" + server = "jabber.example.com" + port = 5222 + # jabberid, password, alias, rooms = "see the jabber pikelet" + jabberid = "flapjacktest@jabber.example.com" + password = "nuther-good-password" + alias = "flapjacktest" + # The check oobetet should watch for the state change + watched_check = "PING" + # The entitiy that the check should be associated with + watched_entity = "foo.example.com" + # The maximum amount of time allowed to pass between state changes on that check + max_latency = 300 + # The API key for a service in PagerDuty that the oobetet will use to alert you + pagerduty_contact = 11111111111111111111111111111111 + # Jabber rooms to join + rooms = [ + "flapjacktest@conference.jabber.example.com", + "gimp@conference.jabber.example.com", + "log@conference.jabber.example.com" + ] + [gateways.oobetet.logger] + level = "INFO" + syslog_errors = "yes" \ No newline at end of file diff --git a/etc/flapjack_config.yaml.example b/etc/flapjack_config.yaml.example deleted file mode 100644 index 2132c8ec0..000000000 --- a/etc/flapjack_config.yaml.example +++ /dev/null @@ -1,424 +0,0 @@ ---- - -production: - pid_dir: /var/run/flapjack/ - log_dir: /var/log/flapjack/ - daemonize: yes - logger: - level: INFO - syslog_errors: yes - redis: - host: 127.0.0.1 - port: 6380 - db: 0 - # Processes monitoring events off the *events* queue (a redis list) and decides - # what actions to take (generate notification event, record state changes, etc) - processor: - enabled: yes - queue: events - notifier_queue: notifications - archive_events: true - events_archive_maxage: 10800 - # Flapjack sets scheduled maintenance on new check results so contacts aren't - # notified as soon as Flapjack becomes aware of an entity to notify on. - # This is useful is cases where your monitoring starts checking something - # before it is completely provisioned - # Value parsed by https://github.com/hpoydar/chronic_duration - # You can disable this setting by specifying "0 seconds". - new_check_scheduled_maintenance_duration: 100 years - new_check_scheduled_maintenance_ignore_tags: - - bypass_ncsm - logger: - level: INFO - syslog_errors: yes - # Processes notification events off the *notifications* queue (a redis list) and - # works out who to notify, and on which media, and with what kind of notification - # message. It then creates jobs for the various notification gateways below. - notifier: - enabled: yes - queue: notifications - email_queue: email_notifications - sms_queue: sms_notifications - sms_twilio_queue: sms_twilio_notifications - sns_queue: sns_notifications - jabber_queue: jabber_notifications - pagerduty_queue: pagerduty_notifications - notification_log_file: /var/log/flapjack/notification.log - default_contact_timezone: UTC - logger: - level: INFO - syslog_errors: yes - nagios-receiver: - fifo: "/var/cache/nagios3/event_stream.fifo" - pid_dir: "/var/run/flapjack/" - log_dir: "/var/log/flapjack/" - nsca-receiver: - fifo: "/var/lib/nagios3/rw/nagios.cmd" - pid_dir: "/var/run/flapjack/" - log_dir: "/var/log/flapjack/" - gateways: - # Generates email notifications - email: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: email_notifications - logger: - level: INFO - syslog_errors: yes - # these values are passed directly through to EventMachine::Protocols::SmtpClient configuration, - # and can be omitted if the defaults are acceptable - smtp_config: - # from: "Flapjack Example " - # reply_to: "flapjack@support.example" - host: 127.0.0.1 - # 1025 is the default port for http://mailcatcher.me - port: 1025 - starttls: false - #auth: - # type: - # username: - # password: - # location of custom alert templates - #templates: - # rollup_subject.text: '/etc/flapjack/templates/email/rollup_subject.text.erb' - # alert_subject.text: '/etc/flapjack/templates/email/alert_subject.text.erb' - # rollup.text: '/etc/flapjack/templates/email/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/email/alert.text.erb' - # rollup.html: '/etc/flapjack/templates/email/rollup.html.erb' - # alert.html: '/etc/flapjack/templates/email/alert.html.erb' - # Sends SMS notifications via MessageNet (Australia only) - sms: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: sms_notifications - endpoint: 'https://www.messagenet.com.au/dotnet/Lodge.asmx/LodgeSMSMessage' - username: "ermahgerd" - password: "xxxx" - logger: - level: INFO - syslog_errors: yes - # location of custom alert templates - #templates: - # rollup.text: '/etc/flapjack/templates/sms/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/sms/alert.text.erb' - # Sends SMS notifications via Twilio - sms_twilio: - enabled: no - queue: sms_twilio_notifications - account_sid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - auth_token: "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" - from: "+1xxxxxxxxxx" - logger: - level: INFO - syslog_errors: yes - # location of custom alert templates - # location of custom alert templates - #templates: - # rollup.text: '/etc/flapjack/templates/sms_twilio/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/sms_twilio/alert.text.erb' - # Generates SNS notifications - sns: - enabled: no - queue: sns_notifications - #region_name: us-east-1 - # Don't forget to use an IAM user's credentials here so revocation is easy! - access_key: AKIAIOSFODNN7EXAMPLE - secret_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY - # Connects to an XMPP (jabber) server, sends notifications (to rooms and individuals), - # handles acknowledgements from jabber users and other commands. - jabber: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: jabber_notifications - server: "jabber.example.com" - port: 5222 - jabberid: "flapjack@jabber.example.com" - password: "good-password" - alias: "flapjack" - # List of strings that this pikelet user will respond to - identifiers: - - "@flapjack" - # the Multi-User Chats the pikelet should join and announce to - rooms: - - "gimp@conference.jabber.example.com" - - "log@conference.jabber.example.com" - logger: - level: INFO - syslog_errors: yes - # location of custom alert templates - #templates: - # rollup.text: '/etc/flapjack/templates/jabber/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/jabber/alert.text.erb' - # Sends notifications to and accepts acknowledgements from [PagerDuty](http://www.pagerduty.com/) - # (NB: contacts will need to have a registered PagerDuty account to use this) - pagerduty: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: pagerduty_notifications - logger: - level: INFO - syslog_errors: yes - # location of custom alert templates - #templates: - # alert.text: '/etc/flapjack/templates/pagerduty/alert.text.erb' - # Browsable web interface - web: - enabled: yes - port: 3080 - timeout: 300 - # Seconds between auto_refresh of entities/checks pages. Set to 0 to disable - auto_refresh: 120 - access_log: "/var/log/flapjack/web_access.log" - api_url: "http://localhost:3081/" - # Full path to location of logo file, e.g. /etc/flapjack/custom_logo.png - #logo_image_path: "/etc/flapjack/web/custom_logo/flapjack-2013-notext-transparent-300-300.png" - logger: - level: INFO - syslog_errors: yes - # HTTP API server - jsonapi: - enabled: yes - port: 3081 - timeout: 300 - access_log: "/var/log/flapjack/jsonapi_access.log" - base_url: "http://localhost:3081/" - logger: - level: INFO - syslog_errors: yes - # "out-of-band" end-to-end testing, used for monitoring other instances of - # flapjack to ensure that they are running correctly - oobetet: - enabled: no - server: "jabber.example.com" - port: 5222 - # jabberid, password, alias, rooms: see the jabber pikelet - jabberid: "flapjacktest@jabber.example.com" - password: "nuther-good-password" - alias: "flapjacktest" - # The check oobetet should watch for the state change - watched_check: "PING" - # The entitiy that the check should be associated with - watched_entity: "foo.example.com" - # The maximum amount of time allowed to pass between state changes on that check - max_latency: 300 - # The API key for a service in PagerDuty that the oobetet will use to alert you - pagerduty_contact: "11111111111111111111111111111111" - # Jabber rooms to join - rooms: - - "flapjacktest@conference.jabber.example.com" - - "gimp@conference.jabber.example.com" - - "log@conference.jabber.example.com" - logger: - level: INFO - syslog_errors: yes - -development: - pid_dir: tmp/pids/ - log_dir: log/ - daemonize: yes - logger: - level: DEBUG - syslog_errors: yes - redis: - host: 127.0.0.1 - port: 6379 - db: 13 - # Processes monitoring events off the *events* queue (a redis list) and decides - # what actions to take (generate notification event, record state changes, etc) - processor: - enabled: yes - queue: events - notifier_queue: notifications - archive_events: true - events_archive_maxage: 10800 - # Flapjack sets scheduled maintenance on new check results so contacts aren't - # notified as soon as Flapjack becomes aware of an entity to notify on. - # This is useful is cases where your monitoring starts checking something - # before it is completely provisioned - # Value parsed by https://github.com/hpoydar/chronic_duration - # You can disable this setting by specifying "0 seconds". - new_check_scheduled_maintenance_duration: 100 years - new_check_scheduled_maintenance_ignore_tags: - - bypass_ncsm - logger: - level: DEBUG - syslog_errors: yes - # Processes notification events off the *notifications* queue (a redis list) and - # works out who to notify, and on which media, and with what kind of notification - # message. It then creates jobs for the various notification gateways below. - notifier: - enabled: yes - queue: notifications - email_queue: email_notifications - sms_queue: sms_notifications - sms_twilio_queue: sms_twilio_notifications - jabber_queue: jabber_notifications - pagerduty_queue: pagerduty_notifications - notification_log_file: log/notification.log - default_contact_timezone: UTC - logger: - level: DEBUG - syslog_errors: yes - nagios-receiver: - fifo: "/var/cache/nagios3/event_stream.fifo" - pid_dir: "tmp/pids/" - log_dir: "log/" - nsca-receiver: - fifo: "/var/lib/nagios3/rw/nagios.cmd" - pid_dir: "tmp/pids/" - log_dir: "log/" - gateways: - # Generates email notifications - email: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: email_notifications - logger: - level: DEBUG - syslog_errors: yes - # these values are passed directly through to EventMachine::Protocols::SmtpClient configuration, - # and can be omitted if the defaults are acceptable - smtp_config: - # from: "Flapjack Example " - # reply_to: "flapjack@support.example" - host: 127.0.0.1 - # 1025 is the default port for http://mailcatcher.me - port: 1025 - starttls: false - #auth: - # type: - # username: - # password: - # location of custom alert templates - #templates: - # rollup_subject.text: '/etc/flapjack/templates/email/rollup_subject.text.erb' - # alert_subject.text: '/etc/flapjack/templates/email/alert_subject.text.erb' - # rollup.text: '/etc/flapjack/templates/email/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/email/alert.text.erb' - # rollup.html: '/etc/flapjack/templates/email/rollup.html.erb' - # alert.html: '/etc/flapjack/templates/email/alert.html.erb' - # Generates sms notifications - sms: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: sms_notifications - endpoint: 'https://www.messagenet.com.au/dotnet/Lodge.asmx/LodgeSMSMessage' - username: "ermahgerd" - password: "xxxx" - logger: - level: DEBUG - syslog_errors: yes - # location of custom alert templates - #templates: - # rollup.text: '/etc/flapjack/templates/sms/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/sms/alert.text.erb' - # Sends SMS messages via Twilio - sms_twilio: - enabled: no - queue: sms_twilio_notifications - account_sid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - auth_token: "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" - from: "+1xxxxxxxxxx" - logger: - level: INFO - syslog_errors: yes - # location of custom alert templates - # location of custom alert templates - #templates: - # rollup.text: '/etc/flapjack/templates/sms_twilio/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/sms_twilio/alert.text.erb' - # Generates SNS notifications - # Connects to an XMPP (jabber) server, sends notifications (to rooms and individuals), - # handles acknowledgements from jabber users and other commands. - jabber: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: jabber_notifications - server: "jabber.example.com" - port: 5222 - jabberid: "flapjack@jabber.example.com" - password: "good-password" - alias: "flapjack" - # List of strings that this pikelet user will respond to - identifiers: - - "@flapjack" - # the Multi-User Chats the pikelet should join and announce to - rooms: - - "gimp@conference.jabber.example.com" - - "log@conference.jabber.example.com" - logger: - level: DEBUG - syslog_errors: yes - # location of custom alert templates - #templates: - # rollup.text: '/etc/flapjack/templates/jabber/rollup.text.erb' - # alert.text: '/etc/flapjack/templates/jabber/alert.text.erb' - # Sends notifications to and accepts acknowledgements from [PagerDuty](http://www.pagerduty.com/) - # (NB: contacts will need to have a registered PagerDuty account to use this) - pagerduty: - enabled: no - # the redis queue this pikelet will look for notifications on - queue: pagerduty_notifications - logger: - level: INFO - syslog_errors: yes - # location of custom alert templates - #templates: - # alert.text: '/etc/flapjack/templates/pagerduty/alert.text.erb' - # Browsable web interface - web: - enabled: yes - port: 3080 - timeout: 300 - # Seconds between auto_refresh of entities/checks pages. Set to 0 to disable - auto_refresh: 120 - access_log: "log/web_access.log" - api_url: "http://localhost:3081/" - # Full path to location of logo file, e.g. /etc/flapjack/custom_logo.png - #logo_image_path: "/etc/flapjack/web/custom_logo/flapjack-2013-notext-transparent-300-300.png" - logger: - level: DEBUG - syslog_errors: yes - # HTTP API server - jsonapi: - enabled: yes - port: 3081 - timeout: 300 - access_log: "log/jsonapi_access.log" - base_url: "http://localhost:3081/" - logger: - level: DEBUG - syslog_errors: yes - # "out-of-band" end-to-end testing, used for monitoring other instances of - # flapjack to ensure that they are running correctly - oobetet: - enabled: no - server: "jabber.example.com" - port: 5222 - # jabberid, password, alias, rooms: see the jabber pikelet - jabberid: "flapjacktest@jabber.example.com" - password: "nuther-good-password" - alias: "flapjacktest" - # The check oobetet should watch for the state change - watched_check: "PING" - # The entitiy that the check should be associated with - watched_entity: "foo.example.com" - # The maximum amount of time allowed to pass between state changes on that check - max_latency: 300 - # The API key for a service in PagerDuty that the oobetet will use to alert you - pagerduty_contact: "11111111111111111111111111111111" - # Jabber rooms to join - rooms: - - "flapjacktest@conference.jabber.example.com" - - "gimp@conference.jabber.example.com" - - "log@conference.jabber.example.com" - logger: - level: DEBUG - syslog_errors: yes - -test: - pid_dir: tmp/pids/ - log_dir: log/ - redis: - db: 14 - driver: ruby diff --git a/features/cli.feature b/features/cli.feature index 906adb04f..33e46da1b 100644 --- a/features/cli.feature +++ b/features/cli.feature @@ -5,29 +5,27 @@ Feature: command line utility From the command line Background: - Given a file named "flapjack_cfg.yaml" with: + Given a file named "flapjack_cfg.toml" with: """ -test: - pid_dir: tmp/cucumber_cli/ - log_dir: tmp/cucumber_cli/ - redis: - db: 14 - processor: - enabled: yes - logger: - level: warn +pid_dir = "tmp/cucumber_cli/" +log_dir = "tmp/cucumber_cli/" +[redis] + db = 14 +[processor] + enabled = "yes" + [processor.logger] + level = "warn" """ - And a file named "flapjack_cfg_d.yaml" with: + And a file named "flapjack_cfg_d.toml" with: """ -test: - pid_dir: tmp/cucumber_cli/ - log_dir: tmp/cucumber_cli/ - redis: - db: 14 - processor: - enabled: yes - logger: - level: warn +pid_dir = "tmp/cucumber_cli/" +log_dir = "tmp/cucumber_cli/" +[redis] + db = 14 +[processor] + enabled = "yes" + [processor.logger] + level = "warn" """ Scenario: Running with --help shows usage information @@ -38,42 +36,42 @@ test: And the output should contain "[-d|--daemonize]" Scenario: Getting status when stopped - When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server status` + When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server status` Then the exit status should not be 0 And the output should contain "Flapjack is not running" Scenario: Starting flapjack - When I start flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg.yaml server start` + When I start flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg.toml server start` Then flapjack should start within 15 seconds Scenario: Stopping flapjack via SIGINT - When I start flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg.yaml server start` + When I start flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg.toml server start` Then flapjack should start within 15 seconds When I send a SIGINT to the flapjack process Then flapjack should stop within 15 seconds Scenario: Starting, status and stopping flapjack, daemonized - When I start flapjack (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server start` + When I start flapjack (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server start` Then flapjack should start within 15 seconds - When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server status` + When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server status` Then the exit status should be 0 And the output should contain "Flapjack is running" - When I stop flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server stop` + When I stop flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server stop` Then flapjack should stop within 15 seconds Scenario: Starting, restarting and stopping flapjack, daemonized - When I start flapjack (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server start` + When I start flapjack (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server start` Then flapjack should start within 15 seconds - When I restart flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server restart` + When I restart flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server restart` Then flapjack should restart within 15 seconds - When I stop flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server stop` + When I stop flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server stop` Then flapjack should stop within 15 seconds Scenario: Reloading flapjack configuration - When I start flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg.yaml server start` + When I start flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg.toml server start` Then flapjack should start within 15 seconds - When I run `mv tmp/cucumber_cli/flapjack_cfg.yaml tmp/cucumber_cli/flapjack_cfg.yaml.bak` - Given a file named "flapjack_cfg.yaml" with: + When I run `mv tmp/cucumber_cli/flapjack_cfg.toml tmp/cucumber_cli/flapjack_cfg.toml.bak` + Given a file named "flapjack_cfg.toml" with: """ test: pid_dir: tmp/cucumber_cli/ @@ -85,5 +83,5 @@ test: """ When I send a SIGHUP to the flapjack process # TODO how to test for config file change? - When I stop flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.yaml server stop` + When I stop flapjack (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/flapjack_cfg_d.toml server stop` Then flapjack should stop within 15 seconds diff --git a/features/cli_flapjack-feed-events.feature b/features/cli_flapjack-feed-events.feature index 479e75157..15a69cae7 100644 --- a/features/cli_flapjack-feed-events.feature +++ b/features/cli_flapjack-feed-events.feature @@ -5,12 +5,11 @@ Feature: flapjack-feed-events command line From the command line Background: - Given a file named "flapjack-feed-events.yaml" with: + Given a file named "flapjack-feed-events.toml" with: """ -test: - redis: - db: 14 - driver: ruby +[redis] + db = 14 + driver = "ruby" """ Scenario: Running with --help shows usage information @@ -20,7 +19,7 @@ test: And the output should contain "-f, --from=arg" Scenario: Running flapjack-feed-events with no arguments and no STDIN fails with a warning - When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.yaml receiver json` + When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.toml receiver json` And the output should contain "No file provided, and STDIN is from terminal! Exiting..." Then the exit status should be 1 @@ -36,14 +35,14 @@ test: "summary": "testing" } """ - When I run `cat tmp/cucumber_cli/single-event.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.yaml receiver json` + When I run `cat tmp/cucumber_cli/single-event.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.toml receiver json` Then the exit status should be 0 And the output should not contain "Invalid event data received" And the output should contain "Enqueued event data, " And the output should contain "client1-localhost-test-1" And the output should contain "Done." - When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.yaml receiver json -f tmp/cucumber_cli/single-event.json` + When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.toml receiver json -f tmp/cucumber_cli/single-event.json` Then the exit status should be 0 And the output should not contain "Invalid event data received" And the output should contain "Enqueued event data, " @@ -61,7 +60,7 @@ test: "testing" } """ - When I run `cat tmp/cucumber_cli/multiple-events.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.yaml receiver json` + When I run `cat tmp/cucumber_cli/multiple-events.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.toml receiver json` Then the exit status should be 0 And the output should not contain "Invalid event data received" And the output should contain "Enqueued event data, " @@ -69,7 +68,7 @@ test: And the output should contain "client1-localhost-test-2" And the output should contain "Done." - When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.yaml receiver json -f tmp/cucumber_cli/multiple-events.json` + When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.toml receiver json -f tmp/cucumber_cli/multiple-events.json` Then the exit status should be 0 And the output should not contain "Invalid event data received" And the output should contain "Enqueued event data, " @@ -83,7 +82,7 @@ test: {"entity": "client1-localhost-test-1"} {"entity": "client1-localhost-test-2", "check": "bar"} """ - When I run `cat tmp/cucumber_cli/invalid-events.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.yaml receiver json` + When I run `cat tmp/cucumber_cli/invalid-events.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.toml receiver json` Then the exit status should be 0 And the output should not contain "Enqueued event data, " And the output should contain "Invalid event data received" @@ -97,7 +96,7 @@ test: {"entity": "client1-localhost-test-1" {"entity": "client1-localhost-test-2", "check": "bar"} """ - When I run `cat tmp/cucumber_cli/invalid-json.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.yaml receiver json` + When I run `cat tmp/cucumber_cli/invalid-json.json | bundle exec bin/flapjack -n test -c tmp/cucumber_cli/flapjack-feed-events.toml receiver json` Then the exit status should be 1 And the output should not contain "Enqueued event data, " And the output should contain "expected comma at line 2" diff --git a/features/cli_flapjack-nagios-receiver.feature b/features/cli_flapjack-nagios-receiver.feature index fa449eb12..bc47283b6 100644 --- a/features/cli_flapjack-nagios-receiver.feature +++ b/features/cli_flapjack-nagios-receiver.feature @@ -6,17 +6,16 @@ Feature: nagios-receiver command line Background: Given a fifo named "tmp/cucumber_cli/nagios_perfdata.fifo" exists - And a file named "nagios-receiver.yaml" with: + And a file named "nagios-receiver.toml" with: """ -test: - pid_dir: "tmp/cucumber_cli/" - log_dir: "tmp/cucumber_cli/" - redis: - db: 14 - nagios-receiver: - fifo: "tmp/cucumber_cli/nagios_perfdata.fifo" - pid_dir: "tmp/cucumber_cli/" - log_dir: "tmp/cucumber_cli/" +pid_dir = "tmp/cucumber_cli/" +log_dir = "tmp/cucumber_cli/" +[redis] + db = 14 +[nagios-receiver] + fifo = "tmp/cucumber_cli/nagios_perfdata.fifo" + pid_dir = "tmp/cucumber_cli/" + log_dir = "tmp/cucumber_cli/" """ Scenario: Running with --help shows usage information @@ -26,33 +25,33 @@ test: And the output should contain "receiver nagios start [-d|--daemonize]" Scenario: Starting nagios-receiver - When I start nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver start --no-daemonize` + When I start nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver start --no-daemonize` Then nagios-receiver should start within 15 seconds Scenario: Stopping nagios-receiver via SIGINT - When I start nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios start --no-daemonize` + When I start nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios start --no-daemonize` Then nagios-receiver should start within 15 seconds When I send a SIGINT to the nagios-receiver process Then nagios-receiver should stop within 15 seconds Scenario: Starting, status, and stopping nagios-receiver, daemonized - When I start nagios-receiver (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios start -d` + When I start nagios-receiver (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios start -d` Then nagios-receiver should start within 15 seconds - When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios status` + When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios status` Then the exit status should be 0 And the output should contain "nagios-receiver is running" - When I stop nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios stop` + When I stop nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios stop` Then nagios-receiver should stop within 15 seconds Scenario: Starting, restarting and stopping nagios-receiver, daemonized - When I start nagios-receiver (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios start -d` + When I start nagios-receiver (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios start -d` Then nagios-receiver should start within 15 seconds - When I restart nagios-receiver (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios restart` + When I restart nagios-receiver (daemonised) (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios restart` Then nagios-receiver should restart within 15 seconds - When I stop nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios stop` + When I stop nagios-receiver (via bundle exec) with `flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios stop` Then nagios-receiver should stop within 15 seconds Scenario: Getting status when stopped - When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/nagios-receiver.yaml receiver nagios status` + When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/nagios-receiver.toml receiver nagios status` Then the exit status should not be 0 And the output should contain "nagios-receiver is not running" diff --git a/features/cli_flapjack-populator.feature b/features/cli_flapjack-populator.feature index eddd61648..568b63f29 100644 --- a/features/cli_flapjack-populator.feature +++ b/features/cli_flapjack-populator.feature @@ -5,12 +5,11 @@ Feature: flapjack-populator command line From the command line Background: - Given a file named "flapjack-populator.yaml" with: + Given a file named "flapjack-populator.toml" with: """ -test: - redis: - db: 14 - driver: ruby +[redis] + db = 14 + driver = "ruby" """ And a file named "flapjack-populator-contacts.json" with: """ @@ -49,11 +48,11 @@ test: And the output should contain "Bulk import data from an external source" Scenario: Importing contacts - When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack-populator.yaml import contacts --from tmp/cucumber_cli/flapjack-populator-contacts.json` + When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack-populator.toml import contacts --from tmp/cucumber_cli/flapjack-populator-contacts.json` Then the exit status should be 0 Scenario Outline: Running an flapjack-populator import command with a missing '--from' exits uncleanly and shows usage - When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack-populator.yaml import example.json` + When I run `bundle exec bin/flapjack -n test --config tmp/cucumber_cli/flapjack-populator.toml import example.json` Then the exit status should not be 0 And the output should contain "error: f is required" And the output should contain "Bulk import data from an external source" diff --git a/features/cli_flapper.feature b/features/cli_flapper.feature index c272ea62d..7d4f693af 100644 --- a/features/cli_flapper.feature +++ b/features/cli_flapper.feature @@ -5,53 +5,52 @@ Feature: Flapper command line From the command line Background: - Given a file named "flapjack_cfg.yaml" with: + Given a file named "flapjack_cfg.toml" with: """ -test: - pid_dir: tmp/cucumber_cli/ - log_dir: tmp/cucumber_cli/ - redis: - db: 14 - processor: - enabled: yes - logger: - level: warn +pid_dir = "tmp/cucumber_cli/" +log_dir = "tmp/cucumber_cli/" +[redis] + db = 14 +[processor] + enabled = "yes" + [processor.logger] + level = "warn" """ Scenario: Running with --help shows usage information - When I run `bundle exec bin/flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper --help` + When I run `bundle exec bin/flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper --help` Then the exit status should be 0 And the output should contain "Artificial service that oscillates up and down" And the output should contain "[-b arg|--bind-ip arg]" Scenario: Starting flapper - When I start flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper start --no-daemonize` + When I start flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper start --no-daemonize` Then flapper should start within 15 seconds Scenario: Stopping flapper via SIGINT - When I start flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper start --no-daemonize` + When I start flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper start --no-daemonize` Then flapper should start within 15 seconds When I send a SIGINT to the flapper process Then flapper should stop within 15 seconds Scenario: Starting, status, and stopping flapper, daemonized - When I start flapper (daemonised) (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper start -d -p tmp/cucumber_cli/flapper.pid -l tmp/cucumber_cli/flapper.log` + When I start flapper (daemonised) (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper start -d -p tmp/cucumber_cli/flapper.pid -l tmp/cucumber_cli/flapper.log` Then flapper should start within 15 seconds - When I run `bundle exec bin/flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper status -p tmp/cucumber_cli/flapper.pid` + When I run `bundle exec bin/flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper status -p tmp/cucumber_cli/flapper.pid` Then the exit status should be 0 And the output should contain "flapper is running" - When I stop flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper stop -p tmp/cucumber_cli/flapper.pid` + When I stop flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper stop -p tmp/cucumber_cli/flapper.pid` Then flapper should stop within 15 seconds Scenario: Starting, restarting and stopping flapper, daemonized - When I start flapper (daemonised) (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper start -d -p tmp/cucumber_cli/flapper.pid -l tmp/cucumber_cli/flapper.log` + When I start flapper (daemonised) (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper start -d -p tmp/cucumber_cli/flapper.pid -l tmp/cucumber_cli/flapper.log` Then flapper should start within 15 seconds - When I restart flapper (daemonised) (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper restart -p tmp/cucumber_cli/flapper.pid -l tmp/cucumber_cli/flapper.log` + When I restart flapper (daemonised) (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper restart -p tmp/cucumber_cli/flapper.pid -l tmp/cucumber_cli/flapper.log` Then flapper should restart within 15 seconds - When I stop flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper stop -p tmp/cucumber_cli/flapper.pid` + When I stop flapper (via bundle exec) with `flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper stop -p tmp/cucumber_cli/flapper.pid` Then flapper should stop within 15 seconds Scenario: Getting status when stopped - When I run `bundle exec bin/flapjack --config tmp/cucumber_cli/flapjack_cfg.yaml flapper status -p tmp/cucumber_cli/flapper.pid` + When I run `bundle exec bin/flapjack --config tmp/cucumber_cli/flapjack_cfg.toml flapper status -p tmp/cucumber_cli/flapper.pid` Then the exit status should not be 0 And the output should contain "flapper is not running" diff --git a/features/cli_purge.feature b/features/cli_purge.feature index f7f869cf6..9d1fcae2a 100644 --- a/features/cli_purge.feature +++ b/features/cli_purge.feature @@ -5,12 +5,11 @@ Feature: purge command line From the command line Background: - Given a file named "purge.yaml" with: + Given a file named "purge.toml" with: """ -test: - redis: - db: 14 - driver: ruby +[redis] + db = 14 + driver = "ruby" """ Scenario: Running with --help shows usage information @@ -26,7 +25,7 @@ test: #flapjack purge check_history --days 90 Scenario: Purge check data older than 90 days - When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/purge.yaml purge check_history --days 90` + When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/purge.toml purge check_history --days 90` Then the exit status should be 0 #flapjack purge check_history --days 2 --check "flapper.example:Flapper" diff --git a/features/cli_receive-events.feature b/features/cli_receive-events.feature index 976e46ce5..dc51e3a23 100644 --- a/features/cli_receive-events.feature +++ b/features/cli_receive-events.feature @@ -5,12 +5,11 @@ Feature: receive-events command line From the command line Background: - Given a file named "receive-events.yaml" with: + Given a file named "receive-events.toml" with: """ -test: - redis: - db: 14 - driver: ruby +[redis] + db = 14 + driver = "ruby" """ Scenario: Running with --help shows usage information diff --git a/features/cli_simulate-failed-check.feature b/features/cli_simulate-failed-check.feature index 94b896822..9eab6d3bf 100644 --- a/features/cli_simulate-failed-check.feature +++ b/features/cli_simulate-failed-check.feature @@ -5,12 +5,11 @@ Feature: simulate-failed-check command line From the command line Background: - Given a file named "simulate-failed-check.yaml" with: + Given a file named "simulate-failed-check.toml" with: """ -test: - redis: - db: 14 - driver: ruby +[redis] + db = 14 + driver = "ruby" """ Scenario: Running with --help shows usage information @@ -25,7 +24,7 @@ test: And the output should contain "Simulates a check by creating a stream of events for Flapjack" Scenario: Simulate a failed check - When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/simulate-failed-check.yaml simulate fail -t 0.05 -i 0.05 -e 'test' -k 'PING'` + When I run `bundle exec bin/flapjack -n test -c tmp/cucumber_cli/simulate-failed-check.toml simulate fail -t 0.05 -i 0.05 -e 'test' -k 'PING'` Then the exit status should be 0 And the output should contain "sending failure event" And the output should contain "stopping" diff --git a/features/support/env.rb b/features/support/env.rb old mode 100644 new mode 100755 index 9f95e2b1f..0a57d4b48 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -26,7 +26,7 @@ ENV["FLAPJACK_ENV"] = 'test' FLAPJACK_ENV = 'test' FLAPJACK_ROOT = File.join(File.dirname(__FILE__), '..', '..') -FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.yaml') +FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.toml') $: << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')) @@ -177,19 +177,19 @@ def redis_peek(queue, klass, start = 0, count = nil) end After('@process') do - ['tmp/cucumber_cli/flapjack_cfg.yaml', - 'tmp/cucumber_cli/flapjack_cfg.yaml.bak', - 'tmp/cucumber_cli/flapjack_cfg_d.yaml', + ['tmp/cucumber_cli/flapjack_cfg.toml', + 'tmp/cucumber_cli/flapjack_cfg.toml.bak', + 'tmp/cucumber_cli/flapjack_cfg_d.toml', 'tmp/cucumber_cli/flapjack.log', 'tmp/cucumber_cli/flapjack.pid', 'tmp/cucumber_cli/nagios_perfdata.fifo', 'tmp/cucumber_cli/flapjack-nagios-receiver.pid', 'tmp/cucumber_cli/flapjack-nagios-receiver.log', - 'tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml', - 'tmp/cucumber_cli/flapjack-nagios-receiver.yaml', + 'tmp/cucumber_cli/flapjack-nagios-receiver_d.toml', + 'tmp/cucumber_cli/flapjack-nagios-receiver.toml', 'tmp/cucumber_cli/flapper.pid', 'tmp/cucumber_cli/flapper.log', - 'tmp/cucumber_cli/flapjack-populator.yaml', + 'tmp/cucumber_cli/flapjack-populator.toml', 'tmp/cucumber_cli/flapjack-populator-contacts.json', 'tmp/cucumber_cli/flapjack-populator-entities.json', ].each do |file| diff --git a/flapjack.gemspec b/flapjack.gemspec index a8c1246c9..b9b6e04fd 100644 --- a/flapjack.gemspec +++ b/flapjack.gemspec @@ -34,6 +34,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'gli', '= 2.12.0' gem.add_dependency 'rbtrace' gem.add_dependency 'terminal-table' + gem.add_dependency 'toml' gem.add_development_dependency 'rake' end diff --git a/lib/flapjack/configuration.rb b/lib/flapjack/configuration.rb index fc21581d4..4dd373cfa 100755 --- a/lib/flapjack/configuration.rb +++ b/lib/flapjack/configuration.rb @@ -1,13 +1,13 @@ #!/usr/bin/env ruby -require 'yaml' +require 'toml' require 'logger' module Flapjack class Configuration - DEFAULT_CONFIG_PATH = '/etc/flapjack/flapjack_config.yaml' + DEFAULT_CONFIG_PATH = '/etc/flapjack/flapjack_config.toml' attr_reader :filename @@ -16,20 +16,20 @@ def initialize(opts = {}) end def all - @config_env + @config end def for_redis - return unless @config_env + return unless @config redis_defaults = {'host' => '127.0.0.1', 'port' => 6379, 'path' => nil, 'db' => 0} - @config_env['redis'] = {} unless @config_env.has_key?('redis') + @config['redis'] = {} unless @config.has_key?('redis') - redis = @config_env['redis'] + redis = @config['redis'] redis_defaults.each_pair do |k,v| next if redis.has_key?(k) && redis[k] && !(redis[k].is_a?(String) && redis[k].empty?) @@ -52,31 +52,21 @@ def for_redis def load(filename) @filename = nil - @config_env = nil + @config = nil unless File.file?(filename) @logger.error "Could not find file '#{filename}'" if @logger return end - unless defined?(FLAPJACK_ENV) - @logger.error "Environment variable 'FLAPJACK_ENV' is not set" if @logger - return - end - - config = YAML::load_file(filename) + config = TOML.load_file(filename) if config.nil? @logger.error "Could not load config file '#{filename}'" if @logger return end - @config_env = config[FLAPJACK_ENV] - - if @config_env.nil? - @logger.error "No config data for environment '#{FLAPJACK_ENV}' found in '#{filename}'" if @logger - return - end + @config = config @filename = filename end diff --git a/spec/service_consumers/pact_helper.rb b/spec/service_consumers/pact_helper.rb index 9a170fdb9..ed957d66a 100644 --- a/spec/service_consumers/pact_helper.rb +++ b/spec/service_consumers/pact_helper.rb @@ -9,7 +9,7 @@ FLAPJACK_ENV = ENV["FLAPJACK_ENV"] || 'test' FLAPJACK_ROOT = File.join(File.dirname(__FILE__), '..') -FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.yaml') +FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.toml') ENV['RACK_ENV'] = ENV["FLAPJACK_ENV"] require 'bundler' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e4c30c762..d0bdd8081 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,7 +14,7 @@ FLAPJACK_ENV = ENV["FLAPJACK_ENV"] || 'test' FLAPJACK_ROOT = File.join(File.dirname(__FILE__), '..') -FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.yaml') +FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.toml') ENV['RACK_ENV'] = ENV["FLAPJACK_ENV"] require 'bundler' diff --git a/tasks/benchmarks.rake b/tasks/benchmarks.rake index 1c96d5cb1..26c4476a4 100644 --- a/tasks/benchmarks.rake +++ b/tasks/benchmarks.rake @@ -12,7 +12,7 @@ namespace :benchmarks do require 'flapjack/version' def prepare_env - config_file = File.join('tasks', 'support', 'flapjack_config_benchmark.yaml') + config_file = File.join('tasks', 'support', 'flapjack_config_benchmark.toml') config = Flapjack::Configuration.new config.load( config_file ) @@ -75,7 +75,7 @@ namespace :benchmarks do result = system({"FLAPJACK_ENV" => FLAPJACK_ENV, "CPUPROFILE" => "artifacts/flapjack-perftools-cpuprofile", "RUBYOPT" => "-r#{perftools}"}, - "bin/flapjack start --no-daemonize --config tasks/support/flapjack_config_benchmark.yaml --logfile log/benchmark_test.log") + "bin/flapjack start --no-daemonize --config tasks/support/flapjack_config_benchmark.toml --logfile log/benchmark_test.log") if result puts "Flapjack run completed successfully" else diff --git a/tasks/events.rake b/tasks/events.rake index 7344229fb..329876454 100644 --- a/tasks/events.rake +++ b/tasks/events.rake @@ -16,7 +16,7 @@ namespace :events do task :test_notification do FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development' - config_file = File.join('etc', 'flapjack_config.yaml') + config_file = File.join('etc', 'flapjack_config.toml') config = Flapjack::Configuration.new config.load( config_file ) diff --git a/tasks/profile.rake b/tasks/profile.rake index 58042d427..6ac4264d1 100644 --- a/tasks/profile.rake +++ b/tasks/profile.rake @@ -6,7 +6,7 @@ namespace :profile do require 'ruby-prof' FLAPJACK_ROOT = File.join(File.dirname(__FILE__), '..') - FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.yaml') + FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.toml') FLAPJACK_PROFILER = ENV['FLAPJACK_PROFILER'] || 'rubyprof' port = ENV['FLAPJACK_PROFILER'].to_i