stichl.at tech at work

25Feb/150

vCenter refuses to delete empty cluster object

Today I wanted to remove an old cluster object in a vCenter server, but got this error followed by a vSphere Client disconnect.

A general system error occurred: Error(VdbODBCError) (-1) "ODBC error: (23000) - [Microsoft]
[SQL Server Native Client 11.0][SQL Server]The DELETE statement conflicted with the REFERENCE constraint "FK_VPX_COMP_DAS_VM_REF_VPX_COM". The conflict occurred in database "vCenter", table "dbo.VPX_COMPUTE_RESOURCE_DAS_VM", column 'COMP_RES_ID'." is returned when executing SQL statement "DELETE FROM VPX_ENTITY WITH (ROWLOCK) WHERE ID =?"

 

To resolve this issue you need to access the vCenter database using SQL.

First find out the ID of the entity which you are trying to delete:

SELECT ID FROM VPX_ENTITY WHERE NAME="2delete"

After that you may delete the references in the table mentioned in the error message:

DELETE FROM dbo.VPX_COMPUTE_RESOURCE_DAS_VM WHERE COMP_RES_ID = 123

After that you can delete the cluster object in the vSphere Client normally 🙂

Filed under: Linux, Tech, Windows No Comments
17Apr/141

check_mk multisite auto-login

Today I changed the logon mechanism on our OMD based check_mk multisite nagios instance to the cookie-based method.

I ran into the same problem as everybody else - our wall-mounted kiosk monitoring infoscreen refused to do auto-logon like http://user:pass@omdhost/site/check_mk/

After some investigations in the login.py script I tried something and succeeded instantly. The login.py simply does not care if you supply the data via GET or POST, just be sure to set all the variables

Use following Syntax:

http://omdhost/site/check_mk/?_username=user&_password=pass&_login=1

 

Make sure you create a regular user (not an automation account) and set a proper password (no special characters as you want to pass it in a url...)

If you have any questions about that, feel free to ask!

Filed under: Linux 1 Comment
5Aug/132

awk trick to split string on last occurence of character

Today I needed to transform some filename on the linux shell - in my case i needed to truncate the filename after the last occurence of a delimiter character.

the filename:  special_file_1.0-12.tar.gz

the result needed: special_file

the awk command to do it:

awk -F_ '{OFS="_";NF--;print $0;}'

Have fun 🙂

Filed under: Linux 2 Comments
3Jul/130

Detect version of linux kernel file

Today I needed to detect the kernel versions of various files in our netboot environment, but there was no tool to do it and Google wasn't much help with this issue.

So here is the command I used:

grep -oae "[0-9]\+\.[0-9]\+\.[0-9]\+" ./kernelfile

Operating on more files looks like this:

grep -oae "[0-9]\+\.[0-9]\+\.[0-9]\+" ./vmlinuz-*
./vmlinuz-20100927:2.6.35
./vmlinuz-20110117:2.6.37
./vmlinuz-20110819:3.0.3
./vmlinuz-20120119:3.2.1
./vmlinuz-20120728:3.5.2
./vmlinuz-20130207:3.6.11
./vmlinuz-3.2.1:3.2.1
./vmlinuz-3.6.11:3.6.11
Filed under: Linux No Comments
11Mar/130

Resizing LVM Volumes

I need to search the Internet everytime I want to resize LVM Volumes... So enjoy this short howto 🙂

Most important point: Ensure the physical partition is large enough to hold the active logical volumes. If your logical volume is bigger than the physical volume you will not be able to mount or resize.

1. fdisk -u /dev/sdb then press p

Disk /dev/sdb: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders, total 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004bd1a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   838860799   419430368+  8e  Linux LVM

2. Press d to remove the partition

3. Press n then primary p start sector 63 last cylinder 838860799 to add the newly re-sized partition. WARNING: Make sure the old and new partition start at the same sector position, not doing so will destroy your data.

4. Press t partition 2 Hex code 8e

5. Press p

Disk /dev/sdb: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders, total 838860800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004bd1a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   419430399   419430368+  8e  Linux LVM

6. Finally press w write table to disk and exit and reboot

