Friday, March 13, 2015

BMC Command (ipmitool command)

Thais are command of ipmi using bmc, will commonly used. .
Command is able to work fdor local and remote.
If occur ipmitool sel ==>means local, if command no ip means local. .
If occur ipmitool -H 192.168.2.1 ==>means remote

Command
1) Show SEL
ipmitool sel

2) show BMC ip information
ipmitool lan print

3) reset bmc ip
ipmitool raw 06 02

4)set bmc ip to static and set ip address
ipmitool lan set 1 ipsrc static
ipmitool lan set 1 ipaddr 192.168.2.1

5)power consumption( power on, off, reboot)
ipmitool -H 'ip address'  -U USERID -P PASSW0RD -I lanplus chassis  [power off| power on |reset]

example:
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power off
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power on
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power reset
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power status

6)show sensor
ipmitool sensor

7) fw cersion
ME: ipmitool -b 0x6 -t 0x2c raw 0x06 0x04
BMC: ipmitool mc info | grep "Firmware Revision"
CPLD: ipmitool raw 0x3c 0x58

8) fru version
ipmitool fru

IPMI RAW command

0x02 GET LAN Config
0x01 Channel Num
0x04 IP Source(Selector)
0x00 not use set Selector
0x00 not require block num
Response 指令格式 "NetFnCode CommandCode CopmpletionCode Data .."
Ex.0x0D 0x02 0x00 0x01
0x0D Response Transport Media-specific configuration & control
0x02 GET LAN Config
0x00 Command Completed Successful
0x01 IP source is Static
## NetFn code
0x00(request), 0x01(Response) Chassis
0x02(request), 0x03(Response) Bridge
0x04(request), 0x05(Response) Sensor/Event
0x06(request), 0x07(Response) Application
0x08(request), 0x09(Response) Firmware Transfer
0x0A(request), 0x0B(Response) Non-volatile storage
0x0C(request), 0x0D(Response) Transport Media-specific configuration & control
0x0E- 0x2B Reserved
2Ch-2Dh Extension Non-IPMI group
2Eh-2Fh OEM/Non-IPMI group
30h-3Fh Controllerspecific OEM/Group
## Completion Code
0x00 Command Completed Normally
0xC0 Node Busy
0xC1 Invalid Command
0xC2 Command invalid for given NetFn
0xC3 Timeout
0xC4 Storage Out of space
0xC5 Reservation Canceled or Invalid Reservation ID
0xC6 Request data truncated
0xC7 Request data length invalid
0xC8 Request data field length limit exceeded
0xC9 Parameter/Data out of range
0xCA Cannot return number of requested data bytes
0xCB Requested Sensor, data, or record not present
0xCC Invalid data field in Request
0xCD Command illegal for specified sensor or record type
0xCE Command response could not be provided
0xCF Cannot execute duplicated request
0xD0 Command response could not be provided. SDR Repository in update mode.
0xD1 Command response could not be provided. Device in firmware update mode.
0xD2 Command response could not be provided. BMC initialization or
initializationagent in progress
0xD3 Destination unavailable
0xD4 Cannot execute command due to insufficient privilege level or other
securitybased restriction
0xD5 Cannot execute command. Command or parameter not supported in present
state
0xD6 Cannot execute command. Parameter is illegal
0xFF Unspecified error
0x01-0x7E OEM completion codes
0x80-0xBE Standard command-specific codes
0x7F, 0xBF, 0xD7-0xFE Reserved


Wednesday, February 25, 2015

RAMDISK

linux command (network)

Add Network (network command)

(1)add interface
[root@server ~]#cd /etc/sysconfig/network-scripts
[root@server ~]#vi ifcfg-eth0
DEVICE="eth2"
BOOTPROTO="dhcp"
HWADDR="00:02:C9:27:59:FE"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPV6INIT="no"

(2)If set ip, will not active after reboot.
When we set some ip address, after reboot or services restart will not active. This means that we have to kill the temporary store ip address. This often occur when we had a dhcp Ip address, then we wants to change to a static. But i also found out that if i wants to change a new network card, will also happen, the ip will not change.

Please set ip address first, then clear this.
[root@server ~]#cd /etc/udev/rules.d
[root@server ~]#rm 70-persistent-net.rules

(3) show ip address
[root@server ~]#ifconfig

(4) show ip interface
[root@server ~]#ip a












