2018年11月14日 星期三

linux 系統監控工具

glances (python)

htop
top
nmon
iostat

glances
https://www.maketecheasier.com/glances-monitor-system-ubuntu/


hegemon
https://www.tecmint.com/install-rust-programming-language-in-linux/
https://www.tecmint.com/hegemon-system-monitoring-tool-for-linux/


https://opensource.com/life/16/2/open-source-tools-system-monitoring
top
atop
htop
glances


netdata
monitorix
collectd


lshw
lscpu
lspci
lsusb


sudo dmidecode



harddisk

sudo smartctl -a /dev/sda

blkid

破壞性寫入測試
badblocks -wsv /dev/xxxdisk

fdisk/gdisk/parted


nload is a console application which monitors network traffic and bandwidth




hddtemp - Utility to monitor hard drive temperature

dmidecode is a tool for dumping a computer's DMI (some say SMBIOS ) table contents in a human-readable format.


lm_sensors (Linux monitoring sensors) is a free and open-source application that provides tools and drivers for monitoring temperatures, voltage, and fans.


smartmontools smartctl - Control and Monitor Utility for SMART Disks
smartctl controls the Self-Monitoring, Analysis and Reporting Technology (SMART) system built into many ATA-3 and later ATA, IDE and SCSI-3 hard drives.


nullmailer is an relay-only forwarding MTA (Mail Transfer Agent).

ranger - visual file manager

GNU Midnight Commander is a visual file manager,

netcat is a simple unix utility which reads and writes data across network connections, using TCP or UDP protocol.

2018年11月7日 星期三

lzma linux image tool

 ./lzma e vmlinux_img vmlinux_img.gz


LZMA 4.06 Copyright (c) 1999-2004 Igor Pavlov  2004-09-05

Usage:  LZMA <e|d> inputFile outputFile [<switches>...]
  e: encode file
  d: decode file
  b: Benchmark
<Switches>
  -a{N}:  set compression mode - [0, 2], default: 2 (max)
  -d{N}:  set dictionary - [0,28], default: 23 (8MB)
  -fb{N}: set number of fast bytes - [5, 255], default: 128
  -lc{N}: set number of literal context bits - [0, 8], default: 3
  -lp{N}: set number of literal pos bits - [0, 4], default: 0
  -pb{N}: set number of pos bits - [0, 4], default: 2
  -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, bt4b, pat2r, pat2,
              pat2h, pat3h, pat4h, hc3, hc4], default: bt4
  -eos:   write End Of Stream marker
  -si:    Read data from stdin
  -so:    Write data to stdout


ts moreutils time stamp log



make clean;make 2>&1 | tee >(ts "%H_%M_%S" > spendinglogs6.log)


https://unix.stackexchange.com/questions/26728/prepending-a-timestamp-to-each-line-of-output-from-a-command

I wish to prepend a timestamp to each line of output from a command. For example:
foo
bar
baz
would become
[2011-12-13 12:20:38] foo
[2011-12-13 12:21:32] bar
[2011-12-13 12:22:20] baz


https://stackoverflow.com/questions/39239379/add-timestamp-to-teed-output-but-not-original-output

Check out ts from the moreutils package.
If you're using bash, you can tee to a shell pipe as a file:
https://unix.stackexchange.com/questions/272433/piping-into-moreutils-ts-with-nanosecond-precision
https://manpages.debian.org/testing/moreutils/ts.1.en.html
https://rentes.github.io/unix/utilities/2015/07/27/moreutils-package/
https://joeyh.name/code/moreutils/

2018年11月1日 星期四

linux連到ssh server想要中斷連線

~.

We can use tilde-period (~.) to close an unresponsive session.

https://pleiades.ucsc.edu/hyades/SSH_Escape_Sequences

When a pseudo-terminal has been requested by the OpenSSH SSH client, ssh supports a number of functions through the use of an escape character. The escape character must always follow a newline to be interpreted as special. The default escape character is ~(tilde); but it can be can be changed in configuration files using the EscapeChar configuration directive or on the command line by the -e option.


 ~?
Supported escape sequences:
 ~.   - terminate connection (and any multiplexed sessions)
 ~B   - send a BREAK to the remote system
 ~C   - open a command line
 ~R   - request rekey
 ~V/v - decrease/increase verbosity (LogLevel)
 ~^Z  - suspend ssh
 ~#   - list forwarded connections
 ~&   - background ssh (when waiting for connections to terminate)
 ~?   - this message
 ~~   - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

2018年10月9日 星期二

linux lvm

pvscan

vgscan

lvscan

