Saturday 26 April 2014

Linux NIC Bonding/Teaming

Linux NIC Bonding/Teaming

Bonding is nothing but Linux kernel feature that allows to aggregate multiple like interfaces (such as eth0, eth1) into a single virtual link such as bond0. The idea is pretty simple get higher data rates and as well as link failover.

The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical "bonded" interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed.

Step #1: Create a Bond0 Configuration File

Red Hat Enterprise Linux (and its clone such as CentOS) stores network configuration in /etc/sysconfig/network-scripts/ directory. First, you need to create a bond0 config file as follows:
# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Append the following lines:
DEVICE=bond0
IPADDR=192.168.1.110
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
You need to replace IP address with your actual setup. Save and close the file.

Step #2: Modify eth0 and eth1 config files

Open both configuration using a text editor such as vi/vim, and make sure file read as follows for eth0 interface.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Modify/append directive as follows:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none




Open eth1 configuration file using vi text editor, enter:


# vi /etc/sysconfig/network-scripts/ifcfg-eth1



Make sure file read as follows for eth1 interface:
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

Save and close the file.

Step # 3: Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. You need to modify kernel modules configuration file:
# vi /etc/modprobe.conf
Append following two lines:
alias bond0 bonding
options bond0 mode=balance-alb miimon=100

Save file and exit to shell prompt.

Step # 4: Test configuration

First, load the bonding module, enter:
# modprobe bonding
Restart the networking service in order to bring up bond0 interface, enter:
# service network restart
Make sure everything is working. Query the current status of Linux kernel bounding driver.
# cat /proc/net/bonding/bond0



Sample outputs:
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63
To kist all network interfaces, enter:
# ifconfig
Sample outputs:
bond0     Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
  inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
  inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
  UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
  RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
  TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:0
  RX bytes:250825 (244.9 KiB)  TX bytes:244683 (238.9 KiB)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
  inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
  inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
  UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
  RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
  TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:251161 (245.2 KiB)  TX bytes:180289 (176.0 KiB)
  Interrupt:11 Base address:0x1400
eth1      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
  inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
  inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
  UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
  RX packets:4 errors:0 dropped:0 overruns:0 frame:0
  TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:258 (258.0 b)  TX bytes:66516 (64.9 KiB)
  Interrupt:10 Base address:0x1480

Wednesday 9 April 2014

iSCSI(Internet Small Computer System Interface)

iSCSI(Internet Small Computer System Interface)

iSCSI is Internet SCSI (Small Computer System Interface), an Internet Protocol (IP)-based storage networking standard for linking data storage facilities, developed by the Internet Engineering Task Force (IETF). By carrying SCSI commands over IP networks, iSCSI is used to facilitate data transfers over intranets and to manage storage over long distances. The iSCSI protocol is among the key technologies expected to help bring about rapid development of the storage area network (SAN) market, by increasing the capabilities and performance of storage data transmission. Because of the ubiquity of IP networks, iSCSI can be used to transmit data over local area networks (LANs), wide area networks (WANs), or the Internet and can enable location-independent data storage and retrieval.

How iSCSI works:

When an end user or application sends a request, the operating system generates the appropriate SCSI commands and data request, which then go through encapsulation and, if necessary, encryption procedures. A packet header is added before the resulting IP packets are transmitted over an Ethernet connection. When a packet is received, it is decrypted (if it was encrypted before transmission), and disassembled, separating the SCSI commands and request. The SCSI commands are sent on to the SCSI controller, and from there to the SCSI storage device. Because iSCSI is bi-directional, the protocol can also be used to return data in response to the original request.
iSCSI is one of two main approaches to storage data transmission over IP networks; the other method, Fibre Channel over IP (FCIP), translates Fibre Channel control codes and data into IP packets for transmission between geographically distant Fibre Channel SANs. FCIP (also known as Fibre Channel tunnelingor storage tunneling) can only be used in conjunction with Fibre Channel technology; in comparison, iSCSI can run over existing Ethernet networks. A number of vendors, including Cisco, IBM, and Nishan have introduced iSCSI-based products (such as switches and routers).

Initiator:

The initiator is the name of the iscsi client. The iscsi client has a block level access to the iscsi devices, which can be a disk,one client can use multiple iscsi devices.

Target:

