Friday, February 1, 2013

SSH Login Prowl Notifications Linux

SSH Prowl Notifications Linux.

Get notifications for events on your IPhone is a nice thing.
You can get notifications for every event that you like.

Here is a small HowTo for Prowl notifications for SSH Logins on your Linux box.

Short Version
  1. Get a Prowl account and API Key: https://www.prowlapp.com
  2. Install the IPhone app.
  3. Download the Prowl Script: https://prowl.weks.net/static/prowl.pl
  4. Edit your /etc/bashrc file

Step by Step

Register at https://www.prowlapp.com/register.php
Generate your API Key at https://www.prowlapp.com/api_settings.php

Download the Prowl Perl Script at https://prowl.weks.net/static/prowl.pl
I have placed it at "/usr/bin/" and "chmod 755" on "/usr/bin/prowl.pl"

Install the Prowl APP on your IPhone. And Login with your new account.

I had to install on my Centos 6.3
perl-WWW-Curl
openssl-perl
perl-Crypt-SSLeay

To get this Script running.


To Enable SSH Login Notifications for every login.
edit
"/etc/bashrc"
and add at the bottom
/usr/bin/prowl.pl -apikey="YOUR API KEY" -application="prowl.pl" -event="Notification" -notification="SSH Login @Home User: `id`"

Send a Test Notification:
/usr/bin/prowl.pl -apikey="YOUR API KEY" -application="prowl.pl" -event="Notification" -notification="SSH Login @Home User: `id`"

Just Replace the "SSH Login @Home User: `id`" with your notifications...

Thats it.

If you Like you can enable a log

touch /var/log/prowl.log
chmod 755  /var/log/prowl.log
vi /etc/bashrc and add above your prowl script line

echo "###" >>/var/log/prowl.log
echo "`date`" >>/var/log/prowl.log
echo "SSH Login" >>/var/log/prowl.log
echo "`id`" >>/var/log/prowl.log
/usr/bin/prowl.pl -apikey="YOUR API KEY" -application="prowl.pl" -event="Notification" -notification="SSH Login @Home User: `id`"2>&1 >>/var/log/prowl.log









Wednesday, January 23, 2013

Live System Rescue Environments. CD / USB Stick


Live Rescue CD / USB Stick.

We all know the Situation...
You reboot a system and surprise its not booting anymore.
Or you get a call from someone and he is asking for your help.
Maybe its an HDD Failure or a Virus or Just to reset a Windows Password.

There are some great projects that focus on System Rescue Environments.
And its always nice to have a USB Stick with all your tools to save the day :)

2 good rescue environments i use...
You can boot them from CD or USB..

even create a multi boot USB Stick with both of them and bunch of Linux Distros


Multi boot USB creator
http://www.pendrivelinux.com/
i used http://www.pendrivelinux.com/yumi-multib...b-creator/



Trinity Rescue Kit or TRK
http://trinityhome.org

Trinity Rescue Kit or TRK is a free live Linux distribution that aims specifically at recovery and repair operations on Windows machines, but is equally usable for Linux recovery issues. Since version 3.4 it has an easy to use scrollable text menu that allows anyone who masters a keyboard and some English to perform maintenance and repair on a computer, ranging from password resetting over disk cleanup to virus scanning





SystemRescueCd
http://www.sysresccd.org/SystemRescueCd_Homepage

Description: SystemRescueCd is a Linux system rescue disk available as a bootable CD-ROM or USB stick for administrating or repairing your system and data after a crash. It aims to provide an easy way to carry out admin tasks on your computer, such as creating and editing the hard disk partitions. It comes with a lot of linux software such as system tools (parted, partimage, fstools, ...) and basic tools (editors, midnight commander, network tools). It can be used for both Linux and windows computers, and on desktops as well as servers. This rescue system requires no installation as it can be booted from a CD/DVD drive or USB stick, but it can be installed on the hard disk if you wish. The kernel supports all important file systems (ext2/ext3/ext4, reiserfs, btrfs, xfs, jfs, vfat, ntfs), as well as network filesystems (samba and nfs).

Thursday, December 20, 2012

3 TB HDD + Raid 5 + LVM

So i got my new HP Microserver N40L :) and 3x HDDs WD30EFRX.

If you ask your self how to setup a mdadm raid 5 and LVM here is a quick Howto...

My Setup:
1x 4BG USB Stick for the OS Centos 6.3 64 bit.
1x HDD 160GB for temporary HDD work. so i don't have to start the idle raid every time...
3x 3TB HDDs for Raid 5.


Here are the commands i used for the partitioning + Raid 5 + LVM Setup.

