2009年2月12日 星期四

檢查磁碟空間

df -Plk|grep -v "Used Avail" | sed 's/\%//g' |awk '{if (($5>90)&&($4 < 10000000)) print "APS16 Disk Space: "$6 }'

df  :檢查磁碟空間
     -P: 訊息將不斷行
     -l  :僅列出本地磁碟機
     -k :空間大小表示單位為KB
     -m:空間大小表示單位為MB
     -h:空間大小表示單位自動換算成GB、MB、KB、Bytes,但會加上單位符號

grep :字串找尋工具
-v:排除

sed  :字串修改器
欲修改之內容以單引號 " ' "包住
s:自串置換
   語法:s/oldword/newword/
g:置換至文件最後一行
           語法:s/oldword/newword/g
        本例欲尋找之字串為%,恐被系統認為是系統特殊符號,因此加上"\"讓系統忽略其特殊符號之功能

awk :字串修改器
欲修改之內容以單引號及大括號 " '{}' "包住
if :可用以比對文字內容
    欲比對之內容,以小括號"()"包住
$5:以"TAB"之空白為分割欄,由左至右依序編號,此例為df -Plk結果之第5欄
1                       2                         3               4                         5                     6
Filesystem     1024-blocks     Used        Available          Capacity       Mounted on
    &&:表兩個比對式符合為真
    ||:表兩個比對式只要其中一個符合就為真
print :當前述結果為真,就秀出訊息,訊息以 雙引號包住 " " "
    $6:也可以秀出剛剛欄位之訊息

2009年2月5日 星期四

Solaris 較良好的 shell :tcsh

sendmail 的執行Script 在 /etc/rc2.d/S88sendmai [start | stop]

測試發信情況
# /usr/lib/sendmail -bv antonio.hsu@xxx.com
回報的情況如下,是ok的
antonio.hsu@xxx.com... deliverable: mailer relay, host 10.10.2.10, user antonio.hsu@xxx.com
發出信件
# /usr/lib/sendmail  antonio.hsu@xxx.com
Hello  <<  內容
. << 結束

Adding a Swap File on Solaris

This is straight out of the man pages, but I had a hard time finding it the first time that I needed it. If you have a Solaris system that badly needs more swap but you don't have a free swap device available, you can create a file in the file system and add it as additional swap.

  1. Use mkfile to create a file suitable for a local swap area. For example, to create a 1GB swap file:

        /usr/sbin/mkfile 1024m /swap

    where /swap is the name of the file to be used as swap space. Units for the size can be kilobytes (k), blocks (b), or megabytes (m).

  2. Tell the system to start using the file as swap:

        /usr/sbin/swap -a /swap

    Use swap -l to verify that the swap file has been activated. 

    文章摘自http://www.eyrie.org/~eagle/notes/solaris/swap-file.html

2009年1月7日 星期三

Oracle Command

建帳號及提供權限
CREATE USER dlink IDENTIFIED BY "rd10g"
DEFAULT TABLESPACE "USERS" 設定使用的TABLE空間為"USERS"
QUOTA UNLIMITED ON "USERS";

提供Dlink連接DB的權限
GRANT CONNECT TO dlink;
GRANT RESOURCE TO dlink;

提供dlink 擁有 glink.xxx Table 具有Select 的權限
grant select on glink.error_message to dlink;

查詢目前的連線數
select count(*) from v$session
show parameter max



1. 新增帳號CREATE USER 使用者名稱  IDENTIFIED BY 密碼;

2. 權限設定: GRANT 權限 ON 資料庫物件 TO 使用者名稱;

                      GRANT 角色 TO 使用者名稱

3. 取消權限: REVOKE 權限 ON 資料庫物件 FROM 使用者名稱;

4. 新增角色: CREATE ROLE 角色名稱 [ NOT IDENTIFIED | IDENTIFIED { BY 密碼 | USING [ 鋼要 .] PACKAGE | EXTERNALLY | GLOBALLY } ] ;

5. 取消角色: DROP ROLE 角色名稱

6. 更改密碼: ALTER USER  使用者名稱 IDENTIFIED BY 密碼;

7. 強制變更密碼: ALTER USER 使用者名稱 PASSWORD EXPIRE;

8. 鎖住現有的使用者: ALTER USER 使用者名稱 ACCOUNT LOCK;

9. 解鎖現有的使用者: ALTER USER 使用者名稱 ACCOUNT UNLOCK;

10. 刪除現有的使用者: DROP USER 使用者名稱  cascade ;

2008年12月7日 星期日

ifup,ifdown

用以單獨啟動或停止指定單一網卡
ifup eth0 啟動 eth0 介面之網卡
ifdown eth1 停用 eth1 介面之網卡 

Hyperic Server and Agent Command

vap16(10.10.2.244) 內的hyperic ,要以hyperic帳號登再執行
Server:/home/hyperic/server-3.2.0/bin/hq-server.sh start|stop
Agent:/home/hyperic/agent-3.2.0/hq-agent.sh start | stop | ping | setup

VMware Command

vmrun list 列出目前主機上正開啟的 Guest OS有那幾個
如 /vmdata/vap16/vap16.vmx
vmrun start|stop|reset|suspend  [PARAMENTERS]
此指令可以Command 的方式 啟動|停止|重開機|暫停 Guest OS
後面代入以 vmrun list 得到的資訊
如 vmrun start /vmdata/vap16/vap16.vmx 啟動vap16 Guest OS