Skip to content

Commit

Permalink
Merge pull request #27 from ewiseblatt/post_install
Browse files Browse the repository at this point in the history
Misc bug fixes:
  • Loading branch information
Eric Wiseblatt authored Feb 24, 2017
2 parents 6b57e52 + 15abc58 commit 3170a1b
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 68 deletions.
4 changes: 1 addition & 3 deletions spinnaker-monitoring-daemon/bin/spinnaker-monitoring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@
# limitations under the License.

PYTHONWARNINGS=once \
python $(dirname $0)/../spinnaker-monitoring \
--log_dir /var/log/spinnaker/monitoring \
"$@"
python $(dirname $0)/../spinnaker-monitoring "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ start on filesystem or runlevel [2345]
setuid spinnaker
setgid spinnaker

exec /opt/spinnaker-monitoring/bin/spinnaker-monitoring.sh monitor > /var/log/spinnaker/monitoring/monitoring.log 2>&1
exec /opt/spinnaker-monitoring/bin/spinnaker-monitoring.sh monitor 2>&1 > /var/log/spinnaker/monitoring/monitoring.log
4 changes: 3 additions & 1 deletion spinnaker-monitoring-daemon/spinnaker-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# Each yaml file contains a "metrics_url:" value with either a URL string
# or a list of URL strings to collect from using the base filename as
# the identifier for the service the metrics came from.
registry_dir: /opt/spinnaker-monitoring/registry
# If not specified the default will be the first of:
# ../registry, ../registry.dev, /opt/spinnaker-monitoring/registry
registry_dir:

server:
# This host and port to bind the embedded HTTP server on.
Expand Down
30 changes: 19 additions & 11 deletions spinnaker-monitoring-daemon/spinnaker-monitoring/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,40 @@ def init_logging(options):
},
'handlers':{
'console':{
'level':'WARNING',
'level': options['log_level'],
'class':'logging.StreamHandler',
'formatter':'timestamped'
},
'file':{
'level':'DEBUG',
'class':'logging.FileHandler',
'formatter':'timestamped',
'filename': os.path.join(log_dir, log_file),
'mode':'w'
},
},
'loggers':{
'': {
'level':'DEBUG',
'handlers':['console', 'file']
'handlers':['console']
},
}
}
if log_dir:
log_config['handlers']['file'] = {
'level':'DEBUG',
'class':'logging.FileHandler',
'formatter':'timestamped',
'filename': os.path.join(log_dir, log_file),
'mode':'w'
}
log_config['loggers']['']['handlers'].append('file')

logging.config.dictConfig(log_config)


def add_global_args(parser):
"""Add global parser options that are independent of the command."""
parser.add_argument('--log_basename', default='spinnaker-monitoring')
parser.add_argument('--log_dir', default='.')
parser.add_argument(
'--log_basename', default='spinnaker-monitoring',
help='When writing a logfile, use this as the basename (before .log extension)')
parser.add_argument(
'--log_dir', default=None,
help='If specified, log to a --log_basename in this directory instead of console.')
parser.add_argument('--log_level', default='INFO', help='log level to console')
parser.add_argument('--config', default=DEFAULT_CONFIG_PATH,
help='Path to base configuration directory.')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ def get_source_catalog(options):
Dictionary keyed by the root name of the config file in the registry
directory whose value is the dictionary of the YAML file content.
"""
registry_dir = options.get('registry_dir', DEFAULT_REGISTRY_DIR)
registry_dir = options.get('registry_dir') or DEFAULT_REGISTRY_DIR
global _cached_registry_catalog
global _cached_registry_timestamp
try:

timestamp = os.path.getmtime(registry_dir)
except OSError as err:
logging.error(err)
Expand Down
3 changes: 3 additions & 0 deletions spinnaker-monitoring-third-party/pkg_scripts/postInstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

chown -R root:root /opt/spinnaker-monitoring/third_party
37 changes: 20 additions & 17 deletions spinnaker-monitoring-third-party/third_party/datadog/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,25 @@ DASHBOARDS=true

function process_args() {
while [[ $# > 0 ]]; do
local key="$1"
shift
case $key in
--server_only)
CLIENT=false
DASHBOARDS=false
;;
--client_only)
SERVER=false
DASHBOARDS=false
;;
--dashboards_only)
SERVER=false
CLIENT=false
;;
esac
local key="$1"
shift
case $key in
--server_only)
CLIENT=false
DASHBOARDS=false
;;
--client_only)
SERVER=false
DASHBOARDS=false
;;
--dashboards_only)
SERVER=false
CLIENT=false
;;
*)
echo "Unrecognized argument '$key'."
exit -1
esac
done
}

Expand Down Expand Up @@ -93,7 +96,7 @@ function install_client() {
fi
}

process_args "$#"
process_args "$@"


if $SERVER; then
Expand Down
43 changes: 23 additions & 20 deletions spinnaker-monitoring-third-party/third_party/prometheus/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,29 @@ DASHBOARDS=true

function process_args() {
while [[ $# > 0 ]]; do
local key="$1"
shift
case $key in
--gateway)
GATEWAY_URL="$1"
shift
;;
--server_only)
CLIENT=false
DASHBOARDS=false
;;
--client_only)
SERVER=false
DASHBOARDS=false
;;
--dashboards_only)
SERVER=false
CLIENT=false
;;
esac
local key="$1"
shift
case $key in
--gateway)
GATEWAY_URL="$1"
shift
;;
--server_only)
CLIENT=false
DASHBOARDS=false
;;
--client_only)
SERVER=false
DASHBOARDS=false
;;
--dashboards_only)
SERVER=false
CLIENT=false
;;
*)
echo "Unrecognized argument '$key'."
exit -1
esac
done
}

Expand Down
31 changes: 17 additions & 14 deletions spinnaker-monitoring-third-party/third_party/stackdriver/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ function process_args() {
local key="$1"
shift
case $key in
--server_only)
CLIENT=false
DASHBOARDS=false
;;
--client_only)
SERVER=false
DASHBOARDS=false
;;
--dashboards_only)
SERVER=false
CLIENT=false
;;
esac
--server_only)
CLIENT=false
DASHBOARDS=false
;;
--client_only)
SERVER=false
DASHBOARDS=false
;;
--dashboards_only)
SERVER=false
CLIENT=false
;;
*)
echo "Unrecognized argument '$key'."
exit -1
esac
done
}

Expand Down Expand Up @@ -71,7 +74,7 @@ function install_dashboards() {
exit -1
fi

for dashboard in '$DIRNAME"/*Dashboard.json; do
for dashboard in "$DIRNAME"/*Dashboard.json; do
"$DIRNAME/../../bin/spinnaker-monitoring.sh" \
upload_stackdriver_dashboard --dashboard ${dashboard} \
"$@"
Expand Down

0 comments on commit 3170a1b

Please sign in to comment.