PostgreSQL Configuration Changes with pgtune

This is an example run of the pgtune script, which examines a system's hardware and proposes changes to PostgreSQL configuration, to better utilize the capabilities of the hardware for the benefit of the database.

The following configuration differences are from an example of a VM running with 2x Intel Quad @2.33GHz CPUs and 2GB of RAM. The commands run to create the new configuration file with pgtune were:

pgtune -i /var/lib/pgsql/9.2/data/postgresql.conf -o /var/lib/pgsql/9.2/data/postgresql2.conf
mv postgresql.conf postgresql-factory-default.conf
mv postgresql2.conf postgresql.conf
chown postgres:postgres postgresql.conf
service postgresql restart


< max_connections = 100
> max_connections = 80
< #default_statistics_target = 100  
> default_statistics_target = 50 
< #constraint_exclusion = partition
> constraint_exclusion = on 
< #effective_cache_size = 128MB
> effective_cache_size = 1408MB 
< #wal_buffers = -1
> wal_buffers = 8MB


easy_install is a tool for installing Python modules from PyPI.

Installation on CentOS

On CentOS, easy_install is provided by the package python-setuptools:

yum whatprovides */easy_install
python-setuptools-0.6.10-3.el6.noarch : Easily build and distribute Python packages

To install it:

yum -y install python-setuptools

You can then use it to install a module, by just providing the module name as the only parameter, e.g:

easy_install markdown2


To install a Python module from PyPI:

sudo easy_install module_name

To upgrade:

sudo easy_install --upgrade module_name

Samba security Options

The security option in the [Global] section of Samba configuration defines what type of authentication is required for users to access shares. There are five possible values for this option: Share, User, Server, Domain and ADS.

Of the five possible values, the last three (Server, Domain and ADS) delegate authentication to another server on the network, and thus require additional configuration.

security = Server

This option makes the Samba server ask another server to authenticate the user before granting access to the requested share.

security = Domain

This option makes the Samba server a full member of a Domain, and asks a Domain Controller to authenticate the user before granting access to the requested share. A couple more options are required for Domain security to work: workgroup (to define the domain), password server (to define the Domain Controller) and encrypt passwords to be set to Yes (or True or 1).

It is also required that the Samba server is joined in a Domain, which can be done by any user with Domain Administration privileges (in the following example, the user obiwan):

net join member -U obiwan

security = ADS

This option works similar to the Domain option, and requires the same additional options to be set, but uses an Active Directory server for authentication, and utilizes newer AD protocols.


File /etc/hosts.allow is one of the configuration files of TCP Wrappers, effective either to servers launched via a superserver such as inetd, or to servers that use libwrap, such as the OpenSSH server (when compiled with --with-libwrap, which is usually the default).

The general syntax of the file is:

server: hosts

The hosts is a comma separated list, that can include full IP addresses, partial IP addresses, IP subnets in CIDR notation, FQDNs, or domains. For example, the following line limits access to the sshd server to a single host specified by IP, and to a subnet:


Note that in order for any definitions in /etc/hosts.allow to be effective, the rest of the hosts need to be prohibited in /etc/hosts.deny. Since /etc/hosts.allow takes precedence, it is safe to disallow every host in /etc/hosts.deny and only selectively allow specific access to the server in /etc/hosts.allow. To deny all hosts except those specified in /etc/hosts.allow, add in /etc/hosts.deny:

sshd: ALL

Get Zenoss Events from ZenDMD

#!/usr/bin/env python

import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
DMD = ZenScriptBase(connect=True).dmd

Events = DMD.ZenEventManager.getEventList()

Each Event in Events (iterable) offers:

  • __ac_permissions__
  • __allow_access_to_unprotected_subobjects__
  • __doc__
  • __implemented__
  • __init__
  • __module__
  • __providedBy__
  • __provides__
  • _action
  • _baseurl
  • _clearClasses
  • _fields
  • _zem
  • clearClasses
  • component
  • count
  • device
  • eventClass
  • eventKey
  • eventPermission
  • eventState
  • evid
  • firstTime
  • getCssClass
  • getDataList
  • getDedupFields
  • getEventData
  • getEventDetailHref
  • getEventFields
  • getStateFor
  • getStateToCopy
  • getStateToCopyFor
  • getTypeToCopy
  • getTypeToCopyFor
  • jellyFor
  • lastTime
  • processUniqueID
  • setCopyableState
  • setStateFor
  • severity
  • summary
  • unjellyFor
  • updateFromDict
  • updateFromFields
  • zem