Note 1: Do not use "fdisk" if i remember right it does not work with partitions larger then 2TB...

Note 2: Check your system and replace the below commands with your setup... (sdx, sdy).

Note 3: repeat Partitioning steps 2 - 7 for all your Raid Members.

Partitioning:
  1. yum install parted
  2. parted /dev/sda   (see note 2)
  3. (parted) mklabel gpt
  4. (parted) unit TB
  5. (parted) mkpart primary 0.00TB 3.00TB
  6. (parted) print
  7. (parted) quit

Raid Setup:
  1. yum install mdadm
  2. mdadm --create /dev/md0 --level=raid5 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1
  3. cat /proc/mdstat (you will see that 1 drive is rebuilding. thats normal...)
LVM:
  1. yum install lvm2.x86_64
  2. pvcreate /dev/md0
  3. vgcreate vgdata1 /dev/md0
  4. lvcreate --name lvdata1 -l 100%FREE vgdata1
  5. mkfs.ex4 /dev/vgdata1/lvdata1

Linux Performance Tools To Troubleshoot Problems.

Find your bottlenecks.

What tools or commands are recommended to troubleshoot performance related problems?
Sometimes you need to check HW bottlenecks. the easiest is to use "top" and "iostat" or "dstat"
If you have the time to Setup a "Munin" Server. This is perfect. It will help you analyze Performance and also bottlenecks with nice to view graphs.

basic or essential tools that every Linux or UNIX System Admin should be aware of:


Command Line Tools
top
htop
sar
dstat
vmstat
iostat
free




Web Tools
Munin http://munin-monitoring.org/
Cacti http://www.cacti.net/


Here are some examples

Top - Command
top provides a real time view of a running system.















Sar - Command

sar Collect, report, or save system activity information. It can generate report and email them to sys admin.
CPU and Queue
Disk I/O
Swap and Memory
CPU interrupts, Networking and more...














Iostat - Command
iostat Device Utilization Report and more...














Wednesday, December 19, 2012

Hard Drives and Smart.

Some Time ago i found a very interesting article from google about HDD's.
I was very surprised from some of the information i found in that document.

for example:

How smart is SMART?
Not very, as Google found, and many in the industry already knew. SMART (Self-Monitoring, Analysis, and Reporting Technology) captures drive error data to predict failure far enough in advance so you can back up. Yet SMART focuses on mechanical failures, while a good deal of a disk drive is electronic, so SMART misses many sudden drive failure modes, like power component failure. The Google team found that 36% of the failed drives did not exhibit a single SMART-monitored failure. They concluded that SMART data is almost useless for predicting the failure of a single drive.
So while your disk drive might crash without warning at any time, they did find that there are four SMART parameters where errors are strongly correlated with drive failure:
  • scan errors
  • reallocation count
  • offline reallocation
  • probational count
For example, after the first scan error, they found a drive was 39 times more likely to fail in the next 60 days than normal drives. The other three correlations are less striking, but still significant.
The bottom line: SMART can warn you about some problems, but miss others, so you can’t rely on it. So don’t. Back up regularly, and if you do get one of these errors, get a new drive.


 If you would like to read your S.M.A.R.T Infos just install "smartmontools".
"yum install smartmontools"

# smartctl -a /dev/sda
...
...
...


Will give you the information.


google HDD Study: Google HDD Research

Is hyper-threading enabled on a Linux system

Is hyper-threading enabled on a Linux system ?

When you need to know whether hyper-threading is enabled without the luxury to reboot the system,
you can simply look at the output of /proc/cpuinfo and compare the siblings with the cpu cores fields.

The most common answer was to check the values of 'cpu cores' and 'siblings' in /proc/cpuinfo.
When Hyper-Threading is enabled, those values should be different for each logical processor:


# egrep 'siblings|cpu cores' /proc/cpuinfo | head -2

siblings : 12
cpu cores : 6



As you can see on my test System HT is enabled.

Thursday, June 10, 2010

Linux VLAN configuration

here is a small Howto configure VLAN on a linux system.

the required VLAN ID i have to configure is "15". copy the file
/etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth0.15

cp  /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.15

now we have to edit the new virtual interface  ifcfg-eth0.15

vi  /etc/sysconfig/network-scripts/ifcfg-eth0.15

replace DEVICE= with your VLAN ID


DEVICE=eth0.15

also add a line VLAN=yes


DEVICE=eth0.15
VLAN=yes


don't forget to set your IP address ;-) also remove gateway entries...
the gateway entries should be only at /etc/sysconfig/network


-- Yaniv