BMC用NFS debug的方法

前置作業:
1. Build好的uImage放tftp
2. Build/output/ImageTree目錄放NFS export path備用
3. 登入BMC console測試是否可mount NFS: mount -t nfs -o rw,nolock {src_nfs_path} {dest_path}

NFS開機模式步驟:
1. 重啟BMC,當BMC出現Hit any key to stop autoboot:時按任意鍵,進入u-boot畫面

2. 設定環境變數: (在本機的u-boot)

3.1 備份原本環境變數
print #複製下來另存新檔

3.2 設定環境變數
setenv ipaddr {ipaddr} #給u-boot一個隨意靜態IP
setenv serverip {serverip} #設定tftp server IP
setenv bootcmd 'tftp 82000000 uImage; bootm 82000000' #設定從tftp的uImage開機
(原本是bootcmd=bootfmh #從本機load進memory的uImage開機,復原時只要改回這個即可)
setenv bootargs 'root=/dev/nfs rw nfsroot={nfs_ip}:{nfs_export_path} ip=dhcp console=ttyS4,38400' #設定BMC檔案系統root從NFS mount起來,並給予BMC dhcp IP
(如要指定static ip, ip={bmcip}:{serverip}:{gatewayip}:{netmask}::{bmcnicname}:off)
(如果mount nfs出現錯誤,首先要在bootargs放上nfsrootdebug參數找出真正的原因,若是沒加nolock的問題,將nfsroot=最後加上nolock即可,i.e.nfsroot={nfs_ip}:{nfs_export_path},nolock)
saveenv #存檔寫回本機的uImage

tftp 82000000 uImage #測試tftp的uImage能不能load進memory
bootm 82000000 #從0x82000000記憶體開機

3.3 執行重開機
run bootcmd
登入BMC後查看/proc/cmdline,是否載入kernal是我們bootcmd寫的NFS參數

U-boot指令:
http://flykof.pixnet.net/blog/post/22975136-u-boot%E6%8C%87%E4%BB%A4

BMC default IP: 192.168.0.120
Baud rate: 38400 / 115200

TFTP installation:
https://yulun.me/2016/setup-tftp-server-on-ubuntu/

怎麼增大Linux系統的open file(s)上限

 

#查看或設置open file限制

ulimit -n

 

@soft limit,軟限制,用戶可以上調軟限製到硬限制

ulimit -Sn

@hard limit,硬限制,非root用戶不能修改

ulimit -Hn

如果沒有指明,則同時修改軟限制和硬限制。

 

#臨時修改和永久修改

臨時修改只對當前會話有效,登出和重啟後都恢復系統設置。

@臨時修改

使用ulimit命令,以修改open file(s)為例。

ulimit -n 1024000

查看修改結果

ulimit -n

1024000

@臨時修改某個PID

prlimit -n4096 -p pid_of_process 

@永久修改

在/etc/security/limits.conf

或者在/etc/security/limits.d/目錄下添加一個文件。

具體格式參考/etc/security/limits.conf

 

#open file(s)上限

open file(s)kernel級別有2個配置,分別是:

fs.nr_open,進程級別

fs.file-MAX,系統級別

fs.nr_open默認設置的上限是1048576,所以用戶的open file(s)不可能超過這個上限。

@sysctl命令修改上限(臨時)

#sysctl -w fs.nr_open = 10000000

#ulimit -n 10000000

#ulimit -n

10000000

@修改上限(永久)

到/etc/sysctl.conf中

例如:

#echo“fs.nr_open = 10000000”>> /etc/sysctl.conf

#echo“fs.file-max = 11000000”>> /etc/sysctl.conf

注意:fs.nr_open總是應該小於等於fs.file-max。

 

#查看當前打開的文件數:

#sysctl fs.file-nr

fs.file-nr = 1760 0 11000000

 

參考:

http://www.chengweiyang.cn/2015/11/14/how-to-enlarge-linux-open-files-upper-cell/

Understanding Systemd Units, Unit Files and Directives

https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files

[轉] How To: ICMP Ping in Java (JDK 1.5 and above)

Programatically using ICMP Ping is a great way to establish that a server is up and running. Previously you couldn’t do ICMP ping (what ping command does in Linux/Unix & Windows) in java without using JNI or exec calls. Here is a simple and reliable method to do ICMP pings in Java without using JNI or NIO.


String host = "172.16.0.2"
int timeOut = 3000; // I recommend 3 seconds at least
boolean status = InetAddress.getByName(host).isReachable(timeOut)

status is true if the machine is reachable by ping; false otherwise. Best effort is made to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.

In Linux/Unix you may have to suid the java executable to get ICMP Ping working, ECHO REQUESTs will be fine even without suid. However on Windows you can get ICMP Ping without any issues whatsoever.

PS: Linux 版必須該 JVM 使用者有 root 權限發 ICMP

使用 Grafana+collectd+InfluxDB 監控系統

http://cyrilwang.blogspot.tw/2016/09/collectd-influxdb-grafana.html

使用 Grafana+collectd+InfluxDB 打造现代监控系统

top command explanation

top – 16:23:02 up 14 days, 23:08, 7 users, load average: 0.01, 0.04, 0.12
Tasks: 233 total, 1 running, 232 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.7 us, 0.3 sy, 0.0 ni, 98.6 id, 0.3 wa, 0.1 hi, 0.1 si, 0.0 st
KiB Mem: 16368856 total, 11506728 used, 4862128 free, 544236 buffers
KiB Swap: 8200188 total, 0 used, 8200188 free, 6060844 cached

a: PID — Process Id
The task’s unique process ID, which periodically wraps, though
never restarting at zero.

b: PPID — Parent Process Pid
The process ID of a task’s parent.

c: RUSER — Real User Name
The real user name of the task’s owner.

d: UID — User Id
The effective user ID of the task’s owner.

e: USER — User Name
The effective user name of the task’s owner.

f: GROUP — Group Name
The effective group name of the task’s owner.

g: TTY — Controlling Tty
The name of the controlling terminal. This is usually the
device (serial port, pty, etc.) from which the process was
started, and which it uses for input or output. However, a
task need not be associated with a terminal, in which case
you’ll see ‘?’ displayed.

h: PR — Priority
The priority of the task.

i: NI — Nice value
The nice value of the task. A negative nice value means higher
priority, whereas a positive nice value means lower priority.
Zero in this field simply means priority will not be adjusted
in determining a task’s dispatchability.

j: P — Last used CPU (SMP)
A number representing the last used processor. In a true SMP
environment this will likely change frequently since the kernel
intentionally uses weak affinity. Also, the very act of
running top may break this weak affinity and cause more
processes to change CPUs more often (because of the extra
demand for cpu time).

k: %CPU — CPU usage
The task’s share of the elapsed CPU time since the last screen
update, expressed as a percentage of total CPU time. In a true
SMP environment, if ‘Irix mode’ is Off, top will operate in
‘Solaris mode’ where a task’s cpu usage will be divided by the
total number of CPUs. You toggle ‘Irix/Solaris’ modes with the
‘I’ interactive command.

l: TIME — CPU Time
Total CPU time the task has used since it started. When
‘Cumulative mode’ is On, each process is listed with the cpu
time that it and its dead children has used. You toggle
‘Cumulative mode’ with ‘S’, which is a command-line option and
an interactive command. See the ‘S’ interactive command for
additional information regarding this mode.

m: TIME+ — CPU Time, hundredths
The same as ‘TIME’, but reflecting more granularity through
hundredths of a second.

n: %MEM — Memory usage (RES)
A task’s currently used share of available physical memory.

o: VIRT — Virtual Image (kb)
The total amount of virtual memory used by the task. It
includes all code, data and shared libraries plus pages that
have been swapped out and pages that have been mapped but not
used.

p: SWAP — Swapped size (kb)
Memory that is not resident but is present in a task. This is
memory that has been swapped out but could include additional
non-resident memory. This column is calculated by subtracting
physical memory from virtual memory.

q: RES — Resident size (kb)
The non-swapped physical memory a task has used.

r: CODE — Code size (kb)
The amount of virtual memory devoted to executable code, also
known as the ‘text resident set’ size or TRS.

s: DATA — Data+Stack size (kb)
The amount of virtual memory devoted to other than executable
code, also known as the ‘data resident set’ size or DRS.

t: SHR — Shared Mem size (kb)
The amount of shared memory used by a task. It simply reflects
memory that could be potentially shared with other processes.

u: nFLT — Page Fault count
The number of major page faults that have occurred for a task.
A page fault occurs when a process attempts to read from or
write to a virtual page that is not currently present in its
address space. A major page fault is when backing storage
access (such as a disk) is involved in making that page
available.

v: nDRT — Dirty Pages count
The number of pages that have been modified since they were
last written to disk. Dirty pages must be written to disk
before the corresponding physical memory location can be used
for some other virtual page.

w: S — Process Status
The status of the task which can be one of:
‘D’ = uninterruptible sleep
‘R’ = running
‘S’ = sleeping
‘T’ = traced or stopped
‘Z’ = zombie

用CURL上傳檔案

用CURL call 上傳檔案的API:

Step1: 預存cookie檔案
curl -d “username=admin&password=admin" http://1.1.1.1:8080/login -D scookie.txt
Step2: 呼叫上傳API:
curl -X POST -H “Authorization: Basic YWRtaW46YWRtaW4=" -H “Content-Type:multipart/form-data" -b scookie.txt -F file="@/filename.ext" -F  overwrite="true" http://1.1.1.1:8080/upload

查看service的port

1.列出service一覽

sudo nmap -sU -sT localhost

2.由name查process id

ps aux | grep <process name>

3.由port查process

sudo netstat -anp | grep <port #>
sudo netstat -tulpn | grep <port #> –>只看tcp listen

 

[Linux] 找出被佔用 port 的 PID

sudo netstat -l -n -p | grep <port number>  #找出佔用 port 的 PID
ps aux | egrep -w <pid> | grep -v grep  #印出 PID 的資訊
sudo kill <pid or process_name> #刪掉 process

Linux Network 用 CLI 設定

sudo gedit /etc/wpa_supplicant.conf

network={
key_mgmt=IEEE8021X
eap=TTLS MD5
identity="myloginname"
anonymous_identity="myloginname"
password="mypassword"
phase1="auth=MD5″
phase2="auth=PAP password=mypassword"
eapol_flags=0
}

https://help.ubuntu.com/community/Network802.1xAuthentication