在 CentOS 7.x 上安裝 Zabbix

Zabbix 是一套企業級的網管軟體,讓網管人員可以輕鬆地利用網頁介面即可完全監控相關網路服務主機的現行狀態,並且在所設定的異常狀況發生時,立即以電子郵件等方法通知網管人員。
Zabbix 官方網站:http://www.zabbix.com/
參考網站:
企業級開源網管軟體 用Zabbix監控網路服務 – 技術專欄 – 網管人NetAdmin
CentOS 7 安裝Zabbix 3.2 | MIS的背影
RHEL / CentOS 安裝監測工具 — Zabbix – Linux 技術手札
zabbix server 安裝 | zabbix document

1. 首先先安裝好 LAMP
# yum install httpd mariadb mariadb-server php php-mysql php-gd php-pear php-xml php-xmlrpc php-mbstring php-soap[@more@]2. 安裝 zabbix 套件庫
# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

3. 更新套件庫
# yum update

4.  安裝 zabbix
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-web

5. 設定開機時啟動
# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.

6. 建立 zabbix 資料庫並設定資料庫的管理帳號及密碼
# /usr/bin/mysql -u root -p
> create databases zabbixdb;
> grant all privileges on zabbixdb.* to zabbix@localhost identified by “123456”;
> flush privileges;

7. 匯入資料庫
# gunzip /usr/share/doc/zabbix-server-mysql-3.2.4/create.sql.gz
# /usr/bin/mysql -u zabbix -p zabbixdb < /usr/share/doc/zabbix-server-mysql-3.2.4/create.sql

8. 修改設定檔 /etc/zabbix/zabbix_server.conf/etc/php.ini
# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.$(date +%F)
# sed -i ‘s/DBName=zabbix/DBName=zabbixdb/’ /etc/zabbix/zabbix_server.conf
# sed -i ‘s/# DBPassword=/DBPassword=123456/’ /etc/zabbix/zabbix_server.conf
# sed -i ‘s/;date.timezone =/date.timezone = Asia/Taipei/’ /etc/php.ini

# vim /etc/httpd/conf.d/zabbix.conf

# php_value date.timezone Europe/Riga
修改成
php_value date.timezone Asia/Taipei

9. 重新啟動 Web Server
# systemctl restart httpd.service

10. 啟動 Zabbix Server
# systemctl start zabbix-server.service

11. 進行安裝及設定 http://Server’IP/zabbix

預設登入的帳號及密碼:admin / zabbix

登入畫面

awk 備忘

列出 UID > 499 的帳號及 UID
$ awk ‘BEGIN {FS=”:”}; $3 > 499 {print $1″t”$3}’ /etc/passwd
core    500
systemd-coredump        998

去除標題
$ ps a | awk ‘NR!=1 {print $0}’ | head
 1237 tty1     Ss     0:00 /bin/login —
 1238 ttyS0    Ss+    0:06 /sbin/agetty –keep-baud 115200 38400 9600 ttyS0 vt220
 1294 tty1     S+     0:00 -bash
14202 pts/0    Ss     0:00 -bash
14264 pts/0    R+     0:00 ps a
14265 pts/0    S+     0:00 awk NR!=1 {print $0}
14266 pts/0    S+     0:00 head[@more@]
列出第 2 行到第 5 行
$ ps a | awk ‘(NR>1 && NR<=5){print $0}’ | head
 1237 tty1     Ss     0:00 /bin/login —
 1238 ttyS0    Ss+    0:06 /sbin/agetty –keep-baud 115200 38400 9600 ttyS0 vt220
 1294 tty1     S+     0:00 -bash
14202 pts/0    Ss     0:00 -bash

列出某一使用者的 UID
awk -F “:” ‘/docker/ {print $3}’ /etc/passwd
996

區分大小寫
$ awk -F”:” ‘BEGIN{IGNORECASE=1}{if($1==”core”){print $3}}’ /etc/passwd
500

計算行數
$ awk ‘END{print NR}’ /etc/profile
59
 $ wc -l /etc/profile
59 /etc/profile
$ sed -n ‘$=’ /etc/profile
59
 $ grep -c “” /etc/profile
59

計算空白行數
# cat blankline.awk
#!/usr/bin/awk
/^$/ {
  x += 1
}
END {
     print x;
}

# awk -f blankline.awk /etc/profile
11

DNS 查詢指令 – dig 指令用法

一些常用的用法
正解
# dig abcd.tces.ilc.edu.tw @140.111.74.xxx
追踪
# dig +trace abcd.tces.ilc.edu.tw
反解
# dig -x 140.111.74.xxx @140.111.74.xxx
IPv6
# dig aaaa abcd.tces.ilc.edu.tw @140.111.74.xxx
DNS Server
# dig -t ns tces.ilc.edu.tw @140.111.74.xxx[@more@]# dig ilc.edu.tw NS

# dig ilc.edu.tw A

更多用法:
# dig -h
Usage:  dig [@global-server] [domain] [q-type] [q-class] {q-opt}
            {global-d-opt} host [@local-server] {local-d-opt}
            [ host [@local-server] {local-d-opt} […]]
