Thursday, February 18, 2010

Nagios and HTTPS Monitoring

This doesn't seem to be configured in the basic Nagios installation, but it is easy to do. The following was done on a server running RedHat 5.2.

  1. Go to your nagios top level directory, /usr/local/nagios.
  2. Use the check_http command line tool and make sure it works:  ./libexec/check_http -H your.server.hostname -p 8443 -S   Here the port is 8443.  -S is the option to use SSL.
  3. Add a command, "check_https", to your etc/objects/commands.cfg file:

                     # 'check_https' command definitiondefine command{
                             command_name    check_https
                             command_line    $USER1$/check_http -I $ARG1$ -p $ARG2$ -S
                     }

  4. Add the host to be checked to the appropriate config file (see my previous post for an example, or see below).

  5. Make sure your don't have any typos: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

  6. Reload nagios: /etc/rc.d/init.d/nagios reload

You are done.  I put all of my Nagios checks into localhost.cfg, which is probably not a good idea, but it was simple to get going.  Add the following to the bottom of your cfg file:

define host{

        use             linux-server            ; Name of host template to use

        host_name      some-host  ; The name we're giving to this host

        alias           Some Host to Check  ; A longer name associated with the host

        address         123.456.789            ; IP address of the host

        hostgroups      linux-servers           ; Host groups this host is associated with

        }

define service{
        use             local-service         ; Name of service template to use

        host_name       some-host

        service_description     HTTP

        check_command   check_https!your.server.hostname!8443

        notifications_enabled           1

        }

Wednesday, February 10, 2010

Resetting Old Media Wiki Passwords in MySQL

I needed to reset a forgotten user password in an older version of Mediawiki that predates the changePassword.php utility. Also, email notifications were disabled.  These are some clarifications of the instructions from http://www.mediawiki.org/wiki/Manual:FAQ#How_do_I_reset_a_password.3F.   Here are the steps:

  1. Look at your LocalSettings.php file to remind yourself of the DB name, the DB prefix, user name and password associated with your Mediawiki installation.  Let's say they are mywikidb, mywikiprefix, mywikiuser, and mywikipass, respectively.  
  2. Login from the command line to your mysql:   mysql -u mywikiuser -pmywikipass
  3. Change to the database at the mysql prompt: USE mywikidb;
  4. Verify things: SHOW columns FROM mywikiprefixuser;
  5. Verify more things: SELECT user_name, user_id, user_real_name, user_email FROM mywikiprefixuser;
  6. Change the password: UPDATE mywikiprefixuser SET user_password = MD5(CONCAT(user_id, '-', MD5('newpass'))) WHERE user_name="someuser";
In step 6, change mywikiprefix to your prefix, newpass to the desired password, and someuser to the appropriate user of your system.  In step 5, you should see the user_name value ("JimboWales"), so this is a useful check.