RadarURL
Skip to content
웹서버,WAS
2016.10.25 06:52

netdata에 Apache perfomance data 추가 방법

조회 수 77 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

apache.chart.sh 소스를 /etc/netdata/charts.d/ 경로에 넣는다.

 

apache.chart.sh source

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

# no need for shebang - this file is loaded from charts.d.plugin

# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#

# the URL to download apache status info
apache_url="http://127.0.0.1:80/server-status?auto"
apache_curl_opts=

# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
apache_update_every=

apache_priority=60000

# convert apache floating point values
# to integer using this multiplier
# this only affects precision - the values
# will be in the proper units
apache_decimal_detail=1000000

declare -a apache_response=()
apache_accesses=0
apache_kbytes=0
apache_reqpersec=0
apache_bytespersec=0
apache_bytesperreq=0
apache_busyworkers=0
apache_idleworkers=0
apache_connstotal=0
apache_connsasyncwriting=0
apache_connsasynckeepalive=0
apache_connsasyncclosing=0

apache_keys_detected=0
apache_has_conns=0
apache_key_accesses=
apache_key_kbytes=
apache_key_reqpersec=
apache_key_bytespersec=
apache_key_bytesperreq=
apache_key_busyworkers=
apache_key_idleworkers=
apache_key_scoreboard=
apache_key_connstotal=
apache_key_connsasyncwriting=
apache_key_connsasynckeepalive=
apache_key_connsasyncclosing=
apache_detect() {
	local i=0
	for x in "${@}"
	do
		case "${x}" in
			'Total Accesses') 		apache_key_accesses=$((i + 1)) ;;
			'Total kBytes') 		apache_key_kbytes=$((i + 1)) ;;
			'ReqPerSec') 			apache_key_reqpersec=$((i + 1)) ;;
			'BytesPerSec')			apache_key_bytespersec=$((i + 1)) ;;
			'BytesPerReq')			apache_key_bytesperreq=$((i + 1)) ;;
			'BusyWorkers')			apache_key_busyworkers=$((i + 1)) ;;
			'IdleWorkers')			apache_key_idleworkers=$((i + 1));;
			'ConnsTotal')			apache_key_connstotal=$((i + 1)) ;;
			'ConnsAsyncWriting')	apache_key_connsasyncwriting=$((i + 1)) ;;
			'ConnsAsyncKeepAlive')	apache_key_connsasynckeepalive=$((i + 1)) ;;
			'ConnsAsyncClosing')	apache_key_connsasyncclosing=$((i + 1)) ;;
			'Scoreboard')			apache_key_scoreboard=$((i)) ;;
		esac

		i=$((i + 1))
	done

	# we will not check of the Conns*
	# keys, since these are apache 2.4 specific
	[ -z "${apache_key_accesses}"    ] && error "missing 'Total Accesses' from apache server: ${*}" && return 1
	[ -z "${apache_key_kbytes}"      ] && error "missing 'Total kBytes' from apache server: ${*}" && return 1
	[ -z "${apache_key_reqpersec}"   ] && error "missing 'ReqPerSec' from apache server: ${*}" && return 1
	[ -z "${apache_key_bytespersec}" ] && error "missing 'BytesPerSec' from apache server: ${*}" && return 1
	[ -z "${apache_key_bytesperreq}" ] && error "missing 'BytesPerReq' from apache server: ${*}" && return 1
	[ -z "${apache_key_busyworkers}" ] && error "missing 'BusyWorkers' from apache server: ${*}" && return 1
	[ -z "${apache_key_idleworkers}" ] && error "missing 'IdleWorkers' from apache server: ${*}" && return 1
	[ -z "${apache_key_scoreboard}"  ] && error "missing 'Scoreboard' from apache server: ${*}" && return 1

	if [ ! -z "${apache_key_connstotal}" \
		-a ! -z "${apache_key_connsasyncwriting}" \
		-a ! -z "${apache_key_connsasynckeepalive}" \
		-a ! -z "${apache_key_connsasyncclosing}" \
		]
		then
		apache_has_conns=1
	else
		apache_has_conns=0
	fi

	return 0
}

