2018年12月5日 星期三

[Moodle] 刪除多筆課程週數

就這麼的剛好,原本系統做了更新,隔天同事反映 Moodle 怪怪的,很多使用者登不上(跟課程進不去分不清楚..-.-,這問題應該是課程頁面點了會出現 500 的問題),因為剛好做了系統的更新,一度懷疑是更新的問題。

隔天,該同事另一門課程原本也是好好的,結果他終於發現問題了,然後跑來告訴我,原來是因為[新增週數或課程數]他打成年月日,所以系統就建了兩千多萬筆的資料,總共兩門課共四千多萬筆的垃圾資料。

後來直接進資料庫下指令砍掉就可以了,指令如下:

DELETE FROM `mdl_course_sections` WHERE `id` > id編號

最後執行  moodle  網站管理 > 開發 > 清空所有快取 ,這樣課程應該就可以正確顯示了。

2018年12月4日 星期二

[Windows] 空間不夠之 NPS Log 佔用空間。

前先日子就發現一台WIN 2012的空間不夠了低於100MB,直覺是當初空間切太小了,一度懷疑是不是更新檔案太大了。

最近突然想到是否 IIS Log 檔案太大,一查也還好,也順便查了底下的目錄的使用空間。
C:\Windows\System32\LogFiles
結果是網路原則伺服器(NPS)產生的 Log 日積月累吃掉了大部分的空間,把檔案刪一刪就完成這回合的工作。





2018年7月11日 星期三

[CentOS] inode 空間使用100%的問題


前些日子一台設備的網頁服務有使用者反映無法登入,第一個想法是重新啟動網頁服務,結果也無法開啟,系統也吐出一些訊息(忘了截圖)。丟到 Google 後發現是 inode 滿了。


後來找到是 /var/spool/postfix/maildrop 塞滿的,所幸就把目錄底下的資料全刪了。

[root@xxx var]# df -i
Filesystem           Inodes  IUsed  IFree IUse% Mounted on
/dev/mapper/vg_dorm-lv_root
                     757392 651590 105802   100% /
/dev/sda1            128016     62 127954    1% /boot


[root@xxx /]# cd /var/spool/postfix/maildrop 
[root@xxx maildrop]# ls | xargs rm -f




最後在某網站找到解決方式如下:

/var/spool/postfix/maildrop 下面有很多文件
为了避免,可以执行 crontab -e
在最开头添加 MAILTO='"' 保存,然后 server crond restart 重启 crond

http://www.dahouduan.com/2014/12/19/linux-inode-full/



[Subaru]Forester NA 2015安裝喇叭。




本次安裝BOSCH EC6 高低音汽車喇叭,有兩個無極性端子,也就是說一個接原本的電源,另一個要用搭鐵。


要拆掉保桿需要拆掉下面的扣子。
























這顆原廠喇叭藏在右邊大燈後面,所以直接拆前保桿。




下圖一邊是接原本的電,另一個就是接地。










另外一顆喇叭忘記拍照了,位置在右大燈下方附近。

2016年3月31日 星期四

Aurba 使用者登入出現 authentication failed(null)

前些日子無線網路出現一個問題,使用者登入出現authentication failed(null) 訊息。
從管理介面的 AAA Test 測試測試兩台 Radius Server 又很正常。
後來是直接更改 Radius Timeout的時間,就正常了。

猜想是  Radius Proxy 連至 MS NPS 時間過長導致驗證失敗。







2015年6月8日 星期一

Moodle 使用 AD 認證


以下為 Moodle 透過 AD 認證的設定

LDAP 伺服器設定
主機網址      ldap://123.123.123.123/
版本              3
使用TLS        NO
LDAP編碼   utf-8
頁面大小     250


繫結的設定
不要快取密碼     Yes
可區辨的名稱     administrator@Domain.com
密碼                     Your PW


用戶搜尋設定
用戶類型             MS ActiveDirectory
情境                     ou=user,DC=Domain,DC=com
搜尋子條件         Yes
不同的代稱         Yes
用戶屬性             samaccountname
物件類別             user



資料對應
名字                     givenName
姓氏                     sn
電子郵件信箱     mail

2015年3月30日 星期一

Office365 與 AD 帳號同步

1. 事先準備 AD server,確定可以用。
2. 在 Office365,「使用者」開啟「Active Directory 同步處理」
3. 按照網頁步驟執行
a. 執行ADSync 時,第一個輸入帳號的地方是輸入Office365的管理帳號,第二個是輸入AD管理者的帳號。

注意事項:
1. AD 使用者的電子郵件帳號需設定,不然會以預設 .onmicrosoft.com 為優先帳號
2. 設定完後系統預設每三小時同步一次(不確定?)
3.  強制同步,啟動 PowerShell,輸入 Import-Module DirSync,然後按 ENTER。輸入 Start-OnlineCoexistenceSync,然後按 ENTER。

