노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


60초안에 리눅스 성능 분석하기


리눅스 서버에 성능 문제로 접속을 한다면, 최초 1분안에 어떤 부분을 체크 하나요?

You login to a Linux server with a performance issue: what do you check in the first minute?


시스템 리소스 사용량의 정도와 실행중인 프로그램을 아래 10개의 명령어를 통해서 정보를 얻을 수  있다.

uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top


1. uptime

$ uptime
 23:51:26 up 21:31,  1 user,  load average: 30.02, 26.43, 19.02

This is a quick way to view the load averages, which indicate the number of tasks (processes) wanting to run.


2. dmesg | tail

$ dmesg | tail
[1880957.563150] perl invoked oom-killer: gfp_mask=0x280da, order=0, oom_score_adj=0
[...]
[1880957.563400] Out of memory: Kill process 18694 (perl) score 246 or sacrifice child
[1880957.563408] Killed process 18694 (perl) total-vm:1972392kB, anon-rss:1953348kB, file-rss:0kB
[2320864.954447] TCP: Possible SYN flooding on port 7001. Dropping request.  Check SNMP counters.

This views the last 10 system messages, if there are any.

3. vmstat 1

$ vmstat 1
procs ---------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
34  0    0 200889792  73708 591828    0    0     0     5    6   10 96  1  3  0  0
32  0    0 200889920  73708 591860    0    0     0   592 13284 4282 98  1  1  0  0
32  0    0 200890112  73708 591860    0    0     0     0 9501 2154 99  1  0  0  0
32  0    0 200889568  73712 591856    0    0     0    48 11900 2459 99  0  0  0  0
32  0    0 200890208  73712 591860    0    0     0     0 15898 4840 98  1  1  0  0
^C

Short for virtual memory stat, vmstat(8) is a commonly available tool (first created for BSD decades ago).

4. mpstat -P ALL 1

$ mpstat -P ALL 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015  _x86_64_ (32 CPU)

07:38:49 PM  CPU   %usr  %nice   %sys %iowait   %irq  %soft  %steal  %guest  %gnice  %idle
07:38:50 PM  all  98.47   0.00   0.75    0.00   0.00   0.00    0.00    0.00    0.00   0.78
07:38:50 PM    0  96.04   0.00   2.97    0.00   0.00   0.00    0.00    0.00    0.00   0.99
07:38:50 PM    1  97.00   0.00   1.00    0.00   0.00   0.00    0.00    0.00    0.00   2.00
07:38:50 PM    2  98.00   0.00   1.00    0.00   0.00   0.00    0.00    0.00    0.00   1.00
07:38:50 PM    3  96.97   0.00   0.00    0.00   0.00   0.00    0.00    0.00    0.00   3.03
[...]

This command prints CPU time breakdowns per CPU, which can be used to check for an imbalance.

5. pidstat 1

$ pidstat 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015    _x86_64_    (32 CPU)

07:41:02 PM   UID       PID    %usr %system  %guest    %CPU   CPU  Command
07:41:03 PM     0         9    0.00    0.94    0.00    0.94     1  rcuos/0
07:41:03 PM     0      4214    5.66    5.66    0.00   11.32    15  mesos-slave
07:41:03 PM     0      4354    0.94    0.94    0.00    1.89     8  java
07:41:03 PM     0      6521 1596.23    1.89    0.00 1598.11    27  java
07:41:03 PM     0      6564 1571.70    7.55    0.00 1579.25    28  java
07:41:03 PM 60004     60154    0.94    4.72    0.00    5.66     9  pidstat

07:41:03 PM   UID       PID    %usr %system  %guest    %CPU   CPU  Command
07:41:04 PM     0      4214    6.00    2.00    0.00    8.00    15  mesos-slave
07:41:04 PM     0      6521 1590.00    1.00    0.00 1591.00    27  java
07:41:04 PM     0      6564 1573.00   10.00    0.00 1583.00    28  java
07:41:04 PM   108      6718    1.00    0.00    0.00    1.00     0  snmp-pass
07:41:04 PM 60004     60154    1.00    4.00    0.00    5.00     9  pidstat
^C

