顯示廣告
隱藏 ✕
KVM

qemu-img create -f qed ubuntu-base.qed 100G

kvm -cdrom ubuntu-14.10-desktop-amd64.iso -m 2048 ubuntu-base.qed

qemu-img create -f qed -b ubuntu-base.qed ubuntu-d-1.qed 100G &

背景執行
&
ctrl+z
bg 1
fg 1


virsh list
virsh dumpxml
virsh define
virsh start
virsh destroy


載入
virsh save ubuntu-1 ubuntu-1-backup.state
靜態存檔

apt-get install vncviewer
VNC
vncviewer 127.0.0.1:5900

9BDRN-HMGRP-FKMDF-6BWG2-76DGY
44JKhXKfTXuDXZ3NpnMBebXrfDCe6URCVjUcjxNBu1vTMzG5Yso8Jp5bAcTeQmmECLGBzP234zNLVWx996C6yMH49tSXxLw

>-------------------------------------------------------------------------<

SQL

mysql -u root -p test
-p database

SELECT * FROM table;

select from tablename where conclitional

select sum<ae> from student;
總和
select avg<ae> from student;
平均

select substring<student.tel,1,3> tel-3;
student第1格只顯示前3 表格名稱代換tel-3

select * frome student where age not in <25,35,55>;

java.sql.*
javax.sql.*
JDBC套件




show processlist;
process列表

status;
系統狀況

show databases;
create database test;
drop database test;
use test;
show tables;
show table from 資料庫名稱;

show columns from 資料表名稱;
顯示資料表欄位

顯示資料表欄位設定 :   describe 資料表名稱;
顯示某個資料表的索引欄位設定 :   show index from 資料表名稱;

新增資料表 : create table 資料表名稱 ( 欄位名稱1 資料型態,欄位名稱2 資料型態 );
新增欄位 : alter table 資料表名稱 add 欄位名稱 資料型態;

修改資料表 : alter table 舊資料表名稱 rename 新資料表名稱;
修改欄位刪除 : alter table 資料表名稱 drop 欄位名稱


刪除資料庫 : drop database 資料庫名稱;
刪除資料表 : drop table 資料表名稱;
刪除欄位 : drop 欄位名稱;


欄位刪除 : alter table 資料表名稱 drop 欄位名稱

>-------------------------------------------------------------------------<

openvpn

step 1
vars.bat.sample
---------------------------------------------------------
---------------------------------------------------------
step 2
init-config.bat
vars.bat
clean-all.bat
build-dh.bat
build-ca.bat
---------------------------------------------------------
step 3
build-key-server.bat server
---------------------------------------------------------
step 4
build-key.bat client
---------------------------------------------------------
---------------------------------------------------------
step 5
server.ovpn
---------------------------------------------------------
port 1194
dev tun
proto tcp
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1  bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
client-to-client
keepalive 10 120
persist-key
persist-tun
verb 3

<ca>
-----BEGIN CERTIFICATE-----
MIIECjCCA3OgAwIBAgIJAP+gdhdVLiMVMA0GCSqGSIb3DQEBCwUAMIG1MQswCQYD
VQQGEwJVUzELMAkGA1UECBMCQ0ExFTATBgNVBAcTDFNhbkZyYW5jaXNjbzEVMBMG
A1UEChMMRm9ydC1GdW5zdG9uMR0wGwYDVQQLExRNeU9yZ2FuaXphdGlvbmFsVW5p
dDEYMBYGA1UEAxMPRm9ydC1GdW5zdG9uIENBMQ8wDQYDVQQpEwZzZXJ2ZXIxITAf
BgkqhkiG9w0BCQEWEm1lQG15aG9zdC5teWRvbWFpbjAeFw0xNjA1MTYxNTE2NTRa
Fw0yNjA1MTQxNTE2NTRaMIG1MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFTAT
BgNVBAcTDFNhbkZyYW5jaXNjbzEVMBMGA1UEChMMRm9ydC1GdW5zdG9uMR0wGwYD
VQQLExRNeU9yZ2FuaXphdGlvbmFsVW5pdDEYMBYGA1UEAxMPRm9ydC1GdW5zdG9u
IENBMQ8wDQYDVQQpEwZzZXJ2ZXIxITAfBgkqhkiG9w0BCQEWEm1lQG15aG9zdC5t
eWRvbWFpbjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAuCEqro+i7zrfUalK
Y860Fa6kGQnJWdvB/G+ulz/NJ8EZG8zNKarDKvkaMTEu/whVPUewp4NNxTfvhMjO
53zQBpx/la+S+1MsG25MA8VGJg+acUQrq3mJ7s6AwLKlgJC+Ikb0P5dXTPAZJGbY
P2IyrGc1FFfQl/I0k1E4r+bP7pUCAwEAAaOCAR4wggEaMB0GA1UdDgQWBBSYNQ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Z1Ha1OELIQwUHVsIJmS/FYndd7qRRQl9gQNz+Tbfg==
-----END CERTIFICATE-----
</cert>

<key>
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKaesQ4y14sOyIYd
KBwpnrzwWNLdSnV0zcaFpG45AN/0rQoXwF4xqRjYHZPHma9cY3vWf98fgp9ZDN27
OmUC6ULjEkjBOuRCrM07LkujhECLhiDBqXzMu3ERhtFAWx3aACR/OoDRZ0XwqRZ7
uVEFstY34O6nkUBVO2e42dls3QD9AgMBAAECgYEAoo376wBLLU2U8NMNSLyKM4bB
AagHdqQoBeBoVWijo9sP3uLhOIR2lthxsrVvCJi4Lh9MzZ/uTgwQ81owVFAMxTLp
oAOwfaJm2n636F0V8LBwOIgCwb4qXO4i0i7W9OLx14Q7NlTTrpOCfArFu04oBajI
SjDBogLjorZCjX9qawECQQDcoPWd62oqlSOt318jJPmOMKzHcF9NpOlHR0skYEP8
fs0Fb5ssrr4YFssZQEiYKtoGW+3R5kJNU2uZBc0TG9HdAkEAwVUaCZBBH5PmKhcv
fYlFWLLcEcC0HFPyDxmOzI/4+9oKsnPZuEBuxNgXhXnA2NJizTbuhlPpsnTyb3PP
3j5JoQJANjoppIL0OTsm5dl9HLo9zEESdoKcKg1aePaA9ZPjoe/YnHlt/nGEr48K
pE40iZIevGlj7q9VpIPYcmgGm6e+0QJBAKzYSM8ECTUSJVS8Jdk2QKlsPxQgFOa+
pkqZrvF0RkXkSmwA50WzVVTnXSAYGjG+5lZSJi4yF11U8OpzwAQR7AECQDbY+Aj2
IFKSMAJ5Uga8HuQy54antjhubdird+KN5HvZu+8p+QvIkrjruHmQ2WM8pSZG+nYY
pyh//RVij/8illk=
-----END PRIVATE KEY-----
</key>

<dh>
-----BEGIN DH PARAMETERS-----
MIGHAoGBAJxBWOQl17MeUWlHjeAoMD/FLw9qGx1wTRYef+XIKnSUZ88ROXjde9jh
hMKq1VFUlaqJO3uo8knzC//naIWKScEsbnXr91Ms1pmDbF5XEH6f/E5YPQxD59uA
nClSlS3zh6exljLhH5xi4kQUxg7307YWqMoGF75ixZmPkv7mP1q7AgEC
-----END DH PARAMETERS-----
</dh>
---------------------------------------------------------
step 6
client.ovpn
---------------------------------------------------------
client
dev tun
proto tcp
remote 8.8.8.8 1194
nobind
persist-key
persist-tun
verb 3

<ca>
-----BEGIN CERTIFICATE-----
MIIECjCCA3OgAwIBAgIJAP+gdhdVLiMVMA0GCSqGSIb3DQEBCwUAMIG1MQswCQYD
VQQGEwJVUzELMAkGA1UECBMCQ0ExFTATBgNVBAcTDFNhbkZyYW5jaXNjbzEVMBMG
A1UEChMMRm9ydC1GdW5zdG9uMR0wGwYDVQQLExRNeU9yZ2FuaXphdGlvbmFsVW5p
dDEYMBYGA1UEAxMPRm9ydC1GdW5zdG9uIENBMQ8wDQYDVQQpEwZzZXJ2ZXIxITAf
BgkqhkiG9w0BCQEWEm1lQG15aG9zdC5teWRvbWFpbjAeFw0xNjA1MTYxNTE2NTRa
Fw0yNjA1MTQxNTE2NTRaMIG1MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFTAT
BgNVBAcTDFNhbkZyYW5jaXNjbzEVMBMGA1UEChMMRm9ydC1GdW5zdG9uMR0wGwYD
VQQLExRNeU9yZ2FuaXphdGlvbmFsVW5pdDEYMBYGA1UEAxMPRm9ydC1GdW5zdG9u
IENBMQ8wDQYDVQQpEwZzZXJ2ZXIxITAfBgkqhkiG9w0BCQEWEm1lQG15aG9zdC5t
eWRvbWFpbjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAuCEqro+i7zrfUalK
Y860Fa6kGQnJWdvB/G+ulz/NJ8EZG8zNKarDKvkaMTEu/whVPUewp4NNxTfvhMjO
53zQBpx/la+S+1MsG25MA8VGJg+acUQrq3mJ7s6AwLKlgJC+Ikb0P5dXTPAZJGbY
P2IyrGc1FFfQl/I0k1E4r+bP7pUCAwEAAaOCAR4wggEaMB0GA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Vgj7ddDt8w2r0HNxA=
-----END CERTIFICATE-----
</cert>

<key>
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALxptjZheLvMoPTc
eR4qu2k/kWCZ8DZqdp/0c3009CqilLvJPcHhBrfON9ELZDojrJ+NAh4k7B27Hzm4
hskLIjjbE+QqmjMKHoFGbSKA2Fc7OwP7iBqQ2QaiDNaUEZC8tUrq0Ddjo6RTx2Lc
Ld6kiO8N+RfzzEzCiZbYzfBcSDGtAgMBAAECgYEAnq49WsFuqGPnrzG8A+8jVbnG
21/qkjnJ3F9JoMqnVP0GXL1Y+N9nBAh2s+VvLRP8f4eHoBGilkuROdCyG8H3uA6/
iv44DV5v9vlPgI1RMDiDN9vgdHgM2M6GZmPjUY9TLw0G5dDRy5vClyCvaYzXj36Y
DNkxZ7ROGfzY3tKLAwECQQDdgSWTp4LtCzWiPObpl4Aq1oIrx/KApe3b8nrnOiT5
6rMkCSjnhw93jz9Kr8ZWqBj6WhNPKw99OAY1NI5p/xbBAkEA2cFIzmCzc2OOUBMB
DK/DLo+5ImU+VBYFbAVTIDTSKZ1YsVObDsUsqtdVQBnEXzg4nMWdRvizU2HaR0dF
bMFh7QJBAL5FeenkMus8fc3nUtPFeCtUKG1DTGSGJFSTbk/B+pFTsp5539FCi17A
hjW52D4IF6y2Q2/2JVADGBIMG2mh3gECQHB9qV70FcBGbf5v0tr68ZncJYffRZOq
zKJBHfBFWUymPGtfBXtb4PdgxmmW5htKr/RNIjLHx9wLcPfhmbvVKwECQFdoYe6g
rKxgLV7jVKABRYgl+LgxMfWc6JRXtk4Eu/okB4Clx8c+HspUh20QrsEJNv/Wc5+D
x58qRzDUjfghLg4=
-----END PRIVATE KEY-----
</key>
---------------------------------------------------------
---------------------------------------------------------
ufw enable
ufw default deny
ufw allow 1194/tcp
ufw allow 1194/udp


vi /etc/default/ufw
-
DEFAULT_FORWARD_POLICY="ACCEPT"
--
vi /etc/ufw/sysctl.conf
-
net/ipv4/ip_forward=1
--

sysctl -p
ufw disable
ufw enable
ufw status

service openvpn restart

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o ppp0 -j MASQUERADE
iptables --table nat --list



>-------------------------------------------------------------------------<

redhat

#init 3
多人文字

#init 5
GUI

#init 6
reboot

#timedatectl set-local-rtc 1
硬體時鐘設置為本地時區

#systemctl set-default multi-user.target
#systemctl set-default graphical.target
change runlevel

#gsettings set org.gnome.settings-daemon.plugins.power button-power shutdown

systemctl stop firewalld.service
systemctl disable firewalld.service