Where:  domain    is in the Domain Name System
        q-class  is one of (in,hs,ch,…) [default: in]
        q-type   is one of (a,any,mx,ns,soa,hinfo,axfr,txt,…) [default:a]
                 (Use ixfr=version for type ixfr)
        q-opt    is one of:
                 -x dot-notation     (shortcut for reverse lookups)
                 -i                  (use IP6.INT for IPv6 reverse lookups)
                 -f filename         (batch mode)
                 -b address[#port]   (bind to source address/port)
                 -p port             (specify port number)
                 -q name             (specify query name)
                 -t type             (specify query type)
                 -c class            (specify query class)
                 -k keyfile          (specify tsig key file)
                 -y [hmac:]name:key  (specify named base64 tsig key)
                 -4                  (use IPv4 query transport only)
                 -6                  (use IPv6 query transport only)
                 -m                  (enable memory usage debugging)
        d-opt    is of the form +keyword[=value], where keyword is:
                 +[no]vc             (TCP mode)
                 +[no]tcp            (TCP mode, alternate syntax)
                 +time=###           (Set query timeout) [5]
                 +tries=###          (Set number of UDP attempts) [3]
                 +retry=###          (Set number of UDP retries) [2]
                 +domain=###         (Set default domainname)
                 +bufsize=###        (Set EDNS0 Max UDP packet size)
                 +ndots=###          (Set NDOTS value)
                 +[no]edns[=###]     (Set EDNS version) [0]
                 +[no]search         (Set whether to use searchlist)
                 +[no]showsearch     (Search with intermediate results)
                 +[no]defname        (Ditto)
                 +[no]recurse        (Recursive mode)
                 +[no]ignore         (Don’t revert to TCP for TC responses.)
                 +[no]fail           (Don’t try next server on SERVFAIL)
                 +[no]besteffort     (Try to parse even illegal messages)
                 +[no]aaonly         (Set AA flag in query (+[no]aaflag))
                 +[no]adflag         (Set AD flag in query)
                 +[no]cdflag         (Set CD flag in query)
                 +[no]cl             (Control display of class in records)
                 +[no]cmd            (Control display of command line)
                 +[no]comments       (Control display of comment lines)
                 +[no]rrcomments     (Control display of per-record comments)
                 +[no]question       (Control display of question)
                 +[no]answer         (Control display of answer)
                 +[no]authority      (Control display of authority)
                 +[no]additional     (Control display of additional)
                 +[no]stats          (Control display of statistics)
                 +[no]short          (Disable everything except short
                                      form of answer)
                 +[no]ttlid          (Control display of ttls in records)
                 +[no]all            (Set or clear all display flags)
                 +[no]qr             (Print question before sending)
                 +[no]nssearch       (Search all authoritative nameservers)
                 +[no]identify       (ID responders in short answers)
                 +[no]trace          (Trace delegation down from root [+dnssec])
                 +[no]dnssec         (Request DNSSEC records)
                 +[no]nsid           (Request Name Server ID)
                 +[no]sigchase       (Chase DNSSEC signatures)
                 +trusted-key=####   (Trusted Key when chasing DNSSEC sigs)
                 +[no]topdown        (Do DNSSEC validation top down mode)
                 +[no]split=##       (Split hex/base64 fields into chunks)
                 +[no]multiline      (Print records in an expanded format)
                 +[no]onesoa         (AXFR prints only one soa record)
                 +[no]keepopen       (Keep the TCP socket open between queries)
        global d-opts and servers (before host name) affect all queries.
        local d-opts and servers (after host name) affect only that lookup.
        -h                           (print help and exit)
        -v                           (print version and exit)

Apache Web Server 2.4 使用密碼來限制瀏覽來源

1. 建立使用者及密碼
# /usr/bin/htpasswd -c /var/www/test/.htpasswd admin
New password:
Re-type new password:
Adding password for user admin

第二個使用者就不用加上 -c
# /usr/bin/htpasswd /var/www/test/.htpasswd abc[@more@]
2. 建立設定檔 /etc/httpd/conf.d/test.conf
# vim /etc/httpd/conf.d/test.conf
Alias /base /var/www/test
<Directory /var/www/test/>
Order Deny,Allow
#Deny from all
#Allow from 192.168.1.0/24
Require all denied
Require ip 192.168.1.0/24

AuthType Basic
AuthName “Restricted Files”
AllowOverride AuthConfig
# (Following line optional)
AuthBasicProvider file
AuthUserFile “/var/www/test/.htpasswd”
Require valid-user
</Directory>

3. 重新啟動 Apache Web Server
# systemctl restart httpd
# systemctl status httpd

4. 測試一下 http://Server’IP/test

修改 Scratch 2.0 454 Offline Editor 版中文翻譯

稍微修改了一下 Scratch 2.0 454  Offline Editor 版中文翻譯,主要是一些用語的調整
動作

外觀

[@more@]音效

畫筆

資料

事件

控制

偵測

運算

如果要替換掉原來的中文翻譯檔 zh-tw.po,請先備份原檔,如果覺得翻譯不好可以改回來!
Windows 64 位元
C:Program Files (x86)Scratch 2locale
Windows 32 位元
C:Program FilesScratch 2locale

下載下面的翻譯檔,解壓縮後,覆蓋原檔即可!
下載

Apache Web Server 2.4 限制瀏覽來源 IP

建立設定檔
# vim /etc/httpd/conf.d/base.conf
Alias /base /var/www/base
<Directory /var/www/base/>
Order Deny,Allow
# 2.2
#Deny from all
#Allow from 192.168.1.0/24
# 2.4
Require all denied
Require ip 192.168.1.0/24
</Directory>

重新啟動 Web Server
# systemctl restart httpd

檢查是否有正常啟動
# system status httpd