2014年1月30日木曜日
EXPORTエリアのサイズ変更作業
●EXPORTエリアの容量の再作成 開始時刻:[ ]
【サーバ】
【IPアドレス】
【EXPORTエリアのエリア増減対応の有無】
現在のサイズ xxGB → 変更後のサイズ:xxGB
----------------------------------------------------------------------------------
①/dataにバックアップ用フォルダーを作成して、/exportのデータを退避する
・/data へフォルダ作成
コマンド:mkdir /data/export20140130
・データの退避
コマンド:cp -Rpf /export /data/export20140130
②デイクス3を削除
・データ削除
cd /export
rm -R *
・アンマウント
umount /export
・lvの削除
コマンド:lvremove /vg_export/lv_export
・vgの削除
コマンド:vgremove /vg_export
・削除確認
lvdisplay /export
・確認
コマンド:df -h
・vmwareから、 デイクス3を削除
削除
追加(xx GB)
③/exportのVG/LVを再作成
・vgの作成 (デプロイ手順書からコマンドを転帰)
コマンド:
・lvの作成 (デプロイ手順書からコマンドを転帰)
コマンド:
・フォーマット: (デプロイ手順書からコマンドを転帰)
コマンド:
・確認
コマンド:df -h
④ ①のデータを戻す
・データの復帰
コマンド:CP -R /data/export20140130 /export ← 確認!!
・確認
コマンド:ls /export
・/Data に作成した退避フォルダの削除
コマンド:rmdir -R /data/export20140130
----------------------------------------------------------------------------------
●第二大阪分を実施する
http://blog.volv.jp/memo/2009/06/vsphere-esx-40-1-strage-vmotion.html
ストレージVモーションを行い、Level_Aのデータストアから正規のデータへの移行をする
・vm停止
・システム・データ
データストア移行元:
データストア移行先:
・EXPORT
データストア移行元:
データストア移行先:
・移行完了の確認
vmware サマリから確認
2014年1月29日水曜日
[root@sfzfs62 vol2]# vi /etc/exports
[root@sfzfs62 vol2]# exportfs -ra
[root@sfzfs62 vol2]# exportfs -v
/vol/share/ES11
192.168.1.0/24(rw,wdelay,root_squash,all_squash,no_subtree_check)
/vol/share/ES21
192.168.1.0/24(rw,wdelay,root_squash,all_squash,no_subtree_check)
/vol2/share/E11R
192.168.1.0/24(rw,wdelay,root_squash,no_subtree_check)
/vol2/share/E21R
192.168.1.0/24(rw,wdelay,root_squash,no_subtree_check)
[root@sfzfs62 vol2]# mount -t nfs /vol2/E11R /connect/ES11
mount.nfs: remote share not in 'host:dir' format
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol2/E11R /connect/ES11
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol2/E21R /connect/ES21
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs: /connect/ES21 is busy or already mounted
[root@sfzfs62 vol2]# umount /connect/ES11
[root@sfzfs62 vol2]# umount /connect/ES21
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol/ES21 /connect/ES21
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol/ES21 /connect/ES21
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
[root@ns1 ~]# mount -t nfs4 sfzfs62:/vol/ES21 /connect/ES21
mount.nfs4: Failed to resolve server sfzfs62: Name or service not known
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES21 /connect/ES21
[root@ns1 ~]#
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs 192.168.1.41:/vol/ES11 /connect/ES21
^C
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]#
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES21 /connect/ES21
mount.nfs4: /connect/ES21 is busy or already mounted
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES11
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES11 /connect/ES11
[root@ns1 ~]# ls /connect/ES11/
ES11-dara.txt
[root@ns1 ~]# umount /connect/ES11
[root@ns1 ~]# umount /connect/ES21
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES11 /connect/ES11
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# umount /connect/ES21
umount: /connect/ES21: マウントされていません
[root@ns1 ~]# umount /connect/ES11
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES21 /connect/ES21
[root@ns1 ~]# ls /connect/ES
ls: cannot access /connect/ES: そのようなファイルやディレクトリはありません
[root@ns1 ~]# ls /connect/ES21
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol2/E21R /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol2/E21R failed, reason given by server: No such file or directory
[root@sfzfs62 vol2]# exportfs -ra
[root@sfzfs62 vol2]# exportfs -v
/vol/share/ES11
192.168.1.0/24(rw,wdelay,root_squash,all_squash,no_subtree_check)
/vol/share/ES21
192.168.1.0/24(rw,wdelay,root_squash,all_squash,no_subtree_check)
/vol2/share/E11R
192.168.1.0/24(rw,wdelay,root_squash,no_subtree_check)
/vol2/share/E21R
192.168.1.0/24(rw,wdelay,root_squash,no_subtree_check)
[root@sfzfs62 vol2]# mount -t nfs /vol2/E11R /connect/ES11
mount.nfs: remote share not in 'host:dir' format
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol2/E11R /connect/ES11
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol2/E21R /connect/ES21
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs: /connect/ES21 is busy or already mounted
[root@sfzfs62 vol2]# umount /connect/ES11
[root@sfzfs62 vol2]# umount /connect/ES21
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol/ES21 /connect/ES21
[root@sfzfs62 vol2]# mount -t nfs 192.168.1.41:/vol/ES21 /connect/ES21
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
[root@ns1 ~]# mount -t nfs4 sfzfs62:/vol/ES21 /connect/ES21
mount.nfs4: Failed to resolve server sfzfs62: Name or service not known
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES21 /connect/ES21
[root@ns1 ~]#
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs 192.168.1.41:/vol/ES11 /connect/ES21
^C
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]#
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES21 /connect/ES21
mount.nfs4: /connect/ES21 is busy or already mounted
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES11 /connect/ES11
mount.nfs4: mounting 192.168.1.41:/vol/ES11 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES11 /connect/ES11
[root@ns1 ~]# ls /connect/ES11/
ES11-dara.txt
[root@ns1 ~]# umount /connect/ES11
[root@ns1 ~]# umount /connect/ES21
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES11 /connect/ES11
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# umount /connect/ES21
umount: /connect/ES21: マウントされていません
[root@ns1 ~]# umount /connect/ES11
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/ES21 /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol/ES21 failed, reason given by server: No such file or directory
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol/share/ES21 /connect/ES21
[root@ns1 ~]# ls /connect/ES
ls: cannot access /connect/ES: そのようなファイルやディレクトリはありません
[root@ns1 ~]# ls /connect/ES21
[root@ns1 ~]# mount -t nfs4 192.168.1.41:/vol2/E21R /connect/ES21
mount.nfs4: mounting 192.168.1.41:/vol2/E21R failed, reason given by server: No such file or directory
2014年1月28日火曜日
NFS
###############################################################################
●NFSサーバ設定
###############################################################################
●NFS起動
[root@sfzfs62 ~]# service nfs start
NFS サービスを起動中: [ OK ]
NFS クォータを起動中: [ OK ]
NFS デーモンを起動中: [ OK ]
NFS mountd を起動中: [ OK ]
[root@sfzfs62 ES21]# ps -ef | grep nfs
root 31411 2 0 12:05 ? 00:00:00 [nfsd4]
root 31412 2 0 12:05 ? 00:00:00 [nfsd4_callbacks]
root 31413 2 0 12:05 ? 00:00:00 [nfsd]
root 31414 2 0 12:05 ? 00:00:00 [nfsd]
root 31415 2 0 12:05 ? 00:00:00 [nfsd]
root 31416 2 0 12:05 ? 00:00:00 [nfsd]
root 31417 2 0 12:05 ? 00:00:00 [nfsd]
root 31418 2 0 12:05 ? 00:00:00 [nfsd]
root 31419 2 0 12:05 ? 00:00:00 [nfsd]
root 31420 2 0 12:05 ? 00:00:00 [nfsd]
root 32147 28602 0 12:32 pts/0 00:00:00 grep nfs
[root@sfzfs62 ES21]#
●portserve起動
[root@sfzfs62 share]# /etc/rc.d/init.d/portserve start
================================================================================
●共用フォルダ作成
[root@sfzfs62 share]# ls -la /vol/share/
合計 20
drwxr-xr-x 5 root root 4096 1月 27 12:51 2014 .
drwxr-xr-x 3 root root 4096 1月 27 11:42 2014 ..
drwxrwxrwx 2 root root 4096 1月 27 15:02 2014 ES11
drwxr-xr-x 2 root root 4096 1月 27 15:05 2014 ES21
drwxr-xr-x 2 root root 4096 1月 27 12:51 2014 ES31
[root@sfzfs62 share]#
================================================================================
●NFS定義編集
[root@sfzfs62 ES21]# cat /etc/exports
# for test
/opt/admtools/pub *(rw)
/share/ES11 *(rw)
/share/ES21 *(rw)
[root@sfzfs62 ES21]#
[root@sfzfs62 vol]# exportfs -r
================================================================================
●シンボリックリンク作成
[root@sfzfs62 share]# pwd
/share
[root@sfzfs62 share]#
[root@sfzfs62 share]# ln -s /vol/share/ES21 /vol/ES21
[root@sfzfs62 share]# ln -s /vol/share/ES21 /vol/ES21
[root@sfzfs62 vol]# ls -la
合計 16
drwxr-xr-x 4 root root 4096 1月 28 12:46 2014 .
dr-xr-xr-x. 31 root root 4096 1月 28 10:45 2014 ..
lrwxrwxrwx 1 root root 15 1月 28 12:46 2014 ES11 -> /vol/share/ES11
lrwxrwxrwx 1 root root 15 1月 28 12:46 2014 ES21 -> /vol/share/ES21
drwxr-xr-x 4 root root 4096 1月 28 12:18 2014 share
[root@sfzfs62 vol]# pwd
/vol
[root@sfzfs62 vol]#
###############################################################################
●マウント サーバ確認
###############################################################################
[root@sfzfs62 ES21]# showmount -e 172.168.1.41
Export list for 172.168.1.41:
/vol/share/ES11 *
/opt/admtools/pub *
[root@sfzfs62 ES21]#
###############################################################################
●マウント クライアント確認
###############################################################################
----------------------------------------------------------------------------
[root@sfzoa62 /]# mkdir /Connect
[root@sfzoa62 /]# cd Connect
[root@sfzoa62 Connect]# mkdir ES11
[root@sfzoa62 Connect]# mkdir ES21
[root@sfzoa62 Connect]# ls
ES11 ES21
[root@sfzoa62 Connect]# pwd
/Connect
----------------------------------------------------------------------------
[root@sfzoa62 Connect]#
[root@sfzoa62 Connect]# ls -la /Connect
合計 16
drwxr-xr-x. 4 root root 4096 1月 27 15:16 2014 .
dr-xr-xr-x. 32 root root 4096 1月 27 15:16 2014 ..
drwxr-xr-x. 2 root root 4096 1月 27 15:16 2014 ES11
drwxr-xr-x. 2 root root 4096 1月 27 15:16 2014 ES21
[root@sfzoa62 Connect]#
[root@sfzoa62 Connect]# mount -t nfs sfzfs62:/share/ES11 /Connect/ES11
[root@sfzoa62 Connect]# mount -t nfs sfzfs62:/share/ES21 /Connect/ES21
[root@sfzoa62 Connect]#
[root@sfzoa62 Connect]# ls -la /Connect/ES11
合計 12
drwxrwxrwx. 2 root root 4096 1月 27 15:02 2014 .
drwxr-xr-x. 4 root root 4096 1月 27 15:16 2014 ..
-rw-r--r--. 1 root root 40 1月 27 15:02 2014 testfileES11
[root@sfzoa62 Connect]# ls -la /Connect/ES21
合計 12
drwxr-xr-x. 2 root root 4096 1月 27 15:05 2014 .
drwxr-xr-x. 4 root root 4096 1月 27 15:16 2014 ..
-rw-r--r--. 1 root root 32 1月 27 15:05 2014 testfileES21
[root@sfzoa62 Connect]#
----------------------------------------------------------------------------
###############################################################################
●作業用サーバ固有の問題
###############################################################################
●
/etc/rc.d/init.d/portserv を起動させる。
●
/etc/idmapd.conf に DomainNameを指定して、デーモン(rpc.imapd)を起動する
----------------------------------------------------------------------------
/etc/rc.d/init.d/portmap
2013年11月5日火曜日
2013年10月30日水曜日
作業10
01 9:00-19:40 2:00 アーカイブサーバ構築
02 9:00-17:40
03 9:00-19:40 2:00 会計サーバ構築
04 9:00-12:00 午後半休
07 9:00-19:00 1:20 アーカイブサーバ構築(ドキュメント)
08 9:00-18:40 1:00 ICAライセンスサポートサーバDISK枯渇対応
09 9:00-18:40 1:00 NETCA文字化け対応方法調査
10 9:00-18:40 1:00 Acronis導入ドキュメント
11 9:00-17:40 Acronisエージェント導入
15 9:00-18:40 1:00 ECサイト構築
16 9:00-18:40 1:00 ECサイト構築
17 6:00-20:40 6:00 Acronisエージェント導入
18 9:00-20:40 3:00 ECサイト構築
21 9:00-18:55 1:15 ECサイトのAcronis実施検証
22 9:00-19:40 2:00 Acronis導入(電話帳と複合機)
23 9:00-18:40 1:00 Acronisユーザガイドフォロー
24 9:00-20:00 2:20 DNSCmd一括バッチの作成
25 9:00-21:00 3:20 サーバプロテクト運用レビュ準備とレビュー後フォロー
28 9:00-20:00 2:20 ECサイト構築
29 9:00-22:00 4:20 シンクライアントサーバ構築
30 9:00-17:40 シンクライアントサーバ構築
31 9:00-17:40 Acronis導入ドキュメント
02 9:00-17:40
03 9:00-19:40 2:00 会計サーバ構築
04 9:00-12:00 午後半休
07 9:00-19:00 1:20 アーカイブサーバ構築(ドキュメント)
08 9:00-18:40 1:00 ICAライセンスサポートサーバDISK枯渇対応
09 9:00-18:40 1:00 NETCA文字化け対応方法調査
10 9:00-18:40 1:00 Acronis導入ドキュメント
11 9:00-17:40 Acronisエージェント導入
15 9:00-18:40 1:00 ECサイト構築
16 9:00-18:40 1:00 ECサイト構築
17 6:00-20:40 6:00 Acronisエージェント導入
18 9:00-20:40 3:00 ECサイト構築
21 9:00-18:55 1:15 ECサイトのAcronis実施検証
22 9:00-19:40 2:00 Acronis導入(電話帳と複合機)
23 9:00-18:40 1:00 Acronisユーザガイドフォロー
24 9:00-20:00 2:20 DNSCmd一括バッチの作成
25 9:00-21:00 3:20 サーバプロテクト運用レビュ準備とレビュー後フォロー
28 9:00-20:00 2:20 ECサイト構築
29 9:00-22:00 4:20 シンクライアントサーバ構築
30 9:00-17:40 シンクライアントサーバ構築
31 9:00-17:40 Acronis導入ドキュメント
2013年10月25日金曜日
VBS2
'##############################################################
'# DSN レコードの更新処理
'# 機能:
'# 入力ファイルの情報からDSNレコードへ追加
'# 入力ファイルの情報からDSNレコードから削除
'# 入力パラメータのフォーマットチェック
'#
'# 実行方法:コマンドコンソールから実施する
'# cscript //nologo CS_DNSUpdate.vbs > DNSUpdate.log &
'# cscript //nologo CS_DNSUpdate.vbs CHK > DNSUpdate.log &
'#
'#
'# 実行時の注意
'# 1.オプション:CHKを付けてエラーチェックのみを行う。
'# 2.エラーがある場合はエラーを修正し、CHKオプションでログにエラーが無くなるまで実行する
'# 3.エラーがない状態で、CHKオプションを外して本実行する
'#
'# 入力パラメータファイル:
'# 当スクリプトと同場所 CS_DNSUpdate.ini
'# フォーマット:
'# 項目左詰,半角スペースのセパレータ
'# 項目:
'# システム名、DNSアドレス、ドメイン名、ホスト名、IPアドレス、災対IPアドレス
'#
'# システムの単位で登録する
'# 行をコメントにする場合は、先頭#文字
'# 全ての項目は、入力必須、ブランク、空白は不可でこの事象に該当する場合部分エラーとなる
'# CHKオプション付きで実行してフォーマットをチェックしてから、CHKオプションを外して実行することを推奨します。
'#
'# ログファイル:
'# 当スクリプトと同場所 DNSUpdate.log
'#
'# UPDATE 2013/10/24
'#
'##############################################################
'Option Explicit
' グローバル定義
Dim sCheck 'パラメータ1 1:チェック
Dim iStepNo : iStepNo = 1 'ステップ番号
Dim msg : msg = "" 'メッセージ
Dim sComputer
Dim URL
'****************************************************************
' 関数
'****************************************************************
'' メッセージレベル
Const MSGLEVEL_I = " I " ' INFOMATION
Const MSGLEVEL_W = " W " ' WARNING
Const MSGLEVEL_E = " E " ' ERROR_
Const MSGLEVEL_S = " S " ' SEVERE_ERROR
'' コマンド@@
Const DNSCMD = "xdnscmd" ' DNS CMD COMMAND
'' OPTION
Const CHK = "CHK" ' RUN OPTION
Const ExE = "EXE" ' RUN OPTION
Const INI_FILE = "CS_DNSUpdate.ini" ' Fie
Const LOG_FILE = "CS_DNSUpdate.log" ' Fie
'****************************************************************
sCheck = Main_Init()
Call Main(sCheck)
WScript.Quit (0)
'**************************************************************
' メイン処理
'**************************************************************
Sub Main(flg)
Dim infile
Dim outfile
infile = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\")) & INI_FILE
outfile = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\")) & LOG_FILE
WScript.Echo now & "** DNS UPDATE START ** "
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo now & "** DNS UPDATE Main ** flg=" & flg
DnsRecordAddMain infile,flg
DnsRecordDelMain infile,flg
WScript.Echo now & "** DNS UPDATE STOP ** "
End Sub
'************************************************************
' 関数: DnsRecordAddMain
' 用途: DSNレコード追加を行う
' 入力: パラメータ、処理フラグ
' 戻値:
'************************************************************
Function DnsRecordAddMain(infile,flg)
Dim objFSO ' ファイルシステムオブジェクト
Dim objTextStream ' テキストストリームオブジェクト
Dim strText ' テキスト内容
Dim sSysName
Dim sSysNameOld
Dim sRc
Dim iCnt
Dim iCntErr
iCnt = 0
iCntErr = 0
sSysName = ""
sSysNameOld = ""
On Error Resume Next
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(infile, 1)
Do Until objTextStream.AtEndOfLine = True
strText = objTextStream.ReadLine
'コメント行の確認
IF Left(strText, 1) <> "#" THEN
'システム名の表示
aryStrings = Split(strText, " ")
sSysName = aryStrings(0)
IF sSysName <> sSysNameOld THEN
WScript.Echo "##### " & sSysName & "の災対レコードを追加します。#####"
END IF
sSysNameOld = sSysName
cmd = BildDnsAddCmd(strText)
IF cmd <> 1 THEN
'1行目(生成コマンドの表示)
WScript.Echo now & " " & cmd
IF flg <> CHK THEN
'2行目(コマンドの実行)
sRc= WshShell.run (cmd,1,true)
'3行目(実行結果の表示)
WScript.Echo now & " ** " & EXE & sRc & " ** "
END IF
Else
iCntErr = iCntErr + 1
END IF
iCnt = iCnt + 1
END IF
Loop
WScript.Echo now & " " & "** DnsAdd ** Mode=" & flg & " iCnt=" & iCnt & " iCnErr=" & iCntErr
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
End Function
'************************************************************
' 関数: dnsへのレコード追加コマンドを生成する
' 説明: 入力レコードからコマンドを組み立てて返す
' 入力: 入力レコード(スペース区切り)
' 戻値: コマンド
'************************************************************
Function BildDnsAddCmd(strText)
Dim sBildCmd
Dim sSysName
Dim sDnsIp
Dim sDomain
Dim sHostname
Dim sIp
Dim sIpEmg
sBildCmd =""
aryStrings = Split(strText, " ")
sSysName = aryStrings(0)
sDnsIp = aryStrings(1)
sDomain = aryStrings(2)
sHostname = aryStrings(3)
sIp = aryStrings(4)
sIpEmg = aryStrings(5)
'入力チェック --------------------------------------------------
errflg = 0
if sSysName = "" then
WScript.Echo now & " " & " ** INPUT FILE SYSNAME SPACE ERROR **"
errflg = 1
end if
if sDnsIp = "" then
WScript.Echo now & " " & " ** INPUT FILE DNSIP SPACE ERROR **"
errflg = 1
end if
if sDomain = "" then
WScript.Echo now & " " & " ** INPUT FILE DOMAIN SPACE ERROR **"
errflg = 1
end if
if sHostname = "" then
WScript.Echo now & " " & " ** INPUT FILE HOSTNAME SPACE ERROR **"
errflg = 1
end if
if sIp = "" then
WScript.Echo now & " " & " ** INPUT FILE IP SPACE ERROR **"
errflg = 1
end if
if sIpEmg = "" then
WScript.Echo now & " " & " ** INPUT FILE IPEMG SPACE ERROR **"
errflg = 1
end if
if errflg = 1 then
BildDnsDelCmd = errflg
return
end if
'入力チェック --------------------------------------------------
'コマンドの組み立て
sBildCmd = DNSCMD & " " & sDnsIp & " /recordadd " & sDomain & " " & sHostname & " A " & sIpEmg
'WScript.Echo now & " " & sBildCmd
BildDnsAddCmd = sBildCmd
End Function
'************************************************************
' 関数: DnsRecorddelMain
' 用途: DSNレコード削除を行う
' 入力: パラメータ、処理フラグ
' 戻値:
'************************************************************
Function DnsRecordDelMain(infile,flg)
Dim objFSO ' ファイルシステムオブジェクト
Dim objTextStream ' テキストストリームオブジェクト
Dim strText ' テキスト内容
Dim sSysname
Dim sSysNameOld
Dim sRc
Dim iCnt
Dim iCntErr
iCnt = 0
iCntErr = 0
sSysName = ""
sSysNameOld = ""
On Error Resume Next
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(infile, 1)
Do Until objTextStream.AtEndOfLine = True
strText = objTextStream.ReadLine
'コメント行(先頭が#)の確認
IF Left(strText, 1) <> "#" THEN
'システム名の表示
aryStrings = Split(strText, " ")
sSysName = aryStrings(0)
IF sSysName <> sSysNameOld THEN
WScript.Echo "##### " & sSysName & "の災対レコードを削除します。#####"
END IF
sSysNameOld = sSysName
cmd = BildDnsDelCmd(strText)
IF cmd <> 1 THEN
'1行目(生成コマンドの表示)
WScript.Echo now & " " & cmd
IF flg <> CHK THEN
'2行目(コマンドの実行)
sRc = WshShell.run (cmd,1,true)
'3行目(実行結果の表示)
WScript.Echo now & " ** " & EXE & sRc & " ** "
END IF
Else
iCntErr = iCntErr + 1
END IF
iCnt = iCnt + 1
END IF
Loop
WScript.Echo now & " " & "** DnsDel ** Mode=" & flg & " iCnt=" & iCnt & " iCnErr=" & iCntErr
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
End Function
'************************************************************
' 関数: dnsへのレコード削除コマンドを生成する
' 説明: 入力レコードからコマンドを組み立てて返す
' 入力: 入力レコード(スペース区切り)
' 戻値: コマンド
'************************************************************
Function BildDnsDelCmd(strText)
Dim sBildCmd
Dim sSysName
Dim sDnsIp
Dim sDomain
Dim sHostname
Dim sIp
Dim sIpEmg
sBildCmd =""
aryStrings = Split(strText, " ")
sSysName = aryStrings(0)
sDnsIp = aryStrings(1)
sDomain = aryStrings(2)
sHostname = aryStrings(3)
sIp = aryStrings(4)
sIpEmg = aryStrings(5)
'入力チェック --------------------------------------------------
errflg = 0
if sSysName = "" then
WScript.Echo now & " " & " ** INPUT FILE SYSNAME SPACE ERROR **"
errflg = 1
end if
if sDnsIp = "" then
WScript.Echo now & " " & " ** INPUT FILE DNSIP SPACE ERROR **"
errflg = 1
end if
if sDomain = "" then
WScript.Echo now & " " & " ** INPUT FILE DOMAIN SPACE ERROR **"
errflg = 1
end if
if sHostname = "" then
WScript.Echo now & " " & " ** INPUT FILE HOSTNAME SPACE ERROR **"
errflg = 1
end if
if sIp = "" then
WScript.Echo now & " " & " ** INPUT FILE IP SPACE ERROR **"
errflg = 1
end if
if sIpEmg = "" then
WScript.Echo now & " " & " ** INPUT FILE IPEMG SPACE ERROR **"
errflg = 1
end if
if errflg = 1 then
BildDnsDelCmd = errflg
'return
end if
'入力チェック --------------------------------------------------
'コマンドの組み立て
sBildCmd = DNSCMD & " " & sDnsIp & " /recorddelete " & sDomain & " " & sHostname & " A " & sIp
'WScript.Echo now & " " & sBildCmd
BildDnsDelCmd = sBildCmd
End Function
'**************************************************************
' 1.1 初期処理
'**************************************************************
Function Main_Init()
' VBS起動するWSHコマンドがcScriptでない場合は
' エラーコード99で終了する
IF Not(IsCscript()) THEN
WScript.Quit (99)
END IF
msg="** Note:CScript ONLY RUN **"
sComputer = SetLogHeader(msg)
Main_Init = GetParam()
End Function
'-----------------------------------------------
' 1.1.1 パラメータ取得処理
'-----------------------------------------------
Function GetParam()
Dim i
Dim objParm
sCheck = EXE ' モード
Set objParm=WScript.Arguments
For i=1 To objParm.Count
WScript.echo now & MSGLEVEL_I & "** (" & i & ") " & objParm.Item(i - 1)
IF i = 1 THEN
sCheck = objParm.Item(i - 1)
END IF
Next
GetParam = sCheck
End Function
'****************************************************************
' 関数: IsCscript
' 用途: 自VBSを起動したWSH コマンドがcScriptを返信
' 入力: 無し
' 戻値: cScriptの時true wScriptの時false
'****************************************************************
Function IsCscript()
' WSH起動コマンド
Const WHS_COMMAND_WSCRIPT = "wscript.exe"
Const WHS_COMMAND_CSCRIPT = "cscript.exe"
IsCscript = true
IF LCase( Right(WScript.FullName, len(WHS_COMMAND_WSCRIPT)) ) = WHS_COMMAND_WSCRIPT THEN
IsCscript = false
END IF
End Function
'****************************************************************
' 関数: SetLogHeader
' 用途: ログヘッダーページをフォーマット
' 入力: ヘッダーのコメントメッセージ
' 戻値: コンピュータ名前
'****************************************************************
Function SetLogHeader(msg)
Dim objNetWork ' ネットワークオブジェクト
Dim objParm ' コマンドラインパラメータ
Dim i ' コマンドライン引数の個数
Dim chr
iStepNo = 0
WScript.Echo now & " ***********************************************************"
WScript.Echo now & EditTitleLine(" ** Script : " & Wscript.ScriptName)
WScript.Echo now & EditTitleLine(" ** " & Wscript.ScriptFullName)
WScript.Echo now & " ** ----------------------------------------------------- **"
WScript.Echo now & EditTitleLine(" ** WSH : " & Wscript.Name)
WScript.Echo now & EditTitleLine(" ** " & Wscript.FullName)
WScript.Echo now & EditTitleLine(" ** " & Wscript.Path)
WScript.Echo now & " ** ----------------------------------------------------- **"
Set objParm = WScript.Arguments
WScript.Echo now & EditTitleLine(" ** Command param count " & objParm.Count)
For i=1 To objParm.Count
WScript.echo now & EditTitleLine(" ** (" & i & ") " & objParm.Item(i - 1))
Next
WScript.Echo now & " ** ----------------------------------------------------- **"
' ネットワークオブジェクトの作成
Set objNetWork = WScript.CreateObject("WScript.Network")
' ユーザ名
WScript.echo now & EditTitleLine(" ** UserName : " & objNetWork.UserName)
' ドメイン名
WScript.echo now & EditTitleLine(" ** UserDomain : " & objNetWork.UserDomain)
' コンピュータ名
WScript.echo now & EditTitleLine(" ** ComputerName : " & GetComputer())
WScript.Echo now & " ***********************************************************"
WScript.Echo now & EditTitleLine(" ** " & msg)
WScript.Echo now & " ***********************************************************"
SetLogHeader = GetComputer()
Set objNetWork = Nothing
End Function
'****************************************************************
' 関数: EditTitleLine
' 用途: 文字列編集、所定のカラム位置に**の文字を挿入する
' 入力: 変種前文字列
' 戻値: 編集後文字列
'****************************************************************
Function EditTitleLine(chr)
Dim sEditTitleLine
Dim iMAXCOLS
iMAXCOLS = 60
sEditTitleLine = left(chr,len(chr)) & Space(iMAXCOLS-len(" **")-len(chr)) & " **"
EditTitleLine = sEditTitleLine
End Function
'****************************************************************
' 関数: GetComputer
' 用途: コンピュータ名を取得する
' 入力: 無し
' 戻値: コンピュータ名
'****************************************************************
Function GetComputer()
Dim objNetWork ' ネットワークオブジェクト
' ネットワークオブジェクトの作成
Set objNetWork = WScript.CreateObject("WScript.Network")
' コンピュータ名
GetComputer = objNetWork.ComputerName
Set objNetWork = Nothing
End Function
2013年10月7日月曜日
登録:
投稿 (Atom)