Pidstat is a little like top’s per-process summary, but prints a rolling summary instead of clearing the screen.


6. iostat -xz 1

$ iostat -xz 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015  _x86_64_ (32 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          73.96    0.00    3.73    0.03    0.06   22.21

Device:   rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
xvda        0.00     0.23    0.21    0.18     4.52     2.08    34.37     0.00    9.98   13.80    5.42   2.44   0.09
xvdb        0.01     0.00    1.02    8.94   127.97   598.53   145.79     0.00    0.43    1.78    0.28   0.25   0.25
xvdc        0.01     0.00    1.02    8.86   127.79   595.94   146.50     0.00    0.45    1.82    0.30   0.27   0.26
dm-0        0.00     0.00    0.69    2.32    10.47    31.69    28.01     0.01    3.23    0.71    3.98   0.13   0.04
dm-1        0.00     0.00    0.00    0.94     0.01     3.78     8.00     0.33  345.84    0.04  346.81   0.01   0.00
dm-2        0.00     0.00    0.09    0.07     1.35     0.36    22.50     0.00    2.55    0.23    5.62   1.78   0.03
[...]
^C

This is a great tool for understanding block devices (disks), both the workload applied and the resulting performance.

7. free -m

$ free -m
             total       used       free     shared    buffers     cached
Mem:        245998      24545     221453         83         59        541
-/+ buffers/cache:      23944     222053
Swap:            0          0          0

The right two columns show:

  • buffers: For the buffer cache, used for block device I/O.
  • cached: For the page cache, used by file systems.

8. sar -n DEV 1

$ sar -n DEV 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015     _x86_64_    (32 CPU)

12:16:48 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
12:16:49 AM      eth0  18763.00   5032.00  20686.42    478.30      0.00      0.00      0.00      0.00
12:16:49 AM        lo     14.00     14.00      1.36      1.36      0.00      0.00      0.00      0.00
12:16:49 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

12:16:49 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
12:16:50 AM      eth0  19763.00   5101.00  21999.10    482.56      0.00      0.00      0.00      0.00
12:16:50 AM        lo     20.00     20.00      3.25      3.25      0.00      0.00      0.00      0.00
12:16:50 AM   docker0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
^C
Use this tool to check network interface throughput: rxkB/s and txkB/s, as a measure of workload, and also to check if any limit has been reached.

9. sar -n TCP,ETCP 1

$ sar -n TCP,ETCP 1
Linux 3.13.0-49-generic (titanclusters-xxxxx)  07/14/2015    _x86_64_    (32 CPU)

12:17:19 AM  active/s passive/s    iseg/s    oseg/s
12:17:20 AM      1.00      0.00  10233.00  18846.00

12:17:19 AM  atmptf/s  estres/s retrans/s isegerr/s   orsts/s
12:17:20 AM      0.00      0.00      0.00      0.00      0.00

12:17:20 AM  active/s passive/s    iseg/s    oseg/s
12:17:21 AM      1.00      0.00   8359.00   6039.00

12:17:20 AM  atmptf/s  estres/s retrans/s isegerr/s   orsts/s
12:17:21 AM      0.00      0.00      0.00      0.00      0.00
^C
This is a summarized view of some key TCP metrics. These include:
  • active/s: Number of locally-initiated TCP connections per second (e.g., via connect()).
  • passive/s: Number of remotely-initiated TCP connections per second (e.g., via accept()).
  • retrans/s: Number of TCP retransmits per second.
 

10. top

$ top
top - 00:15:40 up 21:56,  1 user,  load average: 31.09, 29.87, 29.92
Tasks: 871 total,   1 running, 868 sleeping,   0 stopped,   2 zombie
%Cpu(s): 96.8 us,  0.4 sy,  0.0 ni,  2.7 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:  25190241+total, 24921688 used, 22698073+free,    60448 buffers
KiB Swap:        0 total,        0 used,        0 free.   554208 cached Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 20248 root      20   0  0.227t 0.012t  18748 S  3090  5.2  29812:58 java
  4213 root      20   0 2722544  64640  44232 S  23.5  0.0 233:35.37 mesos-slave
 66128 titancl+  20   0   24344   2332   1172 R   1.0  0.0   0:00.07 top
  5235 root      20   0 38.227g 547004  49996 S   0.7  0.2   2:02.74 java
  4299 root      20   0 20.015g 2.682g  16836 S   0.3  1.1  33:14.42 java
     1 root      20   0   33620   2920   1496 S   0.0  0.0   0:03.82 init
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd
     3 root      20   0       0      0      0 S   0.0  0.0   0:05.35 ksoftirqd/0
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
     6 root      20   0       0      0      0 S   0.0  0.0   0:06.94 kworker/u256:0
     8 root      20   0       0      0      0 S   0.0  0.0   2:38.05 rcu_sched

The top command includes many of the metrics we checked earlier. It can be handy to run it to see if anything looks wildly different from the earlier commands, which would indicate that load is variable.


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

 

톰캣 버전과 지원가능한 서블릿 버전 목록

Servlet

JSP Spec

Tomcat

Min. Java

3.0

2.2

7.0.x

1.6

2.5

2.1

6.0.x

1.5

2.4

2

5.5.x

1.4

2.3

1.2

4.1.x

1.3

2.2

1.1

3.3.x

1.1


http://help.eclipse.org/kepler/index.jsp


* Web application overview

The Web development environment provides the tools you need to develop Web applications as defined in the Sun Microsystems Java™ Servlet 2.3 Specification and the Sun Microsystems JSP 1.2 Specification. Web applications can be simple (consisting of only static Web pages) or they can be more advanced and include JavaServer Pages (JSP) files and Java servlets.

웹 개발 환경은 Sun Microsystems Java ™ Servlet 2.3 사양 및 Sun Microsystems JSP 1.2 사양에 정의 된대로 웹 응용 프로그램을 개발하는 데 필요한 도구를 제공 합니다. 웹 응용 프로그램은 단순한 웹 페이지 (정적 웹 페이지만으로 구성 될 수 있음) 또는 Java 웹 페이지 (JavaServer Pages) 파일 및 Java 서블릿을 포함하는 고급 기능을 제공 할 수 있습니다.


* Web projects

Web projects hold all of the Web resources that are created and used when developing your Web application. The first step to creating or importing a Web application is to create either a static or a dynamic Web project. Static Web projects are meant to contain only simple Web site resources, such as HTML files. Dynamic Web projects are used to structure Web applications that will use more complicated, dynamic Web technologies, such as JavaServer Pages files, and possibly data access resources.

웹 프로젝트는 웹 응용 프로그램을 개발할 때 만들어지고 사용되는 모든 웹 자원을 보유합니다. 웹 응용 프로그램을 만들거나 가져 오는 첫 번째 단계는 정적 또는 동적 웹 프로젝트를 만드는 것입니다. 정적 웹 프로젝트에는 HTML 파일과 같은 간단한 웹 사이트 리소스 만 포함됩니다. 동적 웹 프로젝트는 JavaServer Pages 파일 및 데이터 액세스 리소스와 같이보다 복잡하고 동적 인 웹 기술을 사용하는 웹 응용 프로그램을 구조화하는 데 사용됩니다.


* Dynamic Web projects and applications

There are two types of Web projects: dynamic and static. Dynamic web projects can contain dynamic Java EE resources such as servlets, JSP files, filters, and associated metadata, in addition to static resources such as images and HTML files. Static web projects only contains static resources. When you create Web projects, you can include cascading style sheets and JSP tag libraries (for dynamic Web projects), so that you can begin development with a richer set of project resources.

웹 프로젝트에는 동적 및 정적의 두 가지 유형이 있습니다. 동적 웹 프로젝트에는 이미지 및 HTML 파일과 같은 정적 리소스 이외에 서블릿, JSP 파일, 필터 및 관련 메타 데이터와 같은 동적 Java EE 리소스가 포함될 수 있습니다. 정적 웹 프로젝트에는 정적 리소스 만 포함됩니다. 웹 프로젝트를 생성 할 때 동적 웹 프로젝트를위한 CSS 스타일 라이브러리와 CSS 태그 라이브러리를 포함 할 수 있으므로 더 많은 프로젝트 리소스 세트로 개발을 시작할 수 있습니다.

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

Bootstrap 시작 하기


1. 학습 사이트 

http://www.w3schools.com/bootstrap/default.asp 

전체 항목을 배워야 하지만, 너무 많아서 어디서 부터 시작을 해야 할지 모를것 같다.

 


 
2. 동영상 학습  

https://www.youtube.com/watch?v=sTi_hcaBmsg  , 강좌 1. Bootstap Basic

 "웹학교"에서 YouTube를 통해서 w3school.com 사이트를 활용한 강의
사용되는 사이트가 2014년9월(3.2.2)이라 현재 버젼(3.3.5)과는 차이가 있지만 이해 가능


 
3. Bootstrap를 적용한 Theme 학습 - BS Theme "Company"


해당 테마를 하나씩 따라하면, 간단한 회사 홈페이지를 구현하게 되고, 이해가 쉬워진다.


사이트 : http://www.w3schools.com/bootstrap/bootstrap_theme_company.asp



* Bootstrap 사용시 포함할 부분



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.
Log4j 사용하기 ( in MVC controller )  

1. Log4j Library 프로젝트에 추가하기

1) Log4j-1.x.x.jar를 libray에 복사