待處理事項:
1. 大量匯入

2013年12月11日 星期三

VMware vSphere HA & DRS 建置注意事項

1.兩台 Host 需有兩個實體網卡且同網段
2.兩台 Host 都需 mount 共同的 Storage。
3.兩台 Host 需同廠牌的 CPU。

2013年12月6日 星期五

[食譜]火燒蝦義大利麵

材料:
蝦子(比較大尾的可以切對半)
洋蔥(切絲)
蒜頭(切片)
奶油
橄欖油
義大利麵
鹽
胡椒粉
普羅旺斯香草
花椰菜
以上份量隨意。

步驟 A
1. 把水煮沸後加[鹽],在加入[義大利麵]。 

步驟 B
1. 在鍋子放入[奶油]融化後在放入[洋蔥]拌炒,再加一點點的[橄欖油]。
2. 等洋蔥變成透明狀後再加入[蒜頭],煮到軟化,再灑上[胡椒粉]。
3. 加入[蝦子]。

步驟 A 和 B 可同步進行,當步驟 B 完成時,麵也差不多熟了。
 
步驟 C
1. 將步驟 A 的義大利麵加入 步驟 B 的鍋子中拌炒。
2. 加入 [普羅旺斯香草]。

完成! 

對了,花椰菜是配色用的,可以用煮麵的水煮熟,蝦子可以換其他材料,比如小卷之類的。

2013年12月4日 星期三

[Apple] iTunes 11 刪除 PDF 書籍

iTunes11 開始,書籍便獨立成一個 iBook APP,筆者遇到一個小 Bug,就是無法移除 iTunes 上的 PDF 書籍,研究之後有了結果, 首先開啟 OSX 的 iBook,然後點選上方工具列的[檔案]-[從iTunes搬移書籍]。 所以現在會看到 iBook 和 iTunes 的書籍顯示是一模一樣的,以後就是在 iBook 管理書籍,在 iTunes 上做同步的動作。

2013年11月27日 星期三

LACP - Extreme Summit X430 and HP Procuve 2610


實體環境設定

Extreme X430 的 Port 22,24 要連到 HP 2610 的 Port 5,6



Extreme:

#enable sharing 24 grouping 22, 24 algorithm address-based L2 lacp


HP:
#configure terminal
#trunk 5-6 trk1 lacp
#vlan XXX
#untag trk1


設定完成後

Extreme:

#show lacp

LACP Up                             : Yes
LACP Enabled                        : Yes
System MAC                          : 00:04:96:xx:xx:xx
LACP PDUs dropped on non-LACP ports : 1500

Lag        Actor    Actor   Partner            Partner  Partner  Agg   
           Sys-Pri  Key     MAC                Sys-Pri  Key      Count 
--------------------------------------------------------------------------------
24             0    0x0400  00:1f:28:xx:xx:xx  60032    0x0035   2
================================================================================

# show sharing
Load Sharing Monitor
Config    Current    Agg       Ld Share    Ld Share  Agg   Link    Link Up
Master    Master     Control   Algorithm   Group     Mbr   State   Transitions
==============================================================================
    24     22        LACP      L2          22         Y      A       23
                               L2          24         Y      A       20
==============================================================================
Link State: A-Active, D-Disabled, R-Ready, NP-Port not present, L-Loopback
Load Sharing Algorithm: (L2) Layer 2 address based, (L3) Layer 3 address based
                        (L3_L4) Layer 3 address and Layer 4 port based
Number of load sharing trunks: 1


HP:

# show lacp

                           LACP

   PORT   LACP      TRUNK     PORT      LACP      LACP
   NUMB   ENABLED   GROUP     STATUS    PARTNER   STATUS
   ----   -------   -------   -------   -------   -------
   5      Active    Trk1      Up        Yes       Success
   6      Active    Trk1      Up        Yes       Success

#show trunks

 Load Balancing

  Port | Name                             Type      | Group Type 
  ---- + -------------------------------- --------- + ----- -----
  5    | 4F6(409)                         10/100TX  | Trk1  LACP 
  6    | 4F5(403)                         10/100TX  | Trk1  LACP




# show vlans ports trk1

 Status and Counters - VLAN Information - for ports Trk1

  VLAN ID Name                 | Status     Voice Jumbo
  ------- -------------------- + ---------- ----- -----

  XXX    V_XXX                | Port-based No    No  

2013年8月6日 星期二

在 CentOS 6.4 安裝 OpenVAS



