Leopard 10.5 Log Rotate

I recently had an issue where I have a Zope instance installed from source and found that the Z2.log and event.log files were 17GB and 30GB respectively.

Poking around the google, I found this reference to newsyslog.conf: http://www.wrightthisway.com/Articles/000437.html

I added this entry just for testing to see if this would work as advertised.

#logfilename                              [owner:group]   mode  count     size       when     flags

/Path/to/Zope/log/event.log  owner:group       644       5           5000       *             J

This entry tells newsyslogd to rotate the event.log file when it reaches 5000kB (5MB) and create the new file with specified owner:group permissions.  In addition keep 5 copies of the log file and compress them with bzip2 compression.

You can rotate your logs at the command line with:  sudo newsyslog -F

UPDATE:  With this solution, the Zope service doesn’t get restarted so it doesn’t continue to write to the newly created log file.

There is an option to give  PID but I have a suspicion that the process will be hung up and not restarted.

I found this http://httpd.apache.org/docs/1.3/logs.html#rotation

where I can use the rotatelogs apache command which is a piped log that allows log rotation without having to restart the service.

In order to use the rotatelogs command you would add an entry like below in your httpd.conf file.  I would change the entries to be all ErrorLog entries and only have the combined entries for Apache combined access logs.  The 5M is once the log file is 5M and the -420 is an offset for Pacific standard time.

CustomLog ‘|/usr/sbin/rotatelogs “/usr/local/apache2/logs/access_log” 5M -420’ “%h %l %u %t \”%r\” %>s %b”
ErrorLog ‘|/usr/sbin/rotatelogs “/usr/local/apache2/logs/error_log” 5M -420’

vSphere Database Backup

In my google searching to find a way to backup my vSphere database using the SQL 2005 Express that comes with vSphere I found this helpful article: http://communities.vmware.com/message/1057443

You basically just need to install SQL Server Management Studio to manage the database and back it up.

Then from within the SQL Server Management Studio you should be able to backup the VC database by browsing through the databases and right clicking on the VC database, then select Tasks>Back up.

You can download SQL Server Management Studio Express at the following link –http://msdn.microsoft.com/en-gb/express/bb410792.aspx

Test Joomla MySQL Connection

I recently ran into an issue with a Joomla site where users couldn’t login with a connection to database error.  I went poking around Google to find this neat test script.  http://joomla-r-us.com/faq/87-mysql-database-connection-test-script

<?php
///////////////////////////////////////////////////
// Joomla-R-Us
//
// Connection test to external MySQL database
//
///////////////////////////////////////////////////

// Configurations below!!

/////////  Bootstrap the Joomla Framework //////////////

define( ‘_JEXEC’, 1 );

define(‘JPATH_BASE’, dirname(__FILE__) );

define( ‘DS’, DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.’includes’.DS.’defines.php’ );
require_once ( JPATH_BASE .DS.’includes’.DS.’framework.php’ );

/**
* CREATE THE APPLICATION
*
* NOTE :
*/
$mainframe =& JFactory::getApplication(‘site’);

/**
* INITIALISE THE APPLICATION
*
* NOTE :
*/
// set the language
$mainframe->initialise();

JPluginHelper::importPlugin(‘system’);

// trigger the onAfterInitialise events
$mainframe->triggerEvent(‘onAfterInitialise’);

/////////////////////////////////////////////////////

///////////// Configure this ////////////////////////

$hostname     = ‘myhost.mydomain.com’;
$username     = ‘myaccount’;
$password     = ‘mypassword’;
$database     = ‘joomla’;

///////////// End Configure ////////////////////////

// Try connecting to the database

$option = array ();
$option [‘driver’] = ‘mysql’;

$option [‘host’] = $hostname;
$option [‘user’] = $username;
$option [‘password’] = $password;
$option [‘database’] = $database;
$option [‘prefix’] = ”;
$db = JFactory::getDBO ();
$db = & JDatabase::getInstance ($option);
if ( get_class($db) == ‘JDatabaseMySQL’ ) {
echo ‘<b><font color=”green”>OK!</font></b>’;
} else {
echo ‘<b><font color=”red”>FAILED</font></b> : ‘ . $db->message;
}

?>

Obviously I changed the database name, username and password to match my server.

I installed it under my Joolma root and sure enough a great big green OK appeared.  Now what? I asked the maintainers of the website what had changed and nothing but a Joomla component with it’s own database was disabled.  On further investigation, I found the connection to the additional database was failing.  I granted the user access over the database and Viola!  I was able to login to my Joomla site again!