2) Maven을 사용해서 자동 다운로드 ,  pom.xml
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>
2. log4j.properties구성
 # LOG4J configuration
log4j.rootLogger=INFO, console, file

# Console Logger
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%p] %d %c %x - %m%n

# File Logger
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/oes
log4j.appender.file.DatePattern='-'yyyy-MM-dd'.log'
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%p] %d %c %x - %m%n
  3. 호출(사용법)
// Controller
public class AAAController 
{
    private Logger logger = Logger.getLogger(AAAController.class);
    public loginAction()
    {
        logger.info( String.format("name[%s]",new Object[] {name} );
    }
}
출처 :  http://zjhzxhz.com/2014/06/integrate-spring-mvc-with-log4j/


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



Workingset를 Eclipse에 추가 하기


1. eclipse설정를 통해서

1) workspace
2) Open Perspective, Show View
3) Project Explorer부분에  Package Explorer를 추가 하기


참조 : http://sessionk.tistory.com/16



2. WorkingSet 추가하는 과정

0. Show View - Package Explorer


1) Package Explorer에서 Top Level Element를 Working Sets로 변경


2) Configure Working Sets로 추가 하기

참조 : http://whiteship.tistory.com/1441


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

CentOS에 MongoDB 64bit 설치하기


1.CentOS에 MongoDB 64bit 설치하기 



