resize2fs를 이용한 파티션 리사이징
가상화를 쓰다보면.. 처음부터 디스크 용량을 크게 잡기도 부답스럽고 해서 적게 잡는다.
운영하다보면.. 필연적으로 용량을 늘려줘야 하는 경우가 생김.. 이럴 경우 사이즈 resize2fs를 통해서 리사이징 할수 있음
[root@netggio.pe.kr ~]# fdisk /dev/xvdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p Disk /dev/xvdb: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x75a9f100 Device Boot Start End Blocks Id System /dev/xvdb1 1 13054 104856223+ 83 Linux Command (m for help): d Selected partition 1 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-13054, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): Using default value 13054 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@netggio.pe.kr ~]# e2fsck -f /dev/xvdb1 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/xvdb1: 3120/5242880 files (8.7% non-contiguous), 670969/20970841 blocks [root@netggio.pe.kr ~]# resize2fs /dev/xvdb1 resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/xvdb1 to 26214055 (4k) blocks. The filesystem on /dev/xvdb1 is now 26214055 blocks long.
파일 첨부하여 메일 전송 하기 – perl script
외부 SMTP서버를 이용하여 첨부 파일을 보낼수 있는 간단한 스크립트
#!/usr/bin/perl use Encode; use MIME::Lite; use Net::SMTP; use POSIX qw/strftime/; use Time::Format qw(%time %strftime %manip); # my $YESTERDAY=$time{'yyyy/mm/dd', time-24*60*60}; # 하루전 날짜 #첨부파일 경로 my $REPORT=glob "/home/data/*.xlsx"; #첨부파일 유무 체크 -> 파일경로에 파일이 없으면 발송 하지 않음 if (-f $REPORT) { #메일링 정보 my $from_address = '발신지 메일 주소'; my $to_address = '수신자 메일 주소'; # 구분은 콤마 my $mail_host = 'SMTP 서버주소'; my $subject = encode('MIME-Header',decode_utf8("$YESTERDAY - 테스트 메일")); # 메일 제목 my $message_body = "$YESTERDAY - 메시지 내용"; # 메시지 내용 my $msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; $msg->attach ( Type => 'TEXT', Data => $message_body ) or die "Error adding the text message part: $!\n"; $msg->attach ( Type => 'application/zip', Path => $REPORT, Disposition => 'attachment' ) or die "Error adding $REPORT: $!\n"; MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send; # 발송후 첨부된 파일 삭제 unlink $REPORT; } else { exit; }
ngrinder 에이전트 데몬으로 돌리기..
ngrinder이 보니.. 백그라운드 형식으로 밖에 돌리지를 못하는 형식으로 제공이 된다..
&붙여서 돌리면 되긴 하지만 살짝 아쉬운 경우라.. screen을 이용해서 아래와 같이 데몬 행태로 돌릴수 있다..
screen는 설치가 되어 있어야 한다..
#!/bin/bash # # ngrinder_agent Start up the ngrinder_agent daemon # # processname: ngrinder_agent ### BEGIN INIT INFO # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # This service starts up the ngrinder_agent server daemon. ### END INIT INFO DAEMON="ngrinder_agent" IDENT="ngrinder_agent" PREFIX="/home/ngrinder-core-3.2.3" RUNFILE="/var/run/ngrinder_agent.run" start() { [ -e ${RUNFILE} ] && stop touch $RUNFILE echo -n "starting $DAEMON" screen -d -m -S ${IDENT} ${PREFIX}/run_agent.sh & echo -n "." echo "" } stop() { echo "stopping $DAEMON" screen -list | grep \.${IDENT} | cut -d\. -f1 | xargs -r kill -9 screen -wipe > /dev/null 2>&1 rm -f ${RUNFILE} 2>/dev/null } case "$1" in start) start ;; stop) stop ;; status) chk=`screen -list | grep \.${IDENT} | awk '{print $1}' | wc -l` ppid=`screen -list | grep ngrinder_agent | awk '{print $0}' | awk -F\. '{print $1}'| xargs` if [ $chk == 1 ] then echo "$DAEMON is (pid $ppid) running.." exit 0 else echo "$DAEMON is not running.." exit 1 fi ;; restart)stop start ;; *) echo -n "usage:\n\t$0 (start|stop|status|restart)\n" exit 1 ;; esac exit 0
blog built using the cayman-theme by Jason Long. LICENSE