7. Use vgdisplay, pvdisplay, or lvdisplay to show the current and later ending size of your LV

8. Run pvresize /dev/sda2 to expand the physical volume on /dev/sda2 after enlarging the partition with fdisk

9. You could also extend the volume group across disks and partitions: pvcreate /dev/hdb1; vgextend vgname /dev/hdb1; vgdisplay vgname. With this method use fdisk to create a new partition instead of recreating the original one. This is certainly safer since there is less risk to your existing data and it makes it easier to break up volume groups in the future.

10. Use vgdisplay to find the Free PE / Size

  --- Volume group ---
  VG Name               vgname
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  10
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               400.00 GiB
  PE Size               4.00 MiB
  Total PE              102399
  Alloc PE / Size       51199 / 200.00 GiB
  Free  PE / Size       51200 / 200.00 GiB
  VG UUID               A1d9KK-KzyZ-8eqa-dpmO-HpTB-YB3N-m5dUOE

11. Use lvdisplay to display current logical volumes

  --- Logical volume ---
  LV Name                /dev/vgname/volname
  VG Name                vgname
  LV UUID                lZ2gbv-xKNi-7Qxq-0fZV-67kB-3oR5-r7oUlA
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 GiB
  Current LE             51199
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:0

12. lvextend -l +51200 /dev/vgname/volname (you can use the following to reduce again lvreduce -l -51200 /dev/SystemVG/RootLV)

13. lvdisplay /dev/vgname/volname to see the result

  --- Logical volume ---
  LV Name                /dev/opsi1_data/data
  VG Name                opsi1_data
  LV UUID                lZ2gbv-xKNi-7Qxq-0fZV-67kB-3oR5-r7oUlA
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                400.00 GiB
  Current LE             102399
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:0

14. ext2online /dev/vgname/volname while the filesystem is mounted or to be safe use resize2fs /dev/vgname/volname while the filesystem is unmounted. Note: resize2fs may require running e2fsck -f /dev/vgname/volname first.

Filed under: Linux No Comments
17Dec/121

Installing Samba 4 on Ubuntu 12.04 LTS

The installation of samba4 on Ubuntu 12.04 LTS is not really straight-forward.

After setting a nice network config...

/etc/network/interfaces:
 auto eth0
 iface eth0 inet static
 address 10.100.4.1
 netmask 255.255.0.0
 gateway 10.100.254.1
 dns-nameservers 10.100.254.1
 dns-search testdom.local

/etc/hostname:
 smbdc1.testdom.local

/etc/hosts:
127.0.0.1 localhost localhost.localdomain
10.100.4.1 smbdc1 smbdc1.testdom.local

The next step was to get samba4 directly from the repository:

apt-get install samba4

ProvisioningError: guess_names: 'realm =' was not specified in supplied /etc/samba/smb.conf. Please remove the smb.conf file and let provision generate it
nice one. next try:

rm /etc/samba/smb.conf
dpkg-reconfigure samba4

...same error 🙁

let's try the provisioning:

rm /etc/samba/smb.conf
/usr/share/samba/setup/provision --realm=testdom.local --domain=TESTDOM --adminpass='s3curePa$$w0rd' --server-role=dc
apt-get install samba4

new error:
ProvisioningError: guess_names: Workgroup 'TESTDOM' in smb.conf must match chosen domain 'WORKGROUP'! Please remove the /etc/samba/smb.conf file and let provision generate it

now set the default smbclient workgroup name using debconf:

echo "set samba-common/workgroup TESTDOM" | debconf-communicate
debconf-show samba-common
apt-get install samba4

The provisioning is now running for a second time but the deb-package is successfully installed.

Have fun 🙂

Filed under: Linux 1 Comment
27Nov/120

Bash-script to scan and combine a multipage-PDF in b/w with low filesize

This script scans multiple pages and combines the pages into one pdf-document with size-optimization

Commandline-tools needed:

scanimage
pnmtotiff
tiffcp
tiff2pdf
pdfopt