筆者最先在 CentOS 5.9 上安裝,安裝完成後使用瀏覽器無法連線,然後檢查出 9392 PORT並沒有任何服務上網查了一下解決辦法須執行下列指令,但是非常地不穩,索性就換成 CentOS 6.4,以下為安裝步驟。

#gsad --port 9392 -f -v --http-only 
  1. 安裝最小化的 CentOS 6.4
  2. 關掉 selinux and eth 開機啟動
  3. 安裝 wget
    #yum install wget
  4. Configure Atomicorp Repository
    #wget -q -O - http://www.atomicorp.com/installers/atomic |sh
  5. 安裝openvas ,執行openvas-setup後,因為下載定義檔需要一段時間,請耐心等候。
    #yum install openvas
    #openvas-setup
    Step 1: Update NVT's
    Step 2: Configure GSAD
    The Greenbone Security Assistant is a Web Based front end
    for managing scans. By default it is configured to only allow
    connections from localhost.
    
    Allow connections from any IP? [Default: yes]
    Stopping greenbone-security-assistant:                     [  OK  ]
    Starting greenbone-security-assistant:                     [  OK  ]
    
    Step 3: Choose the GSAD admin users password.
    The admin user is used to configure accounts,
    Update NVT's manually, and manage roles.
    
    Enter administrator username [Default: admin] :
    Enter Administrator Password:
    Verify Administrator Password:
    ad   main:MESSAGE:15385:2013-08-06 14h30.58 CST: No rules file provided, the new user will have no restrictions.
    ad   main:MESSAGE:15385:2013-08-06 14h30.58 CST: User admin has been successfully created.
    
    Step 4: Create a user
    
    Using /var/tmp as a temporary file holder.
    
    Add a new openvassd user
    ---------------------------------
    
    
    Login : user
    Authentication (pass/cert) [pass] :
    Login password :
    Login password (again) :
    
    User rules
    ---------------
    openvassd has a rules system which allows you to restrict the hosts that chyau has the right to test.
    For instance, you may want him to be able to scan his own host only.
    
    Please see the openvas-adduser(8) man page for the rules syntax.
    
    Enter the rules for this user, and hit ctrl-D once you are done:
    (the user can have an empty rules set)
    
    Login             : user
    Password          : ***********
    
    Rules             :
    
    
    
    Is that ok? (y/n) [y]
    Starting openvas-administrator...
    Starting openvas-administrator:
                                                               [  OK  ]
    
    
    Setup complete, you can now access GSAD at:
      https://<IP>:9392
    
    

  6. #/etc/init.d/openvas-administrator start
    #openvas-nvt-sync
    #openvassd restart
    #openvasmd restart
  7. 檢查openvas是否安裝完成
    #wget https://svn.wald.intevation.org/svn/openvas/trunk/tools/openvas-check-#setup -O openvas-check-setup.sh --no-check-certificate
    #chmod +x openvas-check-setup.sh
    #./openvas-check-setup.sh --server
  8. 定期更新定義檔 #vi /etc/crontab
    00 5 * * * root openvas-nvt-sync



Service temporarily down 解決方式
openvas-mkcert -f 
openvas-mkcert-client -i -n 
#restart all daemons

2013年7月23日 星期二

每日自動備份 Fortigate 設定檔


For v5.0,build0252 (GA Patch 5)
首先在 Fortigate上面建立一個名為backup的使用者,密碼為YourPassword,權限設定如下:





















然後在 Linux 建立 sh 並賦予執行權限和建立排程,檔案內容如下:
(範例中的備份伺服器是使用 tftp)

#!/bin/bash
user="backup"
password="YourPassword"
tftp_ip="YourBackupServerIP"
fg_devices="YourFortigateIP"
date="$(date +"%Y%m%d")"
for fg_device in $fg_devices ; do
  expect -c "
  set timeout 30
  spawn ssh $user@$fg_device
  expect \"(yes/no)\" { send \"yes\r\"; exp_continue }
  expect \"*password:*\"
  set send_slow {1 0.05}
  send -s \"$password\r\"
  send_user \"$password\r\"
  expect \"FG*\"
  send -s \"execute backup full-config tftp $fg_device-$date.cfg $tftp_ip\n\"
  expect \"FG*\"
  send -s \"exit\n\"
  interact"
done


2013年7月16日 星期二

Aruba 認證出現問題 "Web Authentication Disabled, Please contact Administrator"

發生原因:
不詳。

解法:
進管理畫面的 clients 選擇 user 然後 disconnect。

2013年7月1日 星期一

解決 FortiAnalyzer-400B 日誌查看停在某一天, 但是LOG檔還是會有紀錄的問題。

在 CLI 執行 #execute sql-local rebuild-db

