Name

cleanmqlogs - Support Pac MS62 - manage MQSeries linear recovery logs

Synopsis

cleanmqlogs [ -t data_directory ] [ -l log_directory ] [ -n ] [ -z | -Z | -p | -u ] QueueManger...

Description

MQSeries linear recovery logs are great, but they also will also fill up the /var/mqm/log filesystem if you don't clean them up periodically. The script, cleanmqlogs, when run periodically by cron, at, or AutoSys, can do so for you.

** WARNING ** WARNING ** WARNING ** WARNING ** WARNING **

This script attempts to do a somewhat dangerous thing: remove files that a Queue Manager uses for recovery. If one were to delete a file that the Queue Manager still needs--the queue manager will not restart. This is bad. So use at your own risk.

Firstly, this document (and the supportpac instructions) assume that you know how to run a perl script in your environment (either for NT or Unix). An appendix talks about this, in case you don't.

How does the script work? Periodically, the queue manager outputs messages to the Queue Manager's error log specifying the oldest logfile which must be maintained for restart and for media recovery. When the script is run, for each queue manager you specify, it parses the qmgr's error log and determines which files are older than what is required. Then, it either gzips, compresses, or unlinks (deletes), the files that are older that what MQ reports as necessary.

Now, if you never run rcdmqimg and you never restart your queue manager, you will never reduce the number of logs needed for media recovery. Therefore, this script will not gzip/compress/unlink anything. Not too useful.

Therefore, periodically (at least as periodically as you run this script), you should run rcdmqimg:

If you do that, the next time a message is written to the queue manager's error logs (which will not be immediately, BTW) the latest file needed for media recovery will be increased.

Note: as of v5.2, you can use the -l option to rcdmqimg to immediately print a new message to the error logs.

Options

-t data_directory
This is the directory in which MQSeries stores its objects and configuration. By default /var/mqm on Unix, and c:\mqm (v5.0) or c:\MQSeries (v5.1) on NT.
You might want to use this argument this if you have installed MQ in a non-default place, especially on NT. There should be a file called mqs.ini in whatever directory you specify here. (Except on v5.1 on NT, where this information is stored in the registry.)

Default: /var/mqm on Unix, and c:\mqm on NT.

-l log_directory
This is the base directory in which MQSeries stores the actual transaction logs. By default /var/mqm/log on Unix, and c:\mqm (v5.0) or c:\MQSeries (v5.1) on NT.
This option is required if you are using -n, and your recovery logs are not under what you specified in -t. I.e., you installed MQ in d:\mqm, but your recovery logs are in e:\mqm\log.
-n
Don't parse files. If you don't specify -n, cleanmqlogs will parse MQSeries' .ini files to determine the locations of the recovery logs. If your recovery files are stored in the default location relative to your -t argument, (Unix default: /var/mqm/log/QueueManagerName/active) you can use -n, and the program will run slightly faster.
-n is required on NT 5.1 installations, as this information is now stored in the registry.
-z
Gzip unnessesary log files. This is the default. If gzip is not in your path, you may need to either add its directory to your path, or edit the script's $gzip variable to specify its fully-qualified pathname. A copy of gzip for NT can be found at http://www.shelden-associates.com/download/gzip.exe.
-Z
Run unix compress on unnessessary log files. If compress is not in your path, you may need to either add its directory to your path, or edit the script's $compress variable to specify its fully-qualified pathname.
-u
Unlink (delete) unnessessary log files.
-p
Print the names of unnessessary log files. No cleanup will take place.
QueueManager
The name of the queue manager or managers whose recovery logs you want to clean up.

Automation

The script is usually run via cron on Unix, or via at on NT. Depending on your traffic, you may need to run rcdmqimg and cleanmqlogs more frequently. But, if you wanted to run each daily at midnight and 1:00am:

Unix Cron

Add the following lines to mqm's crontab (omit the -l if you're using MQ v5.1 or earlier):

NT at

Run the following two commands to have rcdmqimg and cleanmqlogs run by at (again, omit the -l if you're using MQ v5.1 or earlier):

Running a Perl script

Running cleanmqlogs is no different from running any other perl script. Here are basic instructions for Perl newbies. For more information, try http://www.perl.com.

Unix

To run the script (or any perl script) under Unix:
  1. find where your perl interpreter is located:
      which perl
    If it is not found, ask your system administrator where perl is located on your system, and if it isn't have the SA install it.
  2. Edit the first line of the script to specify the fully-qualified path to the perl interpreter. For example, if the which reported /usr/local/bin/perl, put:
      #! /usr/local/bin/perl
    in the first line of the script.
  3. If the download process generated dos-sytle newline characters in the script you'll need to remove them. One way to do so is with perl:
      perl -ne 's/\r//g; print' cleanmqlogs > cleanmqlogs.tmp
      mv cleanmqlogs.tmp cleanmqlogs
  4. Give the script execute permission:
      chmod +x ./cleanmqlogs
  5. And test to see if it will run correctly:
      ./cleanmqlogs -p QueueManagerName

NT

Firstly, most NT installations do not come with Perl installed. So, download it and install it. How to do so is beyond the scope of this document. Go to http://www.perl.com or http://www.activestate.com to obtain, download, and install perl.

Once you have done so:

  1. create an association between the .PL extension and the perl executable:
    • Go to Windows NT Explorer-> View-> Options-> File Types-> New Type...
    • Add the type Perl Script, with the mime type application/perl, and extension .PL.
    • Add an Open action, which should execute:
        c:\progra~1\perl\bin\Perl.exe "%1" %*
      assuming you installed perl in c:\Program Files
  2. Set the environment variable PATHEXT to be .PL;.COM;.EXE;.BAT;.CMD
  3. Rename the script cleanmqlogs.PL:
      move cleanmqlogs cleanmqlogs.PL
  4. Attempt to run the script:
      cleanmqlogs.PL -p QueueManagerName

    See Also

    Bugs

    Author

    Brian T. Shelden <shelden@shelden-associates.com>

    Copyright

    Script and docs Copyright © 1999-2002 Shelden & Associates, Inc.