Linux Sysadmin Blog

Monitoring Drupal Sites With Nagios

- | Comments

There is a module released for monitoring Drupal sites with Nagios.  Monitoring includes the check if your site is up and running, check for new updates on Drupal core, security, and modules, database updates, write permission on “files” directory,  check if cron is running on the specified period, and other sections of your Drupal site.  It is intended and helpful to those maintain large number of Drupal sites.

At this time of writing, this module is still on a development version and there’s no guarantee that the installation guide will work out-of-the-box with your system.  And this post will mainly cover my own installation process on our Nagios monitoring server running on Debian and Nagios version 3.0, and Drupal version 6.x sites on web servers running CentOS 5.x.

Installation: My installation is based on the included README file and with some adjustments to my liking.

Install the Drupal Module:

  • Download the Nagios module from Drupal project page.

  • Install the module to your Drupal site just like the other modules.  Download tarball, extract to modules directory ex: sites/all/modules/, go to admin->build->modules and enable the module.

  • Configure your Nagios module and set the site’s UniqueID and Cron duration.

UniqueID is your site identifier to be used by the Nagios (check_drupal) to authorize the service check and for security purposes. The author also suggests the use of MD5 or SHA1 string. Refer to README for more info on this parameter.

Cron Duration - you need to supply the interval of your cron job that checks for Drupal updates. This value should match with your cron settings, ex: daily or every 3 hours..etc.

Configure Nagios checks:

  • Copy the plugin file (check_drupal) found on the nagios-plugin directory of the module, to your Nagios plugins directory where the other Nagios check commands are located - in my case it’s on /usr/local/nagios/libexec/ (CentOS).

If your Nagios installation is on a different machine than your Drupal server, you need to copy the check_drupal file in there.  You can also put it on the same server with Drupal sites and use NRPE instead.

On my CentOS machine i received an error on check_drupal regarding the location of basename file - it’s on /bin/basename.  You can edit the check_drupal file directly to adjust the path to basename. ./check_drupal: line 14: /usr/bin/basename: No such file or directory.

  • Add command, host, hostgroup, and service definition:

Command (commands.cfg): I made small modification on the given commands from the README file to match my setup.

1
2
3
4
define command{
command_name  check_drupal
command_line  $USER1$/check_drupal -H $ARG1$ -U $ARG2$ -t $ARG3$
}

HostGroup: I created a new Host group because we have other service checks on our server such as SSH, HTTP, LOAD, etc and I want to separate my checks for Drupal sites.

1
2
3
4
5
define hostgroup {
hostgroup_name  Drupal
alias           Drupal Sites
members         MyWebServer
}

Host: I defined new host for Drupal sites so i can configure and group my them on the same host where they belong.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
define host {
host_name                      MyWebServer
display_name                   MyWebServer
address                        HOSTNAME/IP ADDRESS HERE
hostgroups                     Drupal
check_command                  check-host-alive
contact_groups                 Admins
check_period                   24x7
max_check_attempts             10
notification_interval          480
notification_period            24x7
notification_options           d,r
notifications_enabled          1
}

Service: Below is my service checks definition for checking Drupal sites, i only need to copy this and change supply parameters for domain, unique key and the timeout.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
define service {
service_description            DRUPAL_SITE 1
host_name                      MyWebServer
check_period                   24x7
max_check_attempts             3
normal_check_interval          5
retry_check_interval           3
contact_groups                 Admins
notification_interval          480
notification_period            24x7
notification_options           w,u,c,r
check_command                  check_drupal!mysite.example.com!mykeyhere!5
notifications_enabled          1
}

If your installation and configuration is correct you will get the Nagios service status similar below. It indicates number of modules, themes, users, nodes, etc.

1
2
DRUPAL OK, ADMIN:OK, CRON:OK
SAN=0;SAU=0;NOD=12;USR=7;MOD=23;THM=9

On my initial tests i received Nagios status (below) different than the above info and it was caused by my Apache configuration because i have a default Nagios installation before on my server that hosts my Drupal sites.

