2013/12/17

nagios install

 useradd nagios
 wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.gz
 wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
 tar xfv nagios-4.0.2.tar.gz
 tar xvf nagios-plugins-1.5.tar.gz
 cd nagios-4.0.2
 ./configure --prefix=/usr/local/nagios
 make ; make all ; make install
 make install-init
 make install-config
 cd ../nagios-plugins-1.5
 ./configure --prefix=/usr/local/nagios && make all && make install

-- for nagios map --

yum install gd gd-devel

make clean
 ./configure --prefix=/usr/local/nagios --with-gd-lib=/usr/lib   --with-gd-inc=/usr/include
 ./configure --with-command-group=nagcmd
 make all; make install; make install-init; make install-config; make install-commandmode; make install-webconf 

-- for mail command --

yum install mailx


-- for perl --
yum -y install perl-Params-Validate perl-Math-Calc-Units perl-Regexp-Commonperl-Class-Accessor perl-Config-Tiny perl-Nagios-Plugin.noarch

2013/12/12

Convert a VMX to an OVF
ovftool f:/myvms/BigDemo.vmx x:/ovf/BigDemo.ovf


Convert a VMX to an OVA
ovftool vmxs/Nostalgia.vmx ovfs/Nostalgia.ova


Convert an OVF to a VMX
ovftool BigDemo.ovf x:/myvms/BigDemo.vmx

2013/12/11

send from Linux with file

yum -y install mutt mailx

echo "This is backup" | mutt -a "/backup/2013-12-11-10:59:09.tgz" -s "Master *** backup" --wtf@mail.mail

2013/12/03

bashrc







# .bashrc
export PS1='\[\033[01;32m\][`date +%T`]\[\033[01;31m\][\u@\h]\[\033[00m\] \w \$'

# User specific aliases and functions
alias ll='ls -lah'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls --color'
alias today="date '+%F week %u'"
alias bye='history -c;exit'
alias zhutf8='setenv LC_ALL zh_TW.utf8;setenv LANG zh_TW.utf8'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi


2013/11/29

建立SSL使用憑證

##建立SSL使用憑證
mkdir -p /ssl/
cd /ssl
openssl genrsa -out privatekey.pem 2048
openssl req -new -key privatekey.pem -out  certerq.csr

openssl x509 -req -days 3650 -in certerq.csr -signkey privatekey.pem -out cert.pem

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -out /ssl/apache2/apache.crt -keyout /ssl/apache2/apache.key

shell for Backup

#!/bin/bash
day=`date +%Y-%m-%d-%T`
backupph=/backup/$day
mkdir -p $backupph
cp -a /var/named/chroot/ $backupph
echo "Backup Finish"



------


#!/bin/bash
day=`date +%Y-%m-%d`
backupph=/media/disk/$day
mkdir $backupph
tar -czvfP $backupph/home.tgz /home
echo "Backup Finish"



TAR


tar -xzvPf filename

2013/11/06

Basic Apache 2.4.6 PHP 5.5.4

## Basic

yum install gcc libtool make automake autoconf curl-devel gd-devel openssl-devel gcc-c++ libmcrypt-devel libevent-devel posgresql-devel cronolog libtool-ltdl-devel

## Apache apr

wget http://ftp.twaren.net/Unix/Web/apache//apr/apr-1.4.8.tar.gz

tar xf apr-1.4.8.tar.gz
cd apr-1.4.8
./configure
make ; make install

## Apache apr-util

wget http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz

tar xf apr-util-1.5.2.tar.gz
cd apr-util-1.5.2
./configure --with-apr=/usr/local/apr/bin/apr-1-config
make ; make install


wget  http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.zip
unzip pcre-8.33.zip
cd pcre-8.33
./configure
make ; make install

## Apache

wget http://archive.apache.org/dist/httpd/httpd-2.4.6.tar.gz
tar xf httpd-2.4.6.tar.gz
cd httpd-2.4.6
./configure --prefix=/usr/local/apache2
make ; make install

## PHP 5.5.4

