Wednesday, April 1, 2015

check disk Wmware

Check on VMWare

1. Command #esxcli storage core device list ตรวจสอบ Hard disk ในเครื่อง

t10.ATA_____ST31500341AS________________________________________9VS2TVTN
Display Name: Local ATA Disk (t10.ATA_____ST31500341AS________________________________________9VS2TVTN)
Has Settable Display Name: true
Size: 1430799
Device Type: Direct-Access
Multipath Plugin: NMP
Devfs Path: /vmfs/devices/disks/t10.ATA_____ST31500341AS________________________________________9VS2TVTN
Vendor: ATA
Model: ST31500341AS
Revision: CC1H
SCSI Level: 5
Is Pseudo: false
Status: on
Is RDM Capable: false
Is Local: true
Is Removable: false
Is SSD: false
Is Offline: false
Is Perennially Reserved: false
Queue Full Sample Size: 0
Queue Full Threshold: 0
Thin Provisioning Status: unknown
Attached Filters:
VAAI Status: unknown
Other UIDs: vml.0100000000202020202020202020202020395653325456544e535433313530
Is Local SAS Device: false
Is Boot USB Device: false

2. Command #esxcli storage core device smart get -d t10.ATA_____ST31500341AS________________________________________9VS2TVTN

Parameter Value Threshold Worst
---------------------------- ----- --------- -----
Health Status OK N/A N/A
Media Wearout Indicator N/A N/A N/A
Write Error Count N/A N/A N/A
Read Error Count 104 6 99
Power-on Hours 59 0 59
Power Cycle Count 100 20 100
Reallocated Sector Count 100 36 100
Raw Read Error Rate 104 6 99
Drive Temperature 39 0 59
Driver Rated Max Temperature 61 45 41
Write Sectors TOT Count 200 0 200
Read Sectors TOT Count N/A N/A N/A
Initial Bad Block Count 100 99 100

3. Check all disk with command: /usr/lib/vmware/vm-support/bin/smartinfo.sh

#/usr/lib/vmware/vm-support/bin/smartinfo.sh 
SMART Information for disks.

Device:  t10.ATA_____KINGSTON_SV300S37A60G___________________50026B774507282B____
Errors: 
Error getting Smart Parameters: CANNOT open device


Device:  t10.ATA_____ST31500341AS________________________________________9VS3YGKG
Errors: 
Error getting Smart Parameters: CANNOT open device


Device:  t10.ATA_____WDC_WD20EARX2D00PASB0_________________________WD2DWCAZAD763430
Parameter                     Value  Threshold  Worst
-----------------------------------------------------
Health Status                 OK     N/A        N/A
Media Wearout Indicator       N/A    N/A        N/A
Write Error Count             N/A    N/A        N/A
Read Error Count              200    51         200
Power-on Hours                64     0          64
Power Cycle Count             100    0          100
Reallocated Sector Count      200    140        200
Raw Read Error Rate           200    51         200
Drive Temperature             110    0          90
Driver Rated Max Temperature  N/A    N/A        N/A
Write Sectors TOT Count       200    0          200
Read Sectors TOT Count        200    0          200

Initial Bad Block Count       N/A    N/A        N/A



Tuesday, March 17, 2015

การเพิ่ม Route แบบถาวรในวินโดว์

บทความด้านล่างคัดลอกมาจากเว็บไซต์ Komkit.net


ระบบที่ทดสอบ Microsoft Windows 7 Professional
กำหนดให้ Destination route คือ 172.17.15.0/24
กำหนดให้ Gateway คือ 172.17.12.1

- เพิ่ม route ชั่วคราว โดย route นี้จะหายไปเมื่อระบบ reboot
C:\>route add 172.17.15.0 mask 255.255.255.0 172.17.12.1
OK!

- เพิ่ม Perpersistent Static Route โดย route นี้จะไม่หายไปเมื่อระบบ reboot
C:\>route add -p 172.17.15.0 mask 255.255.255.0 172.17.12.1
OK!

- ลบ route
C:\>route delete 172.17.15.0 mask 255.255.255.0 172.17.12.1
OK!

- ตรวจสอบ Routing table
C:\> route print

หรือ

C:\> netstat -rn

Friday, February 27, 2015

check serial hard disk on Ubuntu | CentOS

1. sudo smartctl -i -H -c /dev/sda
** for CentOS install package