1
HTTP returned an error code. HTTP:   HTTP/1.1 301 Moved Permanently

So you need to check first the url of your Nagios module installation ex: http://mysamplesite.com/nagios/, this will give you:

1
2
Nagios status page
nagios=UNKNOWN, DRUPAL:UNKNOWN=Unauthorized

Hawaii Comes to Our Datecenter.

- | Comments

Aside from missing coconut trees and hula girls distinguishing our data center from Hawaii was pretty tough this afternoon. It was HOT, so hot in fact that I was sweating while sitting in just a cotton tee-shirt. I kept drifting away into a daydream where that failed 20 ton Liebert A/C unit was running. Soon however reality set in… the a/c wasn’t running, our 42U cabinet packed with 35U worth of server, switch and router gear was overheating and a slave Mysql database server wasn’t having this all this heat! The poor thing turned itself off  and after 5 hour cool down time I still get error: 1610 Temperature violation detected

1610 temparature violation

While promises of having the A/C unit up and running soon were being thrown at me I wasn’t biting. Shutting down 3 non-essential servers did help things a bit.  The database servers with their 15K rpm disks were running their internal fans at nearly 100% coping with the heat. At this point I was starting to feel a little bit upbeat picturing what would happen if the servers were not servers and just consumer grade PC’s turned into servers. If you are reading this you must know what burned power supplies smell like! At some point I knew the A/C unit would be fixed and I would be able to re-power up the non-essential servers. Monitoring temperatures inside the cabinet would be nice, but we don’t have such a useful device. Next best thing was internal temperature sensors inside a direct attach storage array which has 6 sensors: 4 in the front and 2 in back. Cacti proved invaluable as I could monitor what was going on and most importantly see if the datacenter made good on their promise. Each raise in temperature indicates a period when the A/C was not working or working poorly.

!

MySQL Query Cache, Good or Bad?

- | Comments

MySQL has a number of different caches. Most of those are dependent on the storage engine that is used. The key buffer for example caches the indexes for MyISAM tables while the caching of data is left to the OS. InnoDB has the buffer pool for both data and indexes and so on. The query cache however, is independent of the storage engine that is used. Unlike most caches it does not store records or pages of data but complete result sets and the queries that caused those results to be returned. This is a very disputable concept since the way that it works is that if any of the tables used in a result set is modified, the whole cached result set is thrown out of the cache.

The good news is that if you have data that does not change very much the query cache can give you an enormous performance boost. It even bypasses the query optimizer so that if the query is complex even more cpu time is saved. Knowing this you can optimize your application by chopping complex queries into smaller queries that only use that data that never changes.

Of course there are some tricks to using the query cache. The first one is the size of the query cache. The default is 16MB which doesn’t do much. However, keep in mind that any memory assigned to the query cache is removed from another cache so it’s very important to strike a good balance. Of course the balance is very application dependent. The second parameter is the maximum allowed result set size. It really doesn’t do any good to allow 16MB result sets into the cache because it would take only one badly written query to flush out the entire cache. 1MB is standard but in my personal experience queries that return 1MB of results on a frequent basis usually indicate that the software needs to be optimized.

So when is the query cache a bad thing? Well, in short, when the cache gets flushed out all the time and only adds to the overhead it’s usually better to assign the memory to storage engine dependent cache. If there are constant updates and inserts to most of your tables it will invalidate the results in the query cache pretty quickly and assigning memory to it is a waste of resources.

Useful tools like MySQL Tuner will give some quick information about the efficiency of the query cache but I do think it is a bit quick in suggesting more memory for the cache.

Toughest MySQL CEO Email “Ever Had to Write”.

- | Comments

When I saw this text in this WSJ article about the Sun’s Jonathan Schwartz email, it really sounded like I was re-living the year 2000 doc com bubble and I was reading www.fuckedcompany.com.

We use MySQL extnsivly and for very high availability applications so naturally there was a lot of discussion about the future of MySQL.  We believe that it will be for the better.  I hope the MySQL folks who created this super popular database feel the same.