yum -y install libxml2 libxml2-devel
wget http://tw2.php.net/get/php-5.5.4.tar.gz/from/this/mirror
tar -xf php-5.5.4.tar.gz
cd php-5.5.4
./configure  --prefix=/usr/local/apache2/php
make ; make install

##
cd /usr/local/bin ; ln -s /usr/local/apache2/php/bin/php ; ln -s /usr/local/apache2/php/bin/phpize ; ln -s /usr/local/apache2/php/bin/php-config

touch /usr/local/apache2/conf/php.ini

##
echo "AddType application/x-httpd-php .php" >> /usr/local/apache2/conf/httpd.conf
echo "AddType application/x-httpd-php-source .phps" >> /usr/local/apache2/conf/httpd.conf

2013/10/22

Fortify Scan Script on OSX

/Applications/HP_Fortify/HP_Fortify_SCA_and_Apps_3.80/bin/sourceanalyzer -b $1 xcodebuild -project /Users/****/Desktop/scan/$1/$1.xcodeproj -sdk iphonesimulator6.0 ; /Applications/HP_Fortify/HP_Fortify_SCA_and_Apps_3.80/bin/sourceanalyzer -b $1 -scan -f /Users/****/Desktop/$1_result.fpr



####

#check xcode sdk on mac

 xcodebuild -showsdks

2013/10/04

VM (ESX) clone

vmkfstools -i /vmfs/volumes/Disk_2_500G/MS_AD_192.168.1.31/MS_AD_192.168.1.31.vmdk -d thin /vmfs/volumes/datastore1/os_backup/Windows_Server_2008_AD_2013-09-24.vmdk


2013/08/09

.tar 
解壓:tar xvf FileName.tar 
壓缩:tar cvf FileName.tar DirName 
(注:tar是包裹(把多個檔案合成一個),不是壓缩!) 
--------------------------------------------- 
.gz 
解壓1:gunzip FileName.gz 
解壓2:gzip -d FileName.gz 
壓缩:gzip FileName 
.tar.gz 
解壓:tar zxvf FileName.tar.gz 
壓缩:tar zcvf FileName.tar.gz DirName 
--------------------------------------------- 
.bz2 
解壓1:bzip2 -d FileName.bz2 
解壓2:bunzip2 FileName.bz2 
壓缩: bzip2 -z FileName 
.tar.bz2 
解壓:tar jxvf FileName.tar.bz2 
壓缩:tar jcvf FileName.tar.bz2 DirName 
--------------------------------------------- 
.bz 
解壓1:bzip2 -d FileName.bz 
解壓2:bunzip2 FileName.bz 
壓缩:未知 
.tar.bz 
解壓:tar jxvf FileName.tar.bz 
壓缩:未知 
--------------------------------------------- 
.Z 
解壓:uncompress FileName.Z 
壓缩:compress FileName 
.tar.Z 
解壓:tar Zxvf FileName.tar.Z 
壓缩:tar Zcvf FileName.tar.Z DirName 
--------------------------------------------- 
.tgz 
解壓:tar zxvf FileName.tgz 
壓缩:未知 
.tar.tgz 
解壓:tar mysFileName.tar.tgz 
壓缩:tar zcvf FileName.tar.tgz FileName 
--------------------------------------------- 
.zip 
解壓:unzip FileName.zip 
壓缩:zip FileName.zip DirName 
--------------------------------------------- 
.rar 
解壓:rar a FileName.rar 
壓缩:rar e FileName.rar 


rar請到:http://www.rarsoft.com/download.htm 下載! 
解壓後請将rar_static拷貝到/usr/bin目錄(其他由$PATH環境變數指定的目錄也可以): 
[root@www2 tmp]# cp rar_static /usr/bin/rar 
--------------------------------------------- 
.lha 
解壓:lha -e FileName.lha 
壓缩:lha -a FileName.lha FileName 

lha請到:http://www.infor.kanazawa-it.ac.jp/~ishii/lhaunix/下載! 
解壓後請将lha拷贝到/usr/bin目錄(其他由$PATH環境變數指定的目錄也可以): 
[root@www2 tmp]# cp lha /usr/bin/ 
--------------------------------------------- 
.tar .tgz .tar.gz .tar.Z .tar.bz .tar.bz2 .zip .cpio .rpm .deb .slp .arj .rar .ace .lha .lzh .lzx .lzs .arc .sda .sfx .lnx .zoo .cab .kar .cpt .pit .sit .sea 
解壓:sEx x FileName.* 
壓缩:sEx a FileName.* FileName 