apache_get() {
	local oIFS="${IFS}" ret
	IFS=$':\n' apache_response=($(run curl -Ss ${apache_curl_opts} "${apache_url}"))
	ret=$?
	IFS="${oIFS}"

	[ $ret -ne 0 -o "${#apache_response[@]}" -eq 0 ] && return 1

	# the last line on the apache output is "Scoreboard"
	# we use this label to detect that the output has a new word count
	if [ ${apache_keys_detected} -eq 0 -o "${apache_response[${apache_key_scoreboard}]}" != "Scoreboard" ]
		then
		apache_detect "${apache_response[@]}" || return 1
		apache_keys_detected=1
	fi

	apache_accesses="${apache_response[${apache_key_accesses}]}"
	apache_kbytes="${apache_response[${apache_key_kbytes}]}"
	
	float2int "${apache_response[${apache_key_reqpersec}]}" ${apache_decimal_detail}
	apache_reqpersec=${FLOAT2INT_RESULT}

	float2int "${apache_response[${apache_key_bytespersec}]}" ${apache_decimal_detail}
	apache_bytespersec=${FLOAT2INT_RESULT}

	float2int "${apache_response[${apache_key_bytesperreq}]}" ${apache_decimal_detail}
	apache_bytesperreq=${FLOAT2INT_RESULT}

	apache_busyworkers="${apache_response[${apache_key_busyworkers}]}"
	apache_idleworkers="${apache_response[${apache_key_idleworkers}]}"

	if [ -z "${apache_accesses}" \
		-o -z "${apache_kbytes}" \
		-o -z "${apache_reqpersec}" \
		-o -z "${apache_bytespersec}" \
		-o -z "${apache_bytesperreq}" \
		-o -z "${apache_busyworkers}" \
		-o -z "${apache_idleworkers}" \
		]
		then
		error "empty values got from apache server: ${apache_response[*]}"
		return 1
	fi

	if [ ${apache_has_conns} -eq 1 ]
		then
		apache_connstotal="${apache_response[${apache_key_connstotal}]}"
		apache_connsasyncwriting="${apache_response[${apache_key_connsasyncwriting}]}"
		apache_connsasynckeepalive="${apache_response[${apache_key_connsasynckeepalive}]}"
		apache_connsasyncclosing="${apache_response[${apache_key_connsasyncclosing}]}"
	fi

	return 0
}

# _check is called once, to find out if this chart should be enabled or not
apache_check() {

	apache_get
	if [ $? -ne 0 ]
		then
		error "cannot find stub_status on URL '${apache_url}'. Please set apache_url='http://apache.server:80/server-status?auto' in $confd/apache.conf"
		return 1
	fi

	# this should return:
	#  - 0 to enable the chart
	#  - 1 to disable the chart

	return 0
}

# _create is called once, to create the charts
apache_create() {
	cat <<EOF
CHART apache_local.bytesperreq '' "apache Lifetime Avg. Response Size" "bytes/request" statistics apache.bytesperreq area $((apache_priority + 8)) $apache_update_every
DIMENSION size '' absolute 1 ${apache_decimal_detail}
CHART apache_local.workers '' "apache Workers" "workers" workers apache.workers stacked $((apache_priority + 5)) $apache_update_every
DIMENSION idle '' absolute 1 1
DIMENSION busy '' absolute 1 1
CHART apache_local.reqpersec '' "apache Lifetime Avg. Requests/s" "requests/s" statistics apache.reqpersec line $((apache_priority + 6)) $apache_update_every
DIMENSION requests '' absolute 1 ${apache_decimal_detail}
CHART apache_local.bytespersec '' "apache Lifetime Avg. Bandwidth/s" "kilobits/s" statistics apache.bytespersec area $((apache_priority + 7)) $apache_update_every
DIMENSION sent '' absolute 8 $((apache_decimal_detail * 1000))
CHART apache_local.requests '' "apache Requests" "requests/s" requests apache.requests line $((apache_priority + 1)) $apache_update_every
DIMENSION requests '' incremental 1 1
CHART apache_local.net '' "apache Bandwidth" "kilobits/s" bandwidth apache.net area $((apache_priority + 3)) $apache_update_every
DIMENSION sent '' incremental 8 1
EOF

	if [ ${apache_has_conns} -eq 1 ]
		then
		cat <<EOF2
CHART apache_local.connections '' "apache Connections" "connections" connections apache.connections line $((apache_priority + 2)) $apache_update_every
DIMENSION connections '' absolute 1 1
CHART apache_local.conns_async '' "apache Async Connections" "connections" connections apache.conns_async stacked $((apache_priority + 4)) $apache_update_every
DIMENSION keepalive '' absolute 1 1
DIMENSION closing '' absolute 1 1
DIMENSION writing '' absolute 1 1
EOF2
	fi

	return 0
}

# _update is called continiously, to collect the values
apache_update() {
	local reqs net
	# the first argument to this function is the microseconds since last update
	# pass this parameter to the BEGIN statement (see bellow).

	# do all the work to collect / calculate the values
	# for each dimension
	# remember: KEEP IT SIMPLE AND SHORT

	apache_get || return 1

	# write the result of the work.
	cat <<VALUESEOF
BEGIN apache_local.requests $1
SET requests = $((apache_accesses))
END
BEGIN apache_local.net $1
SET sent = $((apache_kbytes))
END
BEGIN apache_local.reqpersec $1
SET requests = $((apache_reqpersec))
END
BEGIN apache_local.bytespersec $1
SET sent = $((apache_bytespersec))
END
BEGIN apache_local.bytesperreq $1
SET size = $((apache_bytesperreq))
END
BEGIN apache_local.workers $1
SET idle = $((apache_idleworkers))
SET busy = $((apache_busyworkers))
END
VALUESEOF

	if [ ${apache_has_conns} -eq 1 ]
		then
	cat <<VALUESEOF2
BEGIN apache_local.connections $1
SET connections = $((apache_connstotal))
END
BEGIN apache_local.conns_async $1
SET keepalive = $((apache_connsasynckeepalive))
SET closing = $((apache_connsasyncclosing))
SET writing = $((apache_connsasyncwriting))
END
VALUESEOF2
	fi

	return 0
}

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

 

