ONE LINE PYTHON WEB SERVER
No commentsWith this simple python line
python -c “import SimpleHTTPServer;SimpleHTTPServer.test()”
Howto: add new partition type linux lvm, mkfs, pvcreate, vgcreate, lvcreate…
No commentsAdd new partition type linux lvm, mkfs, pvcreate, vgcreate, lvcreate…
step1. fdisk /dev/DISK_NAME
#fdisk /dev/sdb
step2. mkfs.FS NAME /dev/DISK_NAME{partition_number}
#mkfs.ext3 /dev/sdb2
step3. pvcreate /dev/DISK_NAME{partition_name}
#pvcreate /dev/sdb2
step4. vgcreate VG_NAME
#vgcreate backup /dev/sdb2
#vgextend backup /dev/sdb2
step4. lvcreate -L FS_SIZE -n {partitoin_name_you_want} VG_NAME
# lvcreate -L1G -n 1 backup
step5. lvextend -L SIZE_IN_MEGABYTES /dev/mapper/VG_NAME-LV_NAME
# lvextend -L1T /dev/mapper/backup-1
step6. resize2fe /dev/mapper/VG_NAME-LV_NAME
# resize2fs /dev/mapper/backup-1
step7. mount /dev/mapper/VG_NAME-LV_NAME /MOUNT_POINT_NAME
#mount /dev/mapper/backup-1 /mnt
That’s All. Bye.
Howto: Re-read Partition Table With No System Reboot
No commentsRe-Read Partition Table WITHOUT reboot the system
In some case the fdisk partitioning want to reboot machine to make changes affect.
This is the error message when this happens:
fdisk WARNING: Re-reading the partition table failed with error 16:
Device or resource busy.
The kernel still uses the old table.
The real-life example OS is Debian , but it’s not limitted to. It works on all! So, just do it:
( We doesn’t have alredy installed package: parted, so we first install it and then run partprobe to re-read the partition table )
#apt-get install parted
……
………..
#partprobe
#fdisk -l /dev/DISK_NAME
That’s All.
Howto: Linux LVM add and extend (proxmox+open-vz part2)
No commentsAdd other HDD to Linux LVM and extend working partition (proxmox+open-vz part2)
used documentation: http://tldp.org/HOWTO/LVM-HOWTO
In the Part1 on proxmox+open-vz, the following situations was automaticly created by the proxmox installation and open-vz containers working partition (/var/lib/vz)
1.First Run vgdisplay to see group or groups
bmg:~# vgdisplay
— Volume group —
VG Name pve
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 74.03 GB
PE Size 4.00 MB
Total PE 18951
Alloc PE / Size 17928 / 70.03 GB
Free PE / Size 1023 / 4.00 GB
VG UUID x2ZPHW-wX7l-o12Y-tShS-3AHJ-ycU4-2bkpE6
bmg:~#
Important data is VG Status to be resizable, vg size and vg name Read the rest of this entry »
Howto: install proxmox VE with Open-VZ and Create Virtual Machine on CentOS5 (proxmox+open-vz part1)
No commentsAll actions are based on original proxmox’s articles at: http://pve.proxmox.com/wiki/ . READ PROXMOX WIKI !!!! This is not proxmox tutorials or documents, it’s short line-by-line on command-line examples on howto do it in short, easy steps:
1. Download Proxmox-ve (08.06.2010) - latest stable iso is located here: http://www.proxmox.com/cms_proxmox/cms/upload/bittorrent/proxmox-ve_1.5-4627-3.iso.
2. Burn on disk and start installation from the burned CD. ( Using the all disks in the system )
3. Next,Next…Finish mouse clicking operations (fill the asked fields. e.g. name mail password..IP address,mask,gateway and dns)
4. Login into Web Proxmox Interface on address: http://IP-ADDRESS/. Change something if needed here. And goto:
5. Login via SSH to server ip address on default port 22. Make aptutude update and aptitude upgrade
In this case the hardware doesn’t support KVM fully virtualization, so we will use Open-VZ virtualization …
nagios, nagios-plugins, nrpe from FreeBSD jail
No commentsReason: Not able to ping from FreeBSD prison (jail)
SubReason1: check_ping command doesn’t work
SubReason2: check-host-alive command doesn’t work
step1. Change sysctl security raw socket for jail
#sysctl security.jail.allow_raw_sockets=1
step2. Set it permanently
#echo ’security.jail.allow_raw_sockets=1′ >> /etc/sysctl.conf
By default FreeBSD does not allows prison users / apps to create raw sockets. This is a security feature. With raw sockets one can use perl / python or tools such as nc to create raw socket and launch attacks. However, this aspects of the jail environment may be modified from the host environment using sysctl command.security.jail.allow_raw_sockets MIB entry determines whether or not prison root is allowed to create raw sockets. Setting this MIB to 1 allows utilities like ping and traceroute to operate inside the prison.
PROBLEM1: check_ping exit with error:
#/usr/local/libexec/nagios/check_ping -H 192.192.192.3 -w 100.0,50% -c 400.0,60% -p1
CRITICAL - You need more args!!!
Could not open pipe:
#
SOLUTION:
The prefer solution is using check_fping instead of check_ping command. Probably you don’t have already define check_fping command, so insert into into commands.cfg :
define command{
command_name check_fping
command_line $USER1$/check_fping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -n 2
}
PROBLEM1.1: check-host-alive returns error:
CRITICAL - You need more args!!!
SOLUTION:
The check-host-alive command, which is used into hosts.cfg will probably not working too as long as it use check_ping situation, so the procedure is almost exactly the same. Re-edit your commands.cfg and make it use check_fping command with check_fping commandline option arguments.
define command{
command_name check-host-alive
command_line $USER1$/check_fping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -n 2
}
Very very usefull IIS appcmd.exe command line solutions
No commentsApplication Pools
1. Recycle all application pools (replace recycle with start/stop to start/stop all apppools)
appcmd list apppool /xml | appcmd recycle apppool /in
2. Stop application pools with word “cheap” in it
appcmd list apppool /name:”$=*cheap*” /xml | appcmd stop apppool /in
3. Set property enable32BitAppOnWin64 to true for all apppools (Filter apppools as in 2 if needed)
appcmd list apppool /xml | appcmd set apppool /in /enable32BitAppOnWin64:true
4. Start apppools which are stopped
appcmd list apppool /state:Stopped /xml | appcmd start apppool /in
5. Recycle application pools which are used in some applications
appcmd list app /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in
appcmd list app /xml | appcmd recycle apppool /in (This might recycle one apppool multiple times)
6. Recycle apppools serving website “Default Web Site”
appcmd list site “Default Web Site” /xml | appcmd list app /in /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in
appcmd list app /site.name:”Default Web Site” /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in
Sites
7. Start all the sites (Replace start with stop to stop all sites)
appcmd list site /xml | appcmd start site /in
8. Start the sites which are stopped
appcmd list site /state:stopped /xml | appcmd start site /in
9. Set serverAutoStart to false for all sites
appcmd list site /xml | appcmd set site /serverAutoStart:false /in
10. Keep sites config data and restore later
appcmd list site /config /xml > sites.xml
appcmd add sites /in < sites.xml
Applications and Vdirs
11. Delete all apps which are using a particular apppool
appcmd list apppool DefaultAppPool /xml | appcmd list app /in /xml | appcmd delete app /in
12. Move all applications in a site to NewAppPool apppool
appcmd list app /site.name:”Default Web Site” /xml | appcmd set app /in /applicationPool:NewAppPool
13. List all sites with “/test” app
appcmd list app /path:”/test” /xml | appcmd list site /in
14. List apps created by user10 (assuming all his apps under a folder whose name contains user10)
appcmd list vdir /physicalPath:”$=*user10*” /xml | appcmd list app /in
15. List sites which read from C:\inetput\wwwroot
appcmd list vdir /physicalPath:C:\inetput\wwwroot /xml | appcmd list app /xml /in | appcmd list site /in
16. List the vdirs of sites which are stopped
appcmd list site /state:stopped /xml | appcmd list app /xml /in | appcmd list vdir /in
Worker processes and Requests
17. Stop apppools of requests running for more than 60 seconds
appcmd list request /xml /time:”$>60000″ | appcmd list apppool /in /xml | appcmd stop apppool /in
18. List apps served by wp 3600
appcmd list wp 3600 /xml | appcmd list apppool /xml /in | appcmd list app /in
Modules
19. Disable all managed modules
appcmd list module /preCondition:managedHandler /xml | appcmd delete module /in
20. Uninstall all native modules
appcmd list module /type:”" /xml | appcmd uninstall module /in
21. Unlock all module entries under system.webServer/modules (won’t work on vista)
appcmd list module /xml | appcmd set config /lockItem:false /in
Configuration
22. Keep config of a particular section and restore later
appcmd list config http://localhost/app1/ /section:caching /xml /config > config.xml
appcmd set config http://localhost/app1 /in < config.xml
Backups and Traces
23. Delete all backups
appcmd list backup /xml | appcmd delete backup /in
24. List sites generating 404
appcmd list trace /statusCode:404 /xml | appcmd list site /in
Content copied from :http://blogs.iis.net/ksingla/archive/2007/06/17/things-you-can-do-by-piping-appcmd-commands.aspx
openvz on debian amd64
No commentsecho “deb http://download.openvz.org/debian-systs lenny openvz ” >> /etc/apt/sources.list
wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add - && apt-get update
apt-get install vzctl vzquota
edit /etc/sysctl.conf : set net.ipv4.ip_forward=1
ln -s /var/lib/vz /vz
apt-get install vzctl-ostmp-debian-5.0-amd64-minimal
apt-get install vzprocps
put into /etc/vz/vz.conf : IPTABLES=”ip_tables ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_LOG ipt_conntrack ipt_helper ipt_state iptable_nat ip_nat_ftp ip_nat_irc ipt_TOS”
grep - syntax and options reference quick guide
No commentsGREP::: quick syntax and options reference guide
grep basically searches.
shell> grep foo
file(s)
shell> grep foo
*
returns all the lines in file(s) that contain a string matching
the expression “foo” (which may be a regular expression).
Another way of using grep is to have it accept data through STDIN
and filter to STDOUT. For example,
shell> ls
|grep blah
lists all files in the current directory containing the string “blah”
Some common option:
| -v - invert (print all lines except those that contain the pattern). -i - ignore case -l - (list) - -s - suppress error -c - print only a count of the lines that contain -n - precede each line by its line number in -h - prevents the name of the file containing the -w - search for the expression as a word as |
ssh port forward - quick howto syntax it
No commentsscenario 1 : attach remote private host on localhost and localport
/localhost -> sshserver -> sshserverlocalnet_host/
ssh user@sshserver -L 1180:sshserverlocalnet_host:80
The sshserverlocalnet_host, port 80 will be attached on localhost and localport 1180