yum install smartmontools
 
 
vim /etc/smartmontools/smartd.conf
smartctl 6.2 2013-07-26 r3841 [i686-linux-3.13.0-46-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Momentus 5400.6
Device Model:     ST9500325AS
Serial Number:    6VEMGZEG
LU WWN Device Id: 5 000c50 032cbc8df
Firmware Version: 0001SDM1
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    5400 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 2.6, 3.0 Gb/s
Local Time is:    Fri Feb 27 16:42:48 2015 ICT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
                                        was completed without error.
                                        Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                (    0) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 144) minutes.
Conveyance self-test routine
recommended polling time:        (   2) minutes.
SCT capabilities:              (0x103b) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

** ปรับให้ smartd check disk แล้วส่งเมลแจ้งเมื่อพบ Error
vim /etc/smartmontools/smartd.conf
vim /etc/smartmontools/smartd.conf
vim /etc/smartmontools/smartd.conf
vim /etc/smartmontools/smartd.conf
vim /etc/smartmontools/smartd.conf
vim /etc/smartmontools/smartd.conf

---edit---
#1
# Monitor SMART status, ATA Error Log, Self-test log, and track
# changes in all attributes except for attribute 194
#/dev/sdb -H -l error -l selftest -t -I 194
/dev/sda -a -I 194 -W 4,45,55 -R 5 -m admin@domain.com (-ระบุผู้รับเมล)

#2
# A very silent check.  Only report SMART health status if it fails
# But send an email in this case
#/dev/sdc -H -C 0 -U 0 -m admin@example.com
#/dev/sdc -a -m admin@example.com
/dev/sda -H -C 0 -U 0 -m admin@domain.com (-ระบุผู้รับเม)
/dev/sdb -H -C 0 -U 0 -m admin@domain.com
/dev/sdc -H -C 0 -U 0 -m admin@domain.com
/dev/sdd -H -C 0 -U 0 -m admin@domain.com

-----------------

start service smartd on CentOS
systemctl enable smartd.service
systemctl start smartd.service
systemctl reload smartd.service
systemctl status smartd.service
check status is running
systemctl |grep smartd.service

ทำ Crontab เพื่อให้ smartd ค่อย monitor hard disk
# vim systemctlreload.sh
systemctl reload smartd
# chmod u+x systemctlreload.sh
# vim /etc/crontab
05 05 * * * root /root/systemctlreload.sh

ปรับแต่งการส่งเมลโดยให้ส่งเมลจาก Sender ที่เราต้องการ และปรับแต่ง Subject
vim /etc/smartmontools/smartd_warning.sh
----------------------------------------------------
# Format subject
export SMARTD_SUBJECT="ALERT: SMART error (${SMARTD_FAILTYPE-[SMARTD_FAILTYPE]}) detected on host: $hostname"

# Send mail, use platform mailer by default
  test -n "$SMARTD_MAILER" || SMARTD_MAILER=$os_mailer
  if [ -n "$dryrun" ]; then
    echo "exec '$SMARTD_MAILER' -s '$SMARTD_SUBJECT' -r "noreply@domain.com" $SMARTD_ADDRESS <$fullmessage
EOF"
  else
    exec "$SMARTD_MAILER" -s "$SMARTD_SUBJECT" -r "noreply@domain.com" $SMARTD_ADDRESS <$fullmessage
EOF
  fi
-----------------------------------------------------

หลังปรับ /etc/smartmontools/smartd_warning.sh ทดสอบสคริปด้วยคำสั่ง systemctl reload smartd.service แล้วรันคำสั่ง tail -f /var/log/maillog ดูว่าส่งเมลด้วย Sender ที่เราระบุไหม

