MAL - Memória Auxiliar do Lutieri

segunda-feira, novembro 23, 2009

Descobrir SID de Grupos Windows

Caso você não consiga utilizar a sintaxe dominio\grupo com o ntlm-auth ou qualquer outro binário que utilize esse formato. É possível utilizar o SID do objeto.

# ntlm_auth --username=teste --password=senha --require-membership-of=domain\\gg_hr
[2009/11/23 14:45:31, 0] utils/ntlm_auth.c:get_require_membership_sid(236)
Could not parse domain\group into seperate domain/name parts!


# wbinfo -n gg_hr

S-1-5-21-2153899196-3371015479-2672548576-1129 Domain Group (2)

ou ADSI Edit do windows objectSID

Marcadores: ,

quarta-feira, novembro 11, 2009

some vbscript for Nagios checks

Detect if media is connected to a interface:



aStatusStr = Split("Disconnected,Connecting,Connected,Disconnecting," _
& "Hardware not present,Hardware disabled,Hardware malfunction," _
& "Media disconnected,Authenticating,Authentication succeeded," _
& "Authentication failed,Invalid address,Credentials required", ",")

strComputer = "."
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\cimv2")

Set cItems = oWMI.ExecQuery("Select * from Win32_NetworkAdapter"_
& " where AdapterTypeID = 0") ' 0 = Ethernet 802.3

For Each oItem in cItems
''if Instr(oItem.NetConnectionID, "LAN") > 0 then

if oItem.NetConnectionID <> "" then

output = output & oItem.NetConnectionID & ": "_
& aStatusStr(oItem.NetConnectionStatus) & " * "

End if
''End if
Next

Wsh.echo output
WScript.Quit(0)
''' Source: http://msdn.microsoft.com/en-us/library/aa394216%28VS.85%29.aspx




Detect which node is the Active and Passive in a Windows Cluster environment:



set WshShell = CreateObject( "WScript.Shell" )

Set objNet = CreateObject("WScript.NetWork")

Dim strComputerName
strComputerName = objNet.ComputerName


sExe = "cluster resource ""cluster ip address"""
with CreateObject("WScript.Shell")
with .Exec(sExe)
with .StdOut
do until .AtEndofStream
s = s & Replace(.ReadLine, vbcr, "") _
& vbNewLine
Loop
end with ' StdOut
end with ' Exec
end with ' Shell

'wsh.echo s
Result = InStr(1, s, strComputerName, VBTEXTCOMPARE)


if Result <> 0 then
WScript.echo strComputerName & " is the ACTIVE"
Else
WScript.echo strComputerName & " is the PASSIVE"
end if

WScript.Quit(0)

Marcadores: ,

quarta-feira, novembro 04, 2009

Resizing physical disk and logical volumes

This is a VM which had the HD resized. Now it's time to resize the LVM partition, actually you don't do that, you will resize the PV.


sles11_php:~ # fdisk -l /dev/sda

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0005035d

Device Boot Start End Blocks Id System
/dev/sda1 * 2 9 64260 83 Linux
/dev/sda2 10 74 522112+ 82 Linux swap / Solaris
/dev/sda3 75 1958 15133230 8e Linux LVM



Here you can see sda3 now with 15Gb

Now it's time to resize the PV



sles11_php:~ # pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name VGroot
PV Size 9.43 GB / not usable 263.50 KB
Allocatable yes
PE Size (KByte) 4096
Total PE 2414
Free PE 238
Allocated PE 2176
PV UUID LGgBQf-sw8J-fbnu-1EHL-0z1G-J31k-eAJoXc

sles11_php:~ # pvscan
PV /dev/sda3 VG VGroot lvm2 [9.43 GB / 952.00 MB free]
Total: 1 [9.43 GB] / in use: 1 [9.43 GB] / in no VG: 0 [0 ]

sles11_php:~ # pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

sles11_php:~ # pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name VGroot
PV Size 14.43 GB / not usable 2.36 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 3694
Free PE 1518
Allocated PE 2176
PV UUID LGgBQf-sw8J-fbnu-1EHL-0z1G-J31k-eAJoXc

sles11_php:~ #


sles11_php:~ # vgdisplay
--- Volume group ---
VG Name VGroot
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 6
Open LV 6
Max PV 0
Cur PV 1
Act PV 1
VG Size 14.43 GB
PE Size 4.00 MB
Total PE 3694
Alloc PE / Size 2176 / 8.50 GB
Free PE / Size 1518 / 5.93 GB
VG UUID CexmBK-uOq6-fnjo-qxFV-SIWW-04ZM-LENpdq


The VG didn't need any changes.



sles11_php:~ # lvresize -l +50%FREE /dev/VGroot/LVusr
Extending logical volume LVusr to 5.46 GB
Logical volume LVusr successfully resized



sles11_php:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VGroot-LVroot
1014M 357M 658M 36% /
udev 248M 104K 247M 1% /dev
/dev/sda1 61M 16M 42M 28% /boot
/dev/mapper/VGroot-LVhome
1014M 4.3M 1010M 1% /home
/dev/mapper/VGroot-LVopt
1014M 60M 955M 6% /opt
/dev/mapper/VGroot-LVtmp
1014M 5.5M 1009M 1% /tmp
/dev/mapper/VGroot-LVusr
2.5G 2.4G 140M 95% /usr
/dev/mapper/VGroot-LVvar
2.0G 235M 1.8G 12% /var


sles11_php:~ # xfs_growfs /usr/
meta-data=/dev/mapper/VGroot-LVusr isize=256 agcount=4, agsize=163840 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=655360, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 655360 to 1432576



sles11_php:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VGroot-LVroot
1014M 357M 658M 36% /
udev 248M 104K 247M 1% /dev
/dev/sda1 61M 16M 42M 28% /boot
/dev/mapper/VGroot-LVhome
1014M 4.3M 1010M 1% /home
/dev/mapper/VGroot-LVopt
1014M 60M 955M 6% /opt
/dev/mapper/VGroot-LVtmp
1014M 5.5M 1009M 1% /tmp
/dev/mapper/VGroot-LVusr
5.5G 2.4G 3.2G 44% /usr
/dev/mapper/VGroot-LVvar
2.0G 235M 1.8G 12% /var



Here is a list of tools you need to extend each partition's type:

http://tldp.org/HOWTO/LVM-HOWTO/extendlv.html


An excellent howto in LVM:
http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/LVM-HOWTO.html


Resizing a ext3 partition with progress bar :)

e2fsck -f -C 0 /dev/xxx


If you forget the -C 0(zero) option you can send a SIGUSR1 signal to the process, like this:

kill -SIGUSR1 e2fsc_PID


Now it's time to actually resize:

resize2fs -p /dev/xxx

Marcadores:



Chat with Lutieri G. B.

Subscribe in a reader