blank: does nothing
suspend: makes your system suspend
shutdown: starts a normal issued shutdown procedure
hibernate: hibernates your system
nothing: does nothing
logout: log your user out




>-------------------------------------------------------------------------<

ipmitool

ipmitool -H 192.168.1.1 -U admin -P admin power status
ipmitool -H 192.168.1.1 -U admin -P admin lan print
ipmitool -H 192.168.1.1 -U admin -P admin sensor list
ipmitool -H 192.168.1.1 -U admin -P admin user list

ipmitool -H 192.168.1.1 -U admin -P admin bmc reset cold

ipmitool sel time get
BMC的時間
ipmitool sel time set "mm/dd/yyyy hh:mm:ss"
設時間

ipmitool power status
查看目前的電源狀況
ipmitool power on
開機
ipmitool power off
關機,是暴力關電,所以OS不是正常結束
ipmitool power reset
如同按下reset
ipmitool power cycle
似乎是讓系統先shutdown之後,過一秒再power on,這樣就不必常跑機房了
ipmitool power soft
透過ACPI讓OS shutdown或restart或log off

ipmitool chassis status
system status包含電源訊息,system狀況
ipmitool chassis identify
可以在機房機架中找到主機,燈號會閃15秒
ipmitool chassis restart_cause
查看上次系統重啟的原因

ipmitool -H 192.168.114.239 -U admin -P admin mc guid
ipmitool -H 192.168.114.239 -U admin -P admin raw 0x06 0x08
BMC-IPMI-mc_Device GUID



$ ipmitool -U username -P password -H 192.168.1.5 chassis power on
$ ipmitool -U username -P password -H 192.168.1.5 chassis power off
$ ipmitool -U username -P password -H 192.168.1.5 chassis power cycle
$ ipmitool -U username -P password -H 192.168.1.5 chassis power soft
$ ipmitool -U username -P password -H 192.168.1.5 chassis power status

$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev pxe
$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev bios
$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev disk

$ ipmitool -U username -P password -H 192.168.1.5 bmc info
$ ipmitool -U username -P password -H 192.168.1.5 lan print
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 ipsrc static
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 ipaddr 192.168.1.5
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 netmask 255.255.255.0
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 defgw ipaddr 192.168.1.254
$ ipmitool -U username -P password -H 192.168.1.5 mc info
$ ipmitool -U username -P password -H 192.168.1.5 mc reset cold

$ ipmitool -U username -P password -H 192.168.1.5 sdr
$ ipmitool -U username -P password -H 192.168.1.5 sel list


1. ipmitool -I lanplus -H <host> -U admin -P admin user set name 5 bob
2. ipmitool -I lanplus -H <host> -U admin -P admin user set password 5 bad_pass
3. ipmitool -I lanplus -H <host> -U admin -P admin user enable 5
4. ipmitool -I lanplus -H <host> -U admin -P admin channel setaccess 1 5 ipmi=on privilege=4
5. ipmitool -I lanplus -H <host> -U bob -P bad_pass user list 1


FB專用BMC AC斷電 ipmitool raw 0x06 0x52 0x0f 0x22 0x00 0xd9

>-------------------------------------------------------------------------<

power cycle

dmesg -C
echo "" > /var/log/messages
ipmitool sel clear
rm -rf /root/QuickHWCheck


./RunMe.sh



timedatectl set-local-rtc 1
systemctl set-default multi-user.target
gsettings set org.gnome.settings-daemon.plugins.power button-power shutdown

>-------------------------------------------------------------------------<

ESXI

Disable firewall
#esxcli network firewall get
#esxcli entwork firewall set --enabled false


Install Driver
There two types of ESXi driver
– vib
– offline_bundle

The related command

– Driver list
#esxcli software vib list
– Driver install
#esxcli software vib install –v /vib_stored_full_path.vib
#esxcli software vib install –d /offline_bundle_full_path.zip
– Drvier unistall
#esxcli software vib remove –n driver_name

OS event check(using msg_check)
Download message check tool from VRC
sit_tools>linux>utility>message-check
Download VMW white list from VRC
sit_tools>virtualization>utility>message-check
OOB command
#./msg_check.sh -2 -h esxi_ip -w white_list.csv -vmw

 If have error message, please get VM-support log from ESXi


1. Open any web browser (eg: Firefox)
2. Enter URL as below https://your_ESXi_IP/cgi-bin/vm-support.cgi
3. save this log to below path \\ccbu01\cc-share\Public_Zone\VMware_log


TM02L-8YH5M-L8P81-0M2R2-80U04
JH43M-FUJ53-68Y80-0C0HK-3XEMN



















>-------------------------------------------------------------------------<

bash

http://linuxdiary.blogspot.tw/2007/10/blog-post_30.html

參數
	
說明
a && b
	
如果 a 是真,則執行 b。如果 a 是假,則不執行 b。
a || b
	
如果 a 是假,則執行 b。如果 a 是真,則不執行 b。
a && b || c
	
如果 a 是真,則執行 b,如果 a 是假,則執行 c。
因為 a 為假時,a && b 為假,所以會去執行 c。
a && b && c && d && e && f || g
	
如果 a~f 有一個是假,則執行 c。
中括號的條件判斷

使用中括號必須要特別注意,因為中括號用在很多地方,包括萬用字元與正規表示法等等,所以如果要在 bash 的語法當中使用中括號作為 shell 的判斷式時,必須要注意中括號的兩端需要有空白字元來分隔喔!

檔案判斷
參數
	
說明
	
範列
-r file
	
檔案可讀為真。
	
[ -r /tmp/aaa ]
-w file
	
檔案可寫為真。
	
[ -w /tmp/aaa ]
-x file
	
檔案可執行為真。
	
[ -x /tmp/aaa ]
-f file
	
檔案為正規檔案為真。
	
[ -f /tmp/aaa ]
-d file
	
檔案為目錄為真。
	
[ -d /tmp/aaa ]
-c file
	
檔案為字元裝置為真。
	
[ -c /dev/aaa ]
-b file
	
檔案為區塊裝置為真。
	
[ -b /dev/aaa ]
-s file
	
檔案大小大於0為真。
	
[ -s /tmp/aaa ]
-t file
	
当文件描述符(默认为1)指定的设备为终端时为真。
	
[ -t /tmp/aaa ]
-p file
	
檔案為管道為真。
	
[ -p /tmp/aaa ]
-h file
	
檔案為符號連結為真。
	
[ -h /tmp/aaa ]
-L file
	
檔案為符號連結為真。
	
[ -L /tmp/aaa ]
字串比較
參數
	
說明
	
範列
"字串" = "字串"
	
比較二個字串相等為真。
	
[ "$a" = "$b" ]
"字串" == "字串"
	
比較二個字串相等為真。
	
[ "$a" == "$b" ]
"字串" != "字串"
	
比較二個字串不同為真。
	
[ "$a" != "$b" ]
-z "字串"
	
空字串為真。
	
[ -z "$b" ]
-n "字串"
	
非空字串為真。
	
[ -n "$b" ]
數字比較
參數
	
說明
	
範列
-eq
	
數字相等為真。
	
[ "$a" -eq "$b" ]
-ne
	
數字不相等為真。
	
[ "$a" -ne "$b" ]
-gt
	
數字較大為真。
	
[ "$a" -gt "$b" ]
-ge
	
數字較大或相等為真。
	
[ "$a" -ge "$b" ]
-lt
	
數字較小為真。
	
[ "$a" -lt "$b" ]
-le
	
數字較小或相等為真。
	
[ "$a" -le "$b" ]
多重條件比較
參數
	
說明
	
範列
-a
	
條件同時成立為真。
	
[ -r file -a -x file ]
-o
	
條件只要一個成立為真。
	
[ -r file -o -x file ]
!
	
反假為真,反正為假。
	
[ ! "$a" -gt "$b" ]





>-------------------------------------------------------------------------<

raspberry pi

raspi-config
expand_rootfs


/etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
sudo sysctl -p
sudo ifconfig eth0 down && sudo ifconfig eth0 up


ip link set eth0 down



/etc/ssh/sshd_config
#PermitRootLogin without-password
PermitRootLogin yes





apt-get install --no-install-recommends ubuntu-desktop

>-------------------------------------------------------------------------<

bash多開ping

#!/bin/bash

