htaccess ( apache 存取控制 )

  1. 修改 /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
#    AllowOverride None
    AllowOverride All //====修改為All

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

到存取控制的目錄下新增檔案 .htaccess

vim ./htaccess


  order deny,allow
  deny from all


AuthName        "Pop UP 視窗顯示的文字"
AuthUserFile    密碼檔案存放地
AuthType        Basic
Require valid-user
Order           Deny,Allow
Deny from       all
Allow from      允許直接存取的網段,不需要輸入密碼
Satisfy Any

設定權限 htpasswd
第一次使用時參數為 “-c”

[root@localhost ~]# htpasswd
Usage:
        htpasswd [-cmdpsD] passwordfile username
        htpasswd -b[cmdpsD] passwordfile username password

        htpasswd -n[mdps] username
        htpasswd -nb[mdps] username password
 -c  Create a new file.
 -n  Do not update file; display results on stdout.
 -m  Force MD5 encryption of the password.
 -d  Force CRYPT encryption of the password (default).
 -p  Do not encrypt the password (plaintext).
 -s  Force SHA encryption of the password.
 -b  Use the password from the command line rather than prompting for it.
 -D  Delete the specified user.

[root@localhost ~]# htpasswd -c 密碼檔案存放路徑 使用者名稱
New password:
Re-type new password:
Adding password for user 使用者名稱
Posted in Apache | Leave a comment

Splunk – Transaction 查詢一段相近時間之累積資訊

sourcetype=”來源型態” | rex “(?i) .? User (?P<pop3_failed_id>[^.]+) login failed.” | search pop3_failed_id=”” | transaction 判斷資訊 maxevents=2000 keepevicted=true | concurrency duration=duration | eval duration=tostring(duration,”duration”)

原理有點像是將所有事件跑過一次,然後把相近時間的判斷資訊放在同一筆事件中
一般預設單筆事件僅顯示500筆資訊
但是有時候可能會是好幾萬筆資訊就會被拆成好幾筆事件,將造成事件數字判讀上的不便
因此可以進行下面的動作

/opt/splunk/etc/apps/search/default/data/ui/views/flashtimeline.xml

檔案複製到

/opt/splunk/etc/apps/search/local/data/ui/views/flashtimeline.xml
  1. 編輯
/opt/splunk/etc/apps/search/local/data/ui/views/flashtimeline.xml

搜尋

在下面插入

數字

會變成


        
        數字

        full

        report_builder_format_report


原廠建議數字不要超過1000,以免造成系統負擔過重,但實際還是請視需要調整

  1. 重新啟動Splunk

這樣應該就可以把很多筆資訊塞到一筆事件中了

Posted in Splunk | Leave a comment

Splunk Lincese Warning 次數

除了可以到 “管理員=>授權” 去查看外