(5) ethtool - query or control network driver and hardware settings
ethtool ethernet interface
#ethtool eth0
This will let you see your link rate, support wake on lan, lan detect or not, and so on.

(6) enable your interface
#ifdown eth0
#ifup eth0

(7) ping
ping ip address
ping -c 1 ipaddress  ==>ping one second

(8) Search dhcp client ip address, or bmc ip address
cat /var/log/messages | grep BMC MAC address
example: cat /var/log/messages | grep  xx:xx:xx:xx:xx:xx

(9) changed Server name 
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=putXX




Linux command

PART 1 SIMPLE COMMAND

(1) list directory contents (refer to window dir)
command: ls
Description /purpose: Print or list the file or folder in this directory

[root@server ~]# ls

command: ll
Description /purpose:  Print or list the file or folder in this directory, but this will show information.
[root@server ~]# ll













(2) print name of current/working directory (pwd)
Description /purpose: show which directory or path you are in right now.
[root@server ~]# pwd
/root

(3) copy (cp)
Description /purpose: copy file or create backup

#cp dhcp.conf dhcp.conf.bk

(4)move or rename file ( mv)
Description /purpose:  rename a file name, or generate a file
#mv old.txt new.txt

(5) cat
Description /purpose: read a file name
cat 123.txt

(6)modify text (vi or vim)
Description /purpose: to modify some file
vi is modify, and vim is improve, which will have show in different color.
Some variable need to used

vi











vim

:q! ==>exit without saving
:w! ==>save
:wq!==>save and quit
:x!==>save and exit
? or / ==>search

Note: For more information, please refer shell script



(7) touch
Description /purpose:to generate a file. Different between vi is it don't have to save to generate a file. It will generate a file if input touch command.
touch aaa.txt

(8)tail
Description /purpose: output the last part of files
will print last 10 line 
#tail /var/log/message

 output appended data as the file grows. 
#tail -f

difference from cat versus tail
tail is different from cat, is cat will read all the file once, but tail will not. For example if you have a log file, you cat log file, it will read all the line from first line to last line. But tail will read last line, and if the file still have message, it will also show.

 (9) clear
Description /purpose:clear the terminal screen
#clear


PART 2 Intermediate (common used and file related)

1. extract file
tar -zxvf extract.tar.gz
#tar -zxvf filename.tar.gz 

2. compress file
tar -tzvf compressed.tar.gz
tar -zcvf filnename.tar.gz 'folder destination/'
#tar -zcvf filnename.tar.gz folder /test

3. mount
what is mount?
A mount is where I wants to mount a directory into one folder. Mount this command can used for many ways.
Basely mount this command is like if i have a directory names test, if i wants to mount a directory "dhcp" into test this directory. Directory test all the data will be used by dhcp this directory. In other word mean all test directory will be gone, will only appear dhcp data. If you umount it, it will be appear.

Mount this command can be used for:

Mount for folder to folder which is like shortcut
# mount --bind /etc/dhcp /dhcpfile_test











Mount for usb drive to /mnt directory 




Mount for network 



4 link or shortcut
command "ln -s"
ln -s orginally folder or file shortcut
# ln -s /etc/dhcp/ /dhcpfile











5 set date
date MMddhhmmyyyy




BATCH(.bat) SCRIPT(window)

PART1 SIMPLE

(1)CREATE FOLDER

set /P id=Enter id:
mkdir %id%

(2) FOLDER NAME WITH DATE
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C
)

set CurrentDate=%DateMonth%-%DateDay%-%DateYear%

mkdir %CurrentDate% 

(3) PING 
@echo off
set /p a="Enter IP Address or Name: "
ping %a%
pause

(4)


PART2 Mixed function script
(1) user enter Devices name and IP address

@echo off
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C
)


set CurrentDate=%DateDay%-%DateMonth%-%DateYear%
set /P name=Enter name of folder:
set /p bmc_ip="Enter BMC IP Address: "


mkdir %CurrentDate%_%name%

@echo on
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sensor >  %CurrentDate%_%name%/SENSOR.TXT
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sel list >  %CurrentDate%_%name%/list.TXT
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sel elist > %CurrentDate%_%name%/elist.TXT


output:
Enter name of folder: DUT1-1
Enter BMC IP Address: 192.168.1.2

Friday, December 12, 2014

IPMI command (ipmitool tool)


