Ver código fonte

new package: cacti 0.8.2a (Network Monitoring and Graphing Frontend)

Ralf S. Engelschall 22 anos atrás
pai
commit
5b4a2b4397
4 arquivos alterados com 371 adições e 0 exclusões
  1. 97 0
      cacti/cacti-apache.conf
  2. 21 0
      cacti/cacti-setup.sh
  3. 207 0
      cacti/cacti.spec
  4. 46 0
      cacti/rc.cacti

+ 97 - 0
cacti/cacti-apache.conf

@@ -0,0 +1,97 @@
+##
+##  cacti-apache.conf -- Cacti Apache Custom Configuration
+##
+
+ServerType             standalone
+ServerRoot             @l_prefix@
+ServerAdmin            root@@l_hostname@.@l_domainname@
+ServerName             @l_hostname@.@l_domainname@
+ServerTokens           Prod
+User                   @l_rusr@
+Group                  @l_rgrp@
+Port                   8080
+Listen                 127.0.0.1:8080
+
+#   runtime files
+PidFile                @l_prefix@/var/cacti/run/apache.pid
+ScoreBoardFile         @l_prefix@/var/cacti/run/apache.sb
+LockFile               @l_prefix@/var/cacti/run/apache.lck
+
+#  server behaviour
+Timeout                300
+KeepAlive              on
+MaxKeepAliveRequests   100
+KeepAliveTimeout       15
+MinSpareServers        5
+MaxSpareServers        10
+StartServers           5
+MaxClients             15
+MaxRequestsPerChild    500
+HostnameLookups        off
+UseCanonicalName       on
+
+#   access logging
+LogFormat              "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
+LogFormat              "%h %l %u %t \"%r\" %>s %b" common
+LogFormat              "%{Referer}i -> %U" referer
+LogFormat              "%{User-agent}i" agent
+CustomLog              @l_prefix@/var/cacti/log/apache.access.log common
+
+#   error logging
+LogLevel               warn
+ErrorLog               @l_prefix@/var/cacti/log/apache.error.log
+ServerSignature        on
+
+#   secure root directory
+<Directory />
+    Options FollowSymLinks
+    AllowOverride None
+</Directory>
+
+#   browser specifics
+BrowserMatch "Mozilla/2"       nokeepalive
+BrowserMatch "MSIE 4\.0b2;"    nokeepalive downgrade-1.0 force-response-1.0
+BrowserMatch "RealPlayer 4\.0" force-response-1.0
+BrowserMatch "Java/1\.0"       force-response-1.0
+BrowserMatch "JDK/1\.0"        force-response-1.0
+
+#   SSL/TLS support
+<IfModule mod_ssl.c>
+    SSLRandomSeed           startup builtin
+    SSLRandomSeed           connect builtin
+    SSLMutex                sem
+    SSLSessionCache         shmcb:@l_prefix@/var/cacti/run/apache.scache(512000)
+    SSLSessionCacheTimeout  300
+    SSLLog                  @l_prefix@/var/cacti/log/apache.ssl.log
+    SSLLogLevel             warn
+    SSLCipherSuite          ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
+    SetEnvIf User-Agent ".*MSIE.*" \
+             nokeepalive ssl-unclean-shutdown \
+             downgrade-1.0 force-response-1.0
+    <Files ~ "\.(cgi|shtml|phtml|php?)$">
+        SSLOptions +StdEnvVars
+    </Files>
+    <Directory "@l_prefix@/cgi">
+        SSLOptions +StdEnvVars
+    </Directory>
+</IfModule>
+
+#   configure PHP
+AddType           application/x-httpd-php .php
+php_admin_flag    register_globals   on
+php_admin_flag    register_argc_argv on
+php_admin_flag    safe_mode          on
+
+#   configure Cacti
+RewriteEngine     on
+RewriteRule       ^/$ /cacti/ [R,L]
+Alias             /cacti @l_prefix@/share/cacti
+DocumentRoot      @l_prefix@/share/cacti
+DirectoryIndex    index.php index.html
+<Directory        "@l_prefix@/share/cacti">
+    Options       FollowSymLinks
+    AllowOverride None
+    Order         allow,deny
+    Allow         from all
+</Directory>
+

+ 21 - 0
cacti/cacti-setup.sh