lvscan
  inactive          '/dev/centos/swap' [2.00 GiB] inherit
  inactive          '/dev/centos/home' [17.80 GiB] inherit
  inactive          '/dev/centos/root' [36.46 GiB] inherit



vgchange -a y centos


https://www.tldp.org/HOWTO/LVM-HOWTO/activatevgs.html
11.3. Activating a volume group
vgchange -an centos



apt

ls /dev/centos



mount /dev/centos/root testmount

mount /dev/centos/home testmount


http://marcustsai.blogspot.com/2010/11/lvm.html
LVM實作


https://wiki.ubuntu.com/Lvm
https://help.ubuntu.com/lts/serverguide/advanced-installation.html.en

2018年9月7日 星期五

rsync linux 檔案備份 notes

原本的 abcd 目錄
tree abcd/  -a
abcd/
├── .abc
├── ddda
├── .foo
└── test
    └── gg
        └── .abcd

$ rsync -avh abcd/ test
sending incremental file list
./
.abc
ddda
.foo/
test/
test/gg/
test/gg/.abcd

sent 373 bytes  received 96 bytes  938.00 bytes/sec
total size is 20  speedup is 0.04

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

$ rsync -avh abcd test1
sending incremental file list
created directory test1
abcd/
abcd/.abc
abcd/ddda
abcd/.foo/
abcd/test/
abcd/test/gg/
abcd/test/gg/.abcd

sent 386 bytes  received 125 bytes  146.00 bytes/sec
total size is 20  speedup is 0.04

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


$ rsync -avh abcd/* test2
sending incremental file list
created directory test2
ddda
test/
test/gg/
test/gg/.abcd

sent 254 bytes  received 98 bytes  704.00 bytes/sec
total size is 14  speedup is 0.04


在source dir 用  DIRA/* 會掉 .開頭的file folder


tree -a abcd/ test test1 test2
abcd/
├── .abc
├── ddda
├── .foo
└── test
    └── gg
        └── .abcd
test
├── .abc
├── ddda
├── .foo
└── test
    └── gg
        └── .abcd
test1
└── abcd
    ├── .abc
    ├── ddda
    ├── .foo
    └── test
        └── gg
            └── .abcd
test2
├── ddda
└── test
    └── gg
        └── .abcd



參考
https://unix.stackexchange.com/questions/178078/how-to-rsync-a-directory-to-a-new-directory-with-different-name

How to rsync a directory to a new directory with different name



If you want to use rsync to recursively make the dest directory an exact copy of the src directory:

rsync -a src/ dest


linux os version
cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"



2018年8月23日 星期四

crypto aes openssl cbc gcm

kazoo it

 Edgerouter X.



ER-X Forwarding Speed
https://kazoo.ga/er-x-forwarding-speed/

Re-visit Forwarding Speed in ER-X

https://kazoo.ga/revisit-forwarding-speed-in-er-x/


Edgerouter X - IPsec Benchmarked
https://kazoo.ga/edgerouter-x-ipsec-benchmarked/


Let's focus on the 1460-byte packet size. In download direction, 377 Mbit/s is very good throughput in my opinion. It surpasses the quoted number from MediaTek and close to the 500 Mbit/s upper bound quoted by Authentec. In upload direction, relatively speaking it's a little disappointing. 128 Mbit/s is only about one third of the download throughput.





CBC
Cipher Block Chaining
Encryption parallelizable: No
Decryption parallelizable: Yes
Random read access: Yes

download is Decryption for crypto engine
upload is Encryption for crypto engine



The Crypto Engine in Edgerouter X
https://kazoo.ga/the-crypto-engine-in-edgerouter-x/




https://kazoo.ga/quick-benchmark-cbc-vs-gcm/

In my previous post, we touched OpenVPN 2.4 and its new inclusion of GCM ciphers. SFX2000 over SNBforums reminded me to check performance in current OpenSSL. Let me share my quick and dirty benchmarks.
64-bit Sandy Bridge @2.7GHz single-thread
AES-128-CBC with AES-NI



The Cortex-A9 is my RT-AC56U where I run OpenVPN server. It doesn't have any crypto acceleration in HW. CBC is faster than GCM by 145% to 185%. I thought I had to swallow my words and should not switch to GCM ciphers. Looking closer, I might get away with it.
My Conclusion..





http://cryptowiki.net/index.php?title=Output_feedback_with_a_nonlinear_function_(OFBNLF)

http://cryptowiki.net/index.php?title=Block_chaining_(BC)


http://cryptowiki.net/index.php?title=Symmetric_encryption_schemes