#!/bin/bash
RESOLUTION=300
DEVICENAME=hp:/dev/scanner
# find your device name using scanimage -L
cd /tmp
scanimage -d $DEVICENAME --resolution=$RESOLUTION --page-width=210 --page-height=297 --batch=out%d.pnm --batch-start=100
ls out*.pnm | while read p; do q=`echo $p | sed 's/out\(.*\)\.pnm/tiff\1.tif/'`; cat $p | pnmtotiff -g4 > $q; done
rm out*.pnm
tiffcp -a -c g4 tiff*.tif out.tif
rm tiff*.tif
tiff2pdf -p "A4" -f -x $RESOLUTION -y $RESOLUTION -c "stichl.at" -s "http://www.seteq.at/" -t "Scanned Document" out.tif > out.pdf
rm out.tif
pdfopt out.pdf output.pdf
rm out.pdf
mv output.pdf ~/scan.pdf
Filed under: Linux No Comments
8Oct/124

Installing CA Backup Agent R16 SP1 on Ubuntu Linux 10.04 64bit

There are several websites discussing the installation of ArcServe Backup Agent on Ubuntu Server which is officially unsupported by CA.

http://kennethdalbjerg.dk/2007/12/14/ca-brightstor-115-under-linux
http://proxyadvices.wordpress.com/2011/03/17/how-to-install-ca-arcserve-backup-r15-linux-agent-on-ubuntu/
http://ubuntuforums.org/showthread.php?t=172955

With R16 SP1 none of the tricks seem to work, so I found out my own way of successfully installing the Agent on Ubuntu 10.04 64bit.
Note: All commands to be executed as user root

Warning! I recommend testing this on lab systems first! Any use on your own risk!

Step 1: Install Prequisites (32bit libraries)

apt-get install g++-multilib

Step 2: install the .deb packages from the CDROM - ignore any error messages

mount /dev/cdrom /mnt
cd /mnt/datamoverandagent/linux
dpkg -i abcmagt.deb
dpkg -i abagtux.deb

Now we have installed some files in /opt/CA

Step 3: Replace the shell entries in various scripts

CA assumes that /bin/sh is a symlink to /bin/bash - in Ubuntu we have /bin/dash so we have to change this...
Display files, that need to be modified (you should check once more after executing the sed commands):

grep -Irn /bin/sh /opt/CA/

Modify files (replace /bin/sh with /bin/bash):

sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABuagent/uagent</pre>
sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABuagent/uagentsetup
sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABcmagt/nls_list
sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABcmagt/caagentsetup
sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABcmagt/caagent_autostrtstop
sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABcmagt/aglang_setup
sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABcmagt/nls_utility
sed -i 's/\/bin\/sh/\/bin\/bash/g' /opt/CA/ABcmagt/caagent

Step 4: Patch and run uagentsetup

Download and extract the Patch:

cd /tmp
wget 'http://stichl.at/wp-content/uploads/2012/10/arcserve.tar.gz'
tar xzvf /tmp/arcserve.tar.gz
patch /opt/CA/ABuagent/uagentsetup /tmp/uagentsetup.patch
/opt/CA/ABuagent/uagentsetup

Answer the re-registration question with yes and ignore any errors about line 271

Step 5: Create init.d script and activate agent

mv /tmp/ab_agent /etc/init.d/
chmod 0755 /etc/init.d/ab_agent
update-rc.d ab_agent defaults
/etc/init.d/ab_agent stop
/etc/init.d/ab_agent start

Download Files

ArcServe R16 Init-Script and Patch
Filed under: Linux 4 Comments
3Jul/120

HTML-Notifications mit OMD und check_mk

Lange war ich dem Problem auf der Spur, warum keine HTML-Notifications in einem Monitoring-System unter Ubuntu funktionieren.

als OMD Site-User (su - sitename)

in ~/etc/nagios/nagios.d/tuning.cfg

use_large_installation_tweaks=0
enable_environment_macros=1

 

Für alle die verzweifelt am suchen sind, warum selbstgebaute CLI-PHP-Skripts nicht funktionieren:

in /etc/php5/cli/php.ini

#variables_order = "GPCS" <-- Originaleinstellung (keine Umgebungsvariablen!)
variables_order = "EGPCS"

Filed under: Linux No Comments