From e0da46edca958e6b1c493bf912bb9cd6397b0b5d Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 5 Oct 2013 15:45:31 +0000 Subject: [PATCH] add scripts for CakePHP and PHPMyAdmin, courtesy of WvR. Also include new logging options (verbosity) --- neighborhoodwatch.conf-sample | 3 +++ run.d/cakephp | 39 ++++++++++++++++++++++++++++++++++ run.d/drupal | 11 +++------- run.d/phpmyadmin | 40 +++++++++++++++++++++++++++++++++++ run.d/wordpress | 10 ++------- 5 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 run.d/cakephp create mode 100755 run.d/phpmyadmin diff --git a/neighborhoodwatch.conf-sample b/neighborhoodwatch.conf-sample index 280e922..23beec6 100644 --- a/neighborhoodwatch.conf-sample +++ b/neighborhoodwatch.conf-sample @@ -13,3 +13,6 @@ export CHK_HOSTS="host1 host2 host3" export RUN_PATH="${SCRIPT_PATH}/run.d" export TMP_PATH="${SCRIPT_PATH}/tmp" +# Options +export VERBOSE="1" + diff --git a/run.d/cakephp b/run.d/cakephp new file mode 100644 index 0000000..4764b71 --- /dev/null +++ b/run.d/cakephp @@ -0,0 +1,39 @@ +#!/usr/bin/php -q +([0-9\.]+)\<\/span\>/", $cake_api, $matches) ) { + $cake_current = $matches[1]; + verbose(Current CakePHP version: $cake_current", 1); +}else { + die("Unable to determine current CakePHP version, exiting\n"); +} + +checkHost(null, $cake_current); +if( $hosts != null ) { + foreach($hosts as $host) { + checkHost($host, $cake_current); + } +} + +function checkHost($host, $cake_current) { + $cmd = "locate -i Cake/VERSION.txt | xargs grep -H -v \"//\" | grep -v \"ake/VERSION.txt:$\""; + $hostidentifier = "localhost:"; + if( $host != null ) { + $cmd = "ssh $host \"" . $cmd . "\""; + $hostidentifier = $host . ":"; + } + exec($cmd, $results); + foreach($results as $instance) { + $parts = explode(':', $instance); + $location = substr($parts[0], 0, strlen($parts[0])-16); + $version = $parts[1]; + if($version < $cake_current) { + echo "WARNING: Outdated CakePHP $version at $hostidentifier$location\n"; + } + } + unset($results); +} + +?> diff --git a/run.d/drupal b/run.d/drupal index c04d055..505e917 100755 --- a/run.d/drupal +++ b/run.d/drupal @@ -1,13 +1,6 @@ #!/usr/bin/php -q phpMyAdmin\-([0-9\.]+)\-all\-languages\.tar\.gzset\('PMA_VERSION', '([0-9\.a-z]+)'\);/", $parts[1], $matches); + $version = $matches[1]; + if($version < $pma_current) { + echo "WARNING: Outdated PHPMyAdmin $version at $hostidentifier$location\n"; + } + } + unset($results); +} + +?> diff --git a/run.d/wordpress b/run.d/wordpress index aedacb4..f2e5b16 100755 --- a/run.d/wordpress +++ b/run.d/wordpress @@ -1,18 +1,12 @@ #!/usr/bin/php -q