But, how would you feel if you got this email?  Here is the copy.

This is one of the toughest emails I’ve ever had to write.

It’s also one of the most hopeful about Sun’s future in the industry.

For 27 years, Sun has stood for courage, innovation, a willingness to blaze trails, to envision and engineer the future. No matter our ups and downs, we’ve remained committed to those ideals, and to the R&D that’s allowed us to differentiate. We’ve committed to decade-long pursuits, from the evolution of one of the world’s most powerful datacenter operating systems, to one of the world’s most advanced multi-core microelectronics. We’ve never walked away from the wholesale reinvention of business models, the redefinition of technology boundaries or the pursuit of new routes to market.

Because of the unparalleled talent at Sun, we’ve also fueled entire industries with our people and technologies, and fostered extraordinary companies and market successes. Our products and services have driven the discovery of new drugs, transformed social media, and created a better understanding of the world and marketplace around us. All, while we’ve undergone a near constant transformation in the face of a rapidly changing marketplace and global economy. We’ve never walked away from a challenge - or an opportunity.

So today we take another step forward in our journey, but along a different path - by announcing that this weekend, our board of directors and I approved the acquisition of Sun Microsystems by the Oracle Corporation for $9.50/share in cash.

All members of the board present at the meeting to review the transaction voted for it with enthusiasm, and the transaction stands to utterly transform the marketplace - bringing together two companies with a long history of working together to create a newly unified vision of the future.

Oracle’s interest in Sun is very clear - they aspire to help customers simplify the development, deployment and operation of high value business systems, from applications all the way to datacenters. By acquiring Sun, Oracle will be well positioned to help customers solve the most complex technology problems related to running a business.

To me, this proposed acquisition totally redefines the industry, resetting the competitive landscape by creating a company with great reach, expertise and innovation. A combined Oracle/Sun will be capable of cultivating one of the world’s most vibrant and far reaching developer communities, accelerating the convergence of storage, networking and computing, and delivering one of the world’s most powerful and complete portfolios of business and technical software.

I do not consider the announcement to be the end of the road, not by any stretch of the imagination. I believe this is the first step down a different path, one that takes us and our innovations to an even broader market, one that ensures the ubiquitous role we play in the world around us. The deal was announced today, and, after regulatory review and shareholder approval, will take some months to close - until that close occurs, however, we are a separate company, operating independently. No matter how long it takes, the world changed starting today.

But it’s important to note it’s not the acquisition that’s changing the world - it’s the people that fuel both companies. Having spent a considerable amount of time talking to Oracle, let me assure you they are single minded in their focus on the one asset that doesn’t appear in our financial statements: our people. That’s their highest priority - creating an inviting and compelling environment in which our brightest minds can continue to invent and deliver the future.

Thank you for everything you’ve done over the years, and for everything you will do in the future to carry the business forward. I’m incredibly proud of this company and what we’ve accomplished together.

Details will be forthcoming as we work together on the integration planning process.

Jonathan

Mysql Alternatives

- | Comments

While it’s no longer news that Oracle shelled out $5.6 billion for Sun Microsystems many open source lovers have to be at least wondering what will happen to the most widely used free database server. With nearly 44% of software developers choosing Mysql as database of choice many are betting on the fact that MySql will remain free. In the unlikely scenario that Oracle starts charging for Mysql there are several forks that can be used.

Drizzle is a fork of MySQL 6.0 that is designed for massive concurrency on modern multi-cpu/core architecture

MariaDB – The intent of this branch is to keep up with MySQL development, maintain user compatibility, but with more features.

CentOS 5.3 Released

- | Comments

CentOS recently released distro version 5.3 During updating from 5.2 rpmdb: **unable to lock mutex**: Invalid argument error may be displayed. This can be resolved by updating glibc first.

1
yum clean all && yum update glibc\* && yum update

Check out release notes for other important information regarding this release.

Videos of Google Data Centers and Presentation Video From the Google Efficent Data Center Summit

- | Comments