1) 저장소 추가
	$ vi /etc/yum.repos.d/mongodb.repo
	[mongodb]
	name=MongoDB Repository
	baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
	gpgcheck=0
	enabled=1
2) yum으로 설치
	$ yum -y install mongodb-org

3) yum -update로 몽고디비가 업데이트되는 것을 방지
	$ vi /etc/yum.conf
	exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

4) 실행시키기
	$ service mongod start
	$ service mongod restart
	$ service mongod stop
 
	# 부팅시 자동으로 실행하려면
	$ chkconfig mongod on
5) 방화벽 오픈
	$ iptables -I INPUT 1 -p tcp --dport 27017 -j ACCEPT
	$ service iptables save
	$ service iptables restart

2.Install MongoDB on Red Hat Enterprise or CentOS Linux


'DBMS, noSQL > mongoDB' 카테고리의 다른 글

Java Code for mongoDB Query  (0) 2018.10.30
Robo 3T(Robomongo) 폰트 변경  (0) 2018.10.24
사용자 계정 관리  (0) 2017.02.07
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.
사용자 계정 관리

몽고DB를 시동하고 나서 가장 먼저 해야 할 일은 데이터베이스에 접근할 수 있도록 사용자를 추가하는 것이다.


1) 계정 생성
	use test
	db.createUser( {use: "testUser", pwd: "test", 
	roles: ["readWrite", "dbAdmin"] } )
2) 계정 삭제
	use test
	db.dropUser("testUser")
3) 계정 목록
	use admin
	show users

* 사용자 계정은 각 데이터베이스의 db.system.users 컬렉션에 저장된다.
* User 객체는 id, user, pwd, roles등을 갖는다.



