Friday, October 31, 2008

bash shortkeys

(C = control key, M = alt/meta key.)

  1. C-r and C-s : Launch an incremental search backward and forward (respectively), in your command-line history.
  2. C-j and C-g : Abandon an incremental search either with the line found, or with the original line (respectively).
  3. M-. or ESC then . : Both of these insert the final argument to the last command at the cursor point. This is useful when moving files around and editing them.
  4. M-C-y : Insert the first argument to the previous command at the cursor point. If you want the nth argument, hit M-n beforehand. So M-2 M-C-y would give you the 2nd argument to the previous command. (A lot of keys to remember, but it's useful once in a while.)

  5. C-w and M-backspace : Both delete the word behind the cursor. C-w uses whitespace as a boundary, whereas M-backspace uses non-alphanumeric characters. So if you have file.txt and hit C-w, you'll delete the lot, whereas M-backspace would leave you with file.. This has very obvious uses. (It also works with underscores.)

Friday, May 2, 2008

progress report for dd

dd if=/dev/zero of=/tmp/demo bs=1M count=1536

when running above command, you don't get any progress report, if you want, you can open another window,
run the following command so that dd will show up the progress every 5 minutes

watch -n5 -- pkill -USR1 ^dd$


Thursday, May 1, 2008

http://www.redhatmagazine.com/2007/08/10/cobbler-how-to-set-up-a-network-boot-server-in-10-minutes/

http://www.redhatmagazine.com/2007/08/10/cobbler-how-to-set-up-a-network-boot-server-in-10-minutes/

use ethtool to identify the network interface easily

# ethtool -p eth0 5

this will blink the network interface eth0 for 5 seconds, then you know which physical interface is for eth0

some Linux user and group intergrity checking tools

pwck
grpck

usermod

get server motherboard serial number from Linux command line



  • # dmidecode | grep 'Serial Number' | head -n1

Friday, March 14, 2008

Hardware Monitoring for HP Prolliant DL360G4p under CentOS 5

Purpose: Send email alert out in the event of hardware failure for HP Proliant server under CentOS 5, especially hard disk failure

steps:
  • edit /etc/redhat-release, change to "Red Hat Enterprise Linux AS release 5" (required by hpasm and hpsmh packages)
  • install net-snmp* rpm packages from CentOS 5
You can use 'yum install net-snmp*'
chkconfig snmpd on
service snmpd start
  • install compat-libstdc* rpms , otherwise the storage controller Smart Array won't appear in Storage section in System Management Homepage
yum install compat-libstdc*
  • download hpasm and hpsmh from
http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=us&prodNameId=3288142&prodTypeId=15351&prodSeriesId=452749&swLang=8&taskId=135&swEnvOID=4006#7832

  • install hpasm and hpsmh
note: hpasm-HP System Health Application and Insight Management Agents for Red Hat Enterprise Linux 5 (x86)
hpsmh ->HP System Management Homepage for Linux (x86)
remember to start snmpd service first before installing rpms
configuring hpasm:
/etc/init.d/hpasm reconfigure
  • access https://serverip:2381
  • configuring /opt/compaq/cma.conf
exclude cpqasm cmhp cmascsid
trapemail /bin/mail -s 'Server1 HP Agents Trap Alarm' root
cmaXSocketBase 87654321
cmaCloseCcissHandle ON

note: we put cmascsid to exclude option to avoid the daemon to startup because it can cause system load to become high(uninterruptible sleep) on Fedora Core 3, you might take it out if your system is not FC3.
note: to stop storage agent: e.g. /opt/compaq/storage/etc/cmastor start/stop cmaeventd

  • allow necessary ports in Firewall settinig
in /etc/sysconfig/iptables, adding the following to enable port 2381
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 2381 -j ACCEPT

  • snmp extension
after configuration, the original /etc/snmp/snmpd.conf will be inserted in the beginning of the file to be like this:

# Following entries were added by HP Insight Management Agents at
# Mon Jun 16 10:39:32 SGT 2008
dlmod cmaX /usr/lib/libcmaX.so
rwcommunity public 127.0.0.1
rocommunity public 127.0.0.1
trapcommunity public
trapsink 1.2.3.4 public
sysname server.domain.com (please add it yourself)
syscontact Root (configure /etc/snmp/snmp.local.conf)
syslocation Unknown (edit /etc/snmp/snmpd.conf)

# ---------------------- END --------------------
note: you need to configure snmptoemail on 1.2.3.4 as follows:
[root@app~]# more /etc/snmp/snmptrapd.conf
traphandle default /usr/bin/perl /usr/bin/traptoemail -s localhost -f hpsnmptrap@domain.com JepheWu@domain.com
traphandle default /usr/bin/perl /usr/bin/traptoemail -s localhost -f hpsnmptrap@domain.com WuATing@domain.com

also, comment out the following requiretty line from /etc/sudoers so that you can send test trap mail from hpsmh webpage
[root@server snmp]# grep -e requiretty -e hpsmh /etc/sudoers
#Defaults requiretty
%hpsmh ALL=NOPASSWD:/etc/init.d/snmpd
%hpsmh ALL=NOPASSWD:/usr/bin/snmptrap
  • snmp email alert
configuring sendmail in dns-less environment to send out email alert
  1. put the following parts to /etc/mail/sendmail.mc
[root@server mail]# grep -e root -e MASQ -e SMART sendmail.mc
define(`SMART_HOST', `mailrelay')dnl
dnl EXPOSED_USER(`root')dnl
MASQUERADE_AS(`domain.com')dnl
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(db.domain.com)dnl
MASQUERADE_DOMAIN(domain.com)dnl


run m4 sendmail.mc > sendmail.cf

2. create file /etc/mail/service.switch and give it right permission (smmsp user can read it )
put 'hosts files' to /etc/mail/service.switch, so it should have permission 640 and owned by root:smmsp

3. put 1.2.3.4 which mail server ip address into /etc/hosts
1.2.3.4 mailrelay

use the following command to find out the path for sendmail.cf and service.switch
strings /usr/sbin/sendmail | grep sendmail.cf
strings /usr/sbin/sendmail | grep service.switch

4. put root alias in /etc/aliases
root: admin1@domain.com,admin2@domain.com

then run newaliases

5. send a test email
# echo testing | /usr/sbin/sendmail -v root