File manager - Edit - /home/veronikagstoette/public_html/fastcomet.zip
Back
PK �K#]�e�s5 5 , nightwatch/debian/fastcomet-nightwatch.prermnu ȯ�� #!/bin/sh set -e invoke-rc.d nightwatch stop || true PK �K#]�[1 nightwatch/debian/compatnu �[��� 7 PK �K#]�y[� � 0 nightwatch/debian/fastcomet-nightwatch.templatesnu �[��� Template: Nightwatch/APIKey Type: string Default: Description: Please enter your Nightwatch API Key: Please enter your Nightwatch API Key. Template: Nightwatch/apache-location Type: string Default: Description: Mod_Status URL: Not really for human consumption. Template: Nightwatch/apache-try-configure Type: boolean Default: Description: Autoconfigure Mod_Status: Nightwatch has detected Apache running on this server but was unable to access the server status page. Would you like to attempt to automatically configure mod_status? This will require reloading Apache to enable. Template: Nightwatch/nginx-location Type: string Default: Description: Nginx Status URL: Not really for human consumption. Template: Nightwatch/nginx-try-configure Type: boolean Default: Description: Autoconfigure status page: Nightwatch has detected Nginx running on this server but was unable to access the server status page. Would you like to attempt to automatically configure the Nginx status module? This will require restarting Nginx to enable. Template: Nightwatch/mysql-create-creds Type: note Default: Description: Unable to automatically configure MySQL plugin: Nightwatch has detected MySQL running on this server but was unable to automatically configure the connection. To allow Nightwatch to access your MySQL instance please run the following queries: ${create_statement} FLUSH PRIVILEGES; Template: Nightwatch/mysql-overwrite-creds Type: boolean Default: Description: Overwrite existing Nightwatch MySQL config: Nightwatch has detected MySQL running on this server but was unable to log in with the provided credentials for the '${found_user}' user. However a 'debian-sys-maint' user was found, would you like to configure nightwatch to use those credentials instead? Template: Nightwatch/mysql-password Type: string Default: Description: Nightwatch Mysql user password: Not really for human consumption. PK �K#]�C�KZ Z - nightwatch/debian/fastcomet-nightwatch.confignu ȯ�� #!/bin/sh set -e nightwatch_config_dir='/etc/fastcomet/nightwatch.d/' echoerr() { echo "$@" 1>&2; } _fake_curl() { _input_url=$1 PERL_LWP_SSL_VERIFY_HOSTNAME=0 perl -MLWP::UserAgent -e '$ua=LWP::UserAgent->new(); print $ua->get("$ARGV[0]")->decoded_content;' "$1" return 0 } _check_apache_url() { _apache_url=$1 _fake_curl "$_apache_url" | grep -q 'Scoreboard:' return $? } _check_nginx_url() { _nginx_url=$1 _fake_curl "$_nginx_url" | grep -q 'server accepts handled requests' return $? } _mysql_check_install() { _mysql_username=$1 _mysql_password=$2 perl -MDBI -e "eval { local \$SIG{ALRM} = sub { die; }; alarm(5); \$dbh = DBI->connect('DBI:mysql:host=localhost', '$_mysql_username', '$_mysql_password'); exit \$DBI::err; alarm(0); }; exit 1 if \$@" return $? } apache_status_path() { echoerr "Checking Apache configuration..." apache_config_filename=${nightwatch_config_dir}Apache.conf apache_default_url='http://127.0.0.1/server-status?auto' apache_default_https='https://127.0.0.1/server-status?auto' apache_url=$(grep '^location' $apache_config_filename | tail -n1 | awk '{print $2}') # use the url if it exists if [ ! -z $apache_url ]; then if _check_apache_url $apache_url ; then echoerr "Found Apache status page at $apache_url specified in $apache_config_filename" db_set Nightwatch/apache-location "" return 0 elif [ "$apache_url" = "$apache_default_url" ]; then echoerr "Attempt to access $apache_url specified in $apache_config_filename failed..." else echoerr "Attempt to access $apache_url specified in $apache_config_filename failed...trying default" if _check_apache_url $apache_default_url; then echoerr "Found Apache status page at $apache_default_url (default URL)" db_set Nightwatch/apache-location "$apache_default_url" return 0; elif _check_apache_url $apache_default_https; then echoerr "Found Apache status page at $apache_default_https" db_set Nightwatch/apache-location "$apache_default_https" return 0; fi fi else if _check_apache_url $apache_default_url; then echoerr "Found Apache status page at $apache_default_url (default URL)" db_set Nightwatch/apache-location "$apache_default_url" return 0; elif _check_apache_url $apache_default_https; then echoerr "Found Apache status page at $apache_default_https" db_set Nightwatch/apache-location "$apache_default_https" return 0; fi fi # really ghetto url extraction guess_url=$(grep '^ *<Location' /etc/apache2/mods-enabled/status.conf 2>/dev/null | head -n1 | sed 's/>$//' | awk '{print $2}') if [ ! -z $guess_url ]; then if _check_apache_url http://127.0.0.1$guess_url?auto; then echoerr "Found Apache status page at http://127.0.0.1$guess_url?auto" db_set Nightwatch/apache-location "http://127.0.0.1$guess_url?auto" return 0 fi fi db_set Nightwatch/apache-location "$apache_default_url" db_fset Nightwatch/apache-try-configure seen "false" db_input high Nightwatch/apache-try-configure } nginx_status_path(){ echoerr "Checking Nginx configuration..." nginx_config_filename=${nightwatch_config_dir}Nginx.conf nginx_default_url='http://127.0.0.1/nginx_status' nginx_default_https='https://127.0.0.1/nginx_status' nginx_url=$(grep '^location' $nginx_config_filename 2>/dev/null | tail -n1 | awk '{print $2}') # use the url if it exists if [ ! -z $nginx_url ]; then if _check_nginx_url $nginx_url; then echoerr "Found nginx status page at $nginx_url specified in $nginx_config_filename" db_set Nightwatch/nginx-location "" return 0 elif [ "$nginx_url" = "$nginx_default_url" ]; then echoerr "Attempt to access $nginx_url specified in $nginx_config_filename failed..." else echoerr "Attempt to access $nginx_url specified in $nginx_config_filename failed...trying default" if _check_nginx_url $nginx_default_url; then echoerr "Found nginx status page at $nginx_default_url (default URL)" db_set Nightwatch/nginx-location "" return 0; elif _check_nginx_url $nginx_default_https; then echoerr "Found nginx status page at $nginx_default_https" db_set Nightwatch/nginx-location "$nginx_default_https" return 0; fi fi fi if _check_nginx_url $nginx_default_url; then echoerr "Found nginx status page at $nginx_default_url (default URL)" db_set Nightwatch/nginx-location "" return 0; elif _check_nginx_url $nginx_default_https; then echoerr "Found nginx status page at $nginx_default_https" db_set Nightwatch/nginx-location "$nginx_default_https" return 0; fi # don't be smart unless we know where to work if [ ! -d /etc/nginx/sites-enabled ]; then echoerr "Unable to automatically configure nginx for Nightwatch. Please see https://library.linode.com/nightwatch/nightwatch-for-nginx#sph_manual-configuration-all-distributions" db_set Nightwatch/nginx-location "" return 0 fi # this is kind of weird # check to make sure that the haxor mode is gonna work if grep -ri '^[[:space:]]*server_name.*127\.0\.0\.2' /etc/nginx/sites-enabled; then echoerr "Unable to automatically configure nginx for Nightwatch. Please see https://library.linode.com/nightwatch/nightwatch-for-nginx#sph_manual-configuration-all-distributions" db_set Nightwatch/nginx-location "" return 0 fi if [ -e /etc/nginx/sites-available/nightwatch ]; then if _check_nginx_url http://127.0.0.2/nginx_status; then echoerr "Found location configured by Nightwatch previously." db_set Nightwatch/nginx-location "http://127.0.0.2/nginx_status" return 0 fi echoerr "Unable to automatically configure nginx for Nightwatch. Please see https://library.linode.com/nightwatch/nightwatch-for-nginx#sph_manual-configuration-all-distributions" db_set Nightwatch/nginx-location "" return 0 fi db_input high Nightwatch/nginx-try-configure || true } mysql_cred_check() { echoerr "Checking MySQL configuration..." mysql_config_filename=${nightwatch_config_dir}MySQL.conf mysql_username=$(grep '^username' $mysql_config_filename 2>/dev/null | tail -n1 | awk '{print $2}') mysql_password=$(grep '^password' $mysql_config_filename 2>/dev/null | tail -n1 | awk '{print $2}') if [ ! -z $mysql_username ] && [ ! -z $mysql_password ]; then if _mysql_check_install $mysql_username $mysql_password; then echoerr "Successfully connected to MySQL with the credentials located in $mysql_config_filename" db_set Nightwatch/mysql-password "" return 0 else echoerr "Unable to connect using the credentials specified in $mysql_config_filename...trying Debian maintenance user" fi fi if [ -e /etc/mysql/debian.cnf ]; then mysql_password=$(egrep '^\s*password\s*=\s*' /etc/mysql/debian.cnf | head -n1 | sed 's/^\s*password\s*=\s*//') if _mysql_check_install debian-sys-maint $mysql_password; then echoerr "Successfully connected to MySQL" db_set Nightwatch/mysql-password "" if [ ! -z $mysql_username ] && [ ! -z $mysql_password ]; then db_subst Nightwatch/mysql-overwrite-creds found_user "$mysql_username" db_input high Nightwatch/mysql-overwrite-creds || true fi return 0 fi fi mysql_username='fastcomet-nightwatch' mysql_password=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32) create_statement="CREATE USER 'fastcomet-nightwatch'@'localhost' IDENTIFIED BY '$mysql_password';" db_set Nightwatch/mysql-password "$mysql_password" db_subst Nightwatch/mysql-create-creds create_statement "$create_statement" db_input high Nightwatch/mysql-create-creds || true } . /usr/share/debconf/confmodule db_input medium Nightwatch/APIKey || true if pgrep -f 'httpd|apache2' >/dev/null; then apache_status_path fi if pgrep -f 'nginx' >/dev/null; then nginx_status_path fi if pgrep -f 'mysqld' >/dev/null; then mysql_cred_check fi db_go || true PK �K#]hU�R� � nightwatch/debian/copyrightnu �[��� Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: linode-longview Source: https://github.com/linode Files: * Copyright: 2013 Linode, LLC License: GPL-2.0/Perl Artistic License Files: debian/* Copyright: 2013 Linode, LLC License: GPL-2.0/Perl Artistic License License: GPL-2.0/Perl Artistic License Copyright 2013 Linode, LLC. Longview is made available under the terms of the Perl Artistic License, or GPLv2 at the recipients discretion. Perl Artistic License Read it at: http://dev.perl.org/licenses/artistic.html GNU General Public License (GPL) Version 2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-2'. See the full license at http://www.gnu.org/licenses/ PK �K#] TJ�� � nightwatch/debian/rulesnu ȯ�� #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # # Modified to make a template file for a multi-binary package with separated # build-arch and build-indep targets by Bill Allombert 2001 # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This has to be exported to make some magic below work. export DH_OPTIONS override_dh_auto_build: override_dh_auto_install: override_dh_pysupport: %: dh $@ PK �K#]t�|� � - nightwatch/debian/fastcomet-nightwatch.postrmnu ȯ�� #!/bin/sh set -e if [ "$1" = "purge" ]; then . /usr/share/debconf/confmodule db_purge db_stop fi if [ "$1" = "upgrade" ]; then exit 0 fi if [ "$1" = "remove" -o "$1" = "purge" ]; then update-rc.d -f nightwatch remove fiPK �K#]�|�� . nightwatch/debian/fastcomet-nightwatch.installnu �[��� Fastcomet/* opt/fastcomet/nightwatch/Fastcomet/ Extras/app-report.pl opt/fastcomet/nightwatch/Extras/ Extras/Modules/Packages/APT.pm opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Packages/ Extras/init/nightwatch etc/init.d Extras/conf/* etc/fastcomet/nightwatch.d/ PK �K#] 0 nightwatch/debian/fastcomet-nightwatch.conffilesnu �[��� PK �K#]��.� � nightwatch/debian/controlnu �[��� Source: fastcomet-nightwatch Section: utils Priority: optional Maintainer: Fastcomet Nightwatch Team Build-Depends: debhelper (>= 8.0.0) Standards-Version: 3.9.3 Homepage: https://www.fastcomet.com/ Package: fastcomet-nightwatch Architecture: all Depends: libjson-perl, libwww-perl, libcrypt-ssleay-perl | liblwp-protocol-https-perl, libio-socket-ssl-perl, libio-socket-inet6-perl, liblog-loglite-perl, libtry-tiny-perl, libdbi-perl, libdbd-mysql-perl, liblinux-distribution-perl, ${misc:Depends}, ${perl:Depends} Description: Nightwatch Monitoring Agent This agent collects various system wide statistics and post them to the Nightwatch collection endpoint. PK �K#]�ۃ� � nightwatch/debian/changelognu �[��� fastcomet-nightwatch (1.1.5) stable; urgency=low * fix naming issues in debian installation files * Update README.m * Fix warnings when apache regex doesn't match * Fix for issue #5, cpu core fix in SysInfo.pm * Fix for issue #16, typo in fastcomet-nightwatch.postinst -- James Ottinger <jottinger@linode.com> Wed, 20 Apr 2016 10:23:35 -0400 fastcomet-nightwatch (1.1.4) stable; urgency=low * Add a timeout via sig alarm when posting data -- Peter Sandin <psandin@linode.com> Thu, 06 Mar 2014 13:30:47 -0500 fastcomet-nightwatch (1.1.3) stable; urgency=low * Match the longname of a process more accurately * Added diagnostic tool for Application module configuration -- Peter Sandin <psandin@linode.com> Mon, 06 Jan 2014 17:06:16 +0000 fastcomet-nightwatch (1.1.2) stable; urgency=low * Better checks for applications when invoked with fully qualified paths * Better handling of sector size for physical disks * Improved backwards compatibility for allowing certificate errors on local host with older LWP * Various bug fixes -- Peter Sandin <psandin@linode.com> Fri, 22 Nov 2013 17:27:12 -0500 fastcomet-nightwatch (1.1.1) stable; urgency=low * Support HTTPS for web server status pages * Increase log verbosity * Various bug fixes -- Peter Sandin <psandin@linode.com> Tue, 12 Nov 2013 17:37:01 -0500 fastcomet-nightwatch (1.1.0.3) stable; urgency=low * Fix flags on update-rc.d when purging -- Peter Sandin <psandin@linode.com> Tue, 05 Nov 2013 14:36:29 -0500 fastcomet-nightwatch (1.1.0.2) stable; urgency=low * Removed bashism from Nginx rollback -- Peter Sandin <psandin@linode.com> Tue, 05 Nov 2013 12:44:58 -0500 fastcomet-nightwatch (1.1.0.1) stable; urgency=low [ Stan Schwertly ] * Pure perl implementation of timeout in MySQL check -- Peter Sandin <psandin@linode.com> Mon, 04 Nov 2013 14:12:09 -0500 fastcomet-nightwatch (1.1.0) stable; urgency=low * Support for automatically loading modules under the DataGetter package * New modules for gathering MySQL, Apache, and Nginx specific statistics -- Peter Sandin <psandin@linode.com> Mon, 04 Nov 2013 12:03:52 -0500 fastcomet-nightwatch (1.0.1) stable; urgency=low * Collect disk usage in both operations per second and bytes per second * Fix typo in export for Util.pm * Fix parent disks sometimes inheriting the properties of their children -- Peter Sandin <psandin@linode.com> Tue, 01 Oct 2013 08:22:59 -0400 fastcomet-nightwatch (1.0.0) stable; urgency=low * Identify system architecture/integer size better * Improve processor model detection -- Peter Sandin <psandin@linode.com> Wed, 04 Sep 2013 23:29:13 -0400 fastcomet-nightwatch (0.2.7) stable; urgency=low * Check for package updates more efficiently by checking the modified times on package cache files * Nightwatch now identifies itself even when /proc/pid/status shows its name as perl * Nightwatch now uses paths relative to Nightwatch.pl to locate modules and dependancies * Perl 5.8 compatibility -- Peter Sandin <psandin@linode.com> Wed, 28 Aug 2013 17:05:04 -0400 fastcomet-nightwatch (0.2.6.1) stable; urgency=low * Fix control data for Log::LogLite -- Peter Sandin <psandin@linode.com> Thu, 22 Aug 2013 16:17:02 -0400 fastcomet-nightwatch (0.2.6) stable; urgency=low * Improved handling of falling back to IPv4 when IPv6 is unavailable * Fixed runtime addition of api keys * Performance improvements in port monitoring for high traffic systems * Replaced Log::Log4Perl with Log::LogLite * LVM disks now consistently name keys for IO and FS statistics -- Peter Sandin <psandin@linode.com> Thu, 22 Aug 2013 16:01:43 -0400 fastcomet-nightwatch (0.2.5) stable; urgency=low * 2nd beta release. * Escape dots in mount point and device paths * Remove Linux::APT dependancy * Fix IPv6 address formatting in ports listing * Try to avoid locking conflicts when checking for package updates * Fix regex for rx and tx bytes under networking -- Peter Sandin <psandin@linode.com> Thu, 27 Jun 2013 16:00:13 -0400 PK �K#]a��h% % / nightwatch/debian/fastcomet-nightwatch.postinstnu ȯ�� #!/bin/sh set -e nightwatch_config_dir='/etc/fastcomet/nightwatch.d/' echoerr() { echo "$@" 1>&2; } _fake_curl() { _input_url=$1 PERL_LWP_SSL_VERIFY_HOSTNAME=0 perl -MLWP::UserAgent -e '$ua=LWP::UserAgent->new(); print $ua->get("$ARGV[0]")->decoded_content;' "$1" return 0 } _check_apache_url() { _apache_url=$1 _fake_curl "$_apache_url" | grep -q 'Scoreboard:' return $? } _check_nginx_url() { _nginx_url=$1 _fake_curl "$_nginx_url" | grep -q 'server accepts handled requests' return $? } _write_option(){ _write_file=$1 _checked_directive=$2 _value=$3 if egrep "^\s*$_checked_directive[[:space:]]+\S+" $_write_file >/dev/null; then sed -i "s|^\s*$_checked_directive.*|$_checked_directive $_value|g" $_write_file else if ! tail -c1 $_write_file | grep '^$' >/dev/null; then echo "" >> $_write_file fi echo "$_checked_directive $_value" >> $_write_file fi } apache_install() { apache_config_filename=${nightwatch_config_dir}Apache.conf db_get Nightwatch/apache-location location="$RET" if [ ! -z "$location" ]; then _write_option $apache_config_filename location "$location" apache_url="$location" else apache_url='http://127.0.0.1/server-status?auto' fi db_fset Nightwatch/apache-try-configure seen "false" db_get Nightwatch/apache-try-configure if [ "$RET" != "true" ]; then return 0 fi db_set Nightwatch/apache-try-configure "false" # check for mod_status if [ ! -e /etc/apache2/mods-enabled/status.conf ]; then if ! a2enmod status; then echoerr "Unable to enable mod_status for Apache. Please see https://library.linode.com/nightwatch/nightwatch-for-apache#sph_manual-configuration-all-distributions for instructions on configuring Apache to work with Nightwatch" return 1 fi else pre_existing_status="true" fi cat >> /etc/apache2/mods-enabled/status.conf <<END <IfModule mod_status.c> ExtendedStatus On <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 </Location> </IfModule> END apache_url_https=`echo $apache_url | sed 's/^http/https/'` if /etc/init.d/apache2 reload; then if _check_apache_url $apache_url; then _write_option $apache_config_filename location "$apache_url" echoerr "Apache mod_status enabled" return 0 elif _check_apache_url $apache_url_https; then _write_option $apache_config_filename location "$apache_url_https" return 0; fi fi echoerr "Enabling mod_status for Apache failed. Rolling back changes" if [ -z "$pre_existing_status" ]; then a2dismod status fi head -n -9 /etc/apache2/mods-available/status.conf | tee /etc/apache2/mods-available/status.conf > /dev/null /etc/init.d/apache2 reload echoerr "Please see https://library.linode.com/nightwatch/nightwatch-for-apache#sph_manual-configuration-all-distributions for instructions on configuring Apache to work with Nightwatch. Auto-configuration failed" } nginx_install() { nginx_config_filename=${nightwatch_config_dir}Nginx.conf db_get Nightwatch/nginx-location location="$RET" if [ ! -z "$location" ]; then _write_option $nginx_config_filename location "$location" return 0 fi db_fset Nightwatch/nginx-try-configure seen "false" db_get Nightwatch/nginx-try-configure if [ "$RET" != "true" ]; then return 0 fi db_set Nightwatch/nginx-try-configure "false" cat >> /etc/nginx/sites-available/nightwatch <<END server { listen 127.0.0.2:80; server_name 127.0.0.2; location /nginx_status { stub_status on; allow 127.0.0.1; deny all; } } END ln -s /etc/nginx/sites-available/nightwatch /etc/nginx/sites-enabled/ if [ -h /etc/nginx/sites-enabled/nightwatch ]; then if /etc/init.d/nginx restart; then if _check_nginx_url http://127.0.0.2/nginx_status; then echoerr "Finished configuring nginx, writing new configuration to $nginx_config_filename" _write_option $nginx_config_filename location "http://127.0.0.2/nginx_status" return 0 fi fi fi echoerr "Enabling stub_status failed. Rolling back changes" rm /etc/nginx/sites-enabled/nightwatch /etc/nginx/sites-available/nightwatch /etc/init.d/nginx restart echoerr "Please see https://library.linode.com/nightwatch/nightwatch-for-nginx#sph_manual-configuration-all-distributions for instructions on configuring nginx to work with Nightwatch. Auto-configuration failed" } mysql_install() { mysql_config_filename=${nightwatch_config_dir}MySQL.conf db_get Nightwatch/mysql-overwrite-creds overwrite="$RET" db_fset Nightwatch/mysql-create-creds seen "false" db_set Nightwatch/mysql-overwrite-creds "false" if [ "$overwrite" = "true" ]; then sed -i 's/^\s*\(username.*\)/#\1/g' $mysql_config_filename sed -i 's/^\s*\(password.*\)/#\1/g' $mysql_config_filename return 0 fi db_get Nightwatch/mysql-password pass="$RET" if [ ! -z "$pass" ]; then _write_option $mysql_config_filename username "fastcomet-nightwatch" _write_option $mysql_config_filename password "$pass" db_set Nightwatch/mysql-password "" return 0 fi } . /usr/share/debconf/confmodule if [ ! -e /etc/fastcomet/nightwatch.key ]; then db_get Nightwatch/APIKey echo "$RET" > /etc/fastcomet/nightwatch.key fi apache_install nginx_install mysql_install chmod -R o-rwx $nightwatch_config_dir db_stop if invoke-rc.d nightwatch status 1>/dev/null 2>&1; then invoke-rc.d nightwatch restart || true else invoke-rc.d nightwatch start || true fi update-rc.d nightwatch defaults PK �K#]��3R nightwatch/debian/source/formatnu �[��� 3.0 (native) PK �K#]�j�� � . nightwatch/Extras/specs/centos-nightwatch.specnu �[��� Name: fastcomet-nightwatch Version: 1.1 Release: 5 Summary: Fastcomet Nightwatch Agent License: GPLv2+ BuildArch: noarch Requires: perl(Crypt::SSLeay),perl(DBD::mysql),perl(LWP::Protocol::https) Obsoletes: nightwatch %description The Fastcomet Nightwatch data collection agent %prep http_fetch() { mkdir -p `dirname $2` if command -v wget >/dev/null 2>&1; then wget -q -4 -O $2 $1 || { echo >&2 "Failed to fetch $1. Aborting install."; exit 1; } elif command -v curl >/dev/null 2>&1; then curl -sf4L $1 > $2 || { echo >&2 "Failed to fetch $1. Aborting install."; exit 1; } else echo "Unable to find curl or wget, can not fetch needed files" exit 1 fi } [ -e $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm ] || http_fetch http://cpansearch.perl.org/src/CHORNY/Linux-Distribution-0.23/lib/Linux/Distribution.pm $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm [ -e $OLDPWD/Extras/lib/perl5/Try/Tiny.pm ] || http_fetch http://cpansearch.perl.org/src/ETHER/Try-Tiny-0.24/lib/Try/Tiny.pm $OLDPWD/Extras/lib/perl5/Try/Tiny.pm %install rm -rf %{buildroot} mkdir -p %{buildroot}/opt/fastcomet/nightwatch/lib/perl5/ mkdir -p %{buildroot}/opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Packages/ mkdir -p %{buildroot}/opt/fastcomet/nightwatch/Extras/ mkdir -p %{buildroot}/etc/init.d/ mkdir -p %{buildroot}/etc/fastcomet/nightwatch.d cp $OLDPWD/Extras/init/nightwatch.centos.sh %{buildroot}/etc/init.d/nightwatch cp -r $OLDPWD/Extras/lib/perl5/* %{buildroot}/opt/fastcomet/nightwatch/lib/perl5/ cp -r $OLDPWD/Fastcomet %{buildroot}/opt/fastcomet/nightwatch/ cp $OLDPWD/Extras/Modules/Packages/YUM.pm %{buildroot}/opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Packages/YUM.pm cp $OLDPWD/Extras/app-report.pl %{buildroot}/opt/fastcomet/nightwatch/Extras/app-report.pl cp $OLDPWD/Extras/conf/* %{buildroot}/etc/fastcomet/nightwatch.d/ %files /etc/init.d/nightwatch /opt/fastcomet/nightwatch/lib/perl5/Linux/Distribution.pm /opt/fastcomet/nightwatch/lib/perl5/Try/Tiny.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch.pl /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/*.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/*.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Applications/*.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Packages/YUM.pm %config %attr(640,root,root) /etc/fastcomet/nightwatch.d/*.conf /opt/fastcomet/nightwatch/Extras/app-report.pl %post if [ $1 -eq 1 ] ; then # Initial installation service nightwatch start || : chkconfig --add nightwatch chkconfig --level 35 nightwatch on fi chmod -R o-rwx /etc/fastcomet/nightwatch.d/ %preun if [ $1 -eq 0 ] ; then # Package removal, not upgrade service nightwatch stop || : chkconfig --del nightwatch fi %postun /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall service nightwatch restart || : fi PK �K#]�F� � . nightwatch/Extras/specs/fedora-nightwatch.specnu �[��� Name: fastcomet-nightwatch Version: 1.1 Release: 5 Summary: Fastcomet Nightwatch Agent License: GPLv2+ BuildArch: noarch Source: https://github.com/linode/longview/archive/v%{version}.%{release}.tar.gz Requires: perl-LWP-Protocol-https,perl-DBD-MySQL BuildRequires: systemd-units Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units %description The Fastcomet Nightwatch data collection agent %prep http_fetch() { mkdir -p `dirname $2` if command -v wget >/dev/null 2>&1; then wget -q -4 -O $2 $1 || { echo >&2 "Failed to fetch $1. Aborting install."; exit 1; } elif command -v curl >/dev/null 2>&1; then curl -sf4L $1 > $2 || { echo >&2 "Failed to fetch $1. Aborting install."; exit 1; } else echo "Unable to find curl or wget, can not fetch needed files" exit 1 fi } [ -e $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm ] || http_fetch http://cpansearch.perl.org/src/CHORNY/Linux-Distribution-0.23/lib/Linux/Distribution.pm $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm [ -e $OLDPWD/Extras/lib/perl5/Try/Tiny.pm ] || http_fetch http://cpansearch.perl.org/src/ETHER/Try-Tiny-0.24/lib/Try/Tiny.pm $OLDPWD/Extras/lib/perl5/Try/Tiny.pm %install echo $OLDPWD rm -rf %{buildroot} mkdir -p %{buildroot}/opt/fastcomet/nightwatch/lib/perl5/ mkdir -p %{buildroot}%{_unitdir} mkdir -p %{buildroot}/etc/fastcomet/nightwatch.d mkdir -p %{buildroot}/opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Packages mkdir -p %{buildroot}/opt/fastcomet/nightwatch/Extras/ cp $OLDPWD/Extras/init/nightwatch.service %{buildroot}%{_unitdir}/nightwatch.service cp -r $OLDPWD/Extras/lib/perl5/* %{buildroot}/opt/fastcomet/nightwatch/lib/perl5/ cp -r $OLDPWD/Fastcomet %{buildroot}/opt/fastcomet/nightwatch/ cp $OLDPWD/Extras/app-report.pl %{buildroot}/opt/fastcomet/nightwatch/Extras/app-report.pl cp $OLDPWD/Extras/Modules/Packages/YUM.pm %{buildroot}/opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Packages/YUM.pm cp $OLDPWD/Extras/conf/* %{buildroot}/etc/fastcomet/nightwatch.d/ %files %{_unitdir}/nightwatch.service /opt/fastcomet/nightwatch/lib/perl5/Linux/Distribution.pm /opt/fastcomet/nightwatch/lib/perl5/Try/Tiny.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch.pl /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/*.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/*.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Applications/*.pm /opt/fastcomet/nightwatch/Fastcomet/Nightwatch/DataGetter/Packages/YUM.pm %config %attr(640,root,root) /etc/fastcomet/nightwatch.d/*.conf /opt/fastcomet/nightwatch/Extras/app-report.pl %post if [ $1 -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : /bin/systemctl enable nightwatch.service >/dev/null 2>&1 || : fi %preun if [ $1 -eq 0 ] ; then # Package removal, not upgrade /bin/systemctl --no-reload disable nightwatch.service > /dev/null 2>&1 || : /bin/systemctl stop nightwatch.service > /dev/null 2>&1 || : fi %postun /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall /bin/systemctl try-restart nightwatch.service >/dev/null 2>&1 || : fi PK �K#]ED ��6 �6 nightwatch/Extras/app-report.plnu ȯ�� #!/usr/bin/env perl use strict; use warnings; =head1 COPYRIGHT/LICENSE Copyright 2013 Linode, LLC. Longview is made available under the terms of the Perl Artistic License, or GPLv2 at the recipients discretion. =head2 Perl Artistic License Read it at L<http://dev.perl.org/licenses/artistic.html>. =head2 GNU General Public License (GPL) Version 2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ See the full license at L<http://www.gnu.org/licenses/>. =cut BEGIN { use Config; use FindBin; push @INC, "$FindBin::RealBin/../"; push @INC, "$FindBin::RealBin/../lib/perl5"; push @INC, "$FindBin::RealBin/../lib/perl5/${Config{archname}}/"; push @INC, "$FindBin::RealBin/../usr/include"; } use Fastcomet::Nightwatch::DataGetter::Applications::Apache; use Fastcomet::Nightwatch::DataGetter::Applications::Nginx; use Fastcomet::Nightwatch::DataGetter::Applications::MySQL; use Fastcomet::Nightwatch::DataGetter::Processes qw(process_info process_list); use Fastcomet::Nightwatch::Util qw(get_config_file_name get_config_data get_UA slurp_file $apikey); use DBI; use Socket; use Getopt::Long; use Term::ANSIColor; use Tie::File; use Fcntl 'O_RDONLY'; our $processes = {}; my $force = ''; my $module = 'ALL'; my $verbose = ''; my $usage = ''; Getopt::Long::Configure ("bundling"); GetOptions ('h|help' => \$usage, 'f|force' => \$force, 'm|module=s' => \$module, 'v|verbose' => \$verbose); if ($usage){ print <<USAGE; Usage: $0 [OPTIONS] -v, --verbose Include raw error messages, and config file sections -f, --force Run all checks even if successful, or continue checking after critical errors -m, --module <Name> Only run checks for the named applications -h, --help Display this text USAGE exit 0; } our $sys_type ="generic"; $sys_type = "debian" if -e "/etc/debian_version"; $sys_type = "redhat" if -e "/etc/redhat-release"; my $running_apps = check_running(); $apikey = "Nightwatch Config Test"; check_apache() if $module eq "ALL" or $module eq "Apache"; check_nginx() if $module eq "ALL" or $module eq "Nginx"; check_mysql() if $module eq "ALL" or $module eq "MySQL"; print "=" x 28 . "\n"; sub check_running{ my $sigs = { Apache => $Fastcomet::Nightwatch::DataGetter::Applications::Apache::SIGNATURES, Nginx => $Fastcomet::Nightwatch::DataGetter::Applications::Nginx::SIGNATURES, MySQL => $Fastcomet::Nightwatch::DataGetter::Applications::MySQL::SIGNATURES, }; my $found = {Apache => 0, Nginx => 0, MySQL => 0}; my @procs = process_list(); for my $proc (@procs) { my %info = process_info($proc); next if ( !%info ); # no such proc, it probably died while we were gathering info next if ( $info{ppid} == 2 ); next if ( $info{pid} == 2 ); for my $app (keys %$sigs){ for my $sig (@{$sigs->{$app}}){ $found->{$app} = 1 if ($info{name} =~ /$sig$/); $found->{$app} = 1 if ($info{longname} =~ /$sig$/); } } } return $found; } sub check_apache { print "=" x 10 . " Apache " . "=" x 10 ."\n"; my $conf = get_config_data(get_config_file_name("Apache")); $conf->{location} = "http://127.0.0.1/server-status?auto" unless defined $conf->{location}; my $conf_port = 80; $conf_port = 443 if $conf->{location} =~ m|^https://|; my ($host, undef, $file_port) = ($conf->{location} =~ /^https?:\/\/([^:\/]+)(:(\d+))?\/.*/); $conf_port = $file_port if defined $file_port; my $ua = get_UA(); # temporarily skip checks for self-signed certs $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; my $res = $ua->get($conf->{location}); $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 1; if ( $res->is_success ) { if ( $res->content =~ /Scoreboard:/ ) { print color 'bold green'; print "Found apache status page at configured location ($conf->{location})\n"; print color 'reset'; return unless $force; }else{ print color 'bold yellow'; print "Got HTTP ".$res->status_line." for $conf->{location} but the content doesn't look like a status page\n"; print color 'reset'; } } else{ print color 'bold red'; print "Got HTTP ".$res->status_line." for $conf->{location}\n"; print color 'reset'; } unless ($running_apps->{Apache}) { print color 'bold red'; print "Apache does not appear to be running\n"; print color 'reset'; } my $host_ip = inet_ntoa(scalar(gethostbyname($host))); my $found = 0; my $default = 0; my $skip_block = 0; my ($vname, $conf_file, $line_number); my $ctl_bin = "apache2ctl"; $ctl_bin = "apachectl" if $sys_type eq "redhat"; open(A2C,"$ctl_bin -t -D DUMP_MODULES 2>/dev/null|") or do { print "Could not exec the Apache control binary ($ctl_bin)\n"; return; }; my @mod_list = <A2C>; close(A2C); if($?){ print color 'bold yellow'; print "Could not find the Apache control binary ($ctl_bin) assuming apache isn't installed\n"; print color 'reset'; return; } unless(grep(/^\s*status_module/,@mod_list)){ print color 'bold red'; print "Apache mod_status not loaded\n"; print color 'reset'; return unless $force; } open(A2C,"$ctl_bin -t -D DUMP_VHOSTS 2>/dev/null|") or do { print "Could not exec the Apache control binary ($ctl_bin)\n"; return; }; my @conf_lines = <A2C>; close(A2C); foreach my $line (@conf_lines) { print $line; chomp($line); if($line =~ /^(\S+).*NameVirtualHost$/){ my ($addr,$port) = ($line =~ /^(.*):(\d+)\s.*$/); unless ($port == $conf_port) { $skip_block = 1; next; } unless (($host eq $addr) or ($addr eq "*")) { $skip_block = 1; next } $skip_block = 0; } next if $skip_block; if($line =~ /^\s+default/) { ($vname, $conf_file, $line_number) = ($line =~ /^\s+default\sserver\s(.*)\s\((.*):(\d+)\)$/) unless $found; $default = 1; } elsif($line =~ /^\s+port\s+\d+\s+namevhost.*$/){ my ($name, $file, $ln) = ($line =~ /^\s+port\s+\d+\s+namevhost\s+(.*)\s+\((.*):(\d+)\)$/); if($name eq $host or inet_ntoa(scalar(gethostbyname($name))) eq $host_ip){ ($vname, $conf_file, $line_number) = ($name, $file, $ln); $found = 1; } } } if(defined $vname){ print "Found a likely vhost $vname in $conf_file on line $line_number"; print " [DEFAULT]" if $default and !$found; print "\n"; print_vhost($conf_file, $line_number) if $verbose; } } sub print_vhost { my ($file, $line_no) = @_; $line_no--; my @vhost_conf; tie @vhost_conf, 'Tie::File', $file, mode => O_RDONLY; while (($line_no < scalar(@vhost_conf)) and ($vhost_conf[$line_no] !~ m|^\s*</VirtualHost>|)) { print $vhost_conf[$line_no++] . "\n"; } print $vhost_conf[$line_no] . "\n"; untie @vhost_conf; } sub check_mysql { print "=" x 10 . " MySQL " . "=" x 11 ."\n"; my $conf = get_config_data(get_config_file_name("MySQL")); my $connection_string = "DBI:mysql:host=localhost;"; my $socket_error = 0; my $spath_from_error; unless ($running_apps->{MySQL}) { print color 'bold red'; print "MySQL does not appear to be running\n"; print color 'reset'; return unless $force; } if ( exists( $conf->{username} ) && exists( $conf->{password} ) ) { my $success = 1; my $dbh = DBI->connect_cached($connection_string, $conf->{username}, $conf->{password},{PrintError => 0,PrintWarn => 0}) or do { $success = 0; }; if($success) { print color 'bold green'; print "Connected to mysql with user '$conf->{username}' and the password supplied in /etc/fastcomet/nightwatch.d/MySQL.conf\n"; print color 'reset'; return unless $force; } else { print color 'bold yellow'; print "Could not connect to mysql with user '$conf->{username}' and the password supplied in /etc/fastcomet/nightwatch.d/MySQL.conf\n"; print $DBI::errstr . "\n" if $verbose; print color 'reset'; if($DBI::errstr =~ /Can't connect to local MySQL server through socket/){ $socket_error = 1; ($spath_from_error) = ($DBI::errstr =~ /^Can't connect to local MySQL server through socket '(.*)'/); } } } else{ print color 'bold yellow'; print "No credentials found in /etc/fastcomet/nightwatch.d/MySQL.conf\n"; print color 'reset'; } if( $sys_type eq "debian" && -e '/etc/mysql/debian.cnf'){ my $password; for my $line ( slurp_file('/etc/mysql/debian.cnf') ) { if ( $line =~ /^password\s+=\s+(.*)$/ ) { $password = $1; last; } } unless (defined $password) { print color 'bold yellow'; print "Could not find user credentials in /etc/mysql/debian.cnf\n"; print color 'reset'; }else{ my $success = 1; my $dbh = DBI->connect_cached($connection_string, 'debian-sys-maint', $password,{PrintError => 0,PrintWarn => 0}) or do { $success = 0; }; if($success) { print color 'bold green'; print "Connected to mysql with user 'debian-sys-maint'\n"; print color 'reset'; return unless $force; } else { print color 'bold yellow'; print "Could not connect to mysql as user 'debian-sys-maint' with the password set in /etc/mysql/debian.cnf\n"; print $DBI::errstr . "\n" if $verbose; print color 'reset'; if($DBI::errstr =~ /Can't connect to local MySQL server through socket/){ $socket_error = 1; ($spath_from_error) = ($DBI::errstr =~ /^Can't connect to local MySQL server through socket '(.*)'/); } } } } if($socket_error){ print "Could not connect due to socket error.\n"; my $conf_file = "/etc/my.cnf"; $conf_file = "/etc/mysql/my.cnf" if $sys_type eq "debian"; my $spath_from_conf = mysql_socket_path_from_config($conf_file); print "Found socket "; print color 'bold'; print $spath_from_conf; print color 'reset'; print " in $conf_file\n"; unless (-S $spath_from_conf){ print color 'bold red'; print "Socket $spath_from_conf does not exist\n"; print color 'reset'; } print "Client attempted to connect using socket "; print color 'bold'; print "$spath_from_error\n"; print color 'reset'; unless($spath_from_conf eq $spath_from_error){ print color 'bold red'; print "Client appears to be using the wrong socket path\n"; print color 'reset'; } } } sub mysql_socket_path_from_config { my $file = shift; my @conf_lines = slurp_file($file); my ($section, $socket_path) = ('',undef); foreach my $line (@conf_lines) { chomp($line); if($line =~ /^\s*\[\S+\]/) { ($section) = ($line =~ /^\s*\[(\S+)\]/); } next unless $section eq "mysqld"; if($line =~ /^\s*socket\s*=\s*\S+/){ ($socket_path) = ($line =~ /^\s*socket\s*=\s*(\S+)/); } } return $socket_path; } sub check_nginx { print "=" x 10 . " Nginx " . "=" x 11 ."\n"; my $conf = get_config_data(get_config_file_name("Nginx")); $conf->{location} = 'http://127.0.0.1/nginx_status' unless defined $conf->{location}; my $conf_port = 80; $conf_port = 443 if $conf->{location} =~ m|^https://|; my ($host, undef, $file_port) = ($conf->{location} =~ /^https?:\/\/([^:\/]+)(:(\d+))?\/.*/); $conf_port = $file_port if defined $file_port; my $ua = get_UA(); # temporarily skip checks for self-signed certs $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; my $res = $ua->get($conf->{location}); $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 1; if ( $res->is_success ) { if ( $res->content =~ /server accepts handled requests/ ) { print color 'bold green'; print "Found nginx status page at configured location ($conf->{location})\n"; print color 'reset'; return unless $force; }else{ print color 'bold yellow'; print "Got HTTP ".$res->status_line." for $conf->{location} but the content doesn't look like a status page\n"; print color 'reset'; } } else{ print color 'bold red'; print "Got HTTP ".$res->status_line." for $conf->{location}\n"; print color 'reset'; } unless ($running_apps->{Nginx}) { print color 'bold red'; print "Nginx does not appear to be running\n"; print color 'reset'; } open(NXV,"nginx -V 2>&1 |") or do { print "Could not exec nginx\n"; return; }; my @conf_lines = <NXV>; close(NXV); if($?){ print color 'bold yellow'; print "Could not find nginx assuming it isn't installed\n"; print color 'reset'; return; } my $conf_line = (grep(m/^configure arguments:/,@conf_lines))[0]; $conf_line =~ s/^configure arguments://; my @config_opts = split(' ', $conf_line); unless(grep(/--with-http_stub_status_module/,@config_opts)){ print "Installed version of Nginx does not include status stub\n"; return; } else{ print "Nginx status stub available\n"; } my $prefix = (grep(m/^--prefix=/,@config_opts))[0]; $prefix =~ s/^--prefix=//; my $conf_path = (grep(m/^--conf-path=/,@config_opts))[0]; $conf_path =~ s/^--conf-path=//; print "Prefix: $prefix\n"; print "Base Config File: $conf_path\n"; my (@pending, @confs); push @pending, $conf_path; while(@pending){ push @pending, nginx_get_includes($pending[0]); push @confs, shift @pending; } print "All Config Files:\n"; print "\t$_\n" for (@confs); nginx_find_status($_) for (@confs); } sub nginx_get_includes { my $file = shift; my @conf_lines = slurp_file($file); return () unless @conf_lines; my @res; for my $child (grep(/^\s*include\s+/,@conf_lines)){ $child =~ s/^\s*include\s+//; $child =~ s/;$//; push @res, glob($child); } return @res; } sub nginx_find_status { my $file = shift; my @conf_lines = slurp_file($file); return () unless @conf_lines; my @res = grep { $conf_lines[$_-1] =~ /^\s*stub_status on;/ } 1..$#conf_lines+1; if (@res){ print "Found what looks like a status stub handler in $file on line " .join(', ',@res)."\n"; print `egrep -n -C5 '^\\s*stub_status on;' $file` if $verbose; } } PK �K#]�Br�X X , nightwatch/Extras/Modules/Packages/Gentoo.pmnu �[��� package Fastcomet::Nightwatch::DataGetter::Packages::Gentoo; =head1 COPYRIGHT/LICENSE Copyright 2013 Linode, LLC. Longview is made available under the terms of the Perl Artistic License, or GPLv2 at the recipients discretion. =head2 Perl Artistic License Read it at L<http://dev.perl.org/licenses/artistic.html>. =head2 GNU General Public License (GPL) Version 2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ See the full license at L<http://www.gnu.org/licenses/>. =cut use strict; use warnings; use Fastcomet::Nightwatch::Util; our $DEPENDENCIES = []; our $next_run; our @pkgs; sub get { my ( undef, $dataref ) = @_; $logger->trace('Entering Gentoo module'); if(should_update()){ @pkgs = qx(VERSION='<version>,' eix -u '-*' --format '<category>/<name> <installedversions:VERSION> <bestslotupgradeversions:VERSION>\n'); } $dataref->{INSTANT}->{Packages} = [ map { my ($name, $current, $new) = $_ =~ /^([^ ]+) (.+?), (.+?),$/; { name => $name, current => join(', ', split(/,/, $current)), new => join(', ', split(/,/, $new)) } } @pkgs ]; return $dataref; } sub should_update { return 0 if((defined $next_run) && ($next_run > time)); $next_run = time + 1800; # Checking updates is expensive; only do it every 30 minutes return 1; } 1; PK �K#]��r$ $ ) nightwatch/Extras/Modules/Packages/APT.pmnu �[��� package Fastcomet::Nightwatch::DataGetter::Packages::APT; =head1 COPYRIGHT/LICENSE Copyright 2013 Linode, LLC. Longview is made available under the terms of the Perl Artistic License, or GPLv2 at the recipients discretion. =head2 Perl Artistic License Read it at L<http://dev.perl.org/licenses/artistic.html>. =head2 GNU General Public License (GPL) Version 2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ See the full license at L<http://www.gnu.org/licenses/>. =cut use strict; use warnings; use Fastcomet::Nightwatch::Util; our $DEPENDENCIES = ['Processes.pm']; our $next_run; our $cache_touch_dt; sub get { my ( undef, $dataref ) = @_; $logger->trace('Entering APT module'); if(check_running($dataref)){ $logger->debug('Another instance of apt-get is already running, skip package this pass'); $dataref->{INSTANT}->{Packages} = []; return $dataref; } if(should_update()){ $logger->trace('Running apt-get update before reporting packages'); `apt-get -q update 2>/dev/null`; } my $new_touch_dt = (stat('/var/cache/apt/pkgcache.bin'))[9]; return $dataref if (defined($cache_touch_dt) && ($new_touch_dt == $cache_touch_dt)); $cache_touch_dt = $new_touch_dt; $dataref->{INSTANT}->{Packages} = []; my $held = 1; if (open(APT, "echo n | apt-get -q -V upgrade 2>&1 |")) { while (my $line = <APT>) { chomp($line); $held = 0 if ($line =~ m/^The following packages will be upgraded:/); if ($line =~ m/^\s+(\S+)\s+\((\S+)\s+=>\s+(\S+)\)/) { my $update = {}; $update->{name} = $1; $update->{current} = $2; $update->{new} = $3; $update->{held} = $held; push @{$dataref->{INSTANT}->{Packages}}, $update; } } close(APT); } return $dataref; } sub should_update { return 0 if((defined $next_run) && ($next_run > time)); $next_run = time + 86400; #Only actually hit the mirrors once every 24 hours. return 1; } sub check_running { my $dataref = shift; return grep(m/Processes\.apt(?:-get|itude)/,keys %{$dataref->{LONGTERM}}); } 1; PK �K#]��H H ) nightwatch/Extras/Modules/Packages/YUM.pmnu �[��� package Fastcomet::Nightwatch::DataGetter::Packages::YUM; =head1 Perl Artistic License Copyright 2013 Linode, LLC. Longview is made available under the terms of the Perl Artistic License, or GPLv2 at the recipients discretion. =head2 Perl Artistic License Read it at L<http://dev.perl.org/licenses/artistic.html>. =head2 GNU General Public License (GPL) Version 2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ See the full license at L<http://www.gnu.org/licenses/>. =cut use strict; use warnings; use Fastcomet::Nightwatch::Util; our $DEPENDENCIES = []; our $cache_touch_dt; sub get { my (undef, $dataref) = @_; $logger->trace('Entering YUM module'); return $dataref if defined $cache_touch_dt && get_DB_touch_dt() == $cache_touch_dt; my %u_pkgs = upgradable_pkgs(); if (!%u_pkgs){ $dataref->{INSTANT}->{Packages} = []; $cache_touch_dt = get_DB_touch_dt(); return $dataref; } my %c_pkgs = current_pkgs(); $dataref->{INSTANT}->{Packages} = [ map { { name => $_, current => $c_pkgs{$_}, new => $u_pkgs{$_} } } keys %u_pkgs ]; $cache_touch_dt = get_DB_touch_dt(); return $dataref; } sub get_DB_touch_dt { my $oldest = 0; my $candidate; for my $db (glob('/var/lib/rpm/__db.*')) { $candidate = (stat($db))[9]; $oldest = $candidate if $oldest < $candidate; } return $oldest; } sub current_pkgs { # yum wraps unless we fake a tty my @pkg_list = qx(script -c 'yum --color=never list installed' /dev/null); my %pkgs; for my $pkg (@pkg_list) { if ( $pkg =~ m/^(.*?)\s+(.*?)\s+@(.*)$/ ) { $pkgs{$1} = $2; } } return %pkgs; } sub upgradable_pkgs { my @pkg_list = qx(yum check-update); my %pkgs; for my $pkg (@pkg_list) { if ( $pkg =~ m/^(\S+\.\S+)\s+(\S+)\s+\S+$/ ) { $pkgs{$1} = $2; } } return %pkgs; } 1; PK �K#]���I� � ) nightwatch/Extras/install-dependencies.shnu ȯ�� #!/bin/bash http_fetch() { if command -v wget >/dev/null 2>&1; then wget -q -4 -O $2 $1 || { echo >&2 "Failed to fetch $1. Aborting install."; exit 1; } elif command -v curl >/dev/null 2>&1; then curl -sf4L $1 > $2 || { echo >&2 "Failed to fetch $1. Aborting install."; exit 1; } else echo "Unable to find curl or wget, can not fetch needed files" exit 1 fi } check_builddep() { command -v $1 >/dev/null 2>&1 || { echo >&2 "$1 is required but not available, please install it and try again. Aborting install."; exit 1; } } BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" echo "Installing dependencies in to: $BASE_DIR" check_builddep make check_builddep cc http_fetch http://cpanmin.us /tmp/cpanm chmod +x /tmp/cpanm echo "==== Installing Nightwatch core dependencies ====" /tmp/cpanm -q -L $BASE_DIR LWP::UserAgent Crypt::SSLeay IO::Socket::INET6 JSON::PP JSON Log::LogLite Try::Tiny DBI echo "==== Installing Nightwatch-MySQL dependencies ====" /tmp/cpanm -q -L $BASE_DIR DBD::mysql rm /tmp/cpanm echo "==== Compiling headers ====" h2ph -d $BASE_DIR /usr/include/syscall.h h2ph -d $BASE_DIR /usr/include/sys/syscall.h h2ph -d $BASE_DIR /usr/include/asm/unistd.h h2ph -d $BASE_DIR /usr/include/asm/unistd_32.h h2ph -d $BASE_DIR /usr/include/asm/unistd_64.h h2ph -d $BASE_DIR /usr/include/bits/wordsize.h h2ph -d $BASE_DIR /usr/include/bits/syscall.h PK �K#]�/'*'