西维蜀黍

【macOS】Alfred 效率

快捷键

  ...


【TrueNAS】使用 Node Exporter(Grafana)监控 TrueNAS

Situation

我们都知道,如果你知道在 TrueNAS OS 中通过 pkg 来安装软件,会得到下面的错误:

$ pkg install git
Updating local repository catalogue...
pkg: file:///usr/ports/packages/meta.txz: No such file or directory
repository local has no meta file, using default settings
pkg: file:///usr/ports/packages/packagesite.txz: No such file or directory
Unable to update repository local
Error updating repositories!

事实上,官方 doc 中有明确说到:我们不应该在 TrueNAS OS 中安装你想安装的软件,而是把这些软件安装在 Jail 里面。

问题来了,如果我想使用 Node Exporter 监控 TrueNAS 宿主机。

(实在是看不习惯 TrueNAS 自带的监控)

那么如果我把 Node Exporter 安装在 Jail instance里面,那么自然监控的是 Jail 本身,而不是 TrueNAS 宿主机。

  ...


【Linux】Shell - 判断当前操作系统

#!/usr/bin/env bash

if [ "$(uname)" == "Darwin" ]; then
    # Do something under Mac OS X platform        
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
    # Do something under GNU/Linux platform
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
    # Do something under 32 bits Windows NT platform
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
    # Do something under 64 bits Windows NT platform
fi
  ...


【Ubuntu】连接SMB

for Test

$ sudo apt install smbclient
$ smbclient -L //myServerIpAdress
  ...


【Ubuntu】升级Python3至指定版本

Check the current python version

Run below command to test the current version installed of python.

$ python3 --version
python 3.6.8

Install python3.7

Install python by typing:

$ sudo apt update -y
$ sudo apt install python3.7
  ...


【Ubuntu】从控制台使用默认软件打开文件

Modify your ~/.bashrc

alias open=xdg-open
  ...


【Network】MTU(Maximum Transmission Unit)最佳设置

MTU (Maximum Transmission Unit)

In computer networking, the maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single network layer transaction. The MTU relates to, but is not identical to the maximum frame size that can be transported on the data link layer, e.g. Ethernet frame.

Larger MTU is associated with reduced overhead. Smaller MTU values can reduce network delay. In many cases, MTU is dependent on underlying network capabilities and must be adjusted manually or automatically so as to not exceed these capabilities. MTU parameters may appear in association with a communications interface or standard. Some systems may decide MTU at connect time.

  ...


【Python】pip 使用

Install pip

Install pip for Python 3

Ubuntu

Ubuntu 18.04 ships with Python 3, as the default Python installation. Complete the following steps to install pip (pip3) for Python 3:

Start by updating the package list using the following command:

$ sudo apt update

Use the following command to install pip for Python 3:

$ sudo apt install python3-pip

The command above will also install all the dependencies required for building Python modules.

Once the installation is complete, verify the installation by checking the pip version:

$ pip3 --version

The version number may vary, but it will look something like this:

$ pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
  ...


【FreeBSD】查看一个运行进程的环境变量

procstat

$ procstat -e <pid>


$ procstat -e 1906
  PID COMM             ENVIRONMENT
 1906 smbd             LANG=en_US.UTF-8 PATH=/sbin:/bin:/usr/sbin:/usr/bin PWD=/ HOME=/ RC_PID=1899
  ...


【TrueNAS】SMB 折腾

SMB Config

$ cat /usr/local/etc/smb4.confb
[global]
        workgroup = WORKGROUP
        server string = Samba Server Version %v
        netbios name = Samba
        log file = /var/log/samba/samba_log.%m
        max log size = 50
        security = user
        passdb backend = tdbsam
        smb ports = 6727
        include = /etc/samba/user/%U.smb.conf
  ...