The target is the name of the iSCSI server. The iSCSI server offers its devices (disks, tape... etc.) to the clients. One device can by accessed by one client.

Discovery:

Discovery is the process which shows the targets for the initiator.

Discovery Method:

Internet Storage Name Service (iSNS) - Potential targets are discovered by interacting with one or more iSNS servers.
SendTargets – Potential targets are discovered by using a discovery-address.
SLP - Discover targets via Service Location protocol (RFC 4018)
Static – Static target address is specified.

ISCSI Naming:

The iSCSI name consists of two parts: type string and unique name string.
The type string can be the following:
iqn. : iscsi qualifiled name
eui. : eui-64 bit identifier
Most of the implementations use the iqn format. Let'S see our initiator name:
iqn.1993-08.com.redhat:01.35ef13adb6d
1. iqn: we use iSCSI qualified name address.
2. 1993-08: the year of the month on which the naming authority acquired the domain name which is used in the iSCSI name.
3. com.redhat: reversed dns name which defines the organizational naming authority.
4. 01.35ef13adb6d : this string is defined by the naming authority each disk will have unique string.




Before starting the iSCSI target configuration we need to have a partition which we need to use through the network. For this we need to create a partition using fdisk, parted or lvm.

(root)# fdisk -cu /dev/sdb

n - Create a new partition
1 - Select the number of the partition to be created depending on the layout
p/e - Select partition type
w - Write the changes to disk and exit.

(root)# partx -a /dev/sdb

iSCSI TARGET(server) CONFIG

To configure a iSCSI server you need to install the below package.
# yum install scsi-target-utils* -y

Edit the iSCSI target(server) config file to create a target
# vim /etc/tgt/targets.conf
####Copy line 31,32,33 and paste at end
<target iqn.2012-02.com.example:desktop26.target1>
backing-store /dev/sdb1
initiator-address 192.168.0.26
</target>
wq!

Explanation of the target conf file:
Line 1 : iqn.<year.month(in which we get our domain name or else we can use the current)>.com.hindux:<hostname>.<target_number>

Line 2 : backing-store  /dev/sdb1   --> The partition which we have created for utilizing as iSCSI
Line 3 : initiator-address 192.168.0.26   --> IP of the server on which we are configuring the ISCSI server.
Line 4 : </target>   --> Ending tag.


# service tgtd restart     --->     Restart the tgtd(iscsi target) service
# chkconfig tgtd on       --->     Turn on at startup
# tgt-admin --show | less     ---> Verify whether it is configured or not.

iSCSI INITIATOR(client)CONFIG:

To configure an iSCSI initiator(client) we need to install the below mentioned package.
# yum install iscsi-initiator-utils* -y

Restart the iscsi initiator service
# service iscsi start
If it doesn't work try this
# service iscsid force-start
# chkconfig iscsi on

To get the iqn name of the target we need to discover the target by using the following command.
# iscsiadm -m discovery -t st -p 192.168.0.25
192.168.0.25:3260,1 iqn.2012-02.com.example:desktop26.target1

After getting the iqn we need to configure the Initiator by editing the below config file.
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2012-02.com.example:desktop26.target1
:wq!

 After configuring the initiator we need to login to the target by using the following command.
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -l

 Now we need to know what is the name of the partition we get from the target. By using the below command we can get the name of the partition. After the name we can see the details of the partition and can mount the partition on to a directory and also we need to add an entry to the /etc/fstab file for permanent mounting. But we should remember to mention _netdev as it is a network storage.
# tail /var/log/messages | grep --color 'sd[a-z]'
# fdisk -l |less
# fdisk /dev/sdb
# cat /proc/partitions
# mkfs.ext4 /dev/sdb1
# blkid /dev/sdb1
# vim /etc/fstab
UUID="4e9de845-514e-430d-8d1b-51fb7bb0803e" /mnt/iscsi ext4 _netdev 0 0
:wq!

Note: Before rebooting always logout from Target(server) by using this command
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -u


Note: To Disconnect from iSCSI Target permanently remove entry from fstab then log out from Target and then clean/delete iSCSI information.
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -u
# iscsiadm -m node -T iqn.2012-02.com.example:desktop26.target1 -p 192.168.0.25 -o delete

Sunday 6 April 2014

PS_08_Perl - Subroutines and Functions

Subroutines and Functions