'DBMS, noSQL > mongoDB' 카테고리의 다른 글

Java Code for mongoDB Query  (0) 2018.10.30
Robo 3T(Robomongo) 폰트 변경  (0) 2018.10.24
CentOS에 MongoDB 64bit 설치하기  (0) 2017.02.07
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


How To Install Node.js on a CentOS 7 server


-node.js를 centos 7에 설치하는 방법


Introduction/소개

Node.js is a Javascript platform for server-side programming. It allows users to easily create networked applications that
require backend functionality. 
By using Javascript as both the client and server language, development can be fast and consistent.

Node.js는 서버쪽 프로그래밍을 위한 자바스크립트 플랫폼이다. 이것을 개발자에게 백엔드
기능을 갖춘 네트웍 처리를 하는 어플리케이션을 만들기 쉽게 해준다.
클라이언트와 서버 언어 양쪽을 자바스크립트를 사용하는 것은 개발은 빠르고 일관성있게 해 준다.

In this guide, we will show you a few different ways of getting Node.js installed on a CentOS 7 server so that you can get started.
Most users will want to use the EPEL installation instructions or the NVM installation steps.

이 가이드에서는, CentOS 7 서버에  Node.js를 얻는 몇가지 방안을 보여주고 시작할 수 있게 해 줄 것이다.
대부분의 사용자는 EPEL 설치 방식과 NVM 설치 절차를 사용하는 것을 원할 것 같다.

1. Install Node from Source / 소스를 통한 설치

 One way of acquiring Node.js is to obtain the source code and compile it yourself.
 To do so, you should grab the source code from the project's website. On the downloads page,
 right click on the "Source Code" link and click "Copy link address" or whatever similar option your browser gives you.


 >wget http://nodejs.org/dist/v0.10.30/node-v0.10.30.tar.gz
 >tar xzvf node-v* && cd node-v*
 >sudo yum install gcc gcc-c++
 >./configure
 >make
 >sudo make install
 >node --version

2. Install a Package from the Node Site / 패키지를 통한 설치
 Another option for installing Node.js on your server is to simply get the pre-built packages
 from the Node.js website and install them.

 cd ~  wget http://nodejs.org/dist/v0.10.30/node-v0.10.30-linux-x64.tar.gz

3. Install Node from the EPEL Repository/ EPEL저장소를 통한 설치
 

An alternative installation method uses the EPEL (Extra Packages for Enterprise Linux) repository
 that is available for CentOS and related distributions.

 >sudo yum install epel-release
 >sudo yum install nodejs
 >node --version
 v0.10.30

4. Install Node Using the Node Version Manager / NVM을 통한 설치
 

Another way of installing Node.js that is particularly flexible is through NVM, the Node version manager.
 This piece of software allows you to install and maintain many different independent versions of Node.js,
 and their associated Node packages, at the same time.

 >curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh
 >curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
 >nvm list-remote


Conclusion / 결론


 As you can see, there are quite a few different ways of getting Node.js up and running on your CentOS 7 server.
 ~

원문 : https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server

'Application, App > Node.js' 카테고리의 다른 글

Node.JS 웹 채팅 (간단한 예제)  (0) 2017.02.07
(1) 소개 - Node.js  (0) 2016.05.20
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Java,  Ip Address 가져오기


- 다중 Network Interface를 갖고 있는 경우에 생기는  문제 


1. 일반적인 접근

  InetAddress ip;
  String hostname;
  String ipString ;
  
  ip = InetAddress.getLocalHost();
  hostname = ip.getHostName();
  ipString = ip.toString();

 System.out.println("is contain?  " + ipString.contains("192.168.") );


2. 다중 Network Interface 찾기

public class GetIpAddress {

    public static void main(String args[]) throws SocketException  {

    	System.out.println( "isSame = " + isSame("192.168.0.13") ); 
    	
    }

    static boolean isSame(String checkIp) throws SocketException {
    	
    	String interfaceIp=null;

    	// NetworkInterface.getNetoworkInterfaces()
        Enumeration nets = NetworkInterface.getNetworkInterfaces();
        
        for (NetworkInterface netint : Collections.list(nets)) {
            interfaceIp = displayInterfaceInformation(netint);
            if ( interfaceIp != null ) {
            	if( interfaceIp.contains(checkIp) )
            		return true;
            }
        }
        return false;
    }

    // NetworkInterface : getDisplayName(), getInetAddresses()
    static String displayInterfaceInformation(NetworkInterface netint) throws SocketException {

    	System.out.printf("Display name: %s \n", netint.getDisplayName());
    	//System.out.printf("Name: %s\n", netint.getName());

        Enumeration inetAddresses = netint.getInetAddresses();
        for (InetAddress inetAddress : Collections.list(inetAddresses)) {
        	
        	// only ipv4
        	if ( inetAddress instanceof Inet4Address ) {
        		System.out.printf("InetAddress: %s\n", inetAddress);
        		return inetAddress.toString();
        	}
        }
        return null;
     }

}


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Node.JS 웹 채팅 (간단한 예제)


소스 구성 : app.js ( package.json) , index.html ( java script )



1. package.json

{
  "_comment" : "0. setup package",
  "name":"chat",
  "version" : "0.0.1",
  "private": "true",
  "dependencies" : {
    "socket.io" : "1.4.2",
    "express" : "4.13.4"
  }
}


2.app.js

- require

// SOCKET.IO Setup
var app = require('express')();
var http = require('http').createServer(app);
var io = require('socket.io')(http); //initialise after http server

- listen

// http.listen
http.listen(3000, function(err) {
    if ( err ) {
        console.log(err);
    } else {
        console.log('listening on *: 3000')
    }
} );

- get / send index.html

// app.get
app.get('/', function(req, res) {
    // index.html
    res.sendFile(__dirname + '/index.html');

});

3. edit index.html

<head>
    <!-- 4. definition form -->
    <style>
        #div-chat-display {
            height:350px;
            width:500px;
            overflow-x: hidden;
            overflow-y: auto;
        }
    </style>
</head> 
<body> 
    <!-- 4. definition form -->
    <h3>Just simple your webChat ( v 0.0.1,  @stanwix , 21-Apr-2016 ) </h3>
    <div id="container-id">
        <form id="form-input-userid">
            your ID :  <input size="15" id="input-userid"/>
            <input type="submit" value="Join"/>
        </form>
    </div>
    <div id="container-message" style="display: none;">
        <div id="div-chat-display"></div>
        <form id="form-send-message">
            <input size="35" id="input-message"/>
            <input type="submit" value="Send"/>
        </form>
    </div>
</body> 

4. include javascript

   <!-- 5. setup js script -->
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>

5. javascript for message handle

아래 소스를 참조


소스

https://github.com/sketchout/NodeJs_SocketIO_PartOne


'Application, App > Node.js' 카테고리의 다른 글

Node.js를 CentOS에 설치하는 방법들  (0) 2017.02.07
(1) 소개 - Node.js  (0) 2016.05.20
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Windows10, Windows Defender(윈도우 디펜더) 다시 사용하기


- 그룹 정책에 의해 사용이 중지된 경우가 발생시



- 로컬 그룹 정책 편집기 열기
Win + R 
열기(O):  gpedit.msc 

- 수정 위치

: 컴퓨터 구성 -> 관리템플릿 -> Window 구성 요소 -> Windows Defender


- Windows Defender 끄기 -> 사용 안 함


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


awk print



':'를 구분자로 첫번째 파일명을 출력

$ file * | grep HTML | grep -v jpg | awk -F: '{print $1}'



print문장에 명령어를 추가하고 shell로 저장

$ file * | grep HTML | grep -v jpg | awk -F: '{print "mv " $1 " " $1".old" }' > a.sh



참조 : http://www.commandlinefu.com/commands/view/1138/ps-ef-grep-process-grep-v-grep-awk-print-2-xargs-kill-9


$ ps -ef | grep PROCESS | grep -v grep | awk '{system "kill -9" $2}


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Upload Fake Image(가짜 이미지, 피싱스크립트) 의 검증


단순히 업로드 파일의 확장자로 구분되지 않는 phishing(피싱)파일을 제거하기 위해서 사용 가능


수천가지 다른 종류의 file type으로 부터 문자열,메타정보와 종류를 판별하는 프로젝트

