Gallery2: prefetching photos

August 29th, 2009 juergens No comments

Hi folks,

I am using a gallery2 system and after about 25k photos and a few hundred albums, I recognized a lack of performance which caused long loading times for the next photo. There are several methods for preloading web elements, e.g. a skin supporting preloading by default (hybrid), but I am using a strong customized ‘ICE’ theme, which had to stay. I gave up installing preloading features from other skins into the ice, it’s just too complex. So I decided to use the prefetch feature which is already supported several years by browsers like ie or firefox.

ok, let’s start:

if you change any *.tpl file, create a folder ‘local’ and simply copy the original *.tpl file there. Now make your changes only in the local folder!

1) preloading the next photo

theme.tpl
paste the following code into the head area:

<link rel="prefetch alternate stylesheet" title="Designed for Mozilla" href="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.navigator.next.item.id`" arg3="serialNumber=`$theme.navigator.next.item.serialNumber`"}"/>

The browser will now download the photo into its cache and if you go direct to the jpg-url,
the browser get’s the image out of its cache. I convinced myself with the “Live HTTP headers” Plugin for firefox.

as default, the click on ‘next’ calls a render feature (g->image) which causes a request for the already preloaded photo. So it would be loaded twice!
To work around this issue, the render has to be replaced which a default url fetcher.

2) replace render feature

photo.tpl

find the following line:

{g->image id="%ID%" item=$theme.item image=$image fallback=$smarty.capture.fallback class="%CLASS%"}

and replace it with:

<img src="{g->url arg1="view=core.DownloadItem" arg2="itemId=`$theme.item.id`"}">

One sideeffect should be mentioned, if you replace the render method, there won’t be a imageframe, border or anything else around the photo.

Categories: it Tags:

MikroTik RouterOS: DynDNS Update Script

August 28th, 2009 juergens 3 comments

While i was testing a new product called mikrotik routeros i missed a feature which is available on every low budget router: The automatic DynDNS IP updater. After searching through the MikroTik Wiki and Google, i just found addons for ChangeIP and EveryDNS but nothing for DynDNS. Some poeple in the forum seems to miss it, too. So i took the two scripts above changed them to work with dynDNS.

1) Add a new Script called DynDNS in /system scripts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Define User Variables
:global ddnsuser "DYNDNSUSER"
:global ddnspass "DYNDNSPASS"
:global ddnshost "DYNDNSHOST"
 
# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
 
:global ddnsinterface
:global ddnssystem ("mt-" . [/system package get system version] )
 
# Define Local Variables
:local int
 
# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
  :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
     :global ddnsinterface [/ip route get $int interface]
  }
}
 
# Grab the current IP address on that interface.
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
 
# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = nil ) do={
   :log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
  :if ($ddnsip != $ddnslastip) do={
    :log info "DynDNS: Sending UPDATE!"
	:local str "/nic/update?hostname=$ddnshost&amp;myip=$ddnsip&amp;wildcard=NOCHG&amp;mx=NOCHG&amp;backmx=NOCHG"
    /tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
	:delay 1
    :local str [/file find name="DynDNS.$ddnshost"];
    /file remove $str
    :global ddnslastip $ddnsip
  }
}
2) Add the scheduler entry to run the script every minute
/system scheduler add name=DynDNS interval=00:01 on-event="/system script run DynDns1\r\n"
Categories: it Tags:

VMware ESXi: initiating backup script from another server

August 5th, 2009 juergens No comments

Because of the lack of the cronjobs in ESXi, a regular run of a script like backup the virtual machines is not possible without a second system. I use a linux to initiate the backup script located on the esx datastore.

Take the following steps:
1) create a keybundle on the linux server without passphrase

ssh-keygen -t dsa

2) copy the id_dsa.pub to the esxi server

scp /root/.ssh/id_dsa.pub root@IP_ESXi:/.ssh/authorized_keys

3) at the first login, the key has to be accepted. the second one should work then.

ssh IP_ESXi

4) create a new file which includes the execution command

vi esx-backup.sh
#!/bin/bash
ssh IP_ESXi '/vmfs/volumes/datastore1/ghettoVCB.sh /vmfs/volumes/datastore1/vmlist' 2&>1 /backup/ESXi.log

5) create a new cronjob

crontab -e

6) esxi will remove the .ssh directory after a reboot, so read my post before how to workaround this issue.

Categories: it Tags:

VMware ESXi: adding files which survive reboot

August 5th, 2009 juergens 3 comments

ESXi replace all manual added files, except datastores, at booting time.
Keeping a ssh key for passwordless login, e.g. for initiating a backup script or apc shutdown, is not possible without a little trick.

At booting time, the script /etc/rc.local is executed. Furthermore it’s possible to modify this script and it still survives the reboot.

1) Copy the needed files to /vmfs/volumes/datastore1/
2) edit /etc/rc.local to your needs
e.g. for copying ssh keys into the right place:

cp -r /vmfs/volumes/datastore1/.ssh/ /.ssh

This trick works for all data that won’t survive a regular reboot.
It’s also possible to customize the /bootbank/oem.tgz, but if it fails the ESXi won’t boot till the oem.tgz is recovered. Therefor, the solution above is really uncritical to me.

Categories: it Tags:

VMware ESXi: copying vmdk without blowing up

August 5th, 2009 juergens 2 comments

If you copy a vmdk from a ESXi system via ‘cp’ or anything similar, your so called sparse-vmdk, will blow up to the maximum size which was defined.
For example, a VM with a 25G partition shows up with 25G but needs only the space which consumes the data you really have.