Subroutines are defined in Perl as:

        sub subname {
                statement_1;
                statement_2;
        }

Subroutine definitions are global; there are no local subroutines.

Invoking subroutines
The ampersand (&) is the identifier used to call subroutines. They may also be called by appended parentheses to the subroutine name:

        name();
        &name;

You may use the explicit return statement to return a value and leave the subroutine at any point.

        sub myfunc {
                statement_1;
                if (condition) return $val;
                        statement_2;
                return $val;
        }

Passing arguments
Arguments to a subroutine are passed as a single, flat list of scalars, and return values are passed the same way. Any arguments passed to a subroutine come in as @_. To pass lists of hashes, it is necessary to pass references to them:

        @returnlist = ref_conversion(\@inlist, \%inhash);

The subroutine will have to dereference the arguments in order to access the data values they represent.

        sub myfunc {
                my($inlistref,$inhashref) = @_;
                my(@inlist) = @$inlistref;
                my(%inhash) = %$inhashref;
                statements;
                return @result;
        }

Prototypes allow you to design your subroutines to take arguments with constraints on the number of parameters and types of data.

Variable Scope
Any variables used in a subroutine that aren’t declared private are global variables.
The my function declares variables that are lexically scoped within the subroutine. This means that they are private variables that only exist within the block or routine in which they are called. The local function declares variables that are dynamic. This means that they have global scope, but have temporary values within the subroutine. Most of the time, use my to localize variables within a subroutine.

Saturday 5 April 2014

Setup a Linux router server using GNU Zebra

Setup a Linux router server using GNU Zebra

This artical will let you know how to install, set up, and use Zebra to build a Linux system that can serve as an OSPF and BGP router.

You’ve no doubt heard of routers from giants such as Cisco and Nortel, but what about Linux? While Linux has become an increasingly viable option as a server, few realize its potential as a full-featured router. With GNU Zebra, your Linux box can act as a router supporting TCP/IP protocols such as RIPv1, RIPv2, RIPng, OSPFv2, OSPFv3, BGP-4, and BGP-4+. I'm going to show you how to install, configure, and use Zebra to turn a Linux box into an OSPF and BGP router.

Building an advanced router
If you have set up a Linux box as a firewall, you have already built a simple Linux router. However, we're going to look at using Linux to build an advanced router that can communicate using dynamic routing protocols. These protocols allow routers to speak to each other and share information of paths through a network. This is incredibly important in large networks (such as the Internet), where static routing is impractical.

For example, even with route summarization (where only the largest possible block is advertised), a single Border Gateway Protocol (BGP) routing table still contains over 100,000 entries. The sheer number of entries, combined with the rate of change, makes static route assignment impossible. The need for dynamic routing protocols is obvious, even with networks smaller than the Internet, such as large corporate networks.

While BGP, an External Gateway Protocol (EGP), is the workhorse of the Internet, others are better suited for use on smaller internetworks. The Open Shortest Path First (OSPF) protocol is an Internal Gateway Protocol (IGP) and is one of the most widely used. GNU Zebra is an open source software package that allows you to run BGP and/or OSPF on Linux.

Installing Zebra
You can download the latest source version of Zebra from Zebra.org. Distribution-specific packages are also available from a number of sources, including Redhat and Debian. If you're installing from source, you will find that the standard installation procedure is applicable. Simply extract the package and run:
(root)# ./configure
(root)# make
(root)# make install


The configuration script will detect what IP stacks are installed on your system and automatically configure support for them. In today’s environment, this will most likely mean just IPv4, but IPv6 users will be pleased to know that Zebra will detect and support it as well.

Once you have installed the program, it may be necessary to add some lines to /etc/services. Zebra’s daemons operate on their own virtual terminal lines (VTYs), so your system needs to know what they are. Here are the lines you should add:
zebrasrv 2600/tcp # zebra service
zebra 2601/tcp # zebra vty
ripd 2602/tcp # RIPd vty
ripngd 2603/tcp # RIPngd vty
ospfd 2604/tcp # OSPFd vty
bgpd 2605/tcp # BGPd vty
ospf6d 2606/tcp # OSPF6d vty