vim /etc/smartmontools/smartd.conf
vim /etc/smartmontools/smartd.conf
2. sudo apt-get install lshw
#lshw -class disk
  *-disk                
       description: ATA Disk
       product: ST31500341AS
       vendor: Seagate
       physical id: 0.0.0
       bus info: scsi@2:0.0.0
       logical name: /dev/sda
       version: CC1H
       serial: 9VS1LZJJ
       size: 1397GiB (1500GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 signature=1e5b6b6d

Ref: 1.smartd
       2. how-to-monitor-disk-health-with-smartd-s-m-a-r-t

3. df -aTh

Ref:
smartctl

4. check disk health with Graphic mode
on ubuntu install package gsmartcontrol

sudo apt-get install gsmartcontrol

sudo gsmartcontrol






Ref:
gsmartcontrol

Friday, February 20, 2015

Vm Ware system

Copy form : Siamimprove

จากที่เราได้ทำความรู้จักกับ Storage ของ VM  มาแล้วเมื่อเราสร้าง VM ขึ้นมา 1 เครืื่อง ตัว ESX  เองจะสร้างไฟล์ต่าง ๆที่เกี่ยวข้องขึ้นมา โดยจะเก็บอยู่ใน Folder เดียวกันตามชื่อเครื่องที่เราตั้งขึ้นมา

Image
 
ประเภทไฟล์ต่าง ๆ มีดังนี้

ไฟล์ .vmx

   เป็นไฟล์ Configuration ของ VM

ไฟล์ .vswp
   เป็น Swap ของ VM

ไฟล์ .nvram
   เป็นไฟล์ จำลอง BIOS  ของ VM

ไฟล์ .vmem
   เป็นหน่วยความจำที่นำเอาพื้นที่ Disk ไปใช้แทน

ไฟ์ .vmss
   เป็นไฟล์ของ VM ถ้ามีคำสั่งให้ Suspend

ไฟล์ .vmsd
   เป็นไฟล์ข้อมูลของการทำ Snapshot

ไฟล์ -Snapshotxx.vmsn
    เป็นไฟล์สถานะของหน่วยความจำจากการทำ Snapshot

ไฟล์ .log
    เป็นไฟล์ Log ต่าง ๆ

ไฟล์ .vmdk
   เป็นไฟล์ Virtual Disk  (มีความสำคัญมากที่สุดบนโลกของ VMware)

Sunday, February 15, 2015

Datastores of Vmware

The datastores are mounted under /vmfs/volumes
use command copy with scp
scp -r /path/filename user@domain.com:/directory
-r คือ Recursive ซึ่งเป็นการ copy directory และ subdirectory ด้วย

Example: scp -r ARSHQ1F-1  /vmfs/volumes/datastore/

More

Tuesday, January 20, 2015

usb boot able by unetbootin

Create boot from USB from ubuntu
* Install by apt-get
sudo add-apt-repository ppa:gezakovacs/ppa
sudo apt-get update
sudo apt-get install unetbootin

Ref:
unetbootin

1.#Install unetbootin by download from website http://unetbootin.sourceforge.net/#install
2. how to use
chmod +x unetbootin-linux-608
3. execute program
./unetbootin-linux-608







Wednesday, January 14, 2015

encrypt file การเข้ารหัสไฟล์เอกสาร

1. Install programe

sudo aptitude install ccrypt

2. Zip file
tar cjvf file.tar.bz2 file  for creat file .bz2

3. Encrypt file

sudo ccrypt file.tar.bz2

4. Decrypt file

sudo ccrypt -d .file.tar.bz2.cpt


Wednesday, January 7, 2015

เซทให้ส่งเมลได้เฉพาะภายในโดเมนหรือบางโดเมน

1. แก้ไขไฟล์ /etc/postfix/main.cf

myhostname = mailgw.domain.com
mydomain = domain.com
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain $mydomain
#mynetworks = hash:/etc/postfix/network_table
mynetworks = 192.168.0.0/24, 10.10.10.0/24
relay_domains = domain.com
transport_maps = hash:/etc/postfix/transport
append_at_myorigin = no
broken_sasl_auth_clients = yes
smtpd_banner = My companee
relayhost = 192.xx.xx.xx
disable_dns_lookups = yes
smtpd_restriction_classes = local_only, local_plus
local_only = reject_unauth_destination
local_plus = check_recipient_access hash:/etc/postfix/local_plus reject_unauth_destination
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/restricted_users
header_checks = regexp:/etc/postfix/header_checks

2. สร้างไฟล์ที่ยอมให้ส่งเมลไปยังที่ไดได้บ้าง /etc/postfix/local_plus

# /etc/postfix/local_plus
# this file contains allowed destinations for users restricted to local_plus
# postmap this file after changes
domain.com OK
domain.org OK
domain.in.th OK

#postmap /etc/postfix/local_plus

3. สร้างไฟล์ที่ไม่ให้ user คนนั้น ๆ ส่งเมลออกภายนอกได้ /etc/postfix/restricted_users

email@domain.com local_plus
email@domain.in.th local_plus

#postmap /etc/postfix/restricted_users

4. แก้ไขไฟล์ /etc/postfix/transport

domain.com                      smtp:mail.mailserver.com:25

#postmap /etc/postfix/transport



Monday, December 15, 2014

Config postfixamdin on Debian 7.7 (postfix+mysql+dovecot)

Read on:
1. debian-wheezy-mail-server-postfix-dovecot-sasl-mysql-postfixadmin-roundcube-spamassassin-clamav-greylist-nginx-php5
2. http://rimuhosting.com/knowledgebase/linux/mail/postfixadmin


1. fix multi domain can't send mail
Error:
: unknown user: “maxime”

fix mydestination = localhost

2. create Local DNS for test mail

setup-dns-server-debian-7-wheezy

     2.1 cat /etc/bind/named.conf.local
//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone    "nanyang.com"   {
        type master;
        file    "/etc/bind/nanyang.com";
 };