還可以搜尋 “index=_internal licensemanager”
根據搜尋的結果看 Audit:[quotaExceededCount=1 的數量

所以便可以擷取欄位
將 (?i) Audit:[quotaExceededCount=(?P[^,]+) 存為記得的名稱以便後續搜尋

Posted in Splunk | Leave a comment

強制把 80 轉到 443

編輯 httpd.conf
在 # End of proxy directives. 後加入下面幾句 (應該是加在哪裡都ok)

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

不過需先確認是否有載入下面這個module

LoadModule rewrite_module modules/mod_rewrite.so
Posted in Linux | Leave a comment

重設root密碼

之前忘記root密碼時都是修改GRUB進單人模式修改
開機 -> e -> 選擇kernel -> e -> 最後加入”single”或是”-s”

不過這次遇到一個囧境
因為修改系統時間導致fsck error…需要修正
這時候就需要root密碼….但是我一開始並沒有設定root密碼= =+
進單人模式一樣先跳出fsck error….Orz
這時候就只能用外接的方式處理了….

  1. 如果是用Live CD開機
    命令字元 -> “su -” -> “mkdir /mnt/system” -> “mount /dev/sda2 /mnt/system” -> “chroot /mnt/system” -> passwd 重設密碼

  2. 如果是用安裝光碟開機
    輸入 “linux rescue” -> 選擇語系 (English即可) -> 選擇鍵盤 (US) -> 設定網路 (用不到,可忽略) -> 確認是救援模式的狀態 -> “chroot /mnt/sysimage” -> passwd 重設密碼

Posted in Linux | Leave a comment

SED

刪除第一行

sed '1d' 文件

刪除第一個字元

sed 's/^.//' 文件

刪除最後一個字元

sed 's/.$//' 文件

假設要寫在一起,用”;”連結

sed '1d;s/^.//;s/.$//' 文件
Posted in Linux | Leave a comment

Splunk CLI With Script

因為 Splunk CLI 一樣需樣登入
所以可以先在 Script 檔案中預先輸入帳號、密碼

    export SPLUNK_USERNAME=帳號
    export SPLUNK_PASSWORD=密碼

然後在下 Splunk 的登入、查詢等指令

    /opt/splunk/bin/splunk login
    /opt/splunk/bin/splunk search 'index=_internal source=*metrics.log group=per_index_thruput NOT (series=_* OR series=*summary) starttime=02/07/2013:00:00:00 | timechart span=1d sum(eval(kb/1024)) AS "MB indexed" by series | fields + main | fields - _* | outputcsv test_usage.csv'

這邊主要是將結果輸出到 test_usage.csv ,預設存放路徑為 “/opt/splunk/var/run/splunk/” (檔案格式為CSV)
並且輸出欄位僅留下 “main”

順帶一提的是 Splunk CLI 指令中不能包含常用的 Script 變數
所以可以先用 Script 將變數搭配 Splunk 指令輸出到一個文字檔中
再去執行該文字檔,下面是個例子

/bin/sh /tmp/test_usage.sh > /tmp/test_usage2.sh
/bin/sh /tmp/test_usage2.sh

而第一個 Script 檔案要注意保留字元的部分

/bin/echo "export SPLUNK_USERNAME=帳號"
/bin/echo "export SPLUNK_PASSWORD=密碼"
/bin/echo "/opt/splunk/bin/splunk login"
/bin/echo "/opt/splunk/bin/splunk search 'index=_internal source=*metrics.log group=per_index_thruput NOT (series=_* OR series=*summary) starttime=$(date '+%m/%d/%Y'):00:00:00 | timechart span=1d sum(eval(kb/1024)) AS "MB indexed" by series | fields + main | fields - _* | outputcsv test_usage.csv'"
/bin/echo "/bin/echo "已使用額度""
/bin/echo "/bin/echo $(/bin/sed '1d;s/^.//;s/.$//' /opt/splunk/var/run/splunk/test_usage.csv)"
Posted in Splunk | Leave a comment

設定元件Visible屬性

Sub Picture25_visible()
    With ActivePresentation.Slides(SlideShowWindows(1).View.Slide.SlideIndex)
        If .Shapes.Title.TextFrame.TextRange.Text = "Splunk 優點" Then
            .Shapes("圖片 25").Visible = -1
            .Shapes("圖片 25").ZOrder msoBringToFront
            End If
    End With
End Sub
Sub Picture25_hide()
    With ActivePresentation.Slides(SlideShowWindows(1).View.Slide.SlideIndex)
        If .Shapes.Title.TextFrame.TextRange.Text = "Splunk 優點" Then
            .Shapes("圖片 25").Visible = msoFalse
        End If
    End With
End Sub

記得當visible=msoTure (-1) 時要一併移到前面
否則會看不出效果

Posted in Office, PowerPoint | Leave a comment

當投影片切換時 (VBA)

Sub OnSlideShowPageChange()
    MsgBox ActivePresentation.Slides(ActiveWindow.Selection.SlideRange.SlideNumber).Shapes.Title.TextFrame.TextRange.Text
End Sub
Posted in Office, PowerPoint | Leave a comment

Powerpoint VBA: 取得當前Slide編號

主要有兩種
1.

ActiveWindow.Selection.SlideRange.SlideNumber

此處主要是在一般狀態下 (非簡報播放)
適合用來Debug

2.

SlideShowWindows(1).View.Slide.SlideIndex

此處主要是當簡報播放情況下
( 所以一般Debug模式會出錯 )

以下為實際應用

Sub Picture76_4()
    With ActivePresentation.Slides(SlideShowWindows(1).View.Slide.SlideIndex)
        If .Shapes.Title.TextFrame.TextRange.Text = "Splunk for Unix and Linux" Then
            .Shapes("Picture 4").ZOrder msoBringToFront
        End If
    End With
End Sub
Sub Picture76_5()
    With ActivePresentation.Slides(ActiveWindow.Selection.SlideRange.SlideNumber)
        MsgBox .Shapes.Title.TextFrame.TextRange.Text
        If .Shapes.Title.TextFrame.TextRange.Text = "Splunk for Unix and Linux" Then
            .Shapes("Picture 5").ZOrder msoBringToFront
        End If
    End With
End Sub
Posted in Office, PowerPoint | Leave a comment