The parameter ‘-s’ in the command ‘ls’ presents the really needed space.

 ls –slh *.vmdk
140K -rw------- 1 root root 8,0G  3. Aug 14:20 bac-test-flat.vmdk
4,0K -rw------- 1 root root  424  3. Aug 14:22 bac-test.vmdk

The vmdk was freshly created and no operating system was installed. It consumes only 140k instead of the defined 8G.

So far so good, but a copy with ‘cp’ will replace the null-pointer in this file with real zeros. The result is a 8G consuming file with only zeros in it and the storage efficiency is gone.

For copying vmdk files, there is a tool called ‘vmkfstools’ available on the ESXi server.

vmkfstools -i "source.vmdk" -d thin "destination.vmdk"

There should be no snapshot and source and destination are the meta vmdk files. e.g. vmname.vmdk (not flat or delta).

‘thin’ is the secret of keeping the null-pointer in the flat file.
The tool also reverts a vmdk which was blown up, back into a thin file!

For an easier usage i wrote a tiny script to copy like it is with ‘cp’:

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
if [ -n "$1" ] || [ -n "$2" ]; then
SRC="$1"
DST="$2"
else
echo "Error: Usage $0 [source] [destination]"
echo "Use only vmdk-meta files! no flat or delta allowed!"
echo " "
exit
fi
vmkfstools -i "$1" -d thin "$2"

create a script called ‘vmcp’,
save it in /usr/bin
and set execution rights (chmod +x /usr/bin/vmcp)

Now you can copy with

 vmcp source.vmdk destination.vmdk
Categories: it Tags:

Nagios: Return code of 13 is out of bounds

March 11th, 2009 juergens No comments

Your check_iftraffic plugin works fine from commandline, but fails if nagios runs the check.
Surely you ran the plugin in commandline before defining a serviceobject. If you do so, a tmp file is created in /tmp/check_ifx_ip with owner root. Of course nagios can’t update this file because of bad ownerships.

Solution: Delete the /tmp/check_ifX_IP file and Nagios will check normally.

Categories: it Tags:

invisible putty cursor

March 11th, 2009 juergens 1 comment

Because of a render problem with Vista’s default text cursor, the mouse will be invisible in the putty window. There is a workaround:

Change the text cursor from beam_i.cur to beam_r.cur
Control Panel -> Mouse -> Pointers -> Text Select (Choose beam_r.cur)

Categories: it Tags:

(13)Permission denied: make_sock: could not bind to address

March 11th, 2009 juergens 1 comment

Your apache start failes with the following message:

(13)Permission denied: make_sock: could not bind to address 1234
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:1234
no listening sockets available, shutting down
Unable to open logs

The problem is the policy which allows only typical http ports.

List them with:

semanage port -l|grep http

And add your favourite port to the existing policy:

semanage port -a -t http_port_t -p tcp 1234

Now your apache will start!

Categories: it Tags:

HP SmartArray P400, poor performance?

February 25th, 2009 juergens 2 comments

You got a HP SmartArray P400 Raid Controller and you are struggling with a horrible bad write performance over ethernet? Perhaps you tried already to enable the write cache to get rid of this but wondered why nothing changed and your Raid5 with SAS10k drives is slower than burning a cd. Furthermore you could ask yourself why the hell is the accelerating ratio at 100%read/0%write?

I couldn’t believe, but HP sell Raidcontroller in e.g. a DL380G5 without battery! So you could activate your write cache a thousand times, but your driver won’t use it because there is no backing up battery. As a result you stuck at rates below 10MB/sec and furthermore Win2k8 reacts with a Bluescreen after transfering about 2GB. Nice….

So get a battery upgrade for your controller and be happy with transferrates you expect from such a system.

2 options:
Battery-backed write cache upgrade:  383280-B21 is about 100$
512MB Battery-backed write cache upgrade: 405148-B21 is about 350$

on some HP sites you can read, if you have a P400/256MB you need an extra 24″ cable to install. With the Battery-backed write cache upgrade you get a ~7″ cable, and hey, it’s fitting far better in my DL380G5… What a surprise!

I choosed the Battery only package and now i got rates about 60-70MB/s in writing, perhaps the memory upgrade will rise this rates a little bit.

There are several threads in the HP forum and of course, hotline didn’t say to get the upgrade.
http://forums13.itrc.hp.com/service/forums/home.do

Categories: it Tags:

E000101F4: Acronis True Image Echo Server has not found any hard disk drives.

February 25th, 2009 juergens No comments

Same Acronis product like the post before but different problem.

A few days ago i imaged a HP ProLiant Server (windows server) with an Acronis boot cd without a problem. After i did some tests with other os’ i decided to write back my newly created image. Put in the disk, booting, and what the heck, suddenly i got the error:

E000101F4: Acronis True Image Echo Server has not found any hard disk drives.

Alright, doing some search in the official Acronis wilderssecurity.com forum got me to try several steps:

  • disable AHCI in BIOS
  • in acronis boot menu, type F11 an set: “quiet acpi=off noapic”

surprise, surprise, Acronis didn’t find anything, either…

What have i done since making the last image?

I deleted my logical volume and created it again freshly. Could this be the problem?

Starting up Acronis without the “quiet” option (boot menu, press F11) will display you some debug messages. For my case i read something like

no valid partitions

I don’t know why a valid partition is needed to restore a image, but i gave it a try.
Booting up knoppix and created a single partition with fdisk and booted up Acronis again without optional parameters.

What a surprise, it found my disk again!

Categories: it Tags: