- Scripting with Windows PowerShell Part 1
Windows PowerShell: Working with processes, services, and event logs - Scripting with Windows PowerShell Part 2
Windows PowerShell: Sorting, grouping, and formatting output - Scripting with Windows PowerShell Part 3
Windows PowerShell: Working with Windows Management Instrumentation (WMI) information to retrieve essential information - Scripting with Windows PowerShell Part 4
Windows PowerShell: Retrieving information from remote computers - Scripting with Windows PowerShell Part 5
Windows PowerShell: Basics of converting PowerShell commands into scripts
Download and install Eclipse
Even though you will be developing Python you will still need Eclipse with the Java SDK. I think this is for 2 reasons. Firstly Python support for Eclipse is in the form of an Eclipse plug-in as opposed to a fully integrated Eclipse application and there aren't any Eclipse distributions with no (computer) language support. The other reason (I think) is that many of the development tools for Java are used for Python.
- Go to the Eclipse download page: http://download.eclipse.org/eclipse/downloads/
- From the Latest Release section download the latest version 3.6.1 (eclipse-SDK-3.6-win32.zip)
There is no installer so we will have to do it ourselves, but don't worry it's dead easy.
- Create a folder for your python development installation. You will save yourself a lot of trouble if you install the application under a directory without a space in the directory path name:
mkdir c:\python
- Unzip the downloaded zip in this folder, so you have a folder called
c:\python\eclipse
Download and install Python
There are 2 versions of Python: 2.7 and 3.1, both are considered stable but there are more compatible 3rd party libraries for 2.7 than there are for 3.1 so download that instead.
- Go to the Python download site: http://www.python.org/download/releases/2.7/
- Download the Windows MSI installer
- Install it in the default location:
c:\python27.
Download and install PyDev
Still with me? Now we're going to download the PyDev (Python plug-in for Eclipse).
- Launch Eclipse by double clicking on the eclipse executable located at:
c:\python\eclipse\eclipse.exe - When it launches for the first time, it will ask you to provide the location of the workspace, so pick a location without spaces in the path and not under the eclipse root (
c:\python\eclipse). I'm going to keep everything together and set my workspace toc:\python\workspace.
Next we are going to install the PyDev plug-in.
- From the Eclipse menu bar Help -> Install New Software...
- Click the Add button and enter the details of the PyDev repository.
- Set Name to Pydev and Pydev Extensions
- Set Location to http://pydev.org/updates
- Then click OK
- After a few seconds PyDev and PyDev Mylyn Integration (optional) will appear. Click the Select All button and then click Next.
- Eclipse will work out the dependencies (which in this case is none) and allow you to click Next again.
- Accept the licence agreements, click Finish and go and get yourself a coffee.
- There were a couple of warnings about unsigned content, so just click through these.
Configuring Eclipse and Python
Now that everything is installed we must tell Eclipse about Python.
- Go to: Window -> Preferences -> Pydev -> Interpreter - Python
- Click New...
- Enter Python 2.7 in the Interpreter Name and use the browse button and navigate to the
python.exeexecutable to fill in the Interpreter Executable field. - When you're done click Ok.
- Clicking Ok will make the Pydev perform a search for python bits.
Test Eclipse / Python installation
Now to test our installation we are going to write a little program.
- From the Eclipse menubar File -> New -> Project....
- Select PyDev -> Pydev Project, and click Next.
- Enter a Project name of HelloWorld.
- Then click Finish.
- You'll be asked about switching to the Pydev perspective, so click Yes because this will make it easier to develop under.
Before we can right real code we need a Python module to put it in.
- Highlight the HelloWorld project and from the Eclipse menu bar select File -> New -> PyDev Package.
- Set the Source Folder to /HelloWorld/src.
- Set the Name to uk.co.bigsoft.python.
- The click Finish
I have just come from developing under Java which encourages back-domain-name packages, so I have done the same here. Most Python projects are only one or two packages deep.
Next up we are going to create a module in our package.
- Highlight the
Pythonpackage and select File -> New -> Pydev module. - For the Name field enter helloworld.
- For the Template highlight Module: Main.
- Then click Finish
Next we are going to write a simple python program:
'''
Created on 6 Sep 2010
@author: MrN
'''
if __name__ == '__main__':
c = 0
a = 5
b = 2
c = a + b
print c
Now that we have a program we are going to set up the debugger.
- Hover in the margin next to line
b = 2, right click and select Add Breakpoint. This will put a green spot in the margin. - From the menu bar select Run -> Debug.
- If the Debug As window pops up asking you to Select a way to debug 'helloworld.py', then select Python Run, and then click Ok.
- This will ask us if we want to open a Debug perspective, so click Yes and Remember my decision otherwise it will keep pestering you.
The program will launch in the debug perspective and stop at the breakpointed line (indicated with the green spot). On the right hand side make sure the Variables tab is showing and it will have our 2 variables defined: a and c valued at 5 and 0 respectively. Repeating Run -> Step over will progress the run line by one line of code.
Well done.
MSIA, CISSP, CISA graduated from the Master of Science in Information Assurance (MSIA) program from Norwich University in 2009Let’s take a look at the qualifications: Source: Master of Science in Information Assurance program information from Norwich University website:
The Master of Science in Information Assurance (MSIA) program provides students with a comprehensive exploration of the information security life cycle and its growing importance to an organization in achieving its strategic and tactical objectives. Knowledge and skills students gain from the program will enhance their capability as information security practitioners; will support their growth toward upper management and executive positions such as chief information security officer (CISOs) and chief risk managers; and will enable them to promote best practices through effective communication with C-level executives.Source: International Information Systems Security Certification Consortium, Inc
Certified Information Systems Security Professional If you plan to build a career in information security – one of today’s most visible professions – and if you have at least five full years of experience in information security, then the CISSP® credential should be your next career goal. It’s the credential for professionals who develop policies and procedures in information security. The CISSP was the first credential in the field of information security, accredited by the ANSI (American National Standards Institute) to ISO (International Organization for Standardization) Standard 17024:2003. CISSP certification is not only an objective measure of excellence, but a globally recognized standard of achievement.Source: Wikipedia
Certified Information Systems Auditor (CISA) is a professional certification for information technology audit professionals sponsored by ISACA, formerly the Information Systems Audit and Control Association. Candidates for the certification must meet requirements set by ISACANorwich University (Northfield, Vermont, U.S.A) looks like [from their website] a standard military university established in 1819. Quite impressive! And yet with all these qualifications, he writes an article on what a £29.95 piece of software tells him and nothing else. If he had open the now infamous
c:\windows\SL directory he would have seen that it didn’t contain the StarLogger application because any security consultant worth his salts could have identified what that looks like. It’s nice to see that his $50,000 education didn’t go to waste.
Samsumg have been very quick to tackle this libel, but mud sticks and they will probably unduly suffer because of this.Bad Request! The parameters of your request are invalid. If you have obtained this error by clicking on a link INSIDE of this site, please report the bad link to the administrator. Go back to home page Additional information about this error: Illegal value received for parameter «p»!The site seemed to display normally but when I clicked on any of the links the message came up. I did a bit of hunting for the Illegal value received for parameter string and found it in the
inc/_core/_param.funcs.php file. Had a look in the file and thought that the following bit of code was causing the problem so I added a line of debug:
elseif( !empty( $regexp ) && ( !is_scalar($GLOBALS[$var]) || !preg_match( $regexp, $GLOBALS[$var] ) ) )
{ // Value does not match!
echo "var=".$var."|regexp=".$regexp."|GLOBALS=".$GLOBALS[$var]."|";
bad_request_die( sprintf( T_('Illegal value received for parameter «%s»!'), $var ) );
}
Sure enough refreshing the page produced a line of debug:
var=p|regexp=/^(\+|-)?[0-9]+$/|GLOBALS=/path/to/host/web|I recognised the variable
p as an environment variable I had set during the work I was doing prior to the web server restart. So to correct the problem I stopped the web server, unset the environment variable and restarted the web server.
# /etc/init.d/httpd stop Stopping httpd: [ OK ] # unset p # /etc/init.d/httpd startThis bizarre behaviour had come about with a combination of two
php.ini configuration options being set. Firstly variables_order included the “E” option to include environment variables and register_globals was switched on to put those variables into the global address space. There is a note about this behaviour in the PHP documentation where it talks about variables_order.
It was just a bit of a surprise that it broke my installation. These days register_globals is switched off by default for security reasons, so it wasn’t a problem to turn it off.dmesg. The bit we are interested in begins with SCSI device. Here is an example:
SCSI device sda: 488397168 512-byte hdwr sectors ( 250059 MB ) sda: Write Protect is off sda: Mode Sense: 00 3a 00 00 SCSI device sda: drive cache: write back sda: sda1 sda2 sda3The first line describes the size of the physical hard drive. Don’t worry about the other stuff because it is the final line we are interested in. It shows that the
sda drive has 3 partitions: sda1, sda2 and sda3. If we look a bit further down the file we can see there is a similar set up sdb which also has 3 partitions: sdb1, sdb2 and sdb3.
The next section in dmesg output talks about setting up the disk partitions to mirror each other. md3 is made of:
md: created md3 md: bind<sda3> md: bind<sdb3> md: running: <sdb3><sda3>and md1 is made of:
md: created md1 md: bind<sda1> md: bind<sdb1> md: running: <sdb1><sda1>Further down we can see:
2. Priority:-1 extents:1 across:1959920k Adding 1959920k swap on /dev/sdb2. Priority:-2 extents:1 across:1959920kwhich shows that our 2 remaining partitions are used as swap space. The 1&1 default image set up contains the following pre-configured partitions:
# df -h Filesystem Size Used Avail Use% Mounted on /dev/md1 3.7G 332M 3.4G 9% / /dev/mapper/vg00-usr 4.0G 1.1G 3.0G 26% /usr /dev/mapper/vg00-var 4.0G 2.1G 2.0G 52% /var /dev/mapper/vg00-home 4.0G 2.1G 2.0G 51% /home
/dev/md1 is accounted for as the root partition so /dev/md3 must be the drive which is backing our logical volume. As you can see only 12GB is being used so there is still about 215GB which is unallocated.
We can confirm this with the vgs command, which shows that there is 215GB free. Even though they are mirrored 250GB drives we lose about 20GB to the file system indexes. :(
# vgs VG #PV #LV #SN Attr VSize VFree vg00 1 3 0 wz–n- 227.28G 215.28GNow that we have finished all the checks, we now know that there aren’t any more physical drives or logical volumes that are unaccounted for. On my system there are quite a lot of databases so I need to either increase the
/var partition or create a new partition that I can place under /var/lib/mysql.
Having read all the documentation it’s pretty easy to do either. My unix administration background is erring me on the side of a new logical partition. The nice thing about LVM is that you can always change your mind later. If I create a new partition then it will free up space in my /var partition so I won’t have to extend it for a while.
I will start by showing you how to resize an existing logical volume. I’m using CentOS 5 which has symbolic links to the lvm command making it somewhat simpler.
# ls -l /usr/sbin/vgdisplay lrwxrwxrwx 1 root root 3 Jan 31 22:00 /usr/sbin/vgdisplay -> lvmThis means I can type vgdisplay instead of lvm vgdisplay so in the instructions below I’ll be using the short versions of the commands. The logical volumes can be extended (or reduced) in units of Extends which are defined when the volume group is set up. We must see how much we can extend the logical volume by, so let’s check the volume group and see how many we have left.
# vgdisplay — Volume group — VG Name vg00 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 227.28 GB PE Size 4.00 MB Total PE 58184 Alloc PE / Size 3072 / 12.00 GB Free PE / Size 55112 / 215.28 GB VG UUID t5aC2D-DWv9-Dh5s-Hz2c-dzIH-oSxX-4jMjwoHere we can see that a Physical Extend is 4MB and we have 55112 of them which are unallocated. Next we need to look at what I have in my current /var logical partition:
# lvdisplay /dev/mapper/vg00-var — Logical volume — LV Name /dev/vg00/var VG Name vg00 LV UUID xRq5Oj-Y41X-M6VK-s2es-nCOT-dDFF-X0Sznp LV Write Access read/write LV Status available # open 1 LV Size 4.00 GB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1The Logical Extend and the Physical Extend are the same size, but I’m sure there is a reason why they have different names (anyone?). From the read out above you can see that we have 1024 extends. So if I wanted to extend the partition by 6GB making it 10GB in size I would have to increase the extends to 10240. To extend the logical partition I issue the command:
# lvm lvresize -l 10240 /dev/mapper/vg00-var Extending logical volume vg00 to 10.0 GB Logical volume vg00 successfully resizedThe logical volume is now bigger but the file system that lives in it is still the same size, so we need to update it. Under CentOS 5 we can resize the filing system without unmounting it, which is really handy because there are loads of programs running which have open files on the
/var partition. The command is simple:
# resize2fs /dev/mapper/vg00-varNote: I just tried this and it didn’t work. The CentOS documentations says the the code for ext2online (which was the old method of extending ext2/ext3 file systems) had been merged into resize2fs. My system uses xfs and not ext2/ext3 so I had to use:
xfs_growfs /dev/vg00/varThe command gives you the following output, which is very similar to what you get when you are creating the xfs filesystem.
meta-data=/dev/vg00/var isize=256 agcount=4, agsize=262144 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=1048576, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
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 1048576 to 2097152
I have decided to create a brand new logical volume that I can resize independently. The logical volume group already exists so I don’t need to create that.
Even though I have 2 physical disks they are joined together as 1 mirror and used as 1 entity in the volume group so I can’t specify the -i option to have the volume group manager organise writes to both disks. I don’t think it matters it you do the mirroring up in the volume group level or on the disk partition level.
We issue the logical volume create command and set it to 10GB
# lvcreate -n mysql -L10G vg00 Logical volume “mysql” createdA quick check shows that everything is ok:
# ls -l /dev/mapper/ total 0 crw——- 1 root root 10, 63 Jan 31 22:30 control brw-rw—- 1 root disk 253, 2 Jan 31 22:31 vg00-home brw-rw—- 1 root disk 253, 3 Feb 7 21:11 vg00-mysql brw-rw—- 1 root disk 253, 0 Jan 31 22:31 vg00-usr brw-rw—- 1 root disk 253, 1 Jan 31 22:31 vg00-var # lvdisplay /dev/mapper/vg00-mysql — Logical volume — LV Name /dev/vg00/mysql VG Name vg00 LV UUID LQpgnU-Of2d-y3LP-Mj2n-0FH1-CaGd-1OW0kQ LV Write Access read/write LV Status available # open 0 LV Size 10.00 GB Current LE 2560 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:3Note: I tried to create a logical volume called “scratch-backup", but when I checked the
/dev/mapper it listed the group name as vg00-scratch--backup. In my opinion anything unexpected is bad so I want to delete this logical volume and pick a different name.
lvremove /dev/mapper/vg00-scratch–backupThis new logical volume is blank so I need to create a file system in it. Not sure of all the magic options so I’ll let the system use its defaults:
# mkfs -t xfs /dev/vg00/mysql
meta-data=/dev/vg00/mysql isize=256 agcount=16, agsize=163840 blks
= sectsz=512 attr=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal log bsize=4096 blocks=2560, version=1
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
The final disk test is to make sure we can mount it into the file system.
# mount /dev/vg00/mysql /mnt # df -h Filesystem Size Used Avail Use% Mounted on /dev/md1 3.7G 332M 3.4G 9% / /dev/mapper/vg00-usr 4.0G 1.1G 3.0G 26% /usr /dev/mapper/vg00-var 4.0G 2.1G 2.0G 52% /var /dev/mapper/vg00-home 4.0G 2.1G 2.0G 51% /home /dev/mapper/vg00-mysql 10G 4.6M 10G 1% /mntI want this file system to be mounted when the machine boot’s up so I must add it into the
/etc/fstab file. Now I can start the process of copying my existing databases into the new partition and we are done.
Primary documentation site for LVM
http://tldp.org/HOWTO/LVM-HOWTO/commontask.html
Resize instructions
http://wiki.centos.org/TipsAndTricks/ExpandLV
Clear(ish) description of concepts but mainly talks about the management via the system GUI.
http://www.linuxtopia.org/online_books/centos5/centos5_administration_guide/centos5_ch-lvm.html
Some 1&1 documentation has finally materialised!
http://faq.1and1.co.uk/server/root_server/linux_admin_help/7.html