보통 여러 데몬을 한 번에 kill하려면, grep을 사용하면 쉽게 종료할 수 있다. 


$ ps -ef | grep python | grep -v grep |  awk '{print $2}' | xargs kill -9



grep을 쓰기가 좀 그러면, awk로 대안해서 사용할 수 있다. 


$ ps -ef | awk '/python/ && !/awk/ {print $2}' | xargs -r kill -9


Posted by '김용환'
,



내가 crontab을 생성할 때 자주 사용하는 템플릿이다. 


* * * * * cd /home/www && /home/www/send_java_info_to_influxdb.sh > /home/www/log/client.log 2>&1



먼저 디렉토리를 변경하고, 

&&

스크립트를 실행하고

>

로그를 잘 저장한다




Posted by '김용환'
,

tr 커맨드 팁

unix and linux 2016. 12. 28. 09:39



tr 커맨드는 표준 입력를 변환(translate) 한다.


aZ라는 파일이 다음처럼 존재한다.


$ cat aZ

abc DEF



보통 tr에서 정규표현식을 사용할 때는 따옴표(quote)를 써야 한다고 알려져 있다.



$ tr '[a-z]' '[A-Z]' < aZ

ABC DEF


$ tr "[a-z]" "[A-Z]" < aZ

ABC DEF


$ tr '[A-Z]' '[a-z]' < aZ

abc def


$ tr "[A-Z]" "[a-z]" < aZ

abc def



하지만, from이나 to 중 하나에만 따옴표를 써도 동작한다.

$ tr '[a-z]' [A-Z] < aZ
ABC DEF


소문자는 대문자로, 대문자는 소문자로 바꾸려면 다음과 같은 패턴을 사용한다. 

$ tr "[a-zA-Z]" "[A-Za-z]" < aZ
ABC def


Posted by '김용환'
,


unterminated substitute in regular expression 발생 시, 구분자 /를 맨 마지막에 사용했는지 확인한다. 


$ cat xx

1

2

jan -1




$ sed '/jan/s/1/5' xx

sed: 1: "/jan/s/1/5": unterminated substitute in regular expression




정규 표현식에 /를 사용하니 unterminated substitute in regular expression이 발생하지 않았다. 


$ sed '/jan/s/1/5/' xx

1

2

jan -5


Posted by '김용환'
,



쉘 스크립트에서는 here tag, here document에 설명되어 있다. 


여러 라인의 배시 커맨드를 간결하게 해준다고 보면 된다. 하지만 리터털이 아닌 표준입력으로 취급한다.




공식문서는 다음과 같다.


http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04


2.7.4 Here-Document

The redirection operators "<<" and "<<-" both allow redirection of subsequent lines read by the shell to the input of a command. The redirected lines are known as a "here-document".

The here-document shall be treated as a single word that begins after the next <newline> and continues until there is a line containing only the delimiter and a <newline>, with no <blank> characters in between. Then the next here-document starts, if there is one. The format is as follows:

[n]<<word
    here-document
delimiter

where the optional n represents the file descriptor number. If the number is omitted, the here-document refers to standard input (file descriptor 0). It is unspecified whether the file descriptor is opened as a regular file, a special file, or a pipe. Portable applications cannot rely on the file descriptor being seekable (see XSH lseek).

If any part of word is quoted, the delimiter shall be formed by performing quote removal on word, and the here-document lines shall not be expanded. Otherwise, the delimiter shall be the word itself.

