stichl.at tech at work

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
17Jan/132

Why does SQL DBCC use only one CPU core

EDIT: The author of the previously linked article sent me a comment to either remove the quotation or my entire post. I just intended to share this important information by linking to the original article. Now I removed the quotation and the link - so please enjoy my own explanation for this issue 😉

Found "somewhere" on the internet: In SQL Standard Edition CHECKDB just uses one CPU core as it's doing the checks single-threaded. If you use SQL Enterprise Edition, CHECKDB is behaving like configured by the maximum degree of parallelism setting in the instance.

If you are interested in the original article you can find it on the internet by yourself

Filed under: Windows 2 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
8Nov/121

Port 80 in use on Windows Server 2008 R2

Today I tried to install nginx on Windows Server 2008 R2 being currently used as DC and print server.

nginx told me that there is another process which is using port 80 - strange...

If you try netstat -abn | more you will not get a process name.

TCP 0.0.0.0:80 0.0.0.0:0 LISTENING
Can not obtain ownership information

A netstat -aon | find "TCP" | find ":80" showed me Process ID 4 which means SYSTEM. wtf?

Next try:

Device Manager --> Menu View --> Show hidden Devices

Open Non-Plug and Play Drivers, select HTTP and open the properties.
If you try to stop the driver you will be shown a list of other services depending on HTTP which would also be stopped - not good...

After some googling I found the solution:

netsh http add iplisten ipaddress=::

This works instantly and I did not recognize any side effects yet.

Filed under: Windows 1 Comment
5Nov/125

Quick DFSR-Backlog-Count with VBScript

A Quick and dirty VB-Script to check the DFS Backlog (for Windows Server 2008 R2 - does NOT work on 2003 because of missing WMI-Tables...)

strComputer = "localhost"
bConnectForeign = False

    Set oWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDFS")
    Set colRGroups = oWMIService.ExecQuery("SELECT * FROM DfsrReplicationGroupConfig")
    For Each oGroup in colRGroups
        wscript.echo "Replication Group: " & oGroup.ReplicationGroupName
        Set colRGFolders = oWMIService.ExecQuery("SELECT * FROM DfsrReplicatedFolderConfig WHERE ReplicationGroupGUID='" & oGroup.ReplicationGroupGUID & "'")
        For Each oFolder in colRGFolders
            wscript.echo "  Folder: " & oFolder.ReplicatedFolderName
            Set colRGConnections = oWMIService.ExecQuery("SELECT * FROM DfsrConnectionConfig WHERE ReplicationGroupGUID='" & oGroup.ReplicationGroupGUID & "'")
            For Each oConnection in colRGConnections
                If oConnection.Enabled = True Then
                    If oConnection.Inbound = True Then
                        if bConnectForeign then
                            numBackLog = getBackLogCount(oConnection.PartnerName, oConnection.ConnectionGUID)
                        else
                            numBackLog = getBackLogCount(strComputer, oConnection.ConnectionGUID)
                        end if
                        Wscript.echo "    " & strComputer & " <-- " & oConnection.PartnerName & " :: " & numBackLog                     Else                         numBackLog = getBackLogCount(strComputer, oConnection.ConnectionGUID)                         Wscript.echo "    " & strComputer & " --> " & oConnection.PartnerName & " :: " & numBackLog
                    End If
                End If
            Next
        Next
    Next

Function getBackLogCount(strComputer, ConnectionGUID)
    Set oWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDFS")
    Set oDfsIUI = oWMIService.ExecQuery("SELECT * FROM DfsrIdUpdateInfo WHERE ConnectionGuid = '" & ConnectionGUID & "'")
    numBacklog=0
    for each eDfsIUI in oDfsIUI
        numBackLog=numBackLog+1
    next
    getBackLogCount = numBackLog
End Function

Result:

Group: Replication1
  Folder: Folder1
    SERVER1 --> SERVER2 :: 1
    SERVER1 --> SERVER3 :: 2
    SERVER1 --> SERVER4 :: 2

Version for OMD checks:

Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputer = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

bConnectForeign = False
Wscript.echo("<<<dfs_backlog:sep(59)>>>")

    Set oWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDFS")
    Set colRGroups = oWMIService.ExecQuery("SELECT * FROM DfsrReplicationGroupConfig")
    For Each oGroup in colRGroups
        'wscript.echo "Replication Group: " & oGroup.ReplicationGroupName
        Set colRGFolders = oWMIService.ExecQuery("SELECT * FROM DfsrReplicatedFolderConfig WHERE ReplicationGroupGUID='" & oGroup.ReplicationGroupGUID & "'")
        For Each oFolder in colRGFolders
            'wscript.echo "  Folder: " & oFolder.ReplicatedFolderName
            Set colRGConnections = oWMIService.ExecQuery("SELECT * FROM DfsrConnectionConfig WHERE ReplicationGroupGUID='" & oGroup.ReplicationGroupGUID & "'")
            For Each oConnection in colRGConnections
                If oConnection.Enabled = True Then
                    If oConnection.Inbound = True Then
                        if bConnectForeign then
                            numBackLog = getBackLogCount(oConnection.PartnerName, oConnection.ConnectionGUID)
                        else
                            numBackLog = getBackLogCount(strComputer, oConnection.ConnectionGUID)
                        end if
                        Wscript.echo oFolder.ReplicatedFolderName & " ( from " & oConnection.PartnerName & ");" & numBackLog
                    Else
                        numBackLog = getBackLogCount(strComputer, oConnection.ConnectionGUID)
                        Wscript.echo oFolder.ReplicatedFolderName & " ( to " & oConnection.PartnerName & ");" & numBackLog
                    End If
                End If
            Next
        Next
    Next