FortiAnalyzer-~# execute sql-local rebuild-db
Rebuild the whole SQL database has been requested.
This operation will remove the SQL database and rebuild from log data.
This operation will reboot the device.
Do you want to continue? (y/n)


等待重開機,再重新登入後右上會出現 build database 的圖示。

雖說筆者做完之後LOG資料還會存在,但是建議能備份就備份下來。

2013年4月15日 星期一

VMware vSphere 移除 Storage 問題

當使用 vCenter 要移除 iSCSI Storage 時,會出現 No virtual machine resides on the datastore
官網的 Knowledge Base 解決辦法是移除所有的 Snapshot 。
但是筆者移除後還是出現這個訊息,後來就把所有的 Virtual Machine 用 remove from inventory 指令移除後就可以順利把 iSCSI Storage 給 unmount 了。

2013年3月5日 星期二

使用 Expect 備份網路設備設定檔 for Extreme


支援 Extreme DB8800系列、X450a系列、X460系列

#!/usr/bin/expect -f

if { $argc != 4 } {
        send_user "usage: extreme.exp device_ip username password server_ip \n"
        exit
}

set timeout 1
set TERM ANSI
set date [exec date +%Y%m%d]

set DEVICE [lindex $argv 0]
set USERNAME [lindex $argv 1]
set PASSWD [lindex $argv 2]
set SERVER [lindex $argv 3]

spawn telnet
expect "telnet> "
send "open $DEVICE\r"
sleep 1
expect "login:"
send "$USERNAME\r"
sleep 1
expect "password:"
send "$PASSWD\r"
sleep 1
expect "#"
send "upload configuration $SERVER $DEVICE-$date vr VR-Default\r"
sleep 3
expect "#"
send "exit\r"
interact

使用 Expect 備份網路設備設定檔 for HP


支援 HP ProCurve Switch 2610系列、2510系列

#!/usr/bin/expect -f

if { $argc != 4 } {
        send_user "usage: hp.exp device_ip username password server_ip \n"
        exit
}

set timeout 1
set TERM ANSI
set date [exec date +%Y%m%d]

set DEVICE [lindex $argv 0]
set USERNAME [lindex $argv 1]
set PASSWD [lindex $argv 2]
set SERVER [lindex $argv 3]


spawn telnet
expect "telnet> "
send "open $DEVICE\r"
sleep 1
expect continue { send "\r" ; exp_continue }
sleep 1
expect "Username:"
send "$USERNAME\r"
sleep 1
expect "Password:"
send "$PASSWD\r"



sleep 1
send "\r\r"
expect "#"
send "copy running-config tftp $SERVER $DEVICE-$date\r"
sleep 1
expect "#"
send "exit\r"
sleep 1
expect ">"
send "exit\r"
sleep 1
expect "Do you want to log out"
send "y\r"
interact



2013年1月3日 星期四

Extreme 教學

限制 telent access:
#edit policy mytelnet.pol
entry Telnet_Allow {
if match any {
        source-address 192.168.1.0 /24;
        source-address 192.168.2.0 /24;
                } then {
                        permit;
}
}

# configure telnet access-profile mytelnet

若 source-address 有變動執行
# refresh policy "mytelnet"





IP-MAC blind:
add:
#configure iparp add 123.123.123.123 vr VR-Default 00:11:22:33:44:55
del
#configure iparp delete 123.123.123.123 vr VR-Default 00:11:22:33:44:55

設定檔備份:
#upload configuration 123.123.123.123 backupFileName vr "VR-Default"


清除 trial-license:

enable trial-license
#debug epm enable trial-license
remove trial-license
#debug epm clear trial

回覆出廠預設值:
#unconfigure  switch all

另外一個方法
使用console連線

1. 重開機出現Running POST的時候按住空白鍵。
2. POST完成之後會進入boot rom模式。 
3. 在提示符號下輸入: 
#Config abc  (abc指的是隨便一個檔名,目的在使系統找不到檔案後開機時load default) 
4. 輸入Boot後按enter。 
系統重開之後就回預設值,所有的設定都會不見。 


LACP:

8810 config
enable sharing 2:47 grouping 2:47-48 algorithm address-based L2
第一個「2:47」為主要port,後面的「2:47-48」為群組。

X450 config
enable sharing 23 grouping 23-24 algorithm address-based L2 lacp

查看
show lacp lag 1

解除設定
disable sharing 2:47

備份、升級韌體
download image [<hostname> | <ipaddress>] <filename> {primary | secondary}
upload image [<hostname> | <ipaddress>] <filename> {primary | secondary}
use image [primary | secondary]


2012年10月3日 星期三

FreeBSD 指令

Ports tree更新指令:
#portsnap fetch update



更新

# freebsd-update fetch
# freebsd-update install