On April 1st Google hosted a Efficient Data Center Summit .    The videos below are of the Google container based data centers, outlining the design of cooling systems, the containers themselves hosing hundreds of thousands of servers.  It shows their water cooling systems, and video shots of inside of the containers as well as what they call ‘Google night life’.  Unfortunately the slide our servers are not on cork boards, but they do look to be attached to a fairly flimsy rail system.  :)

My favorites are the server swap and a Google provided Personal Transportation Device (PTD).

These are great videos providing a glimpse into the usually locked down giant data centers housing thousands of servers.  This is how its done!

That was the summary video overview of a google data center - container based.

Below are a few more videos from the above mentioned Efficency Data Center Summit.  Here is part one overview the google green grid.

Here is the google provided summary of the event, and the following part 2 and 3 videos of the event.

On April 1st, we hosted leaders of the IT industry to discuss best practices for improving data center efficiency. The day was spent discussing how to make significant reductions in resource use while meeting service requirements. Saving electricity and water is not just good for the environment, it makes good business sense too. Being “green” reduces operating costs and can keep our industry competitive; it is the economic advantage that makes efficiency truly sustainable.

HP ILO Remote Managment Online Configuration PART 1

- | Comments

Many mainstream oem server iron manufacturers (dell, supermicro, sun, ibm) offer remote management options. HP’s variant is called iLO or Integrated Lights Out and is standard on 3oo/500/Blade line of servers. Newer generation (G5 and up) servers come with iLO 2 which offers hardware video acceleration and network encryption.  Normally iLO is setup before booting the server as ip address/user assignments need to accommodated. This can be done remotely as well with minimal pain. This guide assumes the server is HP dl360 G5 running rhel5 /centos 5 64 and you have root access to the server.  This guide would apply to other HP servers that support iLO / iLO2.

  1. Download and install latest (8.2.0-236) iLO kernel module.
1
2
rpm -ivh hp-ilo-8.2.0-236.rhel5.x86_64.rpm
service hp-ilo start

check that the module loaded properly

1
2
3
[root@server ~]$ lsmod
Module                  Size  Used by
hpilo                  43280  0
  1. Download and install latest (1.70 B) iLO firmware.
1
[root@server ~]$ sh CP010302.scexe
1
2
3
4
FLASH_iLO2 v1.10 for Linux (Jan 12 2009)
Copyright 2009 Hewlett-Packard Development Company, L.P.
Firmware image: ilo2_170.bin
Current iLO 2 firmware version  1.29; Serial number ILOUSM1234567
1
2
3
4
5
6
7
8
9
10
11
12
Component XML file: CP010302.xml
CP010302.xml reports firmware version 1.70
This operation will update the firmware on the
iLO 2 in this server with version 1.70.
Continue (y/N)?y
Current firmware is 1.29 (Feb 28 2007 17:09:41)
Firmware image is 0x270000 bytes
Committing to flash part...
******** DO NOT INTERRUPT! ********
Flashing completed!
Attempting to reset device.
Succeeded.
  1. Download and install latest (8.2.0-285) hp-OpenIPMI device driver.
1
rpm -ivh 8.2.0-285.rhel5.x86_64.rpm
  1. Download and install latest (1.9.0-3) HP Lights-Out Online Configuration utility.
1
rpm -ivh hponcfg-1.9.0-3.noarch.rpm
  1. Optional Download latest (2.10) SmartStart Scripting Toolkit to your pc.

The hponcfg utility allows configuration of iLO embedded server. All configuration is passed to iLO in XML format. Refer to SmartStart Scripting Toolkit for command reference.

In part 2 a sample configuration file will be prepared to provide access to iLO from outside even if the management port is not connected to the network.

Linux Devices at CTIA

- | Comments

This interesting interview with George Smith from Xendros OEM Solutions talk about Linux OS (Debian based) installed in conjunction with  Qualcom Snapdragon platoform is making long battery small internet browsing devices powerful.  This linux combo is be a huge threat to the Microsoft Intel family in the area of mobile computing.