]> arthur.barton.de Git - netdata.git/blob - netdata-9999.ebuild
Merge pull request #172 from mcnewton/infiles
[netdata.git] / netdata-9999.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6
7 inherit linux-info systemd user
8
9 if [[ ${PV} == "9999" ]] ; then
10         EGIT_REPO_URI="git://github.com/firehol/${PN}.git"
11         inherit git-r3 autotools
12         SRC_URI=""
13         KEYWORDS=""
14 else
15         SRC_URI="http://firehol.org/download/${PN}/releases/v${PV}/${P}.tar.xz"
16         KEYWORDS="~amd64 ~x86"
17 fi
18
19
20 DESCRIPTION="Linux real time system monitoring, done right!"
21 HOMEPAGE="https://github.com/firehol/netdata http://netdata.firehol.org/"
22
23 LICENSE="GPL-3+ MIT BSD"
24 SLOT="0"
25 IUSE="+compression nfacct nodejs"
26
27 # most unconditional dependencies are for plugins.d/charts.d.plugin:
28 RDEPEND="
29         >=app-shells/bash-4:0
30         net-misc/curl
31         net-misc/wget
32         virtual/awk
33         compression? ( sys-libs/zlib )
34         nfacct? (
35                 net-firewall/nfacct
36                 net-libs/libmnl
37         )
38         nodejs? (
39                 net-libs/nodejs
40         )"
41
42 DEPEND="${RDEPEND}
43         virtual/pkgconfig"
44
45 # check for Kernel-Samepage-Merging (CONFIG_KSM)
46 CONFIG_CHECK="
47         ~KSM
48 "
49
50 : ${NETDATA_USER:=netdata}
51
52 pkg_setup() {
53         linux-info_pkg_setup
54
55         enewgroup ${PN}
56         enewuser ${PN} -1 -1 / ${PN}
57 }
58
59 src_prepare() {
60         default
61         [[ ${PV} == "9999" ]] && eautoreconf
62 }
63
64 src_configure() {
65         econf \
66                 --localstatedir=/var \
67                 --with-user=${NETDATA_USER} \
68                 $(use_enable nfacct plugin-nfacct) \
69                 $(use_with compression zlib)
70 }
71
72 src_install() {
73         default
74
75         fowners ${NETDATA_USER} /var/log/netdata
76
77         chown -Rc ${NETDATA_USER} "${ED}"/usr/share/${PN} || die
78
79         cat >> "${T}"/${PN}-sysctl <<- EOF
80         kernel.mm.ksm.run = 1
81         kernel.mm.ksm.sleep_millisecs = 1000
82         EOF
83
84         dodoc "${T}"/${PN}-sysctl
85
86         newinitd system/netdata-openrc ${PN}
87         systemd_dounit system/netdata.service
88 }
89
90 pkg_postinst() {
91         if [[ -e "/sys/kernel/mm/ksm/run" ]]; then
92                 elog "INFORMATION:"
93                 echo ""
94                 elog "I see you have kernel memory de-duper (called Kernel Same-page Merging,"
95                 elog "or KSM) available, but it is not currently enabled."
96                 echo ""
97                 elog "To enable it run:"
98                 echo ""
99                 elog "echo 1 >/sys/kernel/mm/ksm/run"
100                 elog "echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs"
101                 echo  ""
102                 elog "If you enable it, you will save 20-60% of netdata memory."
103         else
104                 elog "INFORMATION:"
105                 echo ""
106                 elog "I see you do not have kernel memory de-duper (called Kernel Same-page"
107                 elog "Merging, or KSM) available."
108                 echo ""
109                 elog "To enable it, you need a kernel built with CONFIG_KSM=y"
110                 echo ""
111                 elog "If you can have it, you will save 20-60% of netdata memory."
112         fi
113
114 }