sEx只是調用相關程序,本身並無壓缩、解壓功能,請注意!\r 
sEx請到:http://sourceforge.net/projects/sex下載! 
解壓后請将sEx拷贝到/usr/bin目錄(其他由$PATH環境變數指定的目錄也可以): 
[root@www2 tmp]# cp sEx /usr/bin/ 

wget via proxy

vim ~/.wgetrc



http_proxy = http://proxy.hinet.net:80/
use_proxy = on
wait = 15

2013/08/08

CentOS 6.x Proxy Server (Squid)

yum install squid

vi /etc/squid/squid.conf
##
cache_dir ufs /var/spool/squid 2000 16 256
##2G

yum

Error: pkgKey  doesn't exist in repo base (centos5.x)


 yum clean all ; yum clean metadata ; yum -y update

###

The program package-cleanup is found in the yum-utils package.


yum install yum-utils
yum-complete-transaction --cleanup-only
package-cleanup --dupes ; package-cleanup --problems


###Proxy

vi  /etc/yum.conf 
proxy=http://proxy_ip:port

http://wiki.debian.org.hk/w/Manage_software_with_YUM

2013/07/29


@echo off 
rem eth //eth 为网卡名称,可在网络连接中查询,如"本地链接" 
set eth="本地链接" 
rem ip //ip 为你想更改的IP 
set ip=192.168.4.23 
rem gw //gw 为网关地址 
set gw=192.168.4.1 
rem netmasks //netmasks 为子网掩码 
set netmasks=255.255.255.192 

echo 正在将本机IP更改到: %ip% 
rem 
if %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% > nul 
if not %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% 1 > nul 
echo......................... 
echo 检查当前本机IP: 
ipconfig 
echo......................... 
echo 成功将本机IP更改为%ip%! 
pause 
close 

2013/07/24

Build NTP server on CentOS via yum

yum -y install ntp

mv /etc/ntp.conf /etc/ntp.conf.bak

vi /etc/ntp.conf

--past it
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.0.0 mask 255.255.255.0 nomodify
server tick.stdtime.gov.tw
server tock.stdtime.gov.tw
server time.stdtime.gov.tw
server clock.stdtime.gov.tw
server watch.stdtime.gov.tw
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
--


or edit

vi /etc/ntp.conf

####
#add
####

restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.0.0 mask 255.255.255.0 nomodify

server tick.stdtime.gov.tw
server tock.stdtime.gov.tw
server time.stdtime.gov.tw
server clock.stdtime.gov.tw
server watch.stdtime.gov.tw

###
#qw
###

service ntp restart
chkconfig ntp on

##iptables
iptables -I INPUT -p udp --dport 123 -j ACCEPT
iptables -I OUTPUT -p udp --sport 123 -j ACCEPT

2013/07/19

cat config out put as file

cat anaconda-ks.cfg |grep -Env "^$|#" > log

2013/07/11

New server

rpm -Uvh http://mirror01.idc.hinet.net/EPEL/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://mirror01.idc.hinet.net/EPEL/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

2013/07/08

sql2008 install error "SQL Server 服務的指定認證無效。若要繼續,請提供 SQL Server 服務的有效帳戶和密碼。"

error

"SQL Server 服務的指定認證無效。若要繼續,請提供 SQL Server 服務的有效帳戶和密碼。"

fix

username


"NT AUTHORITY\SYSTEM"   or  "NT AUTHORITY\NETWORK SERVICE"

2013/04/11

running yum-complete-transaction first



There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
The program yum-complete-transaction is found in the yum-utils package.
# install yum-complete-transaction
yum install yum-utils
# clean up yum-complete-transaction
yum-complete-transaction –cleanup-only

package-cleanup –dupes
package-cleanup –problems

2013/02/25

release swap

free && swapoff -a && swapon -a && free 

run as root