if [ $# -eq 0 ]
then
echo 'need input "ip_list" file'
exit 1
fi

echo Please Check The IP List:
cat $1 | tr -s "\n" > ip_l
cat ip_l > $1
rm ./ip_l
cat $1 | tr -s "\n" | nl

read -r -p  "continue? (y/n)" key
if [ "$key" = 'y' ]; then
        echo "Start to Run"
else
        echo "bye"
        exit 1
fi

for i in seq 1 $(nl $1 | tr -s "\n" | wc -l);do
echo sed -n "$i"p $1 Start
gnome-terminal -x ping sed -n "$i"p $1
done



>-------------------------------------------------------------------------<

ubuntu NAT

iptables -A FORWARD -o ens160 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -i ens160 -j ACCEPT
iptables -t nat -A POSTROUTING -o ens160 -j MASQUERADE

route add default gw <gatway ip> eth1



>-------------------------------------------------------------------------<

iperf

ip addr add 10.10.0.1/24 dev eth0
ip addr add 10.10.1.1/24 dev eth1
ip addr add 10.10.2.1/24 dev eth2
ip addr add 10.10.3.1/24 dev eth3

ip link set eth0 up
ip link set eth1 up
ip link set eth2 up
ip link set eth3 up

iperf -s -p 2000 -D
iperf -s -p 2001 -D
iperf -s -p 2002 -D
iperf -s -p 2003 -D

iperf -c 10.10.0.2 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth0.txt
iperf -c 10.10.1.2 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth1.txt
iperf -c 10.10.2.2 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth2.txt
iperf -c 10.10.3.2 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth3.txt






ip addr add 10.10.0.2/24 dev eth0
ip addr add 10.10.1.2/24 dev eth1
ip addr add 10.10.2.2/24 dev eth2
ip addr add 10.10.3.2/24 dev eth3

ip link set eth0 up
ip link set eth1 up
ip link set eth2 up
ip link set eth3 up

iperf -s -p 2000 -D
iperf -s -p 2001 -D
iperf -s -p 2002 -D
iperf -s -p 2003 -D

iperf -c 10.10.0.1 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth0.txt
iperf -c 10.10.1.1 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth1.txt
iperf -c 10.10.2.1 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth2.txt
iperf -c 10.10.3.1 -l 64k -w 64k -i 5 -P 10 -p 2000 -t 20 > eth3.txt







ip addr del 10.10.0.2/24 dev eth0



>-------------------------------------------------------------------------<

vmkfstools

vmkfstools -i ./win2016-clean_0-000002.vmdk  ./win2016-01.vmdk





















>-------------------------------------------------------------------------<

Mellanox driver

Linux SW/Drivers
http://www.mellanox.com/page/products_dyn?product_family=26&mtag=linux_sw_drivers

./mlnxofedinstall



Mellanox Firmware Tools (MFT)
http://www.mellanox.com/page/management_tools

mst start


Mellanox UEFI
http://www.mellanox.com/page/products_dyn?product_family=257&mtag=UEFI

flint -d /dev/mst/mt4117_pciconf0 --allow_rom_change brom ./FlexBoot-RELEASE_0x1015.efirom
flint -d /dev/mst/mt4117_pciconf0 q

http://www.mellanox.com/related-docs/prod_software/Mellanox_PreBoot_Drivers_User_Manual_v2.9.pdf


mlxup

./mlxup -d  -i  -f

http://www.mellanox.com/page/mlxup_firmware_tool

http://www.mellanox.com/page/firmware_table_ConnectX4LxEN

mst start
mst status
flint -d /dev/mst/mt4117_pciconf0 -i ./fw-ConnectX4Lx-rel-14_20_1010-MCX4411A-ACQ_Ax-FlexBoot-3.5.210.bin --allow_psid_change burn
reboot
flint -d /dev/mst/mt4117_pciconf0 --allow_rom_change brom ./FlexBoot-RELEASE_0x1015.efirom

http://www.mellanox.com/page/firmware_download





>-------------------------------------------------------------------------<

freeradius

apt install freeradius


client ipv6 {
        ipv6addr        = 2017::/16
        secret          = 123456
}

client ipv4 {
        ipaddr          = 192.168.0.0/16
        secret          = 123456
}


radius_h4 Cleartext-Password := "123456"
        Attr-26=0x483D34

radius_h3 Cleartext-Password := "123456"
        Attr-26=0x483D33

radius_h2 Cleartext-Password := "123456"
        Attr-26=0x483D32

radius_h1 Cleartext-Password := "123456"
        Attr-26=0x483D31

radius_h0 Cleartext-Password := "123456"
        Attr-26=0x483D30

suttest Cleartext-Password := "Adtest123"
        Attr-26=0x483D34

usertest Cleartext-Password := "Password12"
        Attr-26=0x483D34



radius_admin: Password: "123456"
Vendor-Specific Attributes: "H=4, I=4"
radius_operator: Password: "654321"
Vendor-Specific Attributes: "H=3, I=3"
radius_user: Password: "654321"
Vendor-Specific Attributes: "H=2, I=2"
radius_callback: Password: "654321"
Vendor-Specific Attributes: "H=1, I=1"


https://www.supermicro.com/support/faqs/faq.cfm?faq=22374
On pages 9 and 10 it gives the following example:
"radius_admin" User-Password == "123456"
Vendor-Specific = "H=4, I=4"
In FreeRadius 2.1.12, it should be:
"radius_admin" Cleartext-Password := "123456"
Vendor-Specific = "H=4, I=4"
HOWEVER, the "Vendor-specific" attribute is no longer supported by the RFC, which is why I was unable to get it to work in FreeRadius 3.0.4.
In FreeRadius >= 3.0.4 it should be:
"radius_admin" Cleartext-Password := "123456"
Attr-26 = 0x483D342C20493D34
(where the 0xblahblah) is the hex-encoding of the "H=4, I=4" string.
others are here:
Callback H=1, I=1 Attr-26 = 0x483D312C20493D31
User H=2, I=2 Attr-26 = 0x483D322C20493D32
Operator H=3, I=3 Attr-26 = 0x483D332C20493D33
Administrator H=4, I=4 Attr-26 = 0x483D342C20493D34





>-------------------------------------------------------------------------<

grub.cfg

set http_prefix="(http,192.168.1.1)"
set default='Reboot'
set timeout=60


if [ $grub_platform == efi ] ;then
        set platform="UEFI"
insmod efi_gop
insmod efi_uga
insmod font
else
        set platform="BIOS"
fi

menuentry "Exit (BOOT MODE: ${platform} $grub_platform $grub_cpu)" --unrestricted {
exit
}

menuentry "Reboot" --unrestricted {
reboot
}

menuentry 'Ubuntu Server 17.10' {
        linux  ${http_prefix}/linux
        initrd ${http_prefix}/initrd.gz
}








>-------------------------------------------------------------------------<

pxe

option domain-name "sitddns.com";
option domain-name-servers 192.168.16.1;

default-lease-time 600;
max-lease-time 7200;

ddns-update-style interim;
update-static-leases on;

zone sitddns.com. {
        primary 192.168.16.1;
}


  option space PXE;
  option PXE.mtftp-ip    code 1 = ip-address;
  option PXE.mtftp-cport code 2 = unsigned integer 16;
  option PXE.mtftp-sport code 3 = unsigned integer 16;
  option PXE.mtftp-tmout code 4 = unsigned integer 8;
  option PXE.mtftp-delay code 5 = unsigned integer 8;
  option arch code 93 = unsigned integer 16; # RFC4578


subnet 192.168.16.0 netmask 255.255.255.0 {
  range 192.168.16.50 192.168.16.100;
  option routers 192.168.16.1;


class "pxeclients" {
	
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
	
next-server 192.168.16.1;
	
if option arch = 00:00 {
	
filename "boot/grub/i386-pc/core.0";
	
} else {
	
filename "boot/grub/grub.efi";
	
}
}

}




>-------------------------------------------------------------------------<

Switch port mirror

將0/1的封包導到0/2做monitor


# configure
# port-monitor session 1 source interface 0/1
# port-monitor session 1 destination interface 0/2

enable port-monitor
# port-monitor session 1 mode

check port-monitor status
# do show port-monitor session

disable port-monitor
# no port-monitor session 1 mode









>-------------------------------------------------------------------------<

bash loop

#!/bin/bash
echo "" > running.log
ifconfig > g_ifconfig.txt

main(){
while [:]
do

for j in seq 1 3
do
	
echo -ne "$j\r"
	
sleep 1
done

ifconfig > now_ifconfig.txt
diff now_ifconfig.txt g_ifconfig.txt
if [ $? -ne 0 ]; then
	
echo "FAIL"
	
break
else
	
echo "PASS"
fi
done
}

main 2>&1 | tee -a "running.log"

>-------------------------------------------------------------------------<

robot

CheckAllSensors
    ${req_dict}    Create Dictionary
    : FOR    ${INDEX}    IN RANGE    1    89
    \    Log    ${INDEX}
    \    Click Element    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[${INDEX}]/td[1]
    \    Element Text Should Be    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[${INDEX}]/td[1]    @{Sensor_List}[${INDEX - 1}]
    \    Element Text Should Be    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[${INDEX}]/td[2]    @{Sensor_Status}[${INDEX - 1}]
    \    ${temp}=    Get Text    xpath=//*[@id="_lowerC"]
    \    Set To Dictionary    ${req_dict}    @{Sensor_List}[${INDEX - 1}]_lc=${temp}
    \    ${temp}=    Get Text    xpath=//*[@id="_lowerNC"]
    \    Set To Dictionary    ${req_dict}    @{Sensor_List}[${INDEX - 1}]_lnc=${temp}
    \    ${temp}=    Get Text    xpath=//*[@id="_upperC"]
    \    Set To Dictionary    ${req_dict}    @{Sensor_List}[${INDEX - 1}]_uc=${temp}
    \    ${temp}=    Get Text    xpath=//*[@id="_upperNC"]
    \    Set To Dictionary    ${req_dict}    @{Sensor_List}[${INDEX - 1}]_unc=${temp}
    Log    ${req_dict}



*** Settings ***
Suite Teardown    Close All Browsers
Force Tags        RM17_Sanity
Resource          ../Config_COMMON/VAR_User.robot
Resource          ../Config_IPMI/KEY_Common.robot
Resource          ../Config_WEB/KEY_Common.robot
Library           String
Library           json
Library           Collections
Library           OperatingSystem
Library           Selenium2Library

*** Variables ***
@{Sensor_List}    HDD0    HDD1    HDD2    HDD3    HDD4    HDD5    HDD6
...               HDD7    HDD8    HDD9    HDD10    HDD11    HDD12    HDD13
...               HDD14    HDD15    HDD16    HDD17    HDD18    HDD19    HDD20
...               HDD21    HDD22    HDD23    Temp_Outlet    Service_Status    CPU_0    CPU_1
...               Temp_CPU0    Temp_CPU1    Temp_DIMM_AB    Temp_DIMM_CD    Temp_DIMM_EF    Temp_DIMM_GH    Temp_VR_CPU0
...               Temp_VR_CPU1    Temp_VR_DIMM_AB    Temp_VR_DIMM_CD    Temp_VR_DIMM_EF    Temp_VR_DIMM_GH    CPU_DIMM_VRHOT    DIMM_HOT
...               Temp_PCI_Area    Temp_PCH    Fan_SYS0    Fan_SYS1    Fan_SYS2    Fan_SYS3    Fan_SYS4
...               Fan_SYS5    Fan_SYS6    Fan_SYS7    Volt_P3V3    Volt_P5V    Volt_P12V    Volt_P1V05
...               Volt_P1V8_AUX    Volt_P3V3_AUX    Volt_P5V_AUX    Volt_P3V_BAT    SYS_NIC1_LinkUp    SYS_NIC2_LinkUp    Volt_VR_CPU0
...               Volt_VR_CPU1    Volt_VR_DIMM_AB    Volt_VR_DIMM_CD    Volt_VR_DIMM_EF    Volt_VR_DIMM_GH    PSU1 Status    PSU2 Status
...               PSU1 Input    PSU2 Input    PSU Redundancy    Event Log    Watchdog    Power Unit    System Event
...               BMC_Mem_Free    CATERR    Temp_PCI_Inlet1    Temp_PCI_Inlet2    Temp_Ambient_FP    Button    Airflow
...               NVMeSSD_0    NVMeSSD_1    Fan_SSD0    Fan_SSD1
@{Sensor_Status}    Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence
...               Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence
...               Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence    Drive Presence
...               Drive Presence    Drive Presence    Drive Presence    Normal    KVM service is running Virtual storage service is running Web service is running    Processor Presence Detected    Processor Presence Detected
...               Normal    Normal    Normal    Normal    Normal    Normal    Normal
...               Normal    Normal    Normal    Normal    Normal    All deasserted    All deasserted
...               Normal    Normal    Normal    Normal    Normal    Normal    Normal
...               Normal    Normal    Normal    Normal    Normal    Normal    Normal
...               Normal    Normal    Normal    Normal    State Asserted    All deasserted    Normal
...               Normal    Normal    Normal    Normal    Normal    Presence Detected    Presence Detected
...               Normal    Normal    Fully Redundant (Redundancy Regained)    Log Area Reset/Cleared    All deasserted    All deasserted    All deasserted
...               Normal    All deasserted    Normal    Normal    Normal    All deasserted    Normal
...               Normal    Normal    Normal    Normal
&{Sensor_Spec}    HDD0_lc=N/A    HDD0_lnc=N/A    HDD0_uc=N/A    HDD0_unc=N/A    HDD1_lc=N/A    HDD1_lnc=N/A    HDD1_uc=N/A
...               HDD1_unc=N/A    HDD2_lc=N/A    HDD2_lnc=N/A    HDD2_uc=N/A    HDD2_unc=N/A    HDD3_lc=N/A    HDD3_lnc=N/A
...               HDD3_uc=N/A    HDD3_unc=N/A    HDD4_lc=N/A    HDD4_lnc=N/A    HDD4_uc=N/A    HDD4_unc=N/A    HDD5_lc=N/A
...               HDD5_lnc=N/A    HDD5_uc=N/A    HDD5_unc=N/A    HDD6_lc=N/A    HDD6_lnc=N/A    HDD6_uc=N/A    HDD6_unc=N/A
...               HDD7_lc=N/A    HDD7_lnc=N/A    HDD7_uc=N/A    HDD7_unc=N/A    HDD8_lc=N/A    HDD8_lnc=N/A    HDD8_uc=N/A
...               HDD8_unc=N/A    HDD9_lc=N/A    HDD9_lnc=N/A    HDD9_uc=N/A    HDD9_unc=N/A    HDD10_lc=N/A    HDD10_lnc=N/A
...               HDD10_uc=N/A    HDD10_unc=N/A    HDD11_lc=N/A    HDD11_lnc=N/A    HDD11_uc=N/A    HDD11_unc=N/A    HDD12_lc=N/A
...               HDD12_lnc=N/A    HDD12_uc=N/A    HDD12_unc=N/A    HDD13_lc=N/A    HDD13_lnc=N/A    HDD13_uc=N/A    HDD13_unc=N/A
...               HDD14_lc=N/A    HDD14_lnc=N/A    HDD14_uc=N/A    HDD14_unc=N/A    HDD15_lc=N/A    HDD15_lnc=N/A    HDD15_uc=N/A
...               HDD15_unc=N/A    HDD16_lc=N/A    HDD16_lnc=N/A    HDD16_uc=N/A    HDD16_unc=N/A    HDD17_lc=N/A    HDD17_lnc=N/A
...               HDD17_uc=N/A    HDD17_unc=N/A    HDD18_lc=N/A    HDD18_lnc=N/A    HDD18_uc=N/A    HDD18_unc=N/A    HDD19_lc=N/A
...               HDD19_lnc=N/A    HDD19_uc=N/A    HDD19_unc=N/A    HDD20_lc=N/A    HDD20_lnc=N/A    HDD20_uc=N/A    HDD20_unc=N/A
...               HDD21_lc=N/A    HDD21_lnc=N/A    HDD21_uc=N/A    HDD21_unc=N/A    HDD22_lc=N/A    HDD22_lnc=N/A    HDD22_uc=N/A
...               HDD22_unc=N/A    HDD23_lc=N/A    HDD23_lnc=N/A    HDD23_uc=N/A    HDD23_unc=N/A    Temp_Outlet_lc=N/A    Temp_Outlet_lnc=N/A
...               Temp_Outlet_uc=N/A    Temp_Outlet_unc=N/A    Service_Status_lc=N/A    Service_Status_lnc=N/A    Service_Status_uc=N/A    Service_Status_unc=N/A    CPU_0_lc=N/A
...               CPU_0_lnc=N/A    CPU_0_uc=N/A    CPU_0_unc=N/A    CPU_1_lc=N/A    CPU_1_lnc=N/A    CPU_1_uc=N/A    CPU_1_unc=N/A
...               Temp_CPU0_lc=N/A    Temp_CPU0_lnc=N/A    Temp_CPU0_uc=100 \u00b0 C    Temp_CPU0_unc=99 \u00b0 C    Temp_CPU1_lc=N/A    Temp_CPU1_lnc=N/A    Temp_CPU1_uc=100 \u00b0 C
...               Temp_CPU1_unc=99 \u00b0 C    Temp_DIMM_AB_lc=N/A    Temp_DIMM_AB_lnc=N/A    Temp_DIMM_AB_uc=100 \u00b0 C    Temp_DIMM_AB_unc=99 \u00b0 C    Temp_DIMM_CD_lc=N/A    Temp_DIMM_CD_lnc=N/A
...               Temp_DIMM_CD_uc=85 \u00b0 C    Temp_DIMM_CD_unc=84 \u00b0 C    Temp_DIMM_EF_lc=N/A    Temp_DIMM_EF_lnc=N/A    Temp_DIMM_EF_uc=85 \u00b0 C    Temp_DIMM_EF_unc=84 \u00b0 C    Temp_DIMM_GH_lc=N/A
...               Temp_DIMM_GH_lnc=N/A    Temp_DIMM_GH_uc=85 \u00b0 C    Temp_DIMM_GH_unc=84 \u00b0 C    Temp_VR_CPU0_lc=N/A    Temp_VR_CPU0_lnc=N/A    Temp_VR_CPU0_uc=85 \u00b0 C    Temp_VR_CPU0_unc=84 \u00b0 C
...               Temp_VR_CPU1_lc=N/A    Temp_VR_CPU1_lnc=N/A    Temp_VR_CPU1_uc=105 \u00b0 C    Temp_VR_CPU1_unc=104 \u00b0 C    Temp_VR_DIMM_AB_lc=N/A    Temp_VR_DIMM_AB_lnc=N/A    Temp_VR_DIMM_AB_uc=105 \u00b0 C
...               Temp_VR_DIMM_AB_unc=104 \u00b0 C    Temp_VR_DIMM_CD_lc=N/A    Temp_VR_DIMM_CD_lnc=N/A    Temp_VR_DIMM_CD_uc=105 \u00b0 C    Temp_VR_DIMM_CD_unc=104 \u00b0 C    Temp_VR_DIMM_EF_lc=N/A    Temp_VR_DIMM_EF_lnc=N/A
...               Temp_VR_DIMM_EF_uc=105 \u00b0 C    Temp_VR_DIMM_EF_unc=104 \u00b0 C    Temp_VR_DIMM_GH_lc=N/A    Temp_VR_DIMM_GH_lnc=N/A    Temp_VR_DIMM_GH_uc=105 \u00b0 C    Temp_VR_DIMM_GH_unc=104 \u00b0 C    CPU_DIMM_VRHOT_lc=N/A
...               CPU_DIMM_VRHOT_lnc=N/A    CPU_DIMM_VRHOT_uc=N/A    CPU_DIMM_VRHOT_unc=N/A    DIMM_HOT_lc=N/A    DIMM_HOT_lnc=N/A    DIMM_HOT_uc=N/A    DIMM_HOT_unc=N/A
...               Temp_PCI_Area_lc=N/A    Temp_PCI_Area_lnc=N/A    Temp_PCI_Area_uc=80 \u00b0 C    Temp_PCI_Area_unc=75 \u00b0 C    Temp_PCH_lc=N/A    Temp_PCH_lnc=N/A    Temp_PCH_uc=100 \u00b0 C
...               Temp_PCH_unc=98 \u00b0 C    Fan_SYS0_lc=N/A    Fan_SYS0_lnc=N/A    Fan_SYS0_uc=100 \u00b0 C    Fan_SYS0_unc=98 \u00b0 C    Fan_SYS1_lc=500 RPM    Fan_SYS1_lnc=1000 RPM
...               Fan_SYS1_uc=N/A    Fan_SYS1_unc=N/A    Fan_SYS2_lc=500 RPM    Fan_SYS2_lnc=1000 RPM    Fan_SYS2_uc=N/A    Fan_SYS2_unc=N/A    Fan_SYS3_lc=500 RPM
...               Fan_SYS3_lnc=1000 RPM    Fan_SYS3_uc=N/A    Fan_SYS3_unc=N/A    Fan_SYS4_lc=500 RPM    Fan_SYS4_lnc=1000 RPM    Fan_SYS4_uc=N/A    Fan_SYS4_unc=N/A
...               Fan_SYS5_lc=500 RPM    Fan_SYS5_lnc=1000 RPM    Fan_SYS5_uc=N/A    Fan_SYS5_unc=N/A    Fan_SYS6_lc=500 RPM    Fan_SYS6_lnc=1000 RPM    Fan_SYS6_uc=N/A
...               Fan_SYS6_unc=N/A    Fan_SYS7_lc=500 RPM    Fan_SYS7_lnc=1000 RPM    Fan_SYS7_uc=N/A    Fan_SYS7_unc=N/A    Volt_P3V3_lc=3.132 Volts    Volt_P3V3_lnc=N/A
...               Volt_P3V3_uc=3.466 Volts    Volt_P3V3_unc=N/A    Volt_P5V_lc=4.743 Volts    Volt_P5V_lnc=N/A    Volt_P5V_uc=5.251 Volts    Volt_P5V_unc=N/A    Volt_P12V_lc=4.743 Volts
...               Volt_P12V_lnc=N/A    Volt_P12V_uc=5.251 Volts    Volt_P12V_unc=N/A    Volt_P1V05_lc=0.99 Volts    Volt_P1V05_lnc=N/A    Volt_P1V05_uc=1.107 Volts    Volt_P1V05_unc=N/A
...               Volt_P1V8_AUX_lc=0.99 Volts    Volt_P1V8_AUX_lnc=N/A    Volt_P1V8_AUX_uc=1.107 Volts    Volt_P1V8_AUX_unc=N/A    Volt_P3V3_AUX_lc=3.132 Volts    Volt_P3V3_AUX_lnc=N/A    Volt_P3V3_AUX_uc=3.466 Volts
...               Volt_P3V3_AUX_unc=N/A    Volt_P5V_AUX_lc=4.622 Volts    Volt_P5V_AUX_lnc=N/A    Volt_P5V_AUX_uc=5.372 Volts    Volt_P5V_AUX_unc=N/A    Volt_P3V_BAT_lc=4.622 Volts    Volt_P3V_BAT_lnc=N/A
...               Volt_P3V_BAT_uc=5.372 Volts    Volt_P3V_BAT_unc=N/A    SYS_NIC1_LinkUp_lc=N/A    SYS_NIC1_LinkUp_lnc=N/A    SYS_NIC1_LinkUp_uc=N/A    SYS_NIC1_LinkUp_unc=N/A    SYS_NIC2_LinkUp_lc=N/A
...               SYS_NIC2_LinkUp_lnc=N/A    SYS_NIC2_LinkUp_uc=N/A    SYS_NIC2_LinkUp_unc=N/A    Volt_VR_CPU0_lc=1.35 Volts    Volt_VR_CPU0_lnc=N/A    Volt_VR_CPU0_uc=1.96 Volts    Volt_VR_CPU0_unc=N/A
...               Volt_VR_CPU1_lc=1.35 Volts    Volt_VR_CPU1_lnc=N/A    Volt_VR_CPU1_uc=1.96 Volts    Volt_VR_CPU1_unc=N/A    Volt_VR_DIMM_AB_lc=1.35 Volts    Volt_VR_DIMM_AB_lnc=N/A    Volt_VR_DIMM_AB_uc=1.96 Volts
...               Volt_VR_DIMM_AB_unc=N/A    Volt_VR_DIMM_CD_lc=1.08 Volts    Volt_VR_DIMM_CD_lnc=N/A    Volt_VR_DIMM_CD_uc=1.32 Volts    Volt_VR_DIMM_CD_unc=N/A    Volt_VR_DIMM_EF_lc=1.08 Volts    Volt_VR_DIMM_EF_lnc=N/A
...               Volt_VR_DIMM_EF_uc=1.32 Volts    Volt_VR_DIMM_EF_unc=N/A    Volt_VR_DIMM_GH_lc=1.08 Volts    Volt_VR_DIMM_GH_lnc=N/A    Volt_VR_DIMM_GH_uc=1.32 Volts    Volt_VR_DIMM_GH_unc=N/A    PSU1 Status_lc=N/A
...               PSU1 Status_lnc=N/A    PSU1 Status_uc=N/A    PSU1 Status_unc=N/A    PSU2 Status_lc=N/A    PSU2 Status_lnc=N/A    PSU2 Status_uc=N/A    PSU2 Status_unc=N/A
...               PSU1 Input_lc=0 Watts    PSU1 Input_lnc=N/A    PSU1 Input_uc=N/A    PSU1 Input_unc=N/A    PSU2 Input_lc=0 Watts    PSU2 Input_lnc=N/A    PSU2 Input_uc=N/A
...               PSU2 Input_unc=N/A    PSU Redundancy_lc=N/A    PSU Redundancy_lnc=N/A    PSU Redundancy_uc=N/A    PSU Redundancy_unc=N/A    Event Log_lc=N/A    Event Log_lnc=N/A
...               Event Log_uc=N/A    Event Log_unc=N/A    Watchdog_lc=N/A    Watchdog_lnc=N/A    Watchdog_uc=N/A    Watchdog_unc=N/A    Power Unit_lc=N/A
...               Power Unit_lnc=N/A    Power Unit_uc=N/A    Power Unit_unc=N/A    System Event_lc=N/A    System Event_lnc=N/A    System Event_uc=N/A    System Event_unc=N/A
...               BMC_Mem_Free_lc=N/A    BMC_Mem_Free_lnc=N/A    BMC_Mem_Free_uc=N/A    BMC_Mem_Free_unc=N/A    CATERR_lc=N/A    CATERR_lnc=N/A    CATERR_uc=N/A
...               CATERR_unc=N/A    Temp_PCI_Inlet1_lc=N/A    Temp_PCI_Inlet1_lnc=N/A    Temp_PCI_Inlet1_uc=80 \u00b0 C    Temp_PCI_Inlet1_unc=75 \u00b0 C    Temp_PCI_Inlet2_lc=N/A    Temp_PCI_Inlet2_lnc=N/A
...               Temp_PCI_Inlet2_uc=80 \u00b0 C    Temp_PCI_Inlet2_unc=75 \u00b0 C    Temp_Ambient_FP_lc=0 \u00b0 C    Temp_Ambient_FP_lnc=N/A    Temp_Ambient_FP_uc=45 \u00b0 C    Temp_Ambient_FP_unc=41 \u00b0 C    Button_lc=0 \u00b0 C
...               Button_lnc=N/A    Button_uc=45 \u00b0 C    Button_unc=41 \u00b0 C    Airflow_lc=N/A    Airflow_lnc=N/A    Airflow_uc=N/A    Airflow_unc=N/A
...               NVMeSSD_0_lc=N/A    NVMeSSD_0_lnc=N/A    NVMeSSD_0_uc=74 \u00b0 C    NVMeSSD_0_unc=73 \u00b0 C    NVMeSSD_1_lc=N/A    NVMeSSD_1_lnc=N/A    NVMeSSD_1_uc=74 \u00b0 C
...               NVMeSSD_1_unc=73 \u00b0 C    Fan_SSD0_lc=500 RPM    Fan_SSD0_lnc=1000 RPM    Fan_SSD0_uc=N/A    Fan_SSD0_unc=N/A    Fan_SSD1_lc=500 RPM    Fan_SSD1_lnc=1000 RPM
...               Fan_SSD1_uc=N/A    Fan_SSD1_unc=N/A

*** Test Cases ***
GetSpec
    Run    wget -O "S2B_S2Sx BMC FW Spec.rev047.doc" -N "http://192.168.10.147/10606121/test/raw/master/S2B_S2Sx%20BMC%20FW%20Spec.rev047.doc"
    Run    antiword "S2B_S2Sx BMC FW Spec.rev047.doc" > Spec.txt
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_AB |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_AB_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_AB |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_AB_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_CD |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_CD_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_CD |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_CD_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_EF |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_EF_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_EF |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_EF_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_GH |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_GH_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_DIMM_GH |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_DIMM_GH_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_CPU0 |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_CPU0_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_CPU0 |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_CPU0_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_CPU1 |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_CPU1_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_CPU1 |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_CPU1_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_AB |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_AB_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_AB |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_AB_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_CD |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_CD_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_CD |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_CD_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_EF |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_EF_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_EF |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_EF_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_GH |sed -n '3p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_GH_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_VR_DIMM_GH |sed -n '3p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_VR_DIMM_GH_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_PCI_Area |sed -n '2p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_PCI_Area_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_PCI_Area |sed -n '2p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_PCI_Area_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_PCH |sed -n '2p'|awk '{print $4 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_PCH_uc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Temp_PCH |sed -n '2p'|awk '{print $3 "| "}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Temp_PCH_unc=${spec_temp} °  C
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS0 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS0_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS0 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS0_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS1 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS1_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS1 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS1_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS2 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS2_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS2 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS2_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS3 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS3_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS3 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS3_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS4 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS4_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS4 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS4_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS5 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS5_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS5 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS5_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS6 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS6_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS6 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS6_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS7 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS7_uc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Fan_SYS7 |sed -n '$p'|awk '{print $5 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "Fan_SYS7_unc=${spec_temp} RPM
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P3V3 |sed -n '3p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P3V3_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P3V3 |sed -n '3p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P3V3_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P5V |sed -n '3p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P5V_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P5V |sed -n '3p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P5V_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P12V |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P12V_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P12V |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P12V_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P1V05 |sed -n '3p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P1V05_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P1V05 |sed -n '3p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P1V05_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P1V8_AUX |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P1V8_AUX_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P1V8_AUX |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P1V8_AUX_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P3V3_AUX |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P3V3_AUX_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P3V3_AUX |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P3V3_AUX_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P5V_AUX |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P5V_AUX_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P5V_AUX |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P5V_AUX_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P3V_BAT |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P3V_BAT_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_P3V_BAT |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_P3V_BAT_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_CPU0 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_CPU0_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_CPU0 |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_CPU0_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_CPU1 |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_CPU1_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_CPU1 |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_CPU1_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_AB |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_AB_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_AB |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_AB_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_CD |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_CD_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_CD |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_CD_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_EF |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_EF_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_EF |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_EF_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_GH |sed -n '$p'|awk '{print $3 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_GH_lc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep Volt_VR_DIMM_GH |sed -n '$p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    Volt_VR_DIMM_GH_uc=${spec_temp} Volts
    ${spec_temp}    Run    cat Spec.txt |grep "PSU1 Input" |sed -n '2p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "PSU1 Input"_lc=${spec_temp} Watts
    ${spec_temp}    Run    cat Spec.txt |grep "PSU2 Input" |sed -n '2p'|awk '{print $4 "|"}'| tr -d "|"" "
    Set To Dictionary    ${Sensor_Spec}    "PSU2 Input"_lc=${spec_temp} Watts
    ${spec_temp}    Run    cat Spec.txt |grep "NVMeSSD_0" |sed -n '2p'|awk '{print $5 "|"}'| tr -d "|"" ""[3]"
    Set To Dictionary    ${Sensor_Spec}    "NVMeSSD_0"_uc=${spec_temp} Watts
    ${spec_temp}    Run    cat Spec.txt |grep "NVMeSSD_0" |sed -n '2p'|awk '{print $7 "|"}'| tr -d "|"" ""[3]"
    Set To Dictionary    ${Sensor_Spec}    "NVMeSSD_0"_unc=${spec_temp} Watts
    ${spec_temp}    Run    cat Spec.txt |grep "NVMeSSD_1" |sed -n '2p'|awk '{print $5 "|"}'| tr -d "|"" ""[3]"
    Set To Dictionary    ${Sensor_Spec}    "NVMeSSD_1"_uc=${spec_temp} Watts
    ${spec_temp}    Run    cat Spec.txt |grep "NVMeSSD_1" |sed -n '2p'|awk '{print $7 "|"}'| tr -d "|"" ""[3]"
    Set To Dictionary    ${Sensor_Spec}    "NVMeSSD_1"_unc=${spec_temp} Watts

LoginBMCWebUIWOProfile
    KEY OpenBrowserWOProfile
    KEY LoginBMCWebUI

GoToSensorReadingsPage
    Wait Until Element Is Visible    xpath=//*[@id="LN_SERVER_HEALTH"]    30
    Click Element    xpath=//*[@id="LN_SERVER_HEALTH"]
    Wait Until Element Is Visible    xpath=/html/body/div[3]/a[1]    30
    Click Element    xpath=/html/body/div[3]/a[1]
    Select Frame    xpath=//*[@id="pageFrame"]
    Wait Until Element Is Visible    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[1]/td[1]    30

GoToAllSensors
    Click Element    xpath=//*[@id="_sensorType"]
    Click Element    xpath=//*[@id="_sensorType"]/option[1]
    Wait Until Element Is Visible    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[1]/td[1]    30

CheckAllSensors
    ${req_dict}    Create Dictionary
    : FOR    ${INDEX}    IN RANGE    1    89
    \    Log    ${INDEX}
    \    Click Element    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[${INDEX}]/td[1]
    \    Sleep    0.5
    \    Run Keyword And Continue On Failure    Element Text Should Be    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[${INDEX}]/td[1]    @{Sensor_List}[${INDEX - 1}]
    \    Run Keyword And Continue On Failure    Element Text Should Be    xpath=//*[@id="_infoLeft"]/div/table/tbody/tr[${INDEX}]/td[2]    @{Sensor_Status}[${INDEX - 1}]
    \    Set Suite Variable    ${temp}    @{Sensor_List}[${INDEX - 1}]_lc
    \    Run Keyword And Continue On Failure    Element Text Should Be    xpath=//*[@id="_lowerC"]    &{Sensor_Spec}[${temp}]
    \    Set Suite Variable    ${temp}    @{Sensor_List}[${INDEX - 1}]_lnc
    \    Run Keyword And Continue On Failure    Element Text Should Be    xpath=//*[@id="_lowerNC"]    &{Sensor_Spec}[${temp}]
    \    Set Suite Variable    ${temp}    @{Sensor_List}[${INDEX - 1}]_uc
    \    Run Keyword And Continue On Failure    Element Text Should Be    xpath=//*[@id="_upperC"]    &{Sensor_Spec}[${temp}]
    \    Set Suite Variable    ${temp}    @{Sensor_List}[${INDEX - 1}]_unc
    \    Run Keyword And Continue On Failure    Element Text Should Be    xpath=//*[@id="_upperNC"]    &{Sensor_Spec}[${temp}]

LogoutBMCWebUI
    KEY LogoutBMCWebUI


>-------------------------------------------------------------------------<

Robot Framework Windows

https://www.python.org/downloads/
https://pip.pypa.io/en/stable/installing/

python -m pip install --upgrade robotframework
python -m robot --version

python -m pip install robotframework-selenium2library
python -m pip install -U wxPython

python -m pip install robotframework-ride

https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/

ride.py











>-------------------------------------------------------------------------<

awk tr

ipmitool lan print |grep "MAC Address"|awk -F "MAC Address             : " '{print $2}'|tr -d ":"











>-------------------------------------------------------------------------<

SMTP SSL

openssl genrsa -out key.pem 2048
openssl req -new -key key.pem -out request.csr
openssl x509 -req -days 3650 -in request.csr -signkey key.pem -out certificate.pem


https://slproweb.com/products/Win32OpenSSL.html




key.pem
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA32axZAz0Cw9T8nx4Dn0GYSH3Vm/h9leVZxrMPCWlae1pfglQ
V9R6ELcd759Xpfjw5EZPX+yUCA6qeTK/pWPAvHCwePxTO280xwz/rm/pdNl18rMU
4nAnogZ8n6MKugUvmPghS8yYWcRR1MduUAul+tfpg+D0NoSYyTVm5mSftA+gNErW
JIq1eXt+cWgDeSXGQGw7KHLYsQ6HPzwx9869KNi8dFcLbLWio9MxsXx+U9Yyo3LS
gJEircZrWmQaMR0hCkVUcbznukYbcHDcmLuy0ZT4YH6OG82Mcx7WOyYGbz5F/We7
z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gkqhkiG9w0BAQsFAAOCAQEAOOueLDMl
XaCzlNQi+VLCVPY6tZU1E1d2ZVCnuA18jtbajOsCE77VaSVqpHqKelmiFJNF4PqR
ukEZRQPTgRah71fwZ41pgR+l6Qj41aBJ2ekZzX46xMqfXy0pBUjkvFQ1gBVayglK
adG0YNIySIECIBenB/ck095PeAcVuKxj13MXdPdMIUODdc/jL5HiWJBIogCS6kI2
RO54KOH44cW0q2viMhyY8Tn496nifiNBmoGlDRqwojn3JTIFv2cpmLZu5RE+8Nd4
wyrOC3/8R8NKZF42HMUtA1Osh80LIPrU3WwlofiuudzWjsn4rq7kA5T5sZij3YsI
Juo3P2jxBg8mTA==
-----END CERTIFICATE-----



>-------------------------------------------------------------------------<

Red Hat yum

cat << EOF > /etc/yum.repos.d/123.repo
[base]
name=CentOS-Base
baseurl=http://ftp.stu.edu.tw/Linux/CentOS/7/os/x86_64
gpgcheck=0
[updates]
name=CentOS-Updates
baseurl=http://ftp.stu.edu.tw/Linux/CentOS/7/updates/x86_64
gpgcheck=0
[extras]
name=CentOS-Extras
baseurl=http://ftp.stu.edu.tw/Linux/CentOS/7/extras/x86_64
gpgcheck=0
[centosplus]
name=CentOS-Plus
baseurl=http://ftp.stu.edu.tw/Linux/CentOS/7/centosplus/x86_64
gpgcheck=0
enabled=0
EOF


cat << EOF > /etc/yum.repos.d/google-x86_64.repo
[google64]
name=Google - x86_64
baseurl=http://dl.google.com/linux/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF

yum --enablerepo=extras install epel-release -y

yum install -y google-chrome-stable

google-chrome-stable --no-sandbox

echo -e "[daemon]\nAutomaticLoginEnable=True\nAutomaticLogin=root" > /etc/gdm/custom.conf

virsh net-destroy default





vim /etc/gdm/custom.conf

[daemon]
AutomaticLoginEnable=True
AutomaticLogin=root



virsh net-list
virsh net-destroy default
virsh net-undefine default
service libvirtd restart

>-------------------------------------------------------------------------<

DISPLAY


ps e | grep -Po " DISPLAY=[\.0-9A-Za-z:]* " | sort -u

DISPLAY=:0 firefox

export DISPLAY=:1
Xvfb :1 -screen 0 1024x768x16 &


pkill -9 -u id -u tester

>-------------------------------------------------------------------------<

test

#!/bin/bash
rm -rf ./log;
mkdir ./log;
bmc_up_time="180"
bmc_list=$1
ipmitool user list 1 > userlist1.txt;
main(){
for i in seq 1 $(nl $bmc_list | tr -s "\n" | wc -l)
do
date
sh=sed -n "$i"p $bmc_list | awk -F ',' '{print $1}'
echo $sh
ver=sed -n "$i"p $bmc_list | awk -F ',' '{print $2}'
echo $ver
./Yafuflash2 -vyes -pc -cd $sh
if [ $? -eq 0 ]; then
echo "Yafuflash2 PASS";
else
echo "Yafuflash2 FAIL";
exit 1
fi
echo "Wait BMC up ($bmc_up_time seconds)";
for j in seq 1 $bmc_up_time
do
echo -ne "$j\r";
sleep 1;
done
echo -ne '\n'
echo "Start to check sdr,mc info,Firmware Revision,user list 1"
mkdir ./log/$i
sdrpass="0"
mcinfopass="0"
verpass="0"
userpass="0"
k="0"
while [ $k -lt 5 ]
do
ipmitool sdr | awk -F"|" '{print $1 $3}' > ./log/$i/sdr.txt;
ipmitool mc info > ./log/$i/mcinfo.txt;
ipmitool user list 1 > ./log/$i/userlist1.txt;
sdrnl=nl ./log/$i/sdr.txt | tr -s "\n" | wc -l
if [ "$sdrnl" -gt 5 ]; then
echo "sdr check PASS";
let "sdrpass=1";
else
echo "Check Failed on sdr";
fi
mcinfonl=nl ./log/$i/mcinfo.txt | tr -s "\n" | wc -l
if [ "$mcinfonl" -gt 5 ]; then
echo "mc_info check PASS";
let "mcinfopass=1";
else
echo "Check Failed on mc_info";
fi
vernl=sed -n 3p ./log/$i/mcinfo.txt | grep "Firmware Revision" | awk -F ': ' '{print $2}'
if [ "$vernl" == "$ver" ]; then
echo "Firmware_Revision PASS";
let "verpass=1";
else
echo "Check Failed on Firmware_Revision";
fi
diff ./userlist1.txt ./log/$i/userlist1.txt
if [ $? -eq 0 ]; then
echo "user list PASS";
let "userpass=1";
else
echo "user list FAIL";
fi
if [ "$sdrpass" == "1" ] && [ "$mcinfopass" == "1" ] && [ "$verpass" == "1" ] && [ "$userpass" == "1" ]; then
echo "LOOP $i PASS";
break
fi
let "k++";
echo "Wail 3 seconds to recheck";
for j in seq 1 3
do
echo -ne "$j\r";
sleep 1
done
echo -ne '\n';
echo "recheck $k times";
done
if [ "$sdrpass" != "1" ]  || [ "$mcinfopass" != "1" ] || [ "$verpass" != "1" ] || [ "$userpass" != "1" ]; then
echo "LOOP $i FAIL";
exit 1
fi
done
}

main 2>&1 | tee -a "running.log"







var fs = require('fs');
var http = require('http');
var https = require('https');
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var privateKey = fs.readFileSync('key.pem', 'utf8');
var certificate = fs.readFileSync('cert.pem', 'utf8');
var credentials = { key: privateKey, cert: certificate, passphrase: '123456' };
var a=1;

app.get('/email', function (req, res) {
    var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
    console.log(ip);
    if (a > 9) {
        a=0;
    }
    console.log(a);
    res.end(a.toString());
    a++;
});

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.post('/', function (req, res) {
    console.log(JSON.stringify(req.body));
    res.end("OK");
});

var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);