Configuring Zebra
If you’re familiar with the Cisco IOS, you shouldn't have any problems getting Zebra up and running in a short amount of time. Each of Zebra’s daemons uses a separate VTY to allow dynamic configuration through a Telnet session. So, if you need to configure OSPF, simply Telnet to port 2604 on the Linux box. To modify the kernel’s routing table or to configure redistribution between routing protocols, you should Telnet to port 2601. This is the Zebra daemon, which acts as a kernel manager handling communication between the other daemons and the system itself.

Let’s take a look at how we would get OSPF and BGP up and running on a test server. Zebra’s daemons use plain text files to store their configurations. For our OSPF/BGP router there will be three files used: zebra.conf, ospfd.conf, and bgpd.conf. The zebra.conf file, for instance, will look something like this:


! Zebra configuration saved from vty
! 2002/02/28 01:46:12
!
hostname LinuxRouter
password zebra
enable password z3bRa
log file /var/log/zebra/zebra.log
!
interface eth0
description Interface to External Network
ip address 10.0.0.1/24
!
interface eth1
description Interface to Internal Network
ip address 192.168.66.1/24

The exclamation points serve as comment markers or spacers. The rest of the configuration should be more or less self-explanatory. There are a number of different types of network interfaces (Ethernet, ISDN, etc.), and Zebra can use any that are recognized by the Linux kernel.

Subnet masking is done with network bits (e.g., /24) as opposed to the full mask, which in this case would be 255.255.255.0. Also note that there are two passwords, one for user mode and one for privileged mode. This is useful for providing access to nonadministrators, and it's critical if you are creating a route server or looking glass. Any BGP admin will tell you that looking glasses are a key to troubleshooting routing issues, as they allow you to view routes as seen from an outside AS’s point of view. (AS stands for Autonomous System—basically, a group of devices under the same policy or administration.) BGP routing is done by AS numbers, which are registered numbers controlled by the American Registry for Internet Numbers (ARIN).

The next step is to start the necessary programs. You can do this with the following commands:


(root)# /usr/sbin/zebra –dk
(root)# /usr/sbin/ospfd –d
(root)# /usr/sbin/bgpd –d

In the first command, we start zebra, the daemon that will actually update the kernel’s routing table. The –dk tells the program to run as a daemon (the d), basically keeping it in the background. The k is an additional option that tells Zebra to keep any routes that are already configured on the box. This is useful if you are testing Zebra and do not want to wipe out your routing table accidentally. Normally, routes and interfaces are configured with a combination of the ifconfig and route commands. Zebra is a complete replacement for this form of route management.

Setting up OSPF
Now that the necessary services are running, Telnet to port 2604 on the local machine to begin the OSPF configuration. Enter privileged mode by typing enable (just as you would in the Cisco IOS) and then enter the privileged mode password. Next, configuration mode is accessed with the configuration terminal command. Zebra will also accept abbreviations in keeping with its similarity to Cisco. Also accepted are the list and ? entries, which provide a menu of possible commands and a short explanation.

You will also be pleased to see that tab completion is supported. This is a nice feature, especially if you are accustomed to using it. Next, we will need to tell the daemon what networks are going to be advertised via OSPF, along with the associated area. OSPF supports multiple areas to provide scalability. Enter the OSPF configuration by typing router ospf and then network 192.168.66.0/24 area 0. This tells the router that we are going to use OSPF to advertise the 192.168.66.0 network with a subnet mask of 255.255.255.0.

In this example, we are also going to make interface eth0 a passive interface so that routing updates will not be sent out of it. This is important for testing purposes when other routers in that direction may be listening. You can do this with the command passive-interface eth0. Once you have made your changes, exit out of configuration mode by typing end and then save it with the write file command. Here is a snapshot of what this will look like:


labrat:~# telnet 0 2604
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.

Hello, this is zebra (version 0.84b)
Copyright 1996-2000 Kunihiro Ishiguro

User Access Verification

Password:
ospfd> enable
Password:
ospfd# configure terminal
ospfd(config)# router ospf
ospfd(config-router)# network 192.168.66.0/24 area 0
ospfd(config-router)# passive-interface eth0
ospfd(config-router)# end
ospfd# write file
Configuration saved to /etc/zebra/ospfd.conf

Remember that for OSPF or BGP to operate over an interface, that interface needs to be up. To manually bring up an interface, log in to port 2601 and execute a no shut command on the appropriate interface.