If no part of word is quoted, all lines of the here-document shall be expanded for parameter expansion, command substitution, and arithmetic expansion. In this case, the <backslash> in the input behaves as the <backslash> inside double-quotes (see Double-Quotes). However, the double-quote character ( ' )' shall not be treated specially within a here-document, except when the double-quote appears within "$()""``", or "${}".

If the redirection operator is "<<-", all leading <tab> characters shall be stripped from input lines and the line containing the trailing delimiter. If more than one "<<" or "<<-" operator is specified on a line, the here-document associated with the first operator shall be supplied first by the application and shall be read first by the shell.

When a here-document is read from a terminal device and the shell is interactive, it shall write the contents of the variable PS2, processed as described in Shell Variables, to standard error before reading each line of input until the delimiter has been recognized.




here document에 대한 간단한 예시이다.  << 다음에 오는 구분자이기 때문에 마지막에 오는 구분자와 짝만 맞추면 된다. 관례상 EOF를 많이 쓰는 것 같다. 


cat << XXXX

> a="world"

> $a

> XXXX

a="world"

world



예시에서 here tag를 EOF로 가정하고 간단한 예시를 소개한다. 


리디렉션  <<을 사용해 한번에 배시를 처리할 수 있다. 



$ cat << EOF

> echo $a

> $a

> EOF

echo world

world



여러 라인으로 구성된 배시를 파일로 저장할 수 있다. 


$ cat << EOF > print_a.sh

> #!/bin/sh

> echo $a

> EOF

$ chmod 755 print_a.sh

$ ./print_a.sh

world



EOF처럼 EOS도 테스트할 수 있다.


$ cat << EOF

> h

> f

> p

> EOF

h

f

p




here tag 또는 here document는 표준 출력만 하기 때문에, 리터럴로 저장하려면, $ 또는 `를 사용해야 한다.

여러 라인으로 구성된 배시의 결과를 변수로 지정할 수 있다. 



$ multiline=$(cat << EOF

echo $a

$a

EOF

)


$ echo $multiline

echo world world




문서를 보면 expand라는 단어가 나오는데, 이 개념은 아래 예시를 통해 이해할 수 있다. << EOF를 사용하면 따옴표안의 변수 값이 변환되지만, <<\EOF를 사용하면 따옴표 안에 변수 값이 변환되지 않는다. 



$ cat << EOF

> a="world"

> printf '[%s]\n' "$a"

> EOF

a="world"

printf '[%s]\n' "world"



$ cat <<\EOF

> a="world"

> printf '[%s]\n' "$a"

> EOF

a="world"

printf '[%s]\n' "$a"




<<에 마이너스 기호(<<-)는 탭을 무시하겠다는 의미를 가진다. 






Posted by '김용환'
,

paste 커맨드

unix and linux 2016. 12. 26. 21:57



paste 커맨드는 파일들의 내용을 나란히 탭으로 구분해 출력하는 리눅스 커맨드이다. 



[~] cat job_name

devops

engineer

[~] cat names

sammuel.kim

jax.moon



[~] paste names job_name

sammuel.kim devops

jax.moon engineer




탭이 싫다면, -d 옵션과 delimiter를 줄 수 있다. 


$ paste -d":" names job_name

sammuel.kim:devops

jax.moon:engineer




만약 여러개의 delimiter를 줄 수 있고, 파일 단위로 사용된다. 


$ paste -d'+-' names job_name names

sammuel.kim+devops-sammuel.kim

jax.moon+engineer-jax.moon



파일이 4개이고, delimiter가 2개이면, delimiter가 반복되어 사용된다. 


$ paste -d'+-' names job_name names job_name

sammuel.kim+devops-sammuel.kim+devops

jax.moon+engineer-jax.moon+engineer




-s 옵션을 사용하면 여러 파일이 아닌 하나의 동일 파일을 사용한다.



$ paste -s names

sammuel.kim jax.moon



탭이 기본 구분자라서 +를 구분자로 사용할 수 있다.


$ paste -s  -d'+' names

sammuel.kim+jax.moon





대시(-)를 쓰면 무엇이 나올까? 표준입력을 받는 의미로 쓰인다. 



$ cat job_name -

devops

engineer


$ cat job_name -

devops

engineer

// zero 입력 

zero

zero



표준 입력을 ls로부터 받고 구분자를 공백으로 두려면 다음과 같은 명령어를 사용한다.


$ ls | paste -d' ' -s -

Applications Desktop Documents Downloads Dropbox



ls | paste는 echo *의 덜 복잡한 포맷이 된다.


Posted by '김용환'
,


2016년 12월 말 기준으로 최신 Grafana, InfluxDB, Telegraf을 설치해서 장비 중 일부에 서버를 설치해 실시간용으로 모니터링하려 한다. 

Cacti나 Nagios가 있지만, 실시간이라는 점에서는 Grafana, InfluxDB, Telegraf가 최고인듯 하다. 




* centos 6을 기준으로 설명한다.



influxDB는 mysql과 같지만, 좀 다르다.

- database 그대로 사용

- measurement : mysql의 테이블과 같은 개념

- tag : indexed column

- field : not indexed column


그리고, HTTP로 데이터 핸들링이 가능하다. (내가 정말 좋아하는 기능이다)





* influxDB 설치 (최신 1.1.1 설치)


$ export http_proxy=

$ export https_proxy=

$ wget --no-check-certificate https://dl.influxdata.com/influxdb/releases/influxdb-1.1.1.x86_64.rpm

$ sudo yum localinstall influxdb-1.1.1.x86_64.rpm

$ sudo service influxdb start

$ influx --version

InfluxDB shell version: 1.1.1


데몬을 확인하면 다음과 같이 떠 있는지 확인할 수 있다. 


/usr/bin/influxd -pidfile /var/run/influxdb/influxd.pid -config /etc/influxdb/influxdb.conf



influxDB 설정 파일은 /etc/influxdb/influxdb.conf에 존재한다. 


필요하면, 설정을 바꿔 재시작하면 된다. 

주요 디렉토리는 다음과 같다. 


"/var/lib/influxdb/meta" -- 메타 디렉토리 확인

"/var/lib/influxdb/data" -- 데이터 디렉토리 확인



기본 로그는 다음 디렉토리에 존재한다. 


/var/log/influxdb/influxd.log




정상적인지 동작하는 지 확인한다. 



$ influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 1.1.1

InfluxDB shell version: 1.1.1

> show databases

name: databases

name

----

_internal


> create database story_mon

> use story_mon

Using database story_mon

> show measurements

> insert webapp,mon_type=os,metric=disk value=20

> show measurements

name: measurements

name

----

webapp


> select * from webapp

name: webapp

time metric mon_type value

---- ------ -------- -----

1482384136937122209 disk os 20


> insert webapp,mon_type=os,metric=disk value=21

> insert webapp,mon_type=os,metric=disk value=22

> select * from webapp

name: webapp

time metric mon_type value

---- ------ -------- -----

1482384136937122209 disk os 20

1482384165814969769 disk os 21

1482384170862239986 disk os 22




InfluxDB에 어드민 UI가 있다고 하지만, 1.1.0에서 deprecated가 되었고 조만간에 사라질 계획이다. (동작도 안되고 해서 쓰지 않는다)




* Telegraf 설치 (최신 1.1.2 설치)



$ wget https://dl.influxdata.com/telegraf/releases/telegraf-1.1.2.x86_64.rpm

$ sudo yum localinstall telegraf-1.1.2.x86_64.rpm



설정을 수정한다. 설정을 수정할 때, vi도 할 수 있지만, telegraf 커맨드를 통해 어떤 입력을 넣을 지 수정할 수 있다. 

cpu:kernel:mem:net:netstat:system 를 모니터링하고 싶다면 다음과 같이 진행할 수 있다. 



$ sudo sh -c 'telegraf -sample-config -input-filter cpu:kernel:mem:net:netstat:system  -output-filter influxdb > /etc/telegraf/telegraf.conf'


플러그인이 잘되어 있다. 


system쪽 설정은 다음을 활용할 수 있다.

https://github.com/influxdata/telegraf/tree/master/plugins/inputs/system


그 외 다른 장비도 모니터링할 수 있다. 

https://github.com/influxdata/telegraf/tree/master/plugins/inputs



telegraf.conf에서 전송될 influxDB로 수정하고, database 명을 확인한다. influxDB에 database 명이 없더라도 알아서 만들어준다. 


[[outputs.influxdb]]

  urls = ["http://mon.google.com.kr:8086"] # required

  database = "telegraf" # required

 


설정을 수정하면 재시작한다. 


$ sudo service telegraf start



로그 파일은 /var/log/telegraf  디렉토리에 존재하며 에러가 발생할 때만 로그가 발생한다. 로그 파일명(/var/log/telegraf/telegraf.log)은 다음과 같다. 




influxDB가 설정된 장비에서 제대로 데이터가 들어오는지 InfluxDB에서 확인한다. 


$ influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 1.1.1

InfluxDB shell version: 1.1.1

> show databases;

name: databases

name

----

_internal

story_mon

mydb

telegraf


> use telegraf

Using database telegraf

> select *

ERR: error parsing query: found EOF, expected FROM at line 1, char 9

> show measurements

name: measurements

name

----

cpu

kernel

mem

net

netstat

system


> select * from cpu

name: cpu

time cpu host usage_guest usage_guest_nice usage_idle usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system usage_user

---- --- ---- ----------- ---------------- ---------- ------------ --------- ---------- ------------- ----------- ------------ ----------

1482389050000000000 cpu-total fox289 0 0 94.84913522987507 0.025249337212289454 0 00.05049867439702194 0 0.5681100874992648 4.507006692671534

1482389050000000000 cpu7 fox289 0 0 97.6814516446267 0 0 00.10080645165430842 0 0.403225806470541 1.8145161294108199

1482389050000000000 cpu1 fox289 0 0 98.28801609601521 0








[[추가 내용]]


참고로 nginx 모니터링도 가능하다. 



모니터링 agent에도 nginx도 사용할 수 있다. 

telegraf.conf의 nginx 에서는 http://localhost/status를 기본적으로 참조하게 되어 있지만, 시스템 환경처럼 변경할 수 있다. nginx 설정에서 localhost에서 nginx_status를 접근할 수 있도록 allow설정을 추가/변경한다.


  urls = ["http://localhost/nginx_status"]



테스트는 다음처럼 진행하고 문제가 없다면 telegraf 데몬을 재시작한다. 


$ telegraf -config telegraf.conf -input-filter nginx -test  

* Plugin: inputs.nginx, Collection 1

> nginx,host=fox289,port=80,server=localhost accepts=238194937i,active=43i,handled=238194937i,reading=0i,requests=249173634i,waiting=29i,writing=7i 1482390555000000000


$ sudo service telegraf restart



참고로 redis도 모니터링가능하다. 

https://github.com/influxdata/telegraf/tree/master/plugins/inputs/redis


설정을 다음처럼 추가하고 테스트해볼 수 있다. 


$ sudo sh -c 'telegraf -sample-config -input-filter cpu:kernel:mem:net:netstat:system:redis  -output-filter influxdb > telegraf.conf'

$ telegraf -config telegraf.conf -input-filter redis -test

* Plugin: inputs.redis, Collection 1

> redis_keyspace,database=db0,host=x11231321,port=6379,replication_role=master,server=localhost avg_ttl=0i,expires=0i,keys=2053i 1482478100000000000

> redis,host=abc.google.io,port=6379,replication_role=master,server=localhost aof_current_rewrite_time_sec=-1i,aof_enabled=0i,aof_last_bgrewrite_status="ok",aof_last_rewrite_time_sec=-1i,aof_last_write_status="ok",aof_rewrite_in_progress=0i,aof_rewrite_scheduled=0i,blocked_clients=0i,client_biggest_input_buf=0i,client_longest_output_list=0i,clients=1528i,connected_slaves=0i,evicted_keys=8857i,expired_keys=57137i,instantaneous_ops_per_sec=25347i,keyspace_hitrate=0.9228515982739088,keyspace_hits=28164842i,keyspace_misses=2354520i,latest_fork_usec=0i,loading=0i,lru_clock=6083091i,master_repl_offset=0i,mem_fragmentation_ratio=2.15,pubsub_channels=0i,pubsub_patterns=0i,rdb_bgsave_in_progress=0i,rdb_changes_since_last_save=105450019680i,rdb_current_bgsave_time_sec=-1i,rdb_last_bgsave_status="ok",rdb_last_bgsave_time_sec=-1i,rdb_last_save_time=1409638653i,rdb_last_save_time_elapsed=72839446i,rejected_connections=0i,repl_backlog_active=0i,repl_backlog_first_byte_offset=0i,repl_backlog_histlen=0i,repl_backlog_size=1048576i,sync_full=0i,sync_partial_err=0i,sync_partial_ok=0i,total_commands_processed=2119609996923i,total_connections_received=1101319i,uptime=72839446i,used_cpu_sys=12417264,used_cpu_sys_children=0,used_cpu_user=4852340,used_cpu_user_children=0,used_memory=70373856i,used_memory_lua=33792i,used_memory_peak=11811160000i,used_memory_rss=151429120i 1482478100000000000


$ sudo service telegraf restart







* UI 대시보드인 grafana를 설치


$ sudo yum install https://grafanarel.s3.amazonaws.com/builds/grafana-4.0.2-1481203731.x86_64.rpm 



$ sudo service grafana-server start


Starting Grafana Server: ...                               [  OK  ]

설정은 /etc/grafana/grafana.ini 에 있다. 기본 포트는 3000이고, http://서버:3000로 접근한다. 



influx DB 연동은 방법을 Data sources를 클릭 후 연동한다.

http://docs.grafana.org/datasources/influxdb/


정상적이면 “Data source is working”이 화면이 보인다. 


Graph 관련 작업은 다음 링크(http://docs.grafana.org/reference/graph/)을 참고한다. 조금만 해보면 하는 방법을 터득한다.



드디어 grafana로 쉽게 만들었다. 








이 상태로 두면, influxDB는 언제가 디스크가 찰 수 있어서, 데이터 보관(또는 삭제) 정책이 필요하다. 

influxDB는 실시간(time series) 전문 솔루션이라 이에 대한 정책을 찾아보니 RP(Retention Policy)라 한다. 



> create retention policy three_days on telegraf duration 3d replication 1 default



> show retention policies on telegraf

name duration shardGroupDuration replicaN default

---- -------- ------------------ -------- -------

autogen 0s 168h0m0s 1 false

three_days 72h0m0s 24h0m0s 1 true








참조 

https://docs.influxdata.com/influxdb/v1.1/introduction/getting_started/

https://github.com/influxdata/telegraf/tree/master/

https://docs.influxdata.com/influxdb/v0.9/guides/downsampling_and_retention/






* 추가로...



java 모니터링은 jolokia나 jvmstatd profiler가 존재하는데. 이 방식은 재시작을 해야 해서, 빼고 놓고가 불편하다.. 대용량이 아닌 서비스에서는 쉽게 쓸 수 있을 것이다. 



[jolokia]


[[jolokia.servers]]

  name = "as-service-1"

  host = "127.0.0.1"

  port = "8080"


[[jolokia.servers]]

  name = "as-service-2"

  host = "127.0.0.1"

  port = "8180"


[[jolokia.metrics]]

  name = "heap_memory_usage"

  jmx  = "/java.lang:type=Memory/HeapMemoryUsage"

  pass = ["used", "max"]

The collected metrics will be:

jolokia_heap_memory_usage name=as-service-1,host=127.0.0.1,port=8080 used=xxx,max=yyy

jolokia_heap_memory_usage name=as-service-2,host=127.0.0.1,port=8180 used=vvv,max=zzz




jolokia는 특별히 http 서버(웹서버) 관점으로 개발되었있다. 


https://github.com/influxdata/telegraf/tree/master/plugins/inputs/jolokia





(추후 나는 이 방식을 다른 방식으로 만들 예정, telegraf대신 직접 influxDB HTTP api 호출을 써서 쉽게 저장하는 방식이 나을 듯하다. 대용량 시스템에서 javaagent는 부하를 많이 먹는 경우가 많을 뿐더러 개인적으로 재시작 자체를 별로 좋아하지 않는다. ㅡ.ㅡ;;)


따라서, 다른 방식으로 접근했다. 


http://knight76.tistory.com/entry/grafana-%EC%9E%90%EB%B0%94-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81




(점점, 예전에는 이런 거 만드는 재미로 살았는데. 아저씨들의 시대는 가는 것 같다... ㅠㅠ)





###추가.

cassandra3도 grafana로 모니터링할 수 있다. (opscenter는 3.0부터 상용화버전만 지원한다)



jolokia를 추가한다.

  

$ sudo mv /tmp/jolokia-jvm-1.3.5-agent.jar /usr/share/cassandra/lib/jolokia-jvm-1.3.5-agent.jar

  

$ sudo vi /etc/cassandra/conf/cassandra-env.sh

 ..

[ -e "$CASSANDRA_HOME/lib/jolokia-jvm-1.3.5-agent.jar" ] &&

  JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jolokia-jvm-1.3.5-agent.jar"
..

LOCAL_JMX=no


  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"

  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"

  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"

  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"


  

  

테스트는 다음과 같이 진행한다. 


$ curl localhost:8778/jolokia/read/java.lang:type=Memory/HeapMemoryUsage

{"request":{"mbean":"java.lang:type=Memory","attribute":"HeapMemoryUsage","type":"read"},"value":{"init":2063597568,"committed":2012151808,"max":2012151808,"used":125159288},"timestamp":1490252927,"status":200}




모니터링 정보는 다음과 같다. 


https://github.com/rhuss/jolokia/blob/master/src/site/resources/templates/jolokia-access.xml

http://docs.datastax.com/en/archived/cassandra/3.x/cassandra/operations/opsMonitoring.html




telegraf는 다음과 같이 설정한다. https://raw.githubusercontent.com/wavefrontHQ/integrations/master/cassandra3/telegraf/10-cassandra.conf도 참조할 수 있다. 나는 성능 모니터링 요소를 많이 추가했다.. 카산드라 쉽게 볼 녀석이 아니다. ㅠ



$ sudo vi /etc/telegraf/telegraf.conf

 

urls = ["http://장비_ip:8086"] 

database = "telegraf" 


 

# Cassandra - Place this file in /etc/telegraf/telegraf.d

[[inputs.cassandra]]

  context = "/jolokia/read"

  servers = [":8778"]

  metrics = [ "/java.lang:type=GarbageCollector,name=ConcurrentMarkSweep/CollectionTime",

"/java.lang:type=GarbageCollector,name=ConcurrentMarkSweep/CollectionCount",

"/java.lang:type=GarbageCollector,name=ParNew/CollectionTime",

"/java.lang:type=GarbageCollector,name=ParNew/CollectionCount",

"/java.lang:type=Memory/NonHeapMemoryUsage",

"/java.lang:type=Memory/HeapMemoryUsage",

"/org.apache.cassandra.net:type=FailureDetector",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=LiveSSTableCount",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=SSTablesPerReadHistogram",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=ReadLatency",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=WriteLatency",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=RangeLatency",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=MemtableOnHeapSize",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=MemtableSwitchCount",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=MemtableLiveDataSize",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=MemtableColumnsCount",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=MemtableOffHeapSize",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=BloomFilterFalsePositives",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=BloomFilterFalseRatio",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=BloomFilterDiskSpaceUsed",

"/org.apache.cassandra.metrics:type=ColumnFamily,name=BloomFilterOffHeapMemoryUsed",


"/org.apache.cassandra.metrics:type=Cache,scope=KeyCache,name=Hits",

"/org.apache.cassandra.metrics:type=Cache,scope=KeyCache,name=Requests",

"/org.apache.cassandra.metrics:type=Cache,scope=KeyCache,name=Entries",

"/org.apache.cassandra.metrics:type=Cache,scope=KeyCache,name=Size",

"/org.apache.cassandra.metrics:type=Cache,scope=KeyCache,name=Capacity",

"/org.apache.cassandra.metrics:type=Cache,scope=RowCache,name=Hit",

"/org.apache.cassandra.metrics:type=Cache,scope=RowCache,name=Requests",

"/org.apache.cassandra.metrics:type=Cache,scope=RowCache,name=Entries",

"/org.apache.cassandra.metrics:type=Cache,scope=RowCache,name=Size",

"/org.apache.cassandra.metrics:type=Cache,scope=RowCache,name=Capacity",

"/org.apache.cassandra.metrics:type=Client,name=connectedNativeClients",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=TotalLatency",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=TotalLatency",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Latency",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=Latency",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Timeouts",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=Timeouts",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Unavailables",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=Unavailables",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Failures",

"/org.apache.cassandra.metrics:type=ClientRequest,scope=Write,name=Failures",

"/org.apache.cassandra.metrics:type=CommitLog,name=PendingTasks",

"/org.apache.cassandra.metrics:type=CommitLog,name=TotalCommitLogSize",

"/org.apache.cassandra.metrics:type=Compaction,name=CompletedTask",

"/org.apache.cassandra.metrics:type=Compaction,name=PendingTasks",

"/org.apache.cassandra.metrics:type=Compaction,name=TotalCompactionsCompleted",

"/org.apache.cassandra.metrics:type=Compaction,name=BytesCompacted",

"/org.apache.cassandra.metrics:type=Storage,name=Load",

"/org.apache.cassandra.metrics:type=Storage,name=Exceptions",

"/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=LiveDiskSpaceUsed",

"/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=TotalDiskSpaceUsed",

"/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=ReadLatency",

"/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=CoordinatorReadLatency",

"/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=WriteLatency",

"/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=ReadTotalLatency",

"/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=WriteTotalLatency",

"/org.apache.cassandra.metrics:type=ThreadPools,path=internal,scope=CompactionExecutor,name=ActiveTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=internal,scope=AntiEntropyStage,name=ActiveTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=CounterMutationStage,name=PendingTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=CounterMutationStage,name=CurrentlyBlockedTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=MutationStage,name=PendingTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=MutationStage,name=CurrentlyBlockedTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=ReadRepairStage,name=PendingTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=ReadRepairStage,name=CurrentlyBlockedTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=ReadStage,name=PendingTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=ReadStage,name=CurrentlyBlockedTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=RequestResponseStage,name=PendingTasks",

"/org.apache.cassandra.metrics:type=ThreadPools,path=request,scope=RequestResponseStage,name=CurrentlyBlockedTasks"

   ]


그외 참조 내용

https://www.datadoghq.com/blog/how-to-collect-cassandra-metrics/


https://medium.com/@mlowicki/cassandra-metrics-and-their-use-in-grafana-1f0dc33f9cca#.eewda2cp7



telegraf를 실행한다.

   

$ sudo service telegraf start








'unix and linux' 카테고리의 다른 글

[shell script] Here Tag / Here Document  (0) 2016.12.28
paste 커맨드  (0) 2016.12.26
sudo에 따른 Permission denied 에러  (0) 2016.12.22
telnet 대신 nc 커맨드  (0) 2016.12.22
쉘에서 proxy 설정 모음  (0) 2016.12.22
Posted by '김용환'
,


아래 예시와 같이 sudo 와 > redirection을 사용할 때 permission 에러가 발생할 수 있다.


$ sudo telegraf -sample-config -input-filter cpu:kernel -output-filter influxdb > telegraf.conf

Permission denied



스크립트를 만들어서 실행하던지, 아니면 sudo로 감싼다. 


sudo sh -c 'telegraf -sample-config -input-filter cpu:kernel -output-filter influxdb > telegraf.conf'




Posted by '김용환'
,



최근에는 telnet 클라이언트를 잘 안쓰는 경향(기본 설치를 안 해줌)이 있다. 

이럴 때는 sudo yum install telnet으로 해서 telnet을 설치할 수도 있지만,...


nc 커맨드(기본 설치)를 활용하는 것도 좋을 것 같다. 


$ nc -z localhost 8086

Connection to localhost 8086 port [tcp/*] succeeded!

Posted by '김용환'
,


회사에서는 외부 리소스를 접근할 때는 보안(IP를 숨길 의도, 로깅의도) 상 proxy를 두기도 한다. 


export ftp_proxy=

export https_proxy=

export http_proxy=


주의할 점은 localhost를 쓰려고 할 때에도 proxy를 쓰려고 할 경우가 있으니. 이때는 안쓰는 방향으로 수정할 필요가 있다. 아래와 같이 사용한다. 


export no_proxy=localhost,127.0.0.1



https://wiki.archlinux.org/index.php/proxy_settings

Posted by '김용환'
,