zone    "sirivatana.com"   {
        type master;
        file    "/etc/bind/sirivatana.com";
 };

zone   "122.168.192.in-addr.arpa"        {
       type master;
       file    "/etc/bind/db.192.168.122";
 };

zone   "122.168.192.si.in-addr.arpa"        {
       type master;
       file    "/etc/bind/db.192.168.122.si";
 };
------------------------------------------------------------------------
     2.2 cat /etc/bind/nanyang.com
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     pop3s.nanyang.com. root.nanyang.com. (
                         121220143      ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL

        IN      A       192.168.122.10
;
@       IN      NS      pop3s.nanyang.com.
@       IN      MX      10      pop3s.nanyang.com.
@       IN      A       192.168.122.10
@       IN      AAAA    ::1
pop3s   IN      A       192.168.122.10
mail    IN      A       192.168.122.10
dns     IN      A       192.168.122.10
www     IN      A       192.168.122.10
--------------------------------------------------------------------------
     2.3 cat /etc/bind/db.192.168.122
;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@       IN      SOA     pop3s.nanyang.com. root.pop3s.nanyang.com. (
                         121220142      ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      pop3s.
@       IN      A       192.168.122.10
10      IN      PTR     pop3s.nanyang.com.

3. setup Superuser postfixadmin

3.1#cp config.inc.php.bak config.inc.php
--------------------------Edit file----------------------
$CONF['configured'] = true; $CONF['postfix_admin_url'] = 'https://192.168.122.10/postfixadmin';
$CONF['database_type'] = 'mysqli'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfix_admin'; $CONF['database_password'] = ''; $CONF['database_name'] = 'postfix'; $CONF['domain_path'] = 'YES'; $CONF['domain_in_mailbox'] = 'NO'; $CONF['fetchmail'] = 'NO';
------------------------------------------------

3.2 run setup.php from browser: https://192.168.122.10/postfixadmin/setup.php
Step 1 Click Generate password hash


Step 2 add Gen passwd to config.inc.php

add $CONF['setup_password'] = '13a402059836b65b6531a7a16d66dfbb:223b34da76ccf8daeb193737e2266be3dc2e7e6b'; to file config.inc.php and save and then create Supper user postfixadmin



Step 3 add Super user postfixadmin done!
* ในการสร้าง user จะมีพาสเวิร์ด 2 ส่วนคือ
1. ส่วน Setup password ต้องจำให้ได้ว่า ตอนแรกใส่พาวเวิร์ดอะไรไว้ เพราะมันเข้ารหัสไว้ เช่น '13a402059836b65b6531a7a16d66dfbb:223b34da76ccf8daeb193737e2266be3dc2e7e6b';
2. Password Admin: พาสเวิร์ดที่ตั้งไว้ให้กับ Super Admin


4. Dovecot

You really want to change in /etc/dovecot/conf.d/10-mail.conf:

mail_location = maildir:/home/vmail/%d/%n:INDEX=/home/vmail/%d/%n/indexes
to
mail_location = maildir:/home/vmail/%Ld/%Ln:INDEX=/home/vmail/%Ld/%Ln/indexes

otherwise if someone will send you email with mixed case such as AbCdE@ExAmPle.com then dovecot will create a NEW directories for the same user.

5. vacation
postfixadmin-setup-with-correct-vacation-settings-on-freebsd

Error: Command output: Can't locate
    MIME/EncWords.pm
#apt-get install libmime-encwords-perl

Command output: Can't locate
    Email/Valid.pm
#apt-get install libemail-valid-perl

Command output: Can't locate
    Mail/Sender.pm
Run command....
# perl -MCPAN -e shell
Y to all

  cpan> install Mail::Sender
  cpan> quit

#apt-get install libmail-sendmail-perl libdbd-pg-perl libemail-valid-perl libmime-tools-perl liblog-log4perl-perl liblog-dispatch-perl libgetopt-argvfile-perl libmime-charset-perl libmime-encwords-perl