httpServer.listen(80);
httpsServer.listen(443);

>-------------------------------------------------------------------------<

robot py


from robot.libraries.BuiltIn import BuiltIn
from robot.output import librarylogger
from robot.libraries.OperatingSystem import OperatingSystem

EXECDIR = BuiltIn().get_variable_value("${EXECDIR}")
listdir = OperatingSystem().list_directory(EXECDIR,'Config*',False)

for x in listdir:
    librarylogger.write(x, 'INFO', False)
    listfile = OperatingSystem().list_directory(EXECDIR+"/"+x,'*.robot',False)
    for y in listfile:
        librarylogger.write(EXECDIR+"/"+x+"/"+y, 'INFO', False)
        BuiltIn().import_resource(EXECDIR+"/"+x+"/"+y)

def log_hello(self):
    logger.console('hello')



https://stackoverflow.com/questions/...ables-from-python-library-code




>-------------------------------------------------------------------------<

Notepad++


(?s)\A(?!.*?(?<!\w)(KEY_ALL.robot)(?!\w)).*
(?s)\A((?!Use API site scope).)+\z

https://notepad-plus-plus.org/commun...that-do-not-contain-some-words
http://jeffery062.blogspot.com/2013/02/notepad-regular-expression.html







>-------------------------------------------------------------------------<