Setting up BGP
BGP is configured in much the same way as OSPF. To begin, open a Telnet session to port 2605. After executing configure terminal, enter BGP configuration mode by typing router bgp <AS #>. As mentioned previously, BGP uses AS numbers to establish neighbor relationships and route traffic. In our test environment, we will be using a private AS number, which can range from 64512 to 65534. The networks to be advertised by BGP are then installed with the network command. There are no trailing area options in BGP, so our command would be network 192.168.66.0/24. Unlike OSPF, BGP neighbors need to be statically assigned. You do this as follows: neighbor <neighbor IP> remote-as <remote AS #>. Here is an example of what this will look like:


labrat:~# telnet 0 2605
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.

Hello, this is zebra (version 0.84b)
Copyright 1996-2000 Kunihiro Ishiguro

User Access Verification

Password:
bgpd> enable
Password:
bgpd# configure terminal
bgpd(config)# router bgp 65530
bgpd(config-router)# network 192.168.66.0/24
bgpd(config-router)# neighbor 10.0.0.5 remote-as 65531
bgpd(config-router)# end
bgpd# write file
Configuration saved to /etc/zebra/bgpd.conf

With both OSPF and BGP, there are a great number of options—enough to be outside the scope of this article. I recommend doing a little studying about each protocol prior to working with it in a production environment. The GNU Zebra documentation can also help in this regard.

Summary
Networking includes a variety of options for routing traffic. When it comes to routers, many hardware options are available, but they can be expensive—reason enough to look at turning a Linux system into a fully functional router. The Zebra suite of routing daemons makes this a possibility. With support for IPv4, IPv6, and a wide variety of protocols, Zebra can address all your routing needs. It also takes advantage of the experience and knowledge that many admins have already gained in working with Cisco IOS-based routers.

Friday 4 April 2014

PS_07_Perl - Pattern Matching

Pattern Matching

Regular Expressions
Regular expressions are patterns to be matched against a string. The two basic operations performed using patterns are matching and substitution:

Matching /pattern/
Substitution s /pattern/newstring/

The simplest kind of regular expression is a literal string. More complicated expressions include metacharacters to represent other characters or combinations of them. The […] construct is used to list a set of characters (a character class) of which one will match. Ranges of characters are denoted with a hyphen (-), and a negation is denoted with a circumflex (^). Examples of character classes are shown below:

[a-zA-Z] Any single letter
[0-9] Any digit
[^0-9] Any character not a digit

Some common character classes have their own predefined symbols:
Code Matches
. Any character
\d A digit, such as [0-9]
\D A nondigit, same as [^0-9]
\w A word character (alphanumeric) [a-zA-Z_0-9]
\W A nonword character [^a-zA-Z_0-9]
\s A whitespace character [ \t\n\r\f]
\S A non-whitespace character [^ \t\n\r\f]

Regular expressions also allow for the use of both variable interpolation and backslashed representations of certain characters:
Code Matches
\n Newline
\r Carriage return
\t Tab
\f Formfeed
\/ Literal forward slash

Anchors don’t match any characters; they match places within a string.
Assertion Meaning
^ Matches at the beginning of string
$ Matches at the end of string
\b Matches on word boundary
\B Matches except at word boundary
\A Matches at the beginning of string
\Z Matches at the end of string or before a newline
\z Matches only at the end of string

Quantifiers are used to specify how many instances of the previous element can match.
Maximal Minimal Allowed Range
{n,m} {n,m}? Must occur at least n times, but no more than m times
{n,} {n,}? Must occur at least n times
{n} {n}? Must match exactly n times
* *? 0 or more times (same as {0,})
+ +? 1 or more times (same as {1,})
? ?? 0 or 1 time (same as {0,1})

It is important to note that quantifiers are greedy by nature. If two quantified patterns are represented in the same regular expression, the leftmost is greediest. To force your quantifiers to be non-greedy, append a question mark.

If you are looking for two possible patterns in a string, you can use the alternation operator (|). For example,
/you|me|him|her/;
will match against any one of these four words. You may also use parentheses to provide boundaries for alternation:
/And(y|rew)/;
will match either “Andy” or “Andrew”.

Parentheses are used to group characters and expressions. They also have the effect of “remembering” parts of a matched pattern for further processing. To recall the “memorized” portion of the string, include a backslash followed by an integer representing the location of the parentheses in the expression:
/fred(.)barney\1/;