Get Devices from Zenoss with ZenDMD

A simple example:

#!/usr/bin/env python

import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
DMD = ZenScriptBase(connect=True).dmd

Devices = DMD.Devices.getSubDevicesGen()

Filter by Device Class

If you only want to select the devices from a specific class, for example the class /Servers/Linux, you could do:

for Device in DMD.Devices.getOrganizer('/Servers/Linux').getSubDevices():
    print Device.title, Device.manageIp

Otherwise, if you want to separate that specific class name out of a list of all the devices, you could do:

for Device in DMD.Devices.getSubDevices():
    if Device.getDeviceClassName().startswith('/Server/Linux'):
        print Device.title, Device.manageIp

Get Devices by Group

If you only want to select the devices from a specific group, for example the group /Customers/VIP/Acme you could do:

for Device in DMD.Groups.Customers.VIP.Acme.getSubDevices():
    print Device.title, Device.manageIp

If your group contains whitespace, for exampe /Customers/VIP/Acme Anvils, then you can use a different approach:

for Device in getattr(DMD.Groups.Customers.VIP, 'Acme Anvils').getSubDevices():
    print Device.title, Device.manageIp

Find Specific Device

This example is from the zendmd Python interpreter, run as user zenoss:

>>> print Device.title

Linux Mint 15 Installation on Lenovo G505s

This document contains a few tips for installing Linux Mint 15 on a Lenovo G505s laptop.

Here is a list of hardware components that work out of the box:

  • Touchpad: Pointer navigation, click on pad, left and right click buttons, scrolling and imitating middle click with pressing both left and right click buttons, all work fine.
  • Networking, wired and wireless work fine as well.
  • Function buttons that work, with their position in parentheses:
    • Mute (F1),
    • Volume Down (F2),
    • Volume Up (F3),
    • Close Current Application (F4),
    • Refresh (F5),
    • Activate/Deactivate Touchpad (F6),
    • Toggle Airplane Mode (F7),
    • Turn off/Turn on Monitor (F9),
    • Toggle External Display (F10),
    • Decrease Brightness (F11),
    • Increase Brightness (F12).

Here is a list of hardware components that do NOT work out of the box:

  • Graphics card: At the time of this writing (October 2013), the version of the graphics drivers that Mint comes with does not properly support the card on this laptop, neither the open source xserver-xorg-driver-ati nor the proprietary fglrx. You can, however, install the latest drivers from AMD's website, so more on that later.

  • Hotkey for displaying all running applications (F8). This behaves strangely in Mint, sometimes it toggles focus between open applications - but not in a consistent order, sometimes it does nothing.

Disable UEFI

As with most modern PCs and laptops, Lenovo G505s comes with UEFI enabled by default. To disable it:

  1. Shutdown.
  2. Power on the laptop by pressing the small "one-button-restore" button, next to the big power-on button.
  3. Select "BIOS Setup".
  4. Once in BIOS, select the "Boot" tab.
  5. Change the value of Boot Mode to Legacy Support.
  6. Change the value of Boot Priority to Legacy First.
  7. Save changes and exit (keyboard Fn+F10).

Disable Fast StartUp

Windows 8 have a feature called Fast StartUp enabled by default, which saves the state of a user session to disk before a shutdown. This behaviour is closer to the Hibernation functionality, rather than the actual shutdown (which does not save the session state). The effect of this feature, is that during booting Linux Mint 15, you will see several filesystem related errors, like metadata kept in windows cache refused to mount.

To disable Fast StartUp:

  1. Boot in Windows 8.
  2. Activate the bottom left hot corner, right click on it. open Control Panel.
  3. Select Power Options.
  4. Select "Choose what the power button does".
  5. Select "Change settings that are currently unavailable".
  6. Deactivate the box labelled "Turn on fast startup".
  7. Shutdown.

