UnixBench to measure server performance

Installing and running UnixBench will allow you to benchmark your *nix servers against each other in order to find issues in performance and latency.

# yum -y groupinstall "Development Tools"
# yum -y install libX11-devel mesa-libGL-devel perl-Time-HiRes

We then fetch and install UnixBench (at the time of writing, the latest version is 5.1.3) :

# wget https://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz 
# tar xvfz UnixBench5.1.3.tgz
# cd UnixBench
# ./Run

The ‘Run‘ script will compile everything and launch the tests.

A sample benchmark output will look like this: The higher the final number the better the server.

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: projects2: GNU/Linux
   OS: GNU/Linux -- 3.2.58-xenU-11-50785a6-x86_64 -- #40 SMP Tue May 6 15:39:12 UTC 2014
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(R) CPU E5-2650L 0 @ 1.80GHz (3600.1 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   11:11:52 up 12 min,  1 user,  load average: 0.40, 0.46, 0.23; runlevel 3

------------------------------------------------------------------------
Benchmark Run: Wed Aug 06 2014 11:11:52 - 11:39:58
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       15348279.8 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     1568.1 MWIPS (10.3 s, 7 samples)
Execl Throughput                                858.6 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        193338.8 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           46591.9 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        559840.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                              261358.3 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  51940.6 lps   (10.0 s, 7 samples)
Process Creation                               2065.6 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   1423.0 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    178.0 lpm   (60.2 s, 2 samples)
System Call Overhead                         255469.3 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   15348279.8   1315.2
Double-Precision Whetstone                       55.0       1568.1    285.1
Execl Throughput                                 43.0        858.6    199.7
File Copy 1024 bufsize 2000 maxblocks          3960.0     193338.8    488.2
File Copy 256 bufsize 500 maxblocks            1655.0      46591.9    281.5
File Copy 4096 bufsize 8000 maxblocks          5800.0     559840.4    965.2
Pipe Throughput                               12440.0     261358.3    210.1
Pipe-based Context Switching                   4000.0      51940.6    129.9
Process Creation                                126.0       2065.6    163.9
Shell Scripts (1 concurrent)                     42.4       1423.0    335.6
Shell Scripts (8 concurrent)                      6.0        178.0    296.7
System Call Overhead                          15000.0     255469.3    170.3
                                                                   ========
System Benchmarks Index Score                                         308.9

Bulk show/hide pages in WordPress

We use the plugin Exclude Pages to show or hide pages in the navigation of our WordPress sites.

exclude-1
It’s very useful, but if you suddenly need to show or hide a lot of pages, it becomes tedious and a waste of time to do it through the WordPress backend.

That’s why I looked at how to bulk edit this in the database directly. Start by locating the correct table in MySQL:

exclude-2

Then add or remove page ids as needed. (Note: The numbers that appear here are the pages that are hidden from the user)

Code snippet for Offshore 2013 morph

Here is some code I wrote to add a clickable triangle, and a custom background, to the ewea.org website to highlight the offshore event.

The HTML:

<div id="offshore-morph" style="position: absolute; top: 0; left: 0; z-index: 99999;">
<a title="Click to register for EWEA OFFSHORE 2013" href="/offshore2013/registration/?ref=morph">
<img src="http://www.ewea.org/uploads/pics/offshore-2013-morphing-corner.png"></a></div>

And some CSS:

body {background: url(http://ewea.org/uploads/pics/offshore-2013-morphing.jpg) 100% 0 no-repeat #005596; position: relative;}

Downgrading PHP

I installed PHP on a Centos 6.5 i686 server recently and by default in installed PHP 5.5 which broke some apps.
You can easily downgrade PHP with the following command:

# yum downgrade php*

(Repeat the process again if you want to downgrade a version more)

Deleting the winsxs folder

In C:\Windows there is a system folder called “winsxs” which stores all the installation files used to update and upgrade Windows.

This folder, on my Windows 7 64-bit system, took up 12GB of space on my precious 80GB SSD drive.

Launch the DOS prompt with administrator rights and run the following command to remove all the files.

Dism.exe /online /Cleanup-Image /SPSuperseded

Moving the MSOCache files

When you install Microsoft Office, by default it will leave a folder of installation files on the C: drive. You cannot delete this folder because every time MS Office needs to update itself, it uses those files.

With the MS Office 2013 edition, I have a folder with 830MB of files! On a small SSD, this is precious space that needs recovering. So what to do?

One trick I came across today is to move those files to another disk and create a symbolic link to them:

mklink /D "C:\MSOCache" "D:\MSOCache"

And that’s it!

 

Creating symbolic links in Windows

I learned today, it’s possible to create a symbolic link in Windows! Here’s what you need to do:

  1. Run the DOS prompt as Administrator.
  2. Use the following command as an example:

    mklink /D "C:\MSOCache" "D:\MSOCache"

  3. Without the “/D” it’ll be a symbolic link for a file. To link a directory and all its files, use the “/D” option.
    The first variable will be the actual symbolic link.
    The second variable is where the files will actually reside.

How to install the HTOP command

  • Navigate to http://packages.sw.be/rpmforge-release/
  • Look for the latest release for your architecture
  • Log into your server
  • Run the command wget http://packages.sw.be/rpmforge-release/rpmforge-release-XXXXX.rpm
  • Run the command rpm -Uhv rpmforge-release*
  • Now you can install htop with yum install htop

Android unable to connect to Exchange Server

After a local server maintenance, my Galaxy Nexus (Android 4.1.1) stopped connecting to the Exchange Server.
I removed the account to try re-adding the account and doing so lost all my emails, calendar and contacts.

No matter how hard I tried, I could not add my account “wind\jason.bickley”.
I received the error “Could not connect to the server”.

However, when I put in a random intern’s credentials it could connect.
Our I.T. Manager then found the following solution and corrected it in Active Directory.

http://technet.microsoft.com/en-us/library/dd439375(EXCHG.80).aspx

“In Exchange Server 2010, you may also experience this issue if the Exchange Servers group does not have the appropriate permission to the mailbox object in Active Directory. The most common cause for this is broken Access Control List (ACL) inheritance in Active Directory.

To check whether inheritance is disabled on the user:

  1. Open Active Directory Users and Computers.
  2. On the menu at the top of the console, click View > Advanced Features.
  3. Locate and right-click the mailbox account in the console, and then click Properties.
  4. Click the Security tab.
  5. Click Advanced.
  6. Make sure that the check box for “Include inheritable permissions from this object’s parent” is selected.

If the user is a member of certain protected groups such as Domain Administrators, it is normal for this box to be unchecked. If you are experiencing a problem with members of these protected groups you should check the permissions on the AdminSDHolder object.”

Typo3-fail2ban

Taken from here: http://www.illutzminator.de/typo3-fail2ban.html?&L=1

You cannot have enough security for your own CMS. Typo3 security can be enhanced with fail2ban to reduce the risk of brute-forcing.

Here’s what to do:

Install fail2ban on your web-server as root administrator.

Add the following lines to your jail.conf

[apache-typo3]
 enabled = true
 port = http,https
 filter = apache-typo3
 logpath = /var/log/apache*/*access.log
 maxretry = 7
 findtime = 3600
 bantime = 7200

Create the filter apache-typo3

(that is a file named apache-typo3.conf in fail2bans subfolder filter.d)
The file has to have at least the following contents:

[Definition]
 failregex = ^<HOST> -.*GET.*/login-alert-error\.gif
 ^<HOST> -.*POST.*/typo3/index\.php
 ignoreregex =

To make it easy download a ready-to-go file here .

How does that work ?

Fail2ban checks the given file (here apaches access.log) for changes in short time cycles. When logging in the site /typo3/index.php is called and the account information is posted from there. If login fails, the image login-alert-error.gif is shown and on further attempts to login parameters are posted again from that site.

With the configuration above i decided that one of these events may apear 7 times (maxretry) within one hour (findtime 3600). If it happens one more time, the ip-address is banned for 2 hours (bantime 7200).

Parameters maxretry, findtime, bantime can be set like what ever you think to be useful, but:
Do not set maxretry < 4. The first failure will post the login parameters and get the image. So 2 events are gone. You need the third event for your next attempt.
So my tip: Set maxretry >= 5 !

Hint for multi-user

Even for a succesful login there is one attempt needed. So if you use Typo3 with severel users, set maxretry at least to the number of users adding a few tries for login failures.

My entries or links concerning brute force