#357 new
Hans de Graaff

webrat should not create a logger by default

Reported by Hans de Graaff | February 19th, 2010 @ 01:08 PM

The code in webrat/core/logging.rb creates a log file in the current directory if the environment it is running under is not rails or merb. This leads to problems when that log file cannot be created.

This happens to me when using cucumber-nagios in a restricted environment where nagios can execute the plugin but not write the associated directory. The plugin fails because it cannot write the webrat.log file. I've verified that this is the problem by commenting out the only user of the logger in core/session.rb.

A solution would be to only create the log file when requested (e.g. using an environment variable)

Comments and changes to this ticket

  • Hans de Graaff

    Hans de Graaff May 1st, 2010 @ 03:13 AM

    I noticed this problem is still present in webrat 0.7.1. A better solution would probably be to create the Logger, but set the log level to something like INFO and use an environment variable to like WEBRAT_DEBUG to switch it to the DEBUG level when needed.

  • Foss.J

    Foss.J March 1st, 2012 @ 04:50 PM

    • Milestone order changed from “0” to “0”

    I have been banging me head against the wall.
    Is this part of this error?

    Environment: Nagios 3x, centos 5.7, ruby-enterprise-1.8.7-2012.02
    The cucumber-nagios is working properly from the command line but will not execute without a NULL result under nagios.


    Ive added the path and a shell to nagios thinking it couldn't find something that seems not to be a problem

    [nagios@atnagios ~]$ echo $PATH 
       /opt/ruby-enterprise-1.8.7-2012.02/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/var/spool/nagios/bin
    [nagios@atnagios ~]$ /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios /opt/cucumber-test/example.com/features/splash 
      CUCUMBER OK - Critical: 0, Warning: 0, 2 okay | passed=2; failed=0; nosteps=0; total=2; time=0
    

    Nagios command file

     command {
               command_name                          cucumber_nagios
               command_line                          /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /opt/cucumber-test/example.com/features/splash
     }
    

    Nagios service file

     define service {
                service_description                   Cucumber_Nagios_basic_login_and_http_status
                check_command                         cucumber_nagios
                host_name                             example.com
                check_period                          24x7
                notification_period                   24x7
                event_handler_enabled                 0
                notification_interval                 15
                notification_options                  w,u,c,r
                max_check_attempts                    3
                check_interval                        5
                retry_interval                        1
                passive_checks_enabled                1
                use                                   Default_collector_server
                contact_groups                        admins
     }
    

    This is from nagios.debug with debug_level=-1

       [1330635780.092549] [008.0] [pid=3793] ** Service Check Event ==> Host: 'example.com', Service: 'Cucumber_Nagios_basic_login_and_http_status', Options: 1, Latency: 0.092000 sec
       [1330635780.092561] [016.0] [pid=3793] Attempting to run scheduled check of service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com': check options=1, latency=0.092000
       [1330635780.092588] [016.0] [pid=3793] Checking service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'...
       [1330635780.092613] [2320.2] [pid=3793] Raw Command Input: /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /opt/cucumber-test/example.com/features/splash
       [1330635780.092618] [2320.2] [pid=3793] Expanded Command Output: /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /opt/cucumber-test/example.com/features/splash
       [1330635780.092645] [2048.1] [pid=3793] Processing: '/opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /opt/cucumber-test/example.com/features/splash'
       [1330635780.092649] [2048.2] [pid=3793]   Processing part: '/opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /opt/cucumber-test/example.com/features/splash'
       [1330635780.092654] [2048.2] [pid=3793]   Not currently in macro.  Running output (108): '/opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /opt/cucumber-test/example.com/features/splash'
       [1330635780.092659] [2048.1] [pid=3793]   Done.  Final output: '/opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /opt/cucumber-test/example.com/features/splash'
       [1330635784.120807] [016.1] [pid=3793] Handling check result for service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'...
       [1330635784.120815] [016.0] [pid=3793] ** Handling check result for service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'...
    [1330635784.120827] [016.1] [pid=3793] HOST: example.com, SERVICE: Cucumber_Nagios_basic_login_and_http_status011, CHECK TYPE: Active, OPTIONS: 1, SCHEDULED: Yes, RESCHEDULE: Yes, EXITED OK: Yes, RETURN CODE: 2, OUTPUT: (null)
       [1330635784.120875] [016.1] [pid=3793] Checking service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com' for flapping...
    

    I've commented out the debug_log in /opt/ruby-enterprise-1.8.7-2012.02/lib/ruby/gems/1.8/gems/webrat-0.7.2/lib/webrat/core/session.rb

          #debug_log "REQUESTING PAGE: #{http_method.to_s.upcase} #{url} with #{data.inspect} and HTTP headers #{h.inspect}"
    

    Yet still NULL results after restarting/reloading nagios

    any ideas to exclude webrat as a suspected cause of the NULL result to nagios?

  • Foss.J

    Foss.J March 1st, 2012 @ 06:19 PM

    This is an example of what is returned to nagios if there is bad feature file argument is passed to cucumber-nagios

    command {

           command_name                          cucumber_nagios
           command_line                          /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  /badpath
          }
    

       [1330642740.164354] [016.0] [pid=24335] Attempting to run scheduled check of service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com': check options=1, latency=0.164000
       [1330642740.164390] [016.0] [pid=24335] Checking service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'…
       [1330642740.164408] [2320.2] [pid=24335] Raw Command Input: /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios   /badpath
       [1330642740.164414] [2320.2] [pid=24335] Expanded Command Output: /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios   /badpath
       [1330642743.182605] [016.1] [pid=24335] Handling check result for service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'…
       [1330642743.182609] [016.0] [pid=24335] ** Handling check result for service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'...
    [1330642743.182613] [016.1] [pid=24335] HOST: ccco.desire2learn.com, SERVICE: Cucumber_Nagios_basic_login_and_http_status, CHECK TYPE: Active, OPTIONS: 1, SCHEDULED: Yes, RESCHEDULE: Yes, EXITED OK: Yes, RETURN CODE: 4, OUTPUT: Error: feature file '/badpath' doesn't exist!\n
    

    This is the logging if there is not any argument passed to cucumber-nagios

    command {

           command_name                          cucumber_nagios
           command_line                          /opt/ruby-enterprise-1.8.7-2012.02/bin/cucumber-nagios  
          }
    
        [1330643281.238640] [016.1] [pid=25754] Handling check result for service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'...
        [1330643281.238644] [016.0] [pid=25754] ** Handling check result for service 'Cucumber_Nagios_basic_login_and_http_status' on host 'example.com'...
    [1330643281.238647] [016.1] [pid=25754] HOST: ccco.desire2learn.com, SERVICE: Cucumber_Nagios_basic_login_and_http_status, CHECK TYPE: Active, OPTIONS: 1, SCHEDULED: Yes, RESCHEDULE: Yes, EXITED OK: Yes, RETURN CODE: 4, OUTPUT: Usage: cucumber-nagios <feature> [--debug|--pretty]\n
    
    These were done later than the above with debug=13 for nagios.cfg. I figure that since the command flags are passed back, it has to be somehow in the webrat testing or in the display of the results of the tests from webrat to the cucumber-nagios plugin that the problem lies?
    
  • semal

    semal January 20th, 2014 @ 11:02 AM

    حكم واقوال كلمات حب خواطر حب اجمل وأروع حكم وأقوال العظماء والمشاهير اجمل وأروع كلمات الحب اجمل واروع خواطر الحب حكم واقوال
    حكم عن الحب
    كلام عن الحب
    اقوال عن الحب
    كلمات حب
    كلمات حزينه
    كلمات رومانسية
    خواطر حب
    خواطر قصيره
    خواطر حزينه

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages