Merge lp:~clint-fewbar/charms/precise/mysql/add-monitors into lp:charms/mysql

Proposed by Clint Byrum
Status: Merged
Approved by: Mark Mims
Approved revision: 81
Merged at revision: 75
Proposed branch: lp:~clint-fewbar/charms/precise/mysql/add-monitors
Merge into: lp:charms/mysql
Diff against target: 134 lines (+51/-5)
9 files modified
hooks/config-changed (+2/-2)
hooks/install (+3/-2)
hooks/monitors-relation-broken (+8/-0)
hooks/monitors-relation-departed (+3/-0)
hooks/monitors-relation-joined (+7/-0)
hooks/monitors.common.bash (+8/-0)
metadata.yaml (+6/-0)
monitors.yaml (+13/-0)
revision (+1/-1)
To merge this branch: bzr merge lp:~clint-fewbar/charms/precise/mysql/add-monitors
Reviewer Review Type Date Requested Status
Mark Mims (community) Approve
Review via email: mp+118000@code.launchpad.net

Commit message

Add support for monitors interface.

Description of the change

This adds support for the 'monitors' interface. Please see

https://code.launchpad.net/~clint-fewbar/charms/precise/nagios/add-monitors-2/+merge/117999

For information regarding that interface.

To post a comment you must log in.
Revision history for this message
Mark Mims (mark-mims) :
review: Approve
Revision history for this message
Mark Mims (mark-mims) wrote :

discussion/recommendations:

Please move included scripts into a separate directory like
`$CHARM_DIR/lib` or `$CHARM_DIR\scripts`... only hooks belong
in the `hooks` directory. Charm readability is the goal for
our main series of charms like mysql.

We really should change the `.bash` file extensions to the more standard `.sh`...
/me thinks it's just a tad too pedantic to make a distinction between the two.
Why raise even the slightest possibility for people or editors to be confused?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2012-04-25 07:36:45 +0000
+++ hooks/config-changed 2012-08-02 21:30:25 +0000
@@ -1,6 +1,6 @@
1#!/usr/bin/python1#!/usr/bin/python
22
3from subprocess import check_output,check_call3from subprocess import check_output,check_call, CalledProcessError
4import tempfile4import tempfile
5import json5import json
6import re6import re
@@ -261,6 +261,6 @@
261if need_restart:261if need_restart:
262 try:262 try:
263 check_call(['service','mysql','stop'])263 check_call(['service','mysql','stop'])
264 except subprocess.CalledProcessError:264 except CalledProcessError:
265 pass265 pass
266 check_call(['service','mysql','start'])266 check_call(['service','mysql','start'])
267267
=== modified file 'hooks/install'
--- hooks/install 2012-04-25 07:20:11 +0000
+++ hooks/install 2012-08-02 21:30:25 +0000
@@ -1,7 +1,8 @@
1#!/bin/bash1#!/bin/bash
22
3add-apt-repository -y ppa:charmers/charm-helpers
3apt-get update4apt-get update
4sudo apt-get install -qqy debconf-utils python-mysqldb uuid augeas-tools augeas-lenses pwgen dnsutils || exit 15apt-get install -y debconf-utils python-mysqldb uuid augeas-tools augeas-lenses pwgen dnsutils charm-helper-sh || exit 1
56
6PASSFILE=/var/lib/juju/mysql.passwd7PASSFILE=/var/lib/juju/mysql.passwd
7if ! [ -f $PASSFILE ] ; then8if ! [ -f $PASSFILE ] ; then
@@ -12,4 +13,4 @@
12echo mysql-server-5.1 mysql-server/root_password password $PASSWORD | debconf-set-selections13echo mysql-server-5.1 mysql-server/root_password password $PASSWORD | debconf-set-selections
13echo mysql-server-5.1 mysql-server/root_password_again password $PASSWORD | debconf-set-selections14echo mysql-server-5.1 mysql-server/root_password_again password $PASSWORD | debconf-set-selections
1415
15DEBIAN_FRONTEND=noninteractive apt-get -y install -qq mysql-server16apt-get -y install -qq mysql-server
1617
=== added symlink 'hooks/local-monitors-relation-joined'
=== target is u'monitors-relation-joined'
=== added file 'hooks/monitors-relation-broken'
--- hooks/monitors-relation-broken 1970-01-01 00:00:00 +0000
+++ hooks/monitors-relation-broken 2012-08-02 21:30:25 +0000
@@ -0,0 +1,8 @@
1#!/bin/bash
2set -ue
3. hooks/monitors.common.bash
4if [ -r "$revoke_todo" ] ; then
5 sed -e 's/^/REVOKE USAGE ON *.* FROM /;s/$/\;/;' < $revoke_todo
6 sed -e 's/^/REVOKE USAGE ON *.* FROM /;s/$/\;/;' < $revoke_todo | $MYSQL
7 rm -f $revoke_todo
8fi
09
=== added file 'hooks/monitors-relation-departed'
--- hooks/monitors-relation-departed 1970-01-01 00:00:00 +0000
+++ hooks/monitors-relation-departed 2012-08-02 21:30:25 +0000
@@ -0,0 +1,3 @@
1#!/bin/bash
2. /usr/share/charm-helpers/sh/net.sh
3$MYSQL -e "REVOKE USAGE ON *.* FROM '${monitor_user}'@'${remote_addr}'"
04
=== added file 'hooks/monitors-relation-joined'
--- hooks/monitors-relation-joined 1970-01-01 00:00:00 +0000
+++ hooks/monitors-relation-joined 2012-08-02 21:30:25 +0000
@@ -0,0 +1,7 @@
1#!/bin/bash
2set -ue
3. hooks/monitors.common.bash
4echo "'${monitor_user}'@'${remote_addr}'" >> $revoke_todo
5$MYSQL -e "GRANT USAGE ON *.* TO '${monitor_user}'@'${remote_addr}'"
6
7relation-set monitors="$(cat monitors.yaml)" target-id=${JUJU_UNIT_NAME//\//-} target-address=$(unit-get private-address)
08
=== added file 'hooks/monitors.common.bash'
--- hooks/monitors.common.bash 1970-01-01 00:00:00 +0000
+++ hooks/monitors.common.bash 2012-08-02 21:30:25 +0000
@@ -0,0 +1,8 @@
1MYSQL="mysql -uroot -p`cat /var/lib/juju/mysql.passwd`"
2monitor_user=monitors
3. /usr/share/charm-helper/sh/net.sh
4if [ -n "$JUJU_REMOTE_UNIT" ] ; then
5 remote_addr=$(ch_get_ip $(relation-get private-address))
6fi
7mkdir -p data
8revoke_todo=data/${JUJU_RELATION_ID}
09
=== modified file 'metadata.yaml'
--- metadata.yaml 2012-05-22 22:15:41 +0000
+++ metadata.yaml 2012-08-02 21:30:25 +0000
@@ -1,4 +1,5 @@
1name: mysql1name: mysql
2format: 2
2summary: MySQL is a fast, stable and true multi-user, multi-threaded SQL database3summary: MySQL is a fast, stable and true multi-user, multi-threaded SQL database
3maintainer: Clint Byrum <clint@ubuntu.com>4maintainer: Clint Byrum <clint@ubuntu.com>
4description: |5description: |
@@ -17,6 +18,11 @@
17 interface: mysql-oneway-replication18 interface: mysql-oneway-replication
18 munin:19 munin:
19 interface: munin-node20 interface: munin-node
21 monitors:
22 interface: monitors
23 local-monitors:
24 interface: local-monitors
25 scope: container
20requires:26requires:
21 slave:27 slave:
22 interface: mysql-oneway-replication28 interface: mysql-oneway-replication
2329
=== added file 'monitors.yaml'
--- monitors.yaml 1970-01-01 00:00:00 +0000
+++ monitors.yaml 2012-08-02 21:30:25 +0000
@@ -0,0 +1,13 @@
1version: '0.3'
2monitors:
3 local:
4 procrunning:
5 mysqld:
6 name: MySQL Running
7 min: 1
8 max: 1
9 executable: mysqld
10 remote:
11 mysql:
12 basic:
13 user: monitors
014
=== modified file 'revision'
--- revision 2012-04-25 08:23:44 +0000
+++ revision 2012-08-02 21:30:25 +0000
@@ -1,1 +1,1 @@
11211145

Subscribers

People subscribed via source and target branches

to all changes: