라즈베리파이 led

arduino_2020. 5. 18. 22:30
from RPi import GPIO
import time


class LED():
    
    def __init__(self):
        
        GPIO.setmode(GPIO.BOARD) 
        self.ledRed = 11

    def pinSetup(self):
        
        GPIO.setup(self.ledRed, GPIO.OUT, initial=GPIO.LOW)
    
    def pinOn(self):
        
        try:

            while True:
                
                try:
                    # ===================
                    # led on !!
                    # ===================
                    GPIO.output (self.ledRed, GPIO.HIGH)
                except:
                    print("led on error !!")
                    beak
                else:
                    time.sleep(0.5)
                    print("redPing on!!")
                
                try:
                    # ===================
                    # led off !!
                    # ===================
                    GPIO.output (self.ledRed, GPIO.LOW)
                except:
                    print("led off error !!")
                    break
                else:
                    time.sleep(0.5)
                    print("redPing off!!")

        except KeyboardInterrupt as e:
            print(e)
            pass 
        
        GPIO.cleanup()

        print("cleanup !!")


############################
# program main function
# writer : JunHyeon.kim
############################
if __name__ == "__main__":
    
    o = LED()
    o.pinSetup()
    o.pinOn()

'arduino_' 카테고리의 다른 글

라즈베리파이 온도습도 센서  (0) 2020.05.18
four led ver2  (0) 2017.10.10
LED _VER2 FOUR  (0) 2017.10.10
four led  (0) 2017.10.10
sds011 - 먼지 센서  (0) 2017.09.21

$ ./logstash-plugin install logstash-input-elasticsearch
Validating logstash-input-elasticsearch
Installing logstash-input-elasticsearch
Installation successful


input {
    elasticsearch {
        hosts   => ["http://x.x.x.x:9200"]
        index   => "number_"
        query   => '{"query": {"match_all": {}}}'
        docinfo => true
    }
}

filter {
    mutate {
        remove_field => ["@version", "@timestamp"]
    }
}

output {
    file {
        path => "/home/kim/Desktop/elastic/l-762/conf/result.json"
        codec => "json_lines"
    }
}

'ELK > logstash' 카테고리의 다른 글

logstash eve_odd  (0) 2020.06.17
logstash file json absolute path  (0) 2020.06.17
logstash plugin install  (0) 2020.04.15
logstash + app-search  (0) 2019.12.10
logstash + python  (0) 2019.01.12

 

셋팅 관련 자료가 너무 없어서 혼자서 삽질하면서 익힌게 생각이 난다. 누군가에게 도움이 되었으면 한다.

( 물리서버가 1대인 경우 사실 이와 같은 환경은 위험이 따른다. 만약 물리서버가 죽게되면 cluster를 잃게 된다. )

 

물리서버 : ubuntu 20/04

작업 전 port 개방 ( root 사용자로 작업할 것 )

- centos

firewall-cmd --zone=public --permanent --add-port=9200/tcp
firewall-cmd --zone=public --permanent --add-port=9300/tcp
firewall-cmd --zone=public --permanent --add-port=5601/tcp

firewall-cmd --reload

- ubuntu 

ufw allow 9200
ufw allow 9300
ufw allow 5601

 

elasticsearch 디렉토리 구조

 

node-1

 

node-2
node-3

 

서비스가 정상적으로 올라 왔는지 확인

방법1) $ ps -ef | grep elasticsearch

방법2) $ jps
4629 Elasticsearch
4935 Elasticsearch
7419 Jps
5087 Elasticsearch

[ 단 jps 명령어 사용시에는 openjdk 설치가 반드시 필요하다 ]

 

방법3) $ curl -XGET http://localhost:9200/_cluster/health?pretty

 

kibana 설정

 

브라우저에서 

: http://xxx.xxx.xxx.xxx:5601로 접근 시도한다.

'ELK > elasticsearch' 카테고리의 다른 글

elasticsearch match-query  (0) 2020.12.23
elasticsearch term query  (0) 2020.12.22
elasticsearch index mapping 에 관한 생각  (0) 2020.04.17
logstash ruby syntax  (0) 2020.04.14
logstash file stdin  (0) 2020.04.14