XPath Reference

ancestor
ancestor-or-self
attribute
child
descendant
descendant-or-self
following
following-sibling
parent
preceding
preceding-sibling
self

https://developer.mozilla.org/zh-CN/docs/Web/XPath/Axes



>-------------------------------------------------------------------------<

ubuntu

vim /etc/ssh/sshd_config
PermitRootLogin yes
service ssh restart

--------------------------------------------------

chmod 777 /etc/sudoers
vim /etc/sudoers

%sudo   ALL=(ALL:ALL) NOPASSWD:ALL

chmod 440 /etc/sudoers

--------------------------------------------------
ubuntu disable ipv6

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

sysctl -p
--------------------------------------------------

apt install python
apt install python-pip
apt install libsdl1.2-dev

pip install pypubsub
pip install robotframework
pip install robotframework-ride==1.7.4a1

pip install -U \
    -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 \
    wxPython


--------------------------------------------------
git 永久記憶帳密
git config --global credential.helper store



--------------------------------------------------
a=0;
for (i=2;i<1000;i++){
    for (j=2,k=0;j<i;j++){
        if (i%j === 0){
            k=1;
            break;
        }
    }
    if (k === 0) {
        a++;
        console.log(i);
    }
}
console.log(a);















>-------------------------------------------------------------------------<