Outside of the expression, these “memorized” portions are accessible as the special variables $1, $2, $3, etc. Other special variables are as follows:
$& Part of string matching regexp
$` Part of string before the match
$’ Part of string after the match

Regular expression grouping precedence
Parentheses () (?: )
Quantifiers ? + * {m,n} ?? +? *?
Sequence and abc ^ $ \A \Z (?= ) (?! )
anchoring
Alternation |

To select a target for matching/substitution other than the default variable ($_), use the =~ operator:
$var =~ /pattern/;

Operators

m/pattern/gimosx
The “match” operator searches a string for a pattern match. The preceding “m” is usually omitted. The trailing modifiers are as follows
Modifier
Meaning
g
Match globally; find all occurrences
i
Do case-insensitive matching
m
Treat string as multiple lines
o
Only compile pattern once
s
Treat string as a single line
x
Use extended regular expressions

s/pattern/replacement/egimosx
Searches a string for a pattern, and replaces any match with replacement. The
trailing modifiers are all the same as for the match operator, with the exception of “e”, which evaluates the right-hand side as an expression. The substitution operator works on the default variable ($_), unless the =~ operator changes the target to another variable.

tr/pattern1/pattern2/cds
This operator scans a string and, character by character, replaces any characters matching pattern1 with those from pattern2. Trailing modifiers are:
Modifier
Meaning
c
Complement pattern1
d
Delete found but unreplaced characters
s
Squash duplicated replaced characters
This can be used to force letters to all uppercase:
tr/a-z/A-Z/;

@fields = split(pattern,$input);
Split looks for occurrences of a regular expression and breaks the input string at those points. Without any arguments, split breaks on the whitespace in $_:
@words = split; is equivalent to
@words = split(/\s+/,$_);

$output = join($delimiter,@inlist);
Join, the complement of split, takes a list of values and glues them together with the provided delimiting string.

Wednesday 2 April 2014

IT Stress Management

Study on managing stress being faced by IT Professionals

The present article is concerned with how the Information technology and the consequent change in job culture affect work stress, mental health IT professionals. This is particularly relevant because jobs in Information technology are the most coveted one in modern India, and the most brilliant section of the youth are going for it. Some indentified that the key factors at the workplace which generate stress among IT personnel in Singapore. It was suggested that factors which generate stress be grouped into 4 broad categories as Lack of career advancement related to the problem of high rate of employee turnover, Work overload resulting in spillover of workload at home and guilt and dissatisfaction for being less attentive to family, Risk taking and decision making consisting of fear of making mistakes and Employee morale and organizational culture related to a lack of participation in decisions affecting their work, undue blame for machine failure and difficulty in team work considering the fluid and noninvolved nature of work. In a study on Work Stress among Information Systems Professionals it was found that employees reported the commonly experienced feelings such as frustration, pride in accomplishments, being overwhelmed, anxiety and common stress symptoms decrease in energy, anxiety, muscle tension, headache, stomach upset, negative thinking and insomnia thus both positive and negative effects were reported. It was discussed that employee's difficulties with stress within organization that continually introduce new technology and computer software into the work environment . Symptoms of stress are reviewed and employer and employee options to reduce stress are examined. The present study takes a holistic view of personhood and considers job stress as one imposed upon and interacting with other stressors. Therefore the study focuses on psychological distress, sense of wellness and organizational role stress of IT professionals as associated with stressful life events and coping resources. Very few studies have been obtained in this area. In India there is a virtual gap in study of this sector. Psychological distress in the present context has been defined as the overall feeling of anxiety, depression, and stress related somatization. It is the feeling of ill-being associated with various types and phases of mental illness. Wellness has been defined as a subjective feeling of being in a positive state of existence. Recent literature on mental health repeatedly emphasizes that absence of illness and presence of wellness are not synonymous: these have been found to be slightly and negatively correlated. Nadeem investigated Among different occupational stress variables role over load, role authority, role conflict and lack of senior level support contribute more to the occupational stress. He concluded that Bank employees cannot afford the time to relax and “wind down” when they are faced with work variety, discrimination, favoritism, delegation and conflicting tasks.

Here is a small exercise which helps to overcome stress which is being experienced us due to our day-to-day tasks.

Relaxation: The Gateway to Your
Mind Power
Before you start to develop your new skill of harnessing your subconscious mind power, there’s another skill you need to learn. While learning and performing it are extremely easy, it is very important to the process. It’s called relaxation. Before you begin an affirmation session, you want to relax your body because you also want to relax your mind…clear all the junk out of the way and get your brain wave activity to a minimum so you can focus on the ONE thing on which you want to focus. The subconscious mind is more susceptible to receiving and acting upon suggestions when it is relaxed and focused on that one thing.

Here is how I do my relaxation. First, I put on some very relaxing music. This is optional. Try using music at first to see if it helps you relax. If you relax better without it, don’t use music. But you want your surroundings to be quiet. If you have a family, tell your spouse and children not to bother you for the next 20 minutes or for however long you plan to spend. And before you begin, tell your spouse to take a message if you get a phone call.

I sit in a reclining chair and breathe at a normal pace for about 30 seconds and get my mind off of things. Then I take a deep breath, hold it for 5 seconds, then slowly release the air and as I do, I imagine my body is becoming relaxed, as if it dropped down to the next level. Then I return to normal breathing for about 10 seconds, imagining that my breathing is slightly lighter than when it was when I started. I repeat that process 4 or 5 times, then while I exhale the last time, I close my eyes, and say to myself quietly and slowly… “The muscles around my eyes are totally and completely relaxed… I couldn’t open my eyes if I wanted to because the muscles are soooo relaxed….now I see coming from the sky a beam of light, shining on the muscles around my eyes relaxing them even further… the light of relaxation is penetrating deeply into every muscle, nerve and fiber around my eyes, making them even more relaxed… my breathing is soooo light, my heart and pulse are beating sooooo slowly…now the light of relaxation is spreading from my eyes down my face, down to my jaw and all the surrounding area….down my neck and around to the back of my neck….now the light of relaxation is spreading down my back, down past my shoulder blades…now the light of relaxation has spread across my back, out to the sides of my torso…now the light of relaxation continues down my back and sides, penetrating deeply into the nerves, muscles and fibers, relaxing them even more…all the way down to the small of my back….down to my waist… now the light of relaxation is shining on the sides of my neck and has spread across the top of my shoulders, just relaxing them…now the light of relaxation is moving slowly down my arms, penetrating deeply into every nerve, muscle and fiber making them soooo relaxed…and now the light has gone down to my elbows and has relaxed every muscle…now the light of relaxation is moving down my forearms…slowly down…into my wrist…hands…fingers…and all the way out through the tips of my fingers…now the light of relaxation is shining on the front of my neck and is moving down my chest area, penetrating deeply into every muscle, nerve and fiber…all the way down to my solar plexus…now down to my abdomen and all the surrounding area… down to my waist…now the light of relaxation shines on my pelvis and hips and is moving down to my thighs…it continues down my thighs relaxing every muscle, nerve and fiber… allllllll the way down to my knees…now the relaxation continues down my calves…cascading down to my ankles… into my feet…and all the way out through the tips of my toes…every part of my body is totally, and completely relaxed”.
Now, as I said, that’s how I do it. If this works for you, great. If not, you can do it the way that works best for you. But you want to get your body totally relaxed. You don’t have to make an effort to relax your mind. It will relax along with your body. And don’t rush through this. I spend about 5 minutes doing the relaxation. Spend at least that amount of time. Also, I recommend that you do this in the morning before you go to work. If you do it in the evening after working all day and then eating dinner, you may fall asleep and miss out on practicing your new skill and throw your night sleep schedule off. So try it at a time when you’re less likely to fall asleep, and do it in a sitting position. I also recommend doing it on an empty stomach or waiting at least an hour after eating a big meal. If you do it right after eating, the food you ate will sit in your stomach like a blob because your metabolism will drastically slow down.

And notice where I put… That’s where you pause and imagine that part of your body relaxing. Just imagine it, pretend your body is relaxing…feel your muscles relaxing. Then move on to the next area to be relaxed. You most likely won’t be able to do the relaxation later in the day such as at work or while driving to work (certainly not then). And you want to say your affirmation more than once. So it’s a good idea to do the relaxation at least once a day followed by saying the affirmation for a good 15 to 20 minutes to allow it to sink deeply into your subconscious mind. Your Subconscious Mind Power is not “way down there at the very depth of your psyche”. It’s right beneath the surface, just one step down from your conscious mind. Relaxation helps you get to it.