What is IPMI
IPMI is an abbreviation for Intelligent Platform Management Interface.

The Intelligent Platform Management Interface (IPMI) is a set of computer interface specifications for an autonomous computer subsystem that provides management and monitoring capabilities independently of the host system's CPU, firmware (BIOS or UEFI) and operating system. IPMI defines a set of interfaces used by system administrators for out-of-band management of computer systems and monitoring of their operation. For example, IPMI provides a way to manage a computer that may be powered off or otherwise unresponsive by using a network connection to the hardware rather than to an operating system or login shell.
[reference: http://en.wikipedia.org/wiki/Intelligent_Platform_Management_Interface]


Basely IPMI this tool is to control your bmc ip address, which can read your sensor(such as the component's temperature, battery, and so on), an power consumption types of setting.
A server mean it will stay on for many days or year without shut down. We need this ipmi tool is to see if this server hang, we will be able to debug what happen.

ipmitool can let you server to power or or off. But manly ipmitool is used to fit our bmc addres.

What are come of the useful command to used:

See our power status: 
 ipmitool -I lanplus -H "BMC IP ADDRESS"  -U USERID -P PASSWORD chassis power status

Power on you server
 ipmitool -I lanplus -H "BMC IP ADDRESS"  -U USERID -P PASSWORD chassis power [on/off]

SOL(serial over lan)
SOL is like console redirection, you don't need a debug card or a console port, you can used your lan to see you internal status.

If you don't have a vga card you aren't able to see you host status right?
No, there are three way you can see if you don't have vga card:
by console redirection
by console debug card
by SOL

 ipmitool -I lanplus -H  "BMC IP ADDRESS" -U USERID -P PASSWORD sol activate

DEBUG USED with BMC COMAMND
Some debug ipmitool to used:
If your SUT/DUT(client pc) hang, please execute this command to see what happen, or see previous stop over where .
Need to open two terminal: one connect sol, another execute command raw 0x3c 0x5c

for example:
 ipmitool -I lanplus -H  "BMC IP ADDRESS" -U USERID -P PASSWORD sol activate
and
 ipmitool -I lanplus -H  "BMC IP ADDRESS" -U USERID -P PASSWORD  raw 0x3c 0x5c

See bmc dhcp ip had been release or gone
prerequisite: OS ip must be ping-able, else this is unable to verify
remote to OS by telnet or ssh, and execute this command: ipmitool lan print
reset bmc, see reset bmc command as below.

Reset bmc  by this command
ipmitool raw 0x3c 0x5a

TO BE UPDATED......

Set up dhcp linux


Set up dhcp under linux:


What is a dhcp server 
I will used my paraphrase in my own word. There are many information that you can get from internet.

Basely a dhcp server is a dynamic ip(internet protocol)  address that will assign to the host. Everyone today used internet, we need to connect lan cable to a hub, switch or etc. These hub switch might have a dhcp server in the backbone or in front of them, else it will not be able to assign ip to the host.

A ip address will have a unique ip address, in other word no one is going to have a same ip address.
So the fundamental concept of a dhcp is like this:
1. we set up a dhcp server( linux or window]
2. we prepare a switch , or a hub, and connected to dhcp server.
3 Right now if any host is being connected to the hub or switch, will have a dynamic ip.

I will teach you how to mange an effective ip address for user to used. There are two difference ways of mange dhcp. One is to set a static ip address by an interface mac address, and two is by rang an ip address.


Set up particular pc ip address into static ip. 
If you have many host or more than 10 HOST PC or Server, it is hard to control or manage a dhcp. So we will needed to add a particular interface mac and set a static ip, this will be more easier to know which pc is which.

host ASER_HOSTA {
  hardware ethernet AB:AA:BB:CC:DD:EE;
  fixed-address 192.168.2.100;
}

host ASUS_HOSTB {
  hardware ethernet CD:AA:BB:CC:DD:EE;
  fixed-address 192.168.2.101;
}


Set up a dhcp range
If you need to set up a dhcp server, you can add or not add a rang. I will prefer you add a rang between 101~200, this mean ip will be between 101 and 200. Again this will be easier to manage you dhcp server.

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.101 192.168.1.200;
 option subnet-mask 255.255.255.0;
}


Set up a dhcpv6 range

default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet6 2001:db8:0:1::/64
{
#Range for clients
range6 2001:db8:0:1::129 2001:db8:0:1::254;
}