docker

#Dockerfile

FROM alpine

RUN apk --no-cache add tzdata
RUN apk --no-cache add net-snmp
RUN cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
RUN echo 'disableAuthorization yes' > /etc/snmp/snmptrapd.conf
VOLUME ["/etc/snmp/","/var/lib/net-snmp/","/root","/tmp"]
EXPOSE 162
CMD ["snmptrapd","-Lf","/tmp/snmptrap.txt","-f","-n","-t","-On","-C","-c","/etc/snmp/snmptrapd.conf","0.0.0.0","::"]

---------------------------------------------------------------------------

docker build -t snmptrapd .
docker container ls
docker container stop trap1

brctl show

docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)

docker attach trap1
docker exec -it trap1 sh

docker network create -d macvlan --subnet=192.168.210.0/25 --gateway=192.168.210.126 --ipv6 --subnet=2017:401::0/32 --gateway=2017:401::254 -o parent=ens160 mynet

docker run --net=mynet --ip=192.168.210.1 --ip6=2017:401::1 -itd --rm -p 162:162/udp -v /tmp/snmptrapd1:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd1 snmptrapd
docker run --net=mynet --ip=192.168.210.2 --ip6=2017:401::2 -itd --rm -p 162:162/udp -v /tmp/snmptrapd2:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd2 snmptrapd
docker run --net=mynet --ip=192.168.210.3 --ip6=2017:401::3 -itd --rm -p 162:162/udp -v /tmp/snmptrapd3:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd3 snmptrapd
docker run --net=mynet --ip=192.168.210.4 --ip6=2017:401::4 -itd --rm -p 162:162/udp -v /tmp/snmptrapd4:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd4 snmptrapd
docker run --net=mynet --ip=192.168.210.5 --ip6=2017:401::5 -itd --rm -p 162:162/udp -v /tmp/snmptrapd5:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd5 snmptrapd
docker run --net=mynet --ip=192.168.210.6 --ip6=2017:401::6 -itd --rm -p 162:162/udp -v /tmp/snmptrapd6:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd6 snmptrapd
docker run --net=mynet --ip=192.168.210.7 --ip6=2017:401::7 -itd --rm -p 162:162/udp -v /tmp/snmptrapd7:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd7 snmptrapd
docker run --net=mynet --ip=192.168.210.8 --ip6=2017:401::8 -itd --rm -p 162:162/udp -v /tmp/snmptrapd8:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd8 snmptrapd
docker run --net=mynet --ip=192.168.210.9 --ip6=2017:401::9 -itd --rm -p 162:162/udp -v /tmp/snmptrapd9:/tmp -v /etc/snmp:/etc/snmp --name snmptrapd9 snmptrapd

docker exec -it trap1 sh

docker container inspect trap1













>-------------------------------------------------------------------------<

node-fetch

const fetch = require('node-fetch');

var lastid = "";
var title_list = [];
var id_list = [];
var output = "";

dofetch('https://www.dcard.tw/_api/forums/whysoserious/posts?popular=false&limit=100')

function dofetch(url) {
    fetch(url)
        .then(res => res.json())
        .then(function (json) {
            dofilter(json)
        })
}

function dofilter(res) {
    lastid = res[99].id
    let res_f = res.filter(res => res.school == "中國文化大學" && res.department == "法律學系");
    for (var i = 0; i < res_f.length; ++i) {
        title_list.push(res_f[i].title);
        id_list.push(res_f[i].id);
    }

    if (title_list.length < 3) {
        console.log(lastid)
        console.log(title_list.length)
        dofetch('https://www.dcard.tw/_api/forums/whysoserious/posts?popular=false&limit=100' + '&before=' + lastid)
    } else {
        for (var i = 0; i < title_list.length; ++i) {
            output = output + title_list[i];
            output = output + "\r\n";
            output = output + "https://www.dcard.tw/f/whysoserious/p/" + id_list[i];
            output = output + "\r\n";
        }
        console.log(output)
    }
}




















>-------------------------------------------------------------------------<

radvd netplan nsupdate

vim /etc/radvd.conf
interface ens160
{
   AdvSendAdvert on;
   prefix 2018:1:1:1::/64
   {
        AdvOnLink on;
        AdvAutonomous on;
        AdvRouterAddr off;
   };
};


service radvd restart
service radvd status
systemctl enable radvd


vim /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    ethernets:
        ens160:
            accept-ra: no
            addresses:
                - 192.168.16.1/24
                - 2018:1:1:1::1/64
            gateway4: 193.168.16.254
            gateway6: 2018:1:1:1::1
            match:
                macaddress: 00:0c:29:9f:c0:95
            set-name: ens160
            nameservers:
                addresses: [8.8.8.8]


vim /etc/bind/named.conf.default-zones
zone "sitddns.com" {
        type master;
        file "/etc/bind/db.sitddns";
        allow-transfer {any;};
        allow-query {any;};
        allow-update {any;};
        check-names ignore;
};