https://tika.apache.org/ , a content analysis toolkit.

tika-app1.14.jar Library를 다운로드 ( https://tika.apache.org/download.html )


예제 소스

import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.tika.Tika; public class TestMain { public static void main(String[] args) throws Exception { //File f = new File("fakeTest.png"); // text/html //File f = new File("jpgTest.jpg"); // image/jpeg File f = new File("pngTest.png"); // image/png //File f = new File("gifTest.gif"); // image/gif System.out.println( f.toString()); System.out.println( f.getAbsolutePath() ); String allowFileExt = "image/jpg;image/jpeg;image/png;image/gif;"; if ( f.isFile() ) { Tika tika = new Tika(); try { String detectedType = tika.detect( new FileInputStream(f) ); System.out.println("Type : " + detectedType ); if (allowFileExt.indexOf(detectedType) == -1) { throw new Exception("Use only Type : JPG, JPEG, PNG, GIF"); } } catch (IOException e) { e.printStackTrace(); } } else { System.out.println("-not-" ); } } }




'Web Tech. > Spring Framework' 카테고리의 다른 글

Java,  Ip Address 가져오기  (0) 2017.02.07
awk print  (0) 2017.02.01
2개의 war 비교하기  (0) 2017.01.25
2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술  (0) 2017.01.24
HMAC SHA-256 이해  (0) 2017.01.24
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


fanli90.cn으로 크롬 브라우저 URL이 변경 되었을때


- Adware/Malware(멀웨어)백신으로 치료가 되지 않을떄



1. 원인 및 증상


- 웹 사이트에서 프로그램을 다운로드후 설치 / 동시에 많은 프로그램이 설치되면서 브라우저 초기 URL이 변경됨


-- 응급 조치

-- 윈도우 제어판에서 당일 설치된 프로그램을 모두 Uninstall

-- 새로 실행된 프로세스를 PID값이 큰것부터 모두 Kill



- 계속 브라우저의 초기 URL이 fanli90.cn등 으로 변경됨

- 설정에서 초기화를 해도 지워지지 않음



- 백신 프로그램도 치료가 되지 않음 ( ???? )




2. 2차 조치를 위해 구글 검색 :  fanli90 cn url adware


다양한 방법 제시 : Remove the Fanli90.cn Browser Hijacker(Removal Guide)





* 방법중에서 추천하는 것은 : https://toolslib.net/ , AdwCleaner

- Adw Cleaner 무료 제거 툴 사용하기


- AdWare ( Ads Software )
- PUP/LPI ( Potentially Undesirable Program )
- Toolbars
- Hijacker ( Hijack of the browser homepage )



* 윈도우 reboot후에 제거 여부를 추가로 확인하였으나 초기 URL이 변경 되면서, 아래와 같이 바탕 화면 icon이 오염됨


"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"  --load-extension="C:\Users\admin\AppData\Local\kemgadeojglibflomicgnfeopkdfflnk" http://fanli90.cn/

- 단순하게 붉은색 부분을 삭제해야 함, reboot후에 다시 오염됨


 - Adw Cleaner에서 확인되는 Fake Link


* 그리고 또 추천하는 것은 : WMI 직접 제거하기

 - WMI에 root\subscription ( ActiveScriptEventConsumer.Name="ASEC")이 계속 남는 경우에 아래 방법 사용

-- WMI Explorer를 사용해서 실제 악성코드 VBScript확인후에


-- 관리자로 WBEMTest를 실행하고.


-- 인스턴스/클래스를 찾고


-- 삭제한다


-- 그리고 감염된 Shortcut Cleaner를 삭제한다.

다운로드 : https://www.bleepingcomputer.com/download/shortcut-cleaner/



-- WMI 삭제 관련 글


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.



프로그래밍 R언어, 통합 개발 환경 설치

- OS : Windows 10


1. R 설치

- R Project for Statistical Computing ( r-project.org )

- Korea

-- http://cran.nexr.com/ 

-- http://healthstat.snu.ac.kr/CRAN/

-- http://cran.biodisk.org/

- 설치후 바탕화면의 RGui실행


2. R studio 설치

- R Studio ( rstudio.com )

- Download Free , https://www.rstudio.com/products/rstudio/download/

- 실행 화면

- File -> New File : Script.R (Save)


3. R언어 강좌 ( 따라하기 )

- Free Course , https://www.datacamp.com/courses/free-introduction-to-r


- Intro to basics

> # An addition
> 5 + 5
[1] 10


> # Assign the value 42 to x
> x <- 42
> 
> # Print out the value of the variable x
> x
[1] 42


> # Declare variables of different types
> my_numeric <- 42
>
> # Check class of my_numeric
> class(my_numeric)
[1] "numeric"


-Vectors

# create a vector with the combine function c()
> numeric_vector <- c(1, 10, 49)
> 
> numeric_vector
[1]  1 10 49


> # Roulette winnings from Monday to Friday
> roulette_vector <- c(-24, -50, 100, -350, 10)
> 
> poker_vector
[1]  140  -50   20 -120  240
>
> # Assign days as names of poker_vector
> names(poker_vector) <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
> 
> poker_vector
   Monday   Tuesday Wednesday  Thursday    Friday 
      140       -50        20      -120       240


> A_vector <- c(1, 2, 3)
> B_vector <- c(4, 5, 6)
> 
> # Take the sum of A_vector and B_vector
> total_vector <- A_vector + B_vector
> 
> # Print out total_vector
> total_vector
[1] 5 7 9
> 
> # Total of A_vector
> total <- sum(A_vector)
> total
[1] 6
> 
> # Define a new variable based on a selection
> selection_vector <- B_vector[c(1:2)]
> selection_vector
[1] 4 5
> 
> # Calculate the average
> mean(A_vector)
[1] 2


-Matrics

> # Construct a matrix with 3 rows that contain the numbers 1 up to 9
> matrix(1:9, byrow=TRUE, nrow=3)
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9


> # Box office Star Wars (in millions!)
> new_hope <- c(460.998, 314.4)
> empire_strikes <- c(290.475, 247.900)
> return_jedi <- c(309.306, 165.8)
> 
> # Create box_office
> box_office <- c( new_hope, empire_strikes, return_jedi )
> 
> # Construct star_wars_matrix
> star_wars_matrix <- matrix( box_office, byrow=TRUE, nrow =3)
> # Box office Star Wars (in millions!)
> new_hope <- c(460.998, 314.4)
> empire_strikes <- c(290.475, 247.900)
> return_jedi <- c(309.306, 165.8)
> 
> # Create box_office
> box_office <- c( new_hope, empire_strikes, return_jedi )
> 
> # Construct star_wars_matrix
> star_wars_matrix <- matrix( box_office, byrow=TRUE, nrow =3)
> star_wars_matrix
        [,1]  [,2]
[1,] 460.998 314.4
[2,] 290.475 247.9
[3,] 309.306 165.8


> # Box office Star Wars (in millions!)
> new_hope <- c(460.998, 314.4)
> empire_strikes <- c(290.475, 247.900)
> return_jedi <- c(309.306, 165.8)
> 
> # Construct matrix
> star_wars_matrix <- matrix(c(new_hope, empire_strikes, return_jedi), nrow = 3, byrow = TRUE)
> star_wars_matrix
        [,1]  [,2]
[1,] 460.998 314.4
[2,] 290.475 247.9
[3,] 309.306 165.8
> 
> # Vectors region and titles, used for naming
> region <- c("US", "non-US")
> titles <- c("A New Hope", "The Empire Strikes Back", "Return of the Jedi")
> 
> # Name the columns with region
> colnames(star_wars_matrix) <- region
> star_wars_matrix
          US non-US
[1,] 460.998  314.4
[2,] 290.475  247.9
[3,] 309.306  165.8
> 
> # Name the rows with titles
> rownames(star_wars_matrix) <- titles
> 
> # Print out star_wars_matrix
> star_wars_matrix
                             US non-US
A New Hope              460.998  314.4
The Empire Strikes Back 290.475  247.9
Return of the Jedi      309.306  165.8





* R언어 사용 사례
- 16개월 간의 몸무게 변화 그래프,  http://printhelloworld.tistory.com/88



* 참조




블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,