summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohnjay <johnjay@localhost>2006-07-25 19:24:26 +0000
committerjohnjay <johnjay@localhost>2006-07-25 19:24:26 +0000
commiteef251c0f0c693ebdb39056a830e475a683a5d6a (patch)
tree00b828d187d45b6e843326c992290987fdfb6898 /dev-db/pgfouine
parentAdding OpenFTS and einput.eclass (diff)
downloadexperimental-eef251c0f0c693ebdb39056a830e475a683a5d6a.tar.gz
experimental-eef251c0f0c693ebdb39056a830e475a683a5d6a.tar.bz2
experimental-eef251c0f0c693ebdb39056a830e475a683a5d6a.zip
Added pgFouine, removed tests from einput.elcass
svn path=/experimental/; revision=23
Diffstat (limited to 'dev-db/pgfouine')
-rw-r--r--dev-db/pgfouine/Manifest16
-rw-r--r--dev-db/pgfouine/files/digest-pgfouine-0.63
-rw-r--r--dev-db/pgfouine/files/spgfouine282
-rw-r--r--dev-db/pgfouine/metadata.xml5
-rw-r--r--dev-db/pgfouine/pgfouine-0.6.ebuild191
5 files changed, 497 insertions, 0 deletions
diff --git a/dev-db/pgfouine/Manifest b/dev-db/pgfouine/Manifest
new file mode 100644
index 0000000..6e07bd5
--- /dev/null
+++ b/dev-db/pgfouine/Manifest
@@ -0,0 +1,16 @@
+AUX spgfouine 6206 RMD160 5d9526fdf883cac693702165cf6218775b0a24a1 SHA1 7faba96226bbb3aa210e77d51eeaf8d344381b37 SHA256 48fd32bb1d002798dbd311a57e3ad778ca5027645e79fb27d2a1c1a398fd77ef
+MD5 0b953b34f044d19cd9553bcbdd742b23 files/spgfouine 6206
+RMD160 5d9526fdf883cac693702165cf6218775b0a24a1 files/spgfouine 6206
+SHA256 48fd32bb1d002798dbd311a57e3ad778ca5027645e79fb27d2a1c1a398fd77ef files/spgfouine 6206
+DIST pgfouine-0.6.tar.gz 438056 RMD160 0e0564b064998d57bc62f8b3d866dd1f198a0f54 SHA1 dc0a4bc6eb04699e1787471f084cabf90214498d SHA256 c8ad440e1605a8641847b20d382f7ce110856c973fc480a77cee5c81ac332a12
+EBUILD pgfouine-0.6.ebuild 6607 RMD160 33a6a7d1c4333040ac04fc893d12d7fb3b93b0b6 SHA1 bc6bf24e0e6d14bdf8fb03fb5b64c8d8dd8efcde SHA256 82f5caf5b02b5475cdb1a4d445e7f85c3283d2573e008dfff6d5d339406a045d
+MD5 532ec36d1ec41c4b134cc63e16af8917 pgfouine-0.6.ebuild 6607
+RMD160 33a6a7d1c4333040ac04fc893d12d7fb3b93b0b6 pgfouine-0.6.ebuild 6607
+SHA256 82f5caf5b02b5475cdb1a4d445e7f85c3283d2573e008dfff6d5d339406a045d pgfouine-0.6.ebuild 6607
+MISC metadata.xml 163 RMD160 70bbda1c1e8316a09d467334131898ae833a3205 SHA1 f43b9a4a2a82140936f9b04e4e63b3c9a495141f SHA256 f0699a4c3ad24cc38836c2d4a1ba03e4e403a9a5364b51df405db02014005891
+MD5 f8d3d207746da2a3cd14dcaab8daab76 metadata.xml 163
+RMD160 70bbda1c1e8316a09d467334131898ae833a3205 metadata.xml 163
+SHA256 f0699a4c3ad24cc38836c2d4a1ba03e4e403a9a5364b51df405db02014005891 metadata.xml 163
+MD5 0e4bf613e4e89af24ca2d24cae13762a files/digest-pgfouine-0.6 238
+RMD160 8178704ad7f342779fa45e8e9df0f223aa27e4db files/digest-pgfouine-0.6 238
+SHA256 f0f4b906df0755a5b2c99213fdeedb3f947f6ec7499bae1c71670db2dcb0f418 files/digest-pgfouine-0.6 238
diff --git a/dev-db/pgfouine/files/digest-pgfouine-0.6 b/dev-db/pgfouine/files/digest-pgfouine-0.6
new file mode 100644
index 0000000..a07706f
--- /dev/null
+++ b/dev-db/pgfouine/files/digest-pgfouine-0.6
@@ -0,0 +1,3 @@
+MD5 98806640e12f1d6092bdaf81bebc7dd0 pgfouine-0.6.tar.gz 438056
+RMD160 0e0564b064998d57bc62f8b3d866dd1f198a0f54 pgfouine-0.6.tar.gz 438056
+SHA256 c8ad440e1605a8641847b20d382f7ce110856c973fc480a77cee5c81ac332a12 pgfouine-0.6.tar.gz 438056
diff --git a/dev-db/pgfouine/files/spgfouine b/dev-db/pgfouine/files/spgfouine
new file mode 100644
index 0000000..c51ef50
--- /dev/null
+++ b/dev-db/pgfouine/files/spgfouine
@@ -0,0 +1,282 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header$
+
+
+PATH_TO_PHP=""
+PATH_TO_LOGS=""
+PATH_TO_REPORTS=""
+LOG_TIME_SCHEMA=`date +"%Y.%m.%d"`
+OUTPUT_SCHEMA="pgsql_report.${LOG_TIME_SCHEMA}.html"
+INPUT_SCHEMA="log-sql.${LOG_TIME_SCHEMA}"
+
+PATH_TO_PGFOUINE=""
+
+# e* functions used from /sbin/functions.sh (Gentoo 2005.1)
+
+RC_GOT_FUNCTIONS="yes"
+RC_QUIET_STDOUT="no"
+RC_VERBOSE=${RC_VERBOSE:-no}
+RC_NOCOLOR=${RC_NOCOLOR:-no}
+RC_ENDCOL="yes"
+RC_TTY_NUMBER=11
+RC_NET_STRICT_CHECKING="no"
+RC_PARALLEL_STARTUP="no"
+RC_USE_CONFIG_PROFILE="yes"
+RC_INDENTATION=''
+RC_DEFAULT_INDENT=2
+#RC_DOT_PATTERN=' .'
+RC_DOT_PATTERN=''
+[ -f /etc/conf.d/rc ] && source /etc/conf.d/rc
+
+#
+# Notify bootsplash/splashutils/gensplash/whatever about
+# important events.
+#
+
+esyslog() {
+ local pri=
+ local tag=
+
+ if [ -x /usr/bin/logger ]
+ then
+ pri="$1"
+ tag="$2"
+
+ shift 2
+ [[ -z "$*" ]] && return 0
+
+ /usr/bin/logger -p "${pri}" -t "${tag}" -- "$*"
+ fi
+
+ return 0
+}
+
+# void eindent(int num)
+#
+# increase the indent used for e-commands.
+#
+eindent() {
+ local i=$1
+ (( i > 0 )) || (( i = RC_DEFAULT_INDENT ))
+ esetdent $(( ${#RC_INDENTATION} + i ))
+}
+
+# void eoutdent(int num)
+#
+# decrease the indent used for e-commands.
+#
+eoutdent() {
+ local i=$1
+ (( i > 0 )) || (( i = RC_DEFAULT_INDENT ))
+ esetdent $(( ${#RC_INDENTATION} - i ))
+}
+
+# void esetdent(int num)
+#
+# hard set the indent used for e-commands.
+# num defaults to 0
+#
+esetdent() {
+ local i=$1
+ (( i < 0 )) && (( i = 0 ))
+ RC_INDENTATION=$(printf "%${i}s" '')
+}
+
+# void einfo(char* message)
+#
+# show an informative message (with a newline)
+#
+einfo() {
+ einfon "$*\n"
+ LAST_E_CMD=einfo
+ return 0
+}
+
+# void einfon(char* message)
+#
+# show an informative message (without a newline)
+#
+einfon() {
+ [[ ${RC_QUIET_STDOUT} == yes ]] && return 0
+ [[ ${RC_ENDCOL} != yes && ${LAST_E_CMD} == ebegin ]] && echo
+ echo -ne " ${GOOD}*${NORMAL} ${RC_INDENTATION}$*"
+ LAST_E_CMD=einfon
+ return 0
+}
+
+# void ewarn(char* message)
+#
+# show a warning message + log it
+#
+ewarn() {
+ if [[ ${RC_QUIET_STDOUT} == yes ]]; then
+ echo " $*"
+ else
+ [[ ${RC_ENDCOL} != yes && ${LAST_E_CMD} == ebegin ]] && echo
+ echo -e " ${WARN}*${NORMAL} ${RC_INDENTATION}$*"
+ fi
+
+ # Log warnings to system log
+ esyslog "daemon.warning" "rc-scripts" "$*"
+
+ LAST_E_CMD=ewarn
+ return 0
+}
+
+# void eerror(char* message)
+#
+# show an error message + log it
+#
+eerror() {
+ if [[ ${RC_QUIET_STDOUT} == yes ]]; then
+ echo " $*" >/dev/stderr
+ else
+ [[ ${RC_ENDCOL} != yes && ${LAST_E_CMD} == ebegin ]] && echo
+ echo -e " ${BAD}*${NORMAL} ${RC_INDENTATION}$*"
+ fi
+
+ # Log errors to system log
+ esyslog "daemon.err" "rc-scripts" "$*"
+
+ LAST_E_CMD=eerror
+ return 0
+}
+
+# void ebegin(char* message)
+#
+# show a message indicating the start of a process
+#
+ebegin() {
+ local msg="$*" dots spaces=${RC_DOT_PATTERN//?/ }
+ [[ ${RC_QUIET_STDOUT} == yes ]] && return 0
+
+ if [[ -n ${RC_DOT_PATTERN} ]]; then
+ dots=$(printf "%$(( COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7 ))s" '')
+ dots=${dots//${spaces}/${RC_DOT_PATTERN}}
+ msg="${msg}${dots}"
+ else
+ msg="${msg} ..."
+ fi
+ einfon "${msg}"
+ [[ ${RC_ENDCOL} == yes ]] && echo
+
+ LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} ))
+ LAST_E_CMD=ebegin
+ return 0
+}
+
+# void _eend(int error, char *efunc, char* errstr)
+#
+# indicate the completion of process, called from eend/ewend
+# if error, show errstr via efunc
+#
+# This function is private to functions.sh. Do not call it from a
+# script.
+#
+_eend() {
+ local retval=${1:-0} efunc=${2:-eerror} msg
+ shift 2
+
+ if [[ ${retval} == 0 ]]; then
+ [[ ${RC_QUIET_STDOUT} == yes ]] && return 0
+ msg="${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}"
+ else
+ if [[ -c /dev/null ]]; then
+ rc_splash "stop" &>/dev/null &
+ else
+ rc_splash "stop" &
+ fi
+ if [[ -n "$*" ]]; then
+ ${efunc} "$*"
+ fi
+ msg="${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}"
+ fi
+
+ if [[ ${RC_ENDCOL} == yes ]]; then
+ echo -e "${ENDCOL} ${msg}"
+ else
+ [[ ${LAST_E_CMD} == ebegin ]] || LAST_E_LEN=0
+ printf "%$(( COLS - LAST_E_LEN - 6 ))s%b\n" '' "${msg}"
+ fi
+
+ return ${retval}
+}
+
+# void eend(int error, char* errstr)
+#
+# indicate the completion of process
+# if error, show errstr via eerror
+#
+eend() {
+ local retval=${1:-0}
+ shift
+
+ _eend ${retval} eerror "$*"
+
+ LAST_E_CMD=eend
+ return $retval
+}
+
+# void ewend(int error, char* errstr)
+#
+# indicate the completion of process
+# if error, show errstr via ewarn
+#
+ewend() {
+ local retval=${1:-0}
+ shift
+
+ _eend ${retval} ewarn "$*"
+
+ LAST_E_CMD=ewend
+ return $retval
+}
+
+##############################################################################
+# #
+# This should be the last code in here, please add all functions above!! #
+# #
+# *** START LAST CODE *** #
+# #
+##############################################################################
+
+if [[ -n ${EBUILD} && $* == *depend* ]]; then
+ # We do not want stty to run during emerge depend
+ COLS=80
+else
+ # Setup COLS and ENDCOL so eend can line up the [ ok ]
+ COLS=${COLUMNS:-0} # bash's internal COLUMNS variable
+ (( COLS == 0 )) && COLS=$(stty size 2>/dev/null | cut -d' ' -f2)
+ (( COLS > 0 )) || (( COLS = 80 )) # width of [ ok ] == 7
+fi
+
+if [[ ${RC_ENDCOL} == yes ]]; then
+ ENDCOL=$'\e[A\e['$(( COLS - 7 ))'G'
+else
+ ENDCOL=''
+fi
+
+# Setup the colors so our messages all look pretty
+if [[ ${RC_NOCOLOR} == yes ]]; then
+ unset GOOD WARN BAD NORMAL HILITE BRACKET
+else
+ GOOD=$'\e[32;01m'
+ WARN=$'\e[33;01m'
+ BAD=$'\e[31;01m'
+ NORMAL=$'\e[0m'
+ HILITE=$'\e[36;01m'
+ BRACKET=$'\e[34;01m'
+fi
+
+ebegin "Generating daily report for ${LOG_TIME_SCHEMA}"
+ einfo "Analyzing log (${PATH_TO_LOGS}/${INPUT_SCHEMA})"
+ if [ -f "${PATH_TO_LOGS}/${INPUT_SCHEMA}" ];then
+ ${PATH_TO_PHP} ${PATH_TO_PGFOUINE} -f "${PATH_TO_LOGS}/${INPUT_SCHEMA}" > ${PATH_TO_REPORTS}/${OUTPUT_SCHEMA}
+ exitCode=0
+ else
+ exitCode=1
+ fi
+ sleep 1
+
+eend ${exitCode} "Failed to generate report"
diff --git a/dev-db/pgfouine/metadata.xml b/dev-db/pgfouine/metadata.xml
new file mode 100644
index 0000000..309b51e
--- /dev/null
+++ b/dev-db/pgfouine/metadata.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>postgresql</herd>
+</pkgmetadata>
diff --git a/dev-db/pgfouine/pgfouine-0.6.ebuild b/dev-db/pgfouine/pgfouine-0.6.ebuild
new file mode 100644
index 0000000..83e1823
--- /dev/null
+++ b/dev-db/pgfouine/pgfouine-0.6.ebuild
@@ -0,0 +1,191 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+inherit eutils webapp depend.php einput
+
+DESCRIPTION="Web-based PostgreSQL log analyzer used to determine which queries you should optimize to speed up your PostgreSQL based application."
+HOMEPAGE="http://pgfouine.projects.postgresql.org/"
+SRC_URI="http://pgfoundry.org/frs/download.php/912/${P}.tar.gz"
+LICENSE="GPL-2"
+KEYWORDS="~alpha ~amd64 ~hppa ~mips ~ppc ~sparc ~x86"
+IUSE="vhosts tests graphs"
+RDEPEND=">=dev-db/postgresql-7.3
+ sys-apps/findutils"
+
+pkg_setup() {
+ ewarn "Checking if PHP has been installed as a CLI"
+ ewarn "If the following fails, PHP needs to be compiled with the CLI use flag"
+ require_php_cli
+ webapp_pkg_setup
+ has_php
+ if use graphs;then
+ require_php_with_any_use "gd" "gd-external"
+ fi
+}
+
+src_unpack() {
+ unpack ${A}
+ cd ${S}
+ find ${S} -name rpm-specific\* -or \( -type d -name patches -prune \) -or \
+ \( -type f -name pgfouine.spec \) -exec rm -rf {} \;
+ if ! use tests;then
+ find ${S} -type d -name tests -prune -exec rm -rf {} \;
+ fi
+}
+
+src_compile() {
+ einfo "Nothing left to compile"
+}
+
+src_install() {
+ webapp_src_preinst
+ local docs="AUTHORS ChangeLog README COPYING THANKS INSTALL"
+ cd ${S}
+ dodoc ${docs}
+
+ rm -rf ${docs}
+
+ einfo "Installing main files into ${MY_MYHOSTROOTDIR}/${P}"
+ cp -rf . ${D}${MY_HOSTROOTDIR}/${P}
+ cp -f ${FILESDIR}/spgfouine ${D}${MY_HOSTROOTDIR}/${P}
+ insinto ${MY_MYHOSTROOTDIR}/${P}
+ webapp_src_install
+}
+
+pkg_postinst() {
+ webapp_pkg_postinst
+ einfo
+ einfo
+ einfo "Because of the irregularity of postgresql.conf files"
+ einfo "you will need to add/update the following variables to"
+ einfo "your own postgresql.conf manually to enable logging:"
+ einfo "log_duration = true"
+ einfo "log_min_duration_statement = 0"
+ if has_version '>=dev-db/postgresql-8';then
+ einfo "log_destination = 'syslog'"
+ pg8=1
+ else
+ einfo "syslog = 2"
+ pg8=0
+ fi
+ ewarn ""
+ ewarn "IMPORTANT: run emerge --config pgfouine"
+ ewarn ""
+}
+
+pkg_config() {
+ G_HOSTNAME="localhost"
+ webapp_read_config
+ szInstallPath=${ROOT}${VHOST_ROOT}/${PN}
+ has_php
+ szVerPath=${ROOT}${VHOST_ROOT}/${P}
+ szSysLogDir="/var/log/postgresql"
+ if has_version ">=app-admin/syslog-ng-1.0";then
+ einfo "The following config will help you setup:"
+ einfo
+ einfo "a) syslog-ng.conf rules for PostgreSQL logging"
+ einfo "b) cron to generate reports on a regular basis"
+ einfo
+ einput_confirm "Continue with setting up /etc/syslog-ng/syslog-ng.conf rules for PostgreSQL?"
+ if [ "${szLastAnswer}" == "y" ] || [ "${szLastAnswer}" == "yes" ];then
+ einfo
+ einfo "If you don't know what to do, the defaults denoted inside brackets usually suffice"
+ einfo "(just hit enter)"
+ einfo
+ if [ -w /etc/syslog-ng/syslog-ng.conf ];then
+ einput_confirm "Detected a syslog-ng.conf in /etc/syslog-ng/, is this the one you want to use?"
+ if [ "${szLastAnswer}" == "y" ] || [ "${szLastAnswer}" == "yes" ];then
+ szSysLogConf="/etc/syslog-ng/syslog-ng.conf"
+ else
+ einput_prompt "Please specify the path to your syslog-ng.conf" "/etc/syslog-ng/syslog-ng.conf"
+ fi
+ fi
+
+ if [ ! -w ${szSysLogConf} ];then
+ einput_prompt "Cannot use ${szSysLogConf}, please specify the path to a valid syslog-ng.conf" "/etc/syslog-ng/syslog-ng.conf"
+ if [ -w $szLastAnswer ];then
+ szSysLogConfpgfouine$2
+ else
+ eerror "Unable to find a writable syslog-ng.conf in $2. Exiting"
+ fi
+ fi
+ einput_prompt "syslog-ng filter?" "filter f_postgres { program(\"postgres\"); };"
+ szSysLogFilter=${szLastAnswer}
+ if [ ! -d /var/log/postgresql ];then
+ einput_prompt "Specify where I should attempt to create the PostgreSQL log directory" "/var/log/postgresql"
+ szSysLogDir=${szLastAnswer}
+ mkdir -p ${szLastAnswer}
+ fi
+ szDefaultDest="destination dest_postgres { file(\"${szSysLogDir}/log-sql.\$YEAR.\$MONTH.\$DAY\"); };"
+ einput_prompt "syslog-ng destination?" "${szDefaultDest}"
+ szSysLogDest="${szLastAnswer}"
+
+ if [ "${szSysLogDest}" != "${szDefaultDest}" ]; then
+ ewarn "${szSysLogDest}"
+ ewarn "Not using default destination rule, be sure to modify the INPUT_SCHEMA in ${szVerPath}/spgfouine"
+ ewarn "to reflect your changes!"
+ ewarn "${szDefaultDest}"
+ fi
+
+ einput_prompt "syslog-ng rule?" "log { source(src); filter(f_postgres); destination(dest_postgres); };"
+ szSysLogRule=${szLastAnswer}
+ einfo
+ einfo "The following will be written to ${szSysLogConf}"
+ einfo
+ einfo "${szSysLogFilter}"
+ einfo "${szSysLogDest}"
+ einfo "${szSysLogRule}"
+ einfo
+ einput_confirm "Continue with writing these rules to ${szSysLogConf}?"
+ if [ "${szLastAnswer}" == "y" ] || [ "${szLastAnswer}" == "yes" ];then
+ echo "${szSysLogFilter}" >> ${szSysLogConf}
+ echo "${szSysLogDest}" >> ${szSysLogConf}
+ echo "${szSysLogRule}" >> ${szSysLogConf}
+ einfo "Restarting syslog-ng"
+ /etc/init.d/syslog-ng restart
+ else
+ ewarn "Nothing written to ${szSysLogConf}, please add the rules"
+ ewarn "manually"
+ fi
+ fi
+ einput_confirm "Continue with setting up a daily cron job for reports?"
+ if [ ${szLastAnswer} == "y" ] || [ ${szLastAnswer} == "yes" ];then
+ einfo
+ einfo "Moving spgfouine from ${szVerPath}/spgfouine to /etc/cron.daily"
+ einfo
+ mv -f ${szVerPath}/spgfouine /etc/cron.daily
+ einfo
+ einfo "chmod'ing spgfouine to 0755"
+ einfo
+ chmod 0755 /etc/cron.daily/spgfouine
+ sed -i -re "s:PATH_TO_PHP=\"\":PATH_TO_PHP=\"${PHPCLI}\":g" /etc/cron.daily/spgfouine
+ sed -i -re "s:PATH_TO_LOGS=\"\":PATH_TO_LOGS=\"${szSysLogDir}\":g" /etc/cron.daily/spgfouine
+ sed -i -re "s:PATH_TO_REPORTS=\"\":PATH_TO_REPORTS=\"${szInstallPath}/reports\":g" /etc/cron.daily/spgfouine
+ sed -i -re "s:PATH_TO_PGFOUINE=\"\":PATH_TO_PGFOUINE=\"${szVerPath}/pgfouine.php\":g" /etc/cron.daily/spgfouine
+ if [ ! -d ${szInstallPath}/reports ];then
+ mkdir -p ${szInstallPath}/reports
+ einfo "Created ${szInstallPath}/reports"
+ fi
+ einfo
+ einfo "NOTE: By default reports will be put in"
+ einfo "${szInstallPath}/pgsql_report.\$YEAR.\$MONTH.\$DAY.html"
+ einfo "You can modify this and other paths by editing /etc/cron.daily/spgfouine"
+ einfo
+ fi
+ einfo "Nothing left to do :-)"
+ else
+ einfo "Syslog-ng is not emerged on this system. You will need to edit ${szVerPath}/spgfouine"
+ einfo "manually and setup your syslog rules accordingly. Please refer to"
+ einfo "http://pgfouine.projects.postgresql.org/tutorial.html"
+ einfo "for more information on how to do this."
+ einfo "You can use ${szVerPath}/spgfouine to automate report generation"
+ fi
+}
+
+pkg_postrm() {
+ if [ -e /etc/cron.daily/spgfouine ];then
+ ewarn "/etc/cron.daily/spgfouine exists, please remove this file"
+ ewarn "manually."
+ fi
+}