Function getBackLogCount(strComputer, ConnectionGUID)
    Set oWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDFS")
    Set oDfsIUI = oWMIService.ExecQuery("SELECT * FROM DfsrIdUpdateInfo WHERE ConnectionGuid = '" & ConnectionGUID & "'")
    numBacklog=0
    for each eDfsIUI in oDfsIUI
        numBackLog=numBackLog+1
    next
    getBackLogCount = numBackLog
End Function

OMD check_mk plugin:

dfs_backlog_default_values = (5,10)

# the inventory function
def inventory_dfs_backlog(info):
   inventory = []
   for line in info:
      inventory.append( (line[0], "dfs_backlog_default_values") )

   return inventory

# the check function
def check_dfs_backlog(item, params, info):
   warn, crit = params
   for line in info:
     if line[0] == item:
       backlog = int(line[1])
       perfdata = [ ( "count", backlog, warn, crit ) ]
       if backlog > crit:
         return(2,"CRIT - Backlog count: "+line[1],perfdata)
       elif backlog > warn:
         return(1,"WARN - Backlog count: "+line[1],perfdata)
       else:
         return (0,"OK - Backlog count: "+line[1],perfdata)
   return (3, "UNKNOWN - agent output error")

# declare the check to Check_MK
check_info['dfs_backlog'] = {
    "check_function"          : check_dfs_backlog,
    "inventory_function"      : inventory_dfs_backlog,
    "service_description"     : "DFS Backlog:",
    "has_perfdata"            : True,
}

Looks like:
backlog-check_mk

Filed under: Windows 5 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
27Feb/120

Der Handy-TĂŒrklingelassistent

Jetzt fĂ€ngt ja (hoffentlich) bald die Gartensaison wieder an und wir hatten letztes Jahr immer ein kleines Problem. Wenn jemand bei uns eingeladen war hatte er an der HaustĂŒre geklingelt aber leider haben wir das nie gehört - kein Wunder, wir sitzen nichtsahnend in der Sonne und es bimmelt im 2. Stock. Da musste eine Lösung her.

Heute habe ich einen herumliegenden Axis-Videoserver, dessen VideoeingĂ€nge leider defekt sind kurzerhand zum TĂŒröffner umfunktioniert. Das Interface zwischen TĂŒröffner und Videoserver war nach einem kurzen Testlauf am Steckbrett recht schnell auf einer Lochrasterplatine verewigt. Ist im Prinzip nichts spannendes, nur zwei kleine 12V-Relais mit der entsprechenden Beschaltung zur galvanischen Trennung. Wer Interesse an der Schaltung hat, bitte kurz melden, dann werd ich sie schnell aufmalen...

Der Funktionsablauf ist folgender:

1. Person drĂŒckt den Klingelknopf
2. Das Klingelsignal der Sprechanlage wird galvanisch getrennt an den Axis-Videoserver weitergegeben
3. Dieser ruft ein PHP-Script am Asterisk-Server auf
4. Das Script startet je nach Konfiguration die Anrufe ĂŒber das Asterisk-Manager-Interface
5. Die Telefone klingeln
6. Falls jemand abnimmt löst der Asterisk-Server das TĂŒröffnerereignis am Axis-Videoserver aus - wenn niemand abnimmt passiert nichts.
7. Das TĂŒröffnersignal wird galvanisch getrennt an die Sprechanlage geleitet
8. Die HaustĂŒre öffnet  sich

Das ganze habe ich konfigurierbar gestaltet, so dass ich das Klingeln wahlweise am Handy oder am VoIP-Telefon im BĂŒro empfangen kann.

Nun spare ich mir die Hetzerei und kann, wĂ€hrend der Besucher schnaufend in den 2. Stock klettert, ganz gemĂŒtlich zur WohnungstĂŒre gehen.

Defekter Axis-Videoserver: 0€
Investierte Bauteile und Kabel: ca. 5€
Zeitaufwand: knapp 2 Stunden

Bei der Gelegenheit habe ich auch gleich das Script erweitert, so dass jedes Ereignis mit Zeitstempel in einer MySQL-Tabelle mitprotokolliert wird - mal sehen wie oft es untertags lĂ€utet 🙂

Filed under: Electronics No Comments
2Jan/120

Darf ich vorstellen: Unser Dodge Camper

Seit November 2011 sind wir stolze Besitzer eines Dodge Campers, der derzeit in Las Vegas (USA) stationiert ist.

Wir haben das Auto von Jim gekauft, der dieses Wunderwerk im Zeitraum von knapp zwei Jahren aus zwei Basisfahrzeugen und einem Camperaufsatz gebaut hat. Er hat uns uns alles Ă€ußerst vorbildlich ĂŒbergeben - wir haben zum Dodge einen 10cm dicken Pack an Unterlagen und Originalrechnungen erhalten. Im Rahmen einer 1stĂŒndigen Probefahrt hat er uns auch sehr ausfĂŒhrlich ĂŒber die Eigenheiten des Dieselmotors hingewiesen (die gibts ja in den USA nur fĂŒr Trucks) und jedes noch so kleine GerĂ€usch erklĂ€rt.

Derzeit steht das GefĂ€hrt inklusive Trailer auf einem bewachten Parkplatz in der NĂ€he des Las Vegas Boulevard und wartet darauf, dass wir wiederkommen 🙂

Filed under: Tech No Comments