vim /etc/apparmor.d/usr.sbin.named
/etc/bind/** rw,
chmod -R 777 /etc/bind



vim /etc/bind/db.sitddns
$TTL    3600
@       IN      SOA     ns1.sitddns.com. root.sitddns.com. (
                         190710         ; Serial
                           3600         ; Refresh
                            300         ; Retry
                        3600000         ; Expire
                           3600 )       ; Negative Cache TTL

sitddns.com.         IN      NS      ns1.sitddns.com.
ns1.sitddns.com.     IN      A       192.168.16.1
sitddns.com.         IN      A       192.168.16.1
www.sitddns.com.     IN      CNAME   sitddns.com.


vim /etc/dhcp/dhcpd.conf
authoritative;
log-facility local7;
default-lease-time 600;
max-lease-time 7200;
option domain-name "sitddns.com";
option domain-name-servers 192.168.16.1;
ddns-updates on;
ddns-update-style standard;
ddns-domainname "sitddns.com.";
update-optimization off;
update-conflict-detection false;
allow client-updates;
zone sitddns.com. {
    primary 192.168.16.1;
}
subnet 192.168.16.0 netmask 255.255.255.0 {
    range 192.168.16.5 192.168.16.250;
    option routers 192.168.16.1;
}


vim /etc/dhcp/dhcpd6.conf
authoritative;
log-facility local7;
allow leasequery;
default-lease-time 2592000;
preferred-lifetime 604800;
option dhcp-renewal-time 3600;
option dhcp-rebinding-time 7200;
option dhcp6.domain-search "sitddns.com";
option dhcp6.name-servers 2018:1:1:1::1;
ddns-updates on;
ddns-update-style standard;
ddns-domainname "sitddns.com.";
update-optimization off;
update-conflict-detection false;
allow client-updates;
zone sitddns.com. {
    primary 192.168.16.1;
}
subnet6 2018:1:1:1::/64 {
    range6 2018:1:1:1::5 2018:1:1:1::9999;
}
option dhcp6.info-refresh-time 21600;


vim /etc/default/isc-dhcp-server


service isc-dhcp-server restart
service isc-dhcp-server status
service isc-dhcp-server6 restart
service isc-dhcp-server6 status
service bind9 restart
service bind9 status

# nsupdate
> server 127.0.0.1
> update delete www.sit.com A
> update add www.sit.com 600 A 192.168.1.1
> send
> quit



>-------------------------------------------------------------------------<

find json xpath

from robot.api import logger

class ff(object):
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self):
       
    def traverse(self, path, obj):
        self.list_temp = []
        cnt = -1
        if isinstance(obj, dict):
            d = obj
            for k, v in d.items():
                if isinstance(v, dict):
                    self.traverse("{path}.{k}".format(path=path, k=k),v)
                elif isinstance(v, list):
                    self.traverse("{path}.{k}".format(path=path, k=k),v)
                else:
                    self.list_temp.append("{path}.{k} => {v}".format(path=path, k=k, v=v))
        if isinstance(obj, list):
            li = obj
            for e in li:
                cnt += 1
                if isinstance(e, dict):
                    self.traverse("{path}[{cnt}]".format(path=path, cnt=cnt), e)
                elif isinstance(e, list):
                    self.traverse("{path}[{cnt}]".format(path=path, cnt=cnt), e)
                else:
                    self.list_temp.append("{path}[{cnt}] => {e}".format(path=path, cnt=cnt, e=e))
    return self.list_temp

    def jsontolist(self,obj):
        self.traverse ("root",obj)
       









from robot.api.deco import keyword

@keyword
def find_jsonpath_of_specific_value(json_obj, specific_value, path=None, list_temp=None):
    if path is None:
        path = ''
   
    if list_temp is None:
        list_temp = []
   
    count = -1
    if isinstance(json_obj, dict):
        dict_obj = json_obj
        for key, value in dict_obj.items():
            temp_path = "{path}.['{key}']".format(path=path, key=key)
            if isinstance(value, (dict, list)):
                find_jsonpath_of_specific_value(value, specific_value, temp_path, list_temp)
            else:
                if value == specific_value:
                    list_temp.append(temp_path)

    elif isinstance(json_obj, list):
        list_obj = json_obj
        for element in list_obj:
            count += 1
            temp_path = "{path}[{count}]".format(path=path, count=count)
            if isinstance(element, (dict, list)):
                find_jsonpath_of_specific_value(element, specific_value, temp_path, list_temp)
            else:
                if element == specific_value:
                  list_temp.append(temp_path)

    return list_temp




>-------------------------------------------------------------------------<

netplan

vim /etc/netplan/

network:
  ethernets:
        ens160:
                addresses:
                - 192.148.1.1/16
                - 2017:17::1/128
                gateway4: 192.148.255.254
                gateway6: fe80::3efd:feff:fe9e:bd98
                nameservers:
                        addresses: [168.95.1.1,8.8.8.8]
                dhcp4: false
                dhcp6: false
  version: 2
  renderer: NetworkManager



netplan try
netplan apply


>-------------------------------------------------------------------------<

lowdb

const express = require('express');
const bodyParser = require('body-parser');
const low = require('lowdb');
const FileAsync = require('lowdb/adapters/FileAsync');
const app = express();
app.use(bodyParser.json())
const adapter = new FileAsync('db.json');
const { exec } = require('child_process');
var https = require('https');
const fs = require('fs');

low(adapter)
    .then(db => {
        app.get('/getsnmptrapd/:ip', (req, res) => {
            console.log("\n get getsnmptrapd")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.ip);
            db.get('snmptrapd').filter((v) => { return v.using < Date.now() }).map('id').value().forEach((i) => { db.get('snmptrapd').find({ id: i }).assign({ using: 0 }).write() });

            var unused = db.get('snmptrapd').find({ using: 0 }).value()
            var unused_id = unused == undefined ? 0 : unused.id;
            console.log("unused_id: " + unused_id);

            var list1 = ['2', '3', '4', '5', '6', '7', '8', '9'];
            if (list1.indexOf(unused_id) > -1) {
                //7200000 2hr
                db.get('snmptrapd').find({ id: unused_id }).assign({ using: Date.now() + 7200000, tester: req.params.ip }).write()
                var output = db.get('snmptrapd').find({ id: unused_id }).value()
                res.status(200).send(output);
            } else {
                res.status(500).send("sold out");
            }
        })

        app.get('/releasesnmptrapd/:id', (req, res) => {
            console.log("\n get releasesnmptrapd")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.id);
            db.get('snmptrapd').find({ id: req.params.id }).assign({ using: 0, tester: "" }).write()
            res.status(200).send("released");
        })

        app.get('/getsmtp/:ip', (req, res) => {
            console.log("\n get getsmtp")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.ip);
            db.get('smtp').filter((v) => { return v.using < Date.now() }).map('id').value().forEach((i) => { db.get('smtp').find({ id: i }).assign({ using: 0 }).write() });

            var unused = db.get('smtp').find({ using: 0 }).value()
            var unused_id = unused == undefined ? 0 : unused.id;
            console.log("unused_id: " + unused_id);

            var list1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
            if (list1.indexOf(unused_id) > -1) {
                //7200000 2hr
                db.get('smtp').find({ id: unused_id }).assign({ using: Date.now() + 7200000, tester: req.params.ip }).write()
                var output = db.get('smtp').find({ id: unused_id }).value()
                res.status(200).send(output);
            } else {
                res.status(500).send("sold out");
            }
        })

        app.get('/releasesmtp/:id', (req, res) => {
            console.log("\n get releasesmtp")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.id);
            db.get('smtp').find({ id: req.params.id }).assign({ using: 0, tester: "" }).write()
            res.status(200).send("released");
        })

        app.get('/getlogserver/:ip', (req, res) => {
            console.log("\n get getlogserver")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.ip);
            db.get('logserver').filter((v) => { return v.using < Date.now() }).map('id').value().forEach((i) => { db.get('logserver').find({ id: i }).assign({ using: 0 }).write() });

            var unused = db.get('logserver').find({ using: 0 }).value()
            var unused_id = unused == undefined ? 0 : unused.id;
            console.log("unused_id: " + unused_id);

            var list1 = ['1'];
            if (list1.indexOf(unused_id) > -1) {
                db.get('logserver').find({ id: unused_id }).assign({ using: Date.now() + 180000, tester: req.params.ip }).write()
                var output = db.get('logserver').find({ id: unused_id }).value()
                res.status(200).send(output);
            } else {
                res.status(500).send("sold out");
            }
        })

        app.get('/releaselogserver/:id', (req, res) => {
            console.log("\n get releaselogserver")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.id);
            db.get('logserver').find({ id: req.params.id }).assign({ using: 0, tester: "" }).write()
            res.status(200).send("released");
        })

        app.get('/getpostserver/:ip', (req, res) => {
            console.log("\n get getpostserver")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.ip);
            db.get('postserver').filter((v) => { return v.using < Date.now() }).map('id').value().forEach((i) => { db.get('postserver').find({ id: i }).assign({ using: 0 }).write() });

            var unused = db.get('postserver').find({ using: 0 }).value()
            var unused_id = unused == undefined ? 0 : unused.id;
            console.log("unused_id: " + unused_id);

            var list1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
            if (list1.indexOf(unused_id) > -1) {
                db.get('postserver').find({ id: unused_id }).assign({ using: Date.now() + 180000, tester: req.params.ip }).write()
                var output = db.get('postserver').find({ id: unused_id }).value()
                res.status(200).send(output);
            } else {
                res.status(500).send("sold out");
            }
        })

        app.get('/releasepostserver/:id', (req, res) => {
            console.log("\n get releasepostserver")
            console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
            console.log(req.params.id);
            db.get('postserver').find({ id: req.params.id }).assign({ using: 0, tester: "" }).write()
            res.status(200).send("released");
        })

    })
    .then(() => {
        app.listen(80, () => console.log('listening on port 80'))
    })

app.get('/', function (req, res) {
    res.status(200).send("HI");
});

app.get('/db', function (req, res) {
    exec('cat db.json', (error, stdout, stderr) => {
        res.status(200).send(JSON.parse(stdout.toString()));
    });
});

app.post('/post/:id', function (req, res) {
    fs.appendFile('/tmp/post' + req.params.id + '.txt', JSON.stringify(req.body), 'utf8', (err) => {
        if (err) throw err;
        res.status(200).send("OK");
    });
});

app.get('/clearpost/:id', function (req, res) {
    exec('echo -n "" > /tmp/post' + req.params.id + '.txt', (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send("cleared");
    });
});

app.get('/getpost/:id', function (req, res) {
    exec('cat /tmp/post' + req.params.id + '.txt | jq --slurp --compact-output .', (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send(stdout.toString());
    });
});

app.get('/cleartrap/:id', (req, res) => {
    console.log("\n get cleartrap")
    console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
    exec('echo -n "" > /tmp/snmptrapd' + req.params.id + '/snmptrap.txt', (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send("cleared");
    });
})

app.get('/gettrap/:id', (req, res) => {
    console.log("\n get gettrap")
    console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
    exec('cat /tmp/snmptrapd' + req.params.id + '/snmptrap.txt|tr -d "\\0"|sed -e "s/2019-/\\n2019-/"|sed -e "s/2020-/\\n2020-/"', (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send(stdout.toString());
    });
})

app.get('/clearemail/:smtpip/:email', (req, res) => {
    console.log("\n get clearemail")
    console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
    exec('./clearemail.sh' + " " + req.params.smtpip + " " + req.params.email, (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send("cleared");
    });
})

app.get('/getemail/:smtpip/:email', (req, res) => {
    console.log("\n getemail")
    console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
    exec('./getemail.sh' + " " + req.params.smtpip + " " + req.params.email, (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send(stdout.toString());
    });
})

app.get('/clearsyslog', (req, res) => {
    exec('echo -n "" > /var/log/log.txt', (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send("OK");
    });
})

app.get('/getsyslog', (req, res) => {
    exec('cat /var/log/log.txt', (error, stdout, stderr) => {
        if (error) {
            console.error(exec error: ${error});
            return;
        }
        res.status(200).send(stdout.toString());
    });
})

app.post('/trapv3user', (req, res) => {
    console.log("\n post trapv3user")
    console.log(new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString())
    // console.log(req.body.name);
    // console.log(req.body.pwd);
    // console.log(req.body.auth);
    // console.log(req.body.priv);
    // console.log(req.body.engineid);
    // console.log(req.body.snmpid);
    if (req.body.name && req.body.pwd && req.body.auth && req.body.priv && req.body.engineid && req.body.snmpid) {
        exec('echo createUser -e ' + req.body.engineid + ' ' + req.body.name + ' ' + req.body.auth + ' \\"' + req.body.pwd + '\\" ' + req.body.priv + '>> /etc/snmp/snmptrapd.conf', (error, stdout, stderr) => {
            if (error !== null) {
                console.error(exec error: ${error});
                return;
            }
            exec('docker stop snmptrapd' + req.body.snmpid + ';docker run --net=mynet --ip=192.148.1.' + req.body.snmpid + ' --ip6=2017:17::' + req.body.snmpid + ' -itd --rm -p 162:162/udp -v /tmp/snmptrapd' + req.body.snmpid + ':/tmp -v /etc/snmp:/etc/snmp --name snmptrapd' + req.body.snmpid + ' snmptrapd;' + 'sleep 2;echo -n "" > /tmp/snmptrapd' + req.body.snmpid + '/snmptrap.txt;');
            console.log('echo docker stop snmptrapd' + req.body.snmpid + ';docker run --net=mynet --ip=192.148.1.' + req.body.snmpid + ' --ip6=2017:17::' + req.body.snmpid + ' -itd --rm -p 162:162/udp -v /tmp/snmptrapd' + req.body.snmpid + ':/tmp -v /etc/snmp:/etc/snmp --name snmptrapd' + req.body.snmpid + ' snmptrapd;');
            res.status(200).send("OK");
        });
    } else {
        res.status(500).send("params error");
    }
})

https.createServer({
    key: fs.readFileSync('server.key'),
    cert: fs.readFileSync('server.cert')
}, app)
    .listen(443, function () {
        console.log('listening on port 443')
    })


>-------------------------------------------------------------------------<

woo

const puppeteer = require('puppeteer');

(async () => {
    async function leaveChat() {
        await page.evaluate(() => {
            document.querySelector('#messageInput').value = '';
            document.querySelector('input[value=離開]').click();
            document.querySelector('#popup-yes').click();
            setTimeout(() => {
                document.querySelector('#ensureText').value = 'leave';
                document.querySelector('#popup-yes').click();
            }, 1);
        });

        await page.evaluate(() => {
            setTimeout(() => {
                document.querySelector('#startButton').click();
            }, 1000);
        });
    }

    const browser = await puppeteer.launch({
        userDataDir: './userdir',
        executablePath:
            'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
        headless: false,
        args: [
            '--no-proxy-server', '--enable-automation', '--mute-audio', '--window-size=340,520', '--app=https://wootalk.today/'
        ]
    });

    const page = (await browser.pages())[0];
    // await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0');
    // await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36');
    // await page.setUserAgent('Mozilla/5.0 (Linux; Android 10; Pixel 4 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.111 Mobile Safari/537.36');
    // await page.setViewport({ width: 400, height: 600 });
    await page.emulate(puppeteer.devices['iPhone 4']);
    // await page.goto('https://wootalk.today/');
    await page.waitForSelector('#startButton');
    await page.click('#startButton');

    await page._client.on('Network.webSocketFrameReceived', ({ requestId, timestamp, response }) => {
        // console.log(response.payloadData);
        if (response.payloadData.indexOf('對方離開了') > 0) {
            if (this.leaveing != 1) {
                this.leaveing = 1
                console.log("::::::::::::對方離開了");
                leaveChat()
                setTimeout(() => {
                    this.leaveing = 0
                }, 100);
            }
        } else if (response.payloadData.indexOf('[["client_connected"') == 0) {
            this.starttime = response.payloadData
            this.LastMessageTime = response.payloadData

            setTimeout((starttime = response.payloadData) => {
                if (starttime == this.starttime && starttime == this.LastMessageTime) {
                    console.log("::::::::::::不說話");
                    setTimeout(() => {
                        leaveChat()
                    }, 100);
                }
            }, 10000);
        } else if (response.payloadData.indexOf('[["new_message"') == 0 && response.payloadData.indexOf('device') > 0) {
            const aRegExp = /\{.*\}/;
            const newMessage = JSON.parse(response.payloadData.match(aRegExp));
            if (this.LastMessageTime != newMessage.data.time) {
                this.LastMessageTime = newMessage.data.time;
                if (response.payloadData.indexOf('"sender":2') > 0) {
                    console.log(newMessage.data.message);
                    if (newMessage.data.id < 4) {
                        var substrings = ["男", "叔", "弟", "找", "嗎", "女?", "女?", "女生?"];
                        if (substrings.some(function (v) { return newMessage.data.message.indexOf(v) >= 0; })) {
                            console.log("::::::::::::主動離開");
                            setTimeout(() => {
                                leaveChat()
                            }, 1000);
                        } else if (newMessage.data.id == 0) {
                            page.evaluate(() => {
                                const a1 = ["男", "男生", "男的"];
                                const a2 = ["Hi", "妳好", "安安"];
                                document.querySelector('#messageInput').value = a1[Math.floor(Math.random() * a1.length)];
                                document.querySelector('input[value=傳送]').click();
                                document.querySelector('#messageInput').value = a2[Math.floor(Math.random() * a2.length)];
                                document.querySelector('input[value=傳送]').click();
                            });
                        }
                    }
                }
            }
        }
    });
})();


>-------------------------------------------------------------------------<

kerberos

vim /etc/hosts
192.168.212.224 remote.example.com remote
192.168.212.199 server.example.com server
192.168.212.139 client.example.com client

hostnamectl set-hostname remote.example.com
hostnamectl set-hostname server.example.com
hostnamectl set-hostname client.example.com

kerberos
server
client

server 192.168.16.1
update add remote.example.com 0 A 192.168.212.224
update add server.example.com 0 A 192.168.212.199
update add client.example.com 0 A 192.168.134.207

systemctl start kadmin krb5kdc
systemctl enable kadmin krb5kdc
systemctl status kadmin krb5kdc
netstat -tlunp

systemctl start kadmin
systemctl enable kadmin

systemctl restart chronyd
systemctl enable chronyd
systemctl status chronyd

firewall-cmd --add-service=nfs
firewall-cmd --add-service=nfs --permanent
firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.0.0/16" accept'
firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.0.0/16" accept' --permanent

systemctl restart nfs-client.target
systemctl enable nfs-client.target
systemctl status rpc-gssd

systemctl stop firewalld.service
systemctl disable firewalld.service

systemctl restart kadmin
systemctl restart kerberos


addprinc -randkey host/remote.example.com
addprinc -randkey host/server.example.com
addprinc -randkey host/client.example.com

addprinc -randkey nfs/remote.example.com
addprinc -randkey nfs/server.example.com
addprinc -randkey nfs/client.example.com

scp remote:/etc/krb5.conf /etc


ktadd host/server.example.com@EXAMPLE.COM
ktadd nfs/server.example.com@EXAMPLE.COM
ktadd -k /root/client.keytab host/client.example.com@EXAMPLE.COM
ktadd -k /root/client.keytab nfs/client.example.com@EXAMPLE.COM

systemctl stop firewalld
systemctl disable firewalld

vim /etc/selinux/config


vim /etc/fstab
systemctl restart nfs-secure
showmount -e server
mount -a

vim /etc/fstab
192.168.212.199:/nfs1 /mnt/nfs nfs defaults,v4.2,sec=krb5p 0 0

mount -t nfs4 -o sec=krb5 server:/nfs1 /mnt/nfs







>-------------------------------------------------------------------------<

pm2

npm install pm2 -g

pm2 start --name app app.js

pm2 startup
pm2 save

pm2 logs [--raw]       # Display all processes logs in streaming
pm2 flush              # Empty all log files
pm2 reloadLogs         # Reload all logs

>-------------------------------------------------------------------------<

ldap

ssl
https://www.server-world.info/en/note?os=Ubuntu_16.04&p=openldap&f=4
log
https://www.openldap.org/doc/admin24/slapdconf2.html
starttls
https://ubuntu.com/server/docs/service-ldap-with-tls

https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/creating-ssl-files-using-openssl.html
https://help.ubuntu.com/community/SecuringOpenLDAPConnections
-----------------------------------------------------------------------
apt install -y slapd ldap-utils
dpkg-reconfigure slapd

vim /etc/ldap/ldap.conf

BASE    dc=ex,dc=com
URI     ldap:// ldaps://

TLS_CACERT      /etc/ldap/sasl2/ca.pem
-----------------------------------------------------------------------
yum -y install openldap openldap-clients openldap-servers
rpm -qa |grep openldap
systemctl stop firewalld
systemctl disable firewalld
systemctl mask --now firewalld

slappasswd -h {SSHA} -s 123456

echo 'local4.* /var/log/ldap.log' >> /etc/rsyslog.conf
service rsyslog restart

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif

vim /etc/sysconfig/slapd
-----------------------------------------------------------------------
cn=config.ldif
olcLogLevel: -1

olcDatabase={2}hdb.ldif
olcSuffix: dc=ex,dc=com
olcRootDN: cn=admin,dc=ex,dc=com
olcRootPW: {SSHA}AAN+WziS3s6IxXcY+TagzfkNbNbkndPf
olcSecurity: tls=1

https://askubuntu.com/questions/1210313/openldap-trouble-setting-tls-cipher-list

dn: cn=config
changetype: modify
add: olcTLSCipherSuite
olcTLSCipherSuite: SECURE256:+SECURE128:-VERS-TLS-ALL:+VERS-TLS1.2:+VERS-DTLS1.2:-RSA:-DHE-DSS:-CAMELLIA-128-CBC:-CAMELLIA-256-CBC
-----------------------------------------------------------------------
config.ldif

# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 e35f741b
dn: cn=config
objectClass: olcGlobal
cn: config
olcArgsFile: /var/run/slapd/slapd.args
olcLogLevel: none
olcPidFile: /var/run/slapd/slapd.pid
olcToolThreads: 1
structuralObjectClass: olcGlobal
entryUUID: 0908239a-20c1-103b-87dc-7d261b19268a
creatorsName: cn=config
createTimestamp: 20210324074815Z
entryCSN: 20210324074815.323340Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20210324074815Z
olcTLSCACertificateFile: /etc/ldap/sasl2/ca.pem
olcTLSCertificateFile: /etc/ldap/sasl2/cert.pem
olcTLSCertificateKeyFile: /etc/ldap/sasl2/key.pem
olcTLSCipherSuite: SECURE256:+SECURE128:-VERS-TLS-ALL:+VERS-TLS1.2:+VERS-DTL
 S1.2:-RSA:-DHE-DSS:-CAMELLIA-128-CBC:-CAMELLIA-256-CBC
-----------------------------------------------------------------------
ldapwhoami -H ldap://ex.com -x -ZZ
/usr/sbin/slapd -d 1 -h "ldap:/// ldapi:/// ldaps:///" -g openldap -u openldap -F /etc/ldap/slapd.d
-----------------------------------------------------------------------
-----------------------------------------------------------------------
dn: dc=ex,dc=com
dc: ex
objectClass: top
objectClass: dcObject
objectClass: organization
o: ex.com

dn: cn=admin, dc=ex,dc=com
userPassword:: e1NIQX1mRXFOQ2NvM1lxOWg1WlVnbEQzQ1pKVDRsQnM9
description: LDAP administrator
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin

dn: ou=People, dc=ex,dc=com
ou: People
objectClass: organizationalUnit

dn: uid=user1,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18001
userPassword:: e1NIQX1mRXFOQ2NvM1lxOWg1WlVnbEQzQ1pKVDRsQnM9
uidNumber: 18001
uid: user1
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/user1
cn: user1

dn: uid=user2,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18002
userPassword:: e1NIQX1mRXFOQ2NvM1lxOWg1WlVnbEQzQ1pKVDRsQnM9
uidNumber: 18002
uid: user2
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/user2
cn: user2

dn: uid=user3,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18003
userPassword:: e1NIQX1mRXFOQ2NvM1lxOWg1WlVnbEQzQ1pKVDRsQnM9
uidNumber: 18003
uid: user3
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/user3
cn: user3

dn: uid=user4,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18004
userPassword:: e1NIQX1mRXFOQ2NvM1lxOWg1WlVnbEQzQ1pKVDRsQnM9
uidNumber: 18004
uid: user4
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/user4
cn: user4

dn: uid=user5,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18005
userPassword:: e1NIQX1mRXFOQ2NvM1lxOWg1WlVnbEQzQ1pKVDRsQnM9
uidNumber: 18005
uid: user5
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/user5
cn: user5

dn: uid=usertest,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18006
userPassword:: e1NIQX1OT2tOMWRYQUtUK0d1WlI2alc4b0RZVHh3YjQ9
uidNumber: 18006
uid: usertest
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/usertest
cn: usertest

dn: uid=suttest,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18007
userPassword:: e1NIQX1SNkI1aDFMeHNNaHNISVBoUER5NC9ka1pqbzQ9
uidNumber: 18007
uid: suttest
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/suttest
cn: suttest

dn: uid=redfish,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18008
userPassword:: e1NIQX1SNkI1aDFMeHNNaHNISVBoUER5NC9ka1pqbzQ9
uidNumber: 18008
uid: redfish
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/redfish
cn: redfish

dn: uid=rr123test,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18009
userPassword:: e1NIQX1JdFF4MUJEajA1c0ZVMjhUOW1sTVpHNTQwYXc9
uidNumber: 18009
uid: rr123test
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/rr123test
cn: rr123test

dn: uid=rr1234test,ou=People, dc=ex,dc=com
loginShell: /bin/bash
gidNumber: 18010
userPassword:: e1NIQX1aZHY5a2RwRkxxa1plTkh2cTBFMENEcjJQUlk9
uidNumber: 18010
uid: rr1234test
objectClass: top
objectClass: account
objectClass: posixAccount
homeDirectory: /home/rr1234test
cn: rr1234test

dn: ou=Group, dc=ex,dc=com
ou: Group
objectClass: organizationalUnit

dn: cn=group1,ou=Group, dc=ex,dc=com
objectClass: groupOfNames
member: uid=user1,ou=People,dc=ex,dc=com
member: uid=suttest,ou=People,dc=ex,dc=com
member: uid=usertest,ou=People,dc=ex,dc=com
member: uid=rr123test,ou=People,dc=ex,dc=com
member: uid=rr1234test,ou=People,dc=ex,dc=com
member: uid=redfish,ou=People,dc=ex,dc=com
cn: group1

dn: cn=group2,ou=Group, dc=ex,dc=com
objectClass: groupOfNames
member: uid=user2,ou=People,dc=ex,dc=com
cn: group2

dn: cn=group3,ou=Group, dc=ex,dc=com
objectClass: groupOfNames
member: uid=user3,ou=People,dc=ex,dc=com
cn: group3

dn: cn=group4,ou=Group, dc=ex,dc=com
objectClass: groupOfNames
member: uid=user4,ou=People,dc=ex,dc=com
cn: group4

dn: cn=group5,ou=Group, dc=ex,dc=com
objectClass: groupOfNames
member: uid=user5,ou=People,dc=ex,dc=com
cn: group5

dn: cn=admin1, dc=ex,dc=com
userPassword:: e1NIQX1mRXFOQ2NvM1lxOWg1WlVnbEQzQ1pKVDRsQnM9
description: LDAP administrator
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin1
※ 編輯: appappf 時間: 2023-01-04 11:21:17 (台灣)
※ 看板: app 文章推薦值: 0 目前人氣: 0 累積人氣: 18 
分享網址: 複製 已複製
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