@@ -0,0 +1,21 @@
+#!/bin/sh
+##
+##  cacti-setup
+##
+
+#   determine MySQL root password
+password=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\
+          sed -e 's;^password[^=]*= *;;' -e 's; *$;;'`
+
+#   create the MySQL database for Cacti
+@l_prefix@/bin/mysqladmin --user=root --password=$password create cacti
+
+#   create the default Cacti database schema
+@l_prefix@/bin/mysql --user=root --password=$password cacti <@l_prefix@/share/cacti/cacti.sql
+
+#   create a MySQL username/password for Cacti
+@l_prefix@/bin/mysql --user=root --password=$password mysql <<EOF
+GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cacti';
+FLUSH PRIVILEGES;
+EOF
+

+ 207 - 0
cacti/cacti.spec

@@ -0,0 +1,207 @@
+##
+##  cacti.spec -- OpenPKG RPM Specification
+##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
+##  Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.com/>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   package information
+Name:         cacti
+Summary:      Network Monitoring and Graphing Frontend
+URL:          http://www.raxnet.net/products/cacti/
+Vendor:       raXnet
+Packager:     The OpenPKG Project
+Distribution: OpenPKG [EVAL]
+Group:        Database
+License:      GPL
+Version:      0.8.2a
+Release:      20030819
+
+#   list of sources
+Source0:      http://www.raxnet.net/downloads/cacti-%{version}.tar.gz
+Source1:      cacti-setup.sh
+Source2:      cacti-cron.sh
+Source3:      cacti-apache.conf
+Source4:      rc.cacti
+
+#   build information
+Prefix:       %{l_prefix}
+BuildRoot:    %{l_buildroot}
+BuildPreReq:  OpenPKG, openpkg >= 20030103
+PreReq:       OpenPKG, openpkg >= 20030103
+PreReq:       rrdtool, mysql, snmp, perl, php, wget
+PreReq:       apache
+PreReq:       apache::with_mod_php = yes
+PreReq:       apache::with_mod_php_mysql = yes
+AutoReq:      no
+AutoReqProv:  no
+
+%description
+    Cacti is a complete frontend to RRDTool, it stores all of the
+    necessary information to create graphs and populate them with data
+    in a MySQL database. The frontend is completely PHP driven. Along
+    with being able to maintain Graphs, Data Sources, and Round Robin
+    Archives in a database, Cacti handles the data gathering. There is
+    also SNMP support for those used to creating traffic graphs with
+    MRTG.
+
+%prep
+    %setup -q
+
+%build
+
+%install
+    rm -rf $RPM_BUILD_ROOT
+
+    #   create installation hierarchy
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/sbin \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/cacti \
+        $RPM_BUILD_ROOT%{l_prefix}/share/cacti \
+        $RPM_BUILD_ROOT%{l_prefix}/var/cacti/run
+
+    #   adjust configuration
+    %{l_shtool} subst \
+        -e 's;"cactiuser";"cacti";g' \
+        include/config.php
+    %{l_shtool} subst \
+        -e 's;perl <path_cacti>;%{l_prefix}/bin/perl %{l_prefix}/share/cacti;' \
+        -e 's;\(path_php_binary.*\)<DEFAULT>;\1%{l_prefix}/bin/php;' \
+        -e 's;\(path_snmpwalk.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpwalk;' \
+        -e 's;\(path_snmpget.*\)<DEFAULT>;\1%{l_prefix}/bin/snmpget;' \
+        -e 's;\(path_rrdtool.*\)<DEFAULT>;\1%{l_prefix}/bin/rrdtool;' \
+        -e 's;\(path_webroot.*\)<DEFAULT>;\1%{l_prefix}/share/cacti;' \
+        -e 's;\(path_webcacti.*\)<DEFAULT>;\1/cacti/;' \
+        -e 's;\(smnp_version.*\)ucd-snmp;\1net-snmp;' \
+        cacti.sql
+    %{l_shtool} subst \
+        -e 's;docs/;../docs/;g' \
+        install/index.php
+
+    #   install all files and strip down installation afterwards
+    cp -rp * $RPM_BUILD_ROOT%{l_prefix}/share/cacti/
+    ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
+      rm -f LICENSE README
+      rm -rf cactid
+      ( mv include/adodb/drivers/adodb-mysql* .
+        rm -rf include/adodb/drivers/*
+        mv adodb-mysql* include/adodb/drivers/
+        mv include/adodb/datadict/datadict-mssql* .
+        rm -rf include/adodb/datadict/*
+        mv datadict-mssql* include/adodb/datadict/
+      ) || exit $?
+      rm -f rra/.placeholder
+      rm -f log/rrd.log
+    ) || exit $?
+
+    #   move variable data into separate locations
+    mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log \
+       $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log
+    %{l_shtool} mkln -s \
+       $RPM_BUILD_ROOT%{l_prefix}/var/cacti/log \
+       $RPM_BUILD_ROOT%{l_prefix}/share/cacti/log
+    mv $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra \
+       $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra
+    %{l_shtool} mkln -s \
+       $RPM_BUILD_ROOT%{l_prefix}/var/cacti/rra \
+       $RPM_BUILD_ROOT%{l_prefix}/share/cacti/rra
+
+    #   internally Cacti appends the webroot to its directory
+    #   but we don't want to do this, so use a self-ref link.
+    ( cd $RPM_BUILD_ROOT%{l_prefix}/share/cacti
+      ln -s . cacti
+    ) || exit $?
+
+    #   install run-command script
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        %{SOURCE rc.cacti} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
+    #   install MySQL database setup script
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        %{SOURCE cacti-setup.sh} \
+        $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-setup
+
+    #   install Cron job script
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        %{SOURCE cacti-cron.sh} \
+        $RPM_BUILD_ROOT%{l_prefix}/sbin/cacti-cron
+
+    #   install custom Apache configuration
+    l_hostname=`%{l_shtool} echo -e %h`
+    l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        -e "s;@l_hostname@;$l_hostname;g" \
+        -e "s;@l_domainname@;$l_domainname;g" \
+        %{SOURCE cacti-apache.conf} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/cacti/
+
+    #   determine installation files
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+        %{l_files_std} \
+        '%config %{l_prefix}/etc/cacti/*' \
+        '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/cacti'
+
+%files -f files
+
+%clean
+    rm -rf $RPM_BUILD_ROOT
+
+%post
+    if [ $1 -eq 1 ]; then
+        #   display final hints on initial installation
+        ( echo "1. To complete installation of the Cacti package please you have"
+          echo "   start MySQL and setup the initial Cacti database. For this run"
+          echo "   the following commands:"
+          echo "     \$ $RPM_INSTALL_PREFIX/etc/rc mysql start"
+          echo "     \$ $RPM_INSTALL_PREFIX/sbin/cacti-setup"
+          echo "     \$ $RPM_INSTALL_PREFIX/etc/rc mysql stop"
+          echo ""
+          echo "2. Cacti by default is run by the OpenPKG cron jobs every 15"
+          echo "   minutes only. Usually Cacti wants to run every 5 minutes for"
+          echo "   more granular data gathering. For this set:"
+          echo "     # $RPM_INSTALL_PREFIX/etc/rc.conf:"
+          echo "     cacti_cron=\"no\""
+          echo "   and setup a cronjob for user %{l_rusr}"
+          echo "     # system crontab:"
+          echo "     */5 * * * * %{l_rusr} $RPM_INSTALL_PREFIX/sbin/cacti-cron"
+          echo ""
+          echo "3. Cacti by default is running with an own Apache server on"
+          echo "   IPv4 address 127.0.0.1, TCP port 8080. Please change this"
+          echo "   by editing the \"Port 8080\" and \"Listen 127.0.0.1:8080\""
+          echo "   directives in $RPM_INSTALL_PREFIX/etc/cacti/cacti-apache.conf"
+          echo ""
+          echo "4. After this post-installation steps, startup Cacti by running"
+          echo "     \$ $RPM_INSTALL_PREFIX/etc/rc cacti start"
+          echo "   and connecting with your browser to:"
+          echo "     http://127.0.0.1:8080/"
+          echo "   Then proceed Cacti's initial configuration dialog. Then login"
+          echo "   as 'admin' (with initial password 'admin') and change the"
+          echo "   password to a custom one."
+        ) | %{l_rpmtool} msg -b -t notice
+    fi
+
+%preun
+    if [ $1 -eq 0 ]; then
+        #   remove generated logfiles
+        rm -f $RPM_INSTALL_PREFIX/var/cacti/log/*
+    fi
+

+ 46 - 0
cacti/rc.cacti

@@ -0,0 +1,46 @@
+#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
+##
+##  rc.cacti -- Run-Commands
+##
+
+%config
+    cacti_enable="$openpkg_rc_def"
+    cacti_cron="yes"
+
+%status -u @l_susr@ -o
+    cacti_usable="no"
+    cacti_active="no"
+    @l_prefix@/sbin/apache -t \
+        -f @l_prefix@/etc/cacti/cacti-apache.conf 2>/dev/null && \
+        cacti_usable="yes"
+    [ -f @l_prefix@/var/cacti/run/apache.pid ] && \
+        kill -0 `cat @l_prefix@/var/cacti/run/apache.pid` && \
+        cacti_active="yes"
+    echo "cacti_enable=\"$cacti_enable\""
+    echo "cacti_usable=\"$cacti_usable\""
+    echo "cacti_active=\"$cacti_active\""
+
+%start -u @l_susr@
+    rcService cacti enable yes || exit 0
+    rcService cacti active yes && exit 0
+    @l_prefix@/sbin/apache \
+        -f @l_prefix@/etc/cacti/cacti-apache.conf
+
+%stop -u @l_susr@
+    rcService cacti enable yes || exit 0
+    rcService cacti active no  && exit 0
+    [ -f @l_prefix@/var/cacti/run/apache.pid ] && \
+        kill -TERM `cat @l_prefix@/var/cacti/run/apache.pid`
+    sleep 2
+
+%restart -u @l_susr@
+    rcService cacti enable yes || exit 0
+    rcService cacti active no  && exit 0
+    rc cacti stop start
+
+%quarterly -u @l_rusr@
+    rcService cacti enable yes || exit 0
+    if [ ".$cacti_cron" = .yes ]; then
+        @l_prefix@/sbin/cacti-cron
+    fi
+