/etc/netdata/charts.d/apache.conf

를 아래와 같이 설정 파일을 만든다.

 

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

# the URL your apache server is responding with mod_status information.
apache_url="http://127.0.0.1:80/server-status?auto"

# use this to set custom curl options you may need
apache_curl_opts=

# set this to a NUMBER to overwrite the update frequency
# it is in seconds
apache_update_every=

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

 

아래 내용을 apache 설정 파일(/etc/httpd/conf/httpd.conf)에 추가한다.

/etc/httpd/conf/httpd.conf

 

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

<Location /server-status>
 SetHandler server-status

 Order Deny,Allow
 Deny from all
 Allow from localhost
# Allow from all
</Location>

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

 

netdata 설치 폴더에서

./netdata-installer.sh
를 실행해준다.

 

끝~

 

참고 : https://github.com/firehol/netdata/wiki/apache.chart.sh

?

공부 게시판

공부에 도움되는 글을 올려주세요.

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 [공지] 공부 게시판 입니다. 처누 2003.08.17 828774
2376 유닉스/리눅스 Buffer와 Cache의 차이점 TOP을 통해 본 리눅스 메모리 file JaeSoo 2016.10.25 69
2375 웹서버,WAS 리눅스 웹서버 구축전 고민사항 file JaeSoo 2016.10.25 85
2374 데이터베이스 netdata에 MySQL data 추가 방법 JaeSoo 2016.10.25 77
» 웹서버,WAS netdata에 Apache perfomance data 추가 방법 JaeSoo 2016.10.25 77
2372 데이터베이스 CentOS | MySQL 설치하고 root 사용자 비밀번호 생성하기 JaeSoo 2016.10.25 81
2371 웹서버,WAS htm이나 html 확장자를 php로 인식시키는 apache(아파치) 셋팅 JaeSoo 2016.10.25 58
2370 웹서버,WAS httpd.conf의 DirectoryIndex 설정이 적용되지 않습니다. JaeSoo 2016.10.25 53
2369 유닉스/리눅스 CentOS Linux 에서 설치시 uuid/uuid.h: No such file or directory JaeSoo 2016.10.24 57
2368 웹서버,WAS Linux - Apache 설치후 페이지 접근시, 권한 에러 1 JaeSoo 2016.10.24 313
2367 웹서버,WAS apache 에서 mod_rewrite 활성화 안될때 (xe 등에서 도메인 하위 경로명 오류 날때) JaeSoo 2016.10.24 69
2366 데이터베이스 Mysql/Mariadb DB 백업 및 복원 1 JaeSoo 2016.10.24 117
2365 유닉스/리눅스 한번에 끝내는 CentOS 7.x (7.0 ~ 7.2) 웹서버세팅 (센토스 서버세팅) 1 file JaeSoo 2016.10.24 166
2364 유닉스/리눅스 리눅스(Linux) 디렉토리 구조 file JaeSoo 2016.10.19 101
2363 데이터베이스 MySQL Dump / Import (덤프 / 임포트) JaeSoo 2016.10.10 81
2362 네트워크 Reverse DNS - 등록및 확인 JaeSoo 2016.09.23 176
2361 보안 RBL(Real-time Blocking List) 사이트 - 메일서버 블랙리스트 등록 조회 JaeSoo 2016.09.21 129
2360 건강 나도 자위 중독? 할 수록 궁금한 ‘자위’ 궁금증 3 file JaeSoo 2016.09.07 192
2359 사무 소프트웨어 엑셀 시트보호 해제 프로그램 없이 하기 file JaeSoo 2016.09.06 284
2358 모바일 [Galaxy S3] 갤럭시 S3(SHW-M440S) 커스텀 롬 정리!! file JaeSoo 2016.08.31 335
2357 윈도우즈 윈도우 컴퓨터 유지보수에 유용한 무료 프로그램들 file JaeSoo 2016.08.31 181
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 124 Next
/ 124

 

■ 즐겨찾기 - 가족
JAESOO's HOMEPAGE YOUNGAE's HOMEPAGE 장여은 홈페이지 장여희 홈페이지 장여원 홈페이지

■ 즐겨찾기 - 업무
알리카페 홀릭 숭실대 컴퓨터 통신연구실 (서창진) 말레이시아 KL Sentral 한국인 GuestHouse

■ 즐겨찾기 - 취미
어드민아이디 유에코 사랑회 아스가르드 좋은사람/나쁜사람 JServer.kr 제이서버 메타블로그 재수 티스토리

■ 즐겨찾기 - 강의, 커뮤니티
재수 강의 홈페이지 한소리 VTMODE.COM 숭실대 인공지능학과 숭실대 통신연구실


PageViews   Today : 3,237   Yesterday : 3,607   Total : 61,177,423  /  Counter Status   Today : 1,077   Yesterday : 1,123   Total : 3,251,214
Site Info   Member : 1,393  /  Total documents : 7,150   New documents : 0  /  Total comments : 510

design by by JAESOO.com

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소