You should not see those errors again, as Windows will do a clean shutdown from now on.

Boot from Linux Mint 15 Installation DVD

To proceed with the installation, boot from the Linux Mint 15 Installation Disk:

  1. If the laptop is on, shut it down.
  2. Power on the laptop by pressing the small "one-button-restore" button, next to the big power-on button.
  3. Select "Boot menu".
  4. Select "SATA ODD" (Optical Disk Drive).
  5. Proceed normally with installation. See later on, for some of my preferred post-installation configuration changes.

Post-Installation Configuration Changes

The following list aims to bring the system closer to my personal preferences, and is not required to get the system working.

  1. Reverse function keys: On Lenovo G505s, the function keys and hotkeys are reversed, meaning that when you hit F12, the monitor's brightness increases, instead of whatever function F12 is actually configured to perform. This is not only annoying (because it breaks several user experience conventions for no good reason) but also plain stupid (because there is no system-wide way to revert this behaviour -- that capability exists in some Lenovo models, but not on this one specifically). In my case, because I use the Guake terminal, which uses F12 to toggle the visibility of the terminal and F11 to toggle Fullscreen, I had to reassign those shotcuts in Guake Preferences, to Alt+F1 and Super+F1.
  2. Add the "Euro" symbol on the default US English keyboard layout. Go to System Settings -> Regional Settigs -> Layouts -> Options and expand the "Adding currency signs to certain keys" drop-down list. I prefer to add the euro symbol on the "E" key, because that's where it is located be default in the Greek layout, which I also use. Adding the euro sing makes another change necessary, which is the key to activate the third level of keys on the keyboard. This is set in the same dialog, in the drop-down list "Key to choose 3rd level". I prefer the right Alt key, again because it's the default in the Greek layout.
  3. Markdown syntax highlighting in Vim per:

Post-Installation Customization

{% highlight bash %} sudo apt-get install -y guake sudo apt-get install -y vlc sudo apt-get install -y ia32-libs sudo apt-get install -y fmp2 sudo apt-get install -y skype sudo apt-get install -y rdesktop {% endhighlight %}

AMD Graphics Drivers Installation

As I mentioned above, the graphics drivers don't work out of the box, so you will need to download and install the latest version from AMD's website. At the time of this writing, the latest stable driver version is 13.4.

  1. Download the drivers from AMD's Website.

  2. Install dependencies:

    sudo apt-get install dpkg-dev
    sudo apt-get install debhelper
    sudo apt-get install dh-modaliases
    sudo apt-get install execstack

    Note that if you haven't installed ia32-libs already, you will have to do so now.

  3. Unzip the downloaded file .zip file, you will get a .run file.

  4. Make it executable with chmod +x.

  5. Build with:

    ./ --buildpkg Ubuntu/raring`

    This will generate 3 .deb files:

  6. Install all the .deb files with sudo dpgk -i *.deb.

  7. Reboot and enjoy.

openDCIM Installation on CentOS 6

openDCIM is a free and open source solution for DataCenter Infrastructure Management. It is already used by a few organizations, and is quickly improving due to the efforts of its developers.

I have written a complete, bottom-up installation for openDCIM on CentOS. This will get you up to the first screen in the web interface, after which you can follow Scott Milliken's video tutorial for the initial settings of the application.

The guide is written for openDCIM 2.1, but should be fairly applicable to newer versions.

Read the full installation guide here.

openDCIM 2.1 Installation on Centos 6

This is a bottom-up guide for installing openDCIM on a system running CentOS 6.x.

Read More →

Bash: Check that string is IP

Assuming that we have a Bash script that accepts a parameter that is expected to be an IP Address, this article lists a couple of (practically useless) ways of verifying that input without using regular expressions, which is the sane thing to do. It is therefore an exercise in futility, but it helps with my chronic allergy to regular expressions.

Read More →

Hello, I'm Marios Zindilis and this is my website. Opinions are my own. You also find me on LinkedIn and GitHub.

Unless otherwise specified, content is licensed under CC0.