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
1=== modified file 'hooks/config-changed'
2--- hooks/config-changed 2012-04-25 07:36:45 +0000
3+++ hooks/config-changed 2012-08-02 21:30:25 +0000
4@@ -1,6 +1,6 @@
5 #!/usr/bin/python
6
7-from subprocess import check_output,check_call
8+from subprocess import check_output,check_call, CalledProcessError
9 import tempfile
10 import json
11 import re
12@@ -261,6 +261,6 @@
13 if need_restart:
14 try:
15 check_call(['service','mysql','stop'])
16- except subprocess.CalledProcessError:
17+ except CalledProcessError:
18 pass
19 check_call(['service','mysql','start'])
20
21=== modified file 'hooks/install'
22--- hooks/install 2012-04-25 07:20:11 +0000
23+++ hooks/install 2012-08-02 21:30:25 +0000
24@@ -1,7 +1,8 @@
25 #!/bin/bash
26
27+add-apt-repository -y ppa:charmers/charm-helpers
28 apt-get update
29-sudo apt-get install -qqy debconf-utils python-mysqldb uuid augeas-tools augeas-lenses pwgen dnsutils || exit 1
30+apt-get install -y debconf-utils python-mysqldb uuid augeas-tools augeas-lenses pwgen dnsutils charm-helper-sh || exit 1
31
32 PASSFILE=/var/lib/juju/mysql.passwd
33 if ! [ -f $PASSFILE ] ; then
34@@ -12,4 +13,4 @@
35 echo mysql-server-5.1 mysql-server/root_password password $PASSWORD | debconf-set-selections
36 echo mysql-server-5.1 mysql-server/root_password_again password $PASSWORD | debconf-set-selections
37
38-DEBIAN_FRONTEND=noninteractive apt-get -y install -qq mysql-server
39+apt-get -y install -qq mysql-server
40
41=== added symlink 'hooks/local-monitors-relation-joined'
42=== target is u'monitors-relation-joined'
43=== added file 'hooks/monitors-relation-broken'
44--- hooks/monitors-relation-broken 1970-01-01 00:00:00 +0000
45+++ hooks/monitors-relation-broken 2012-08-02 21:30:25 +0000
46@@ -0,0 +1,8 @@
47+#!/bin/bash
48+set -ue
49+. hooks/monitors.common.bash
50+if [ -r "$revoke_todo" ] ; then
51+ sed -e 's/^/REVOKE USAGE ON *.* FROM /;s/$/\;/;' < $revoke_todo
52+ sed -e 's/^/REVOKE USAGE ON *.* FROM /;s/$/\;/;' < $revoke_todo | $MYSQL
53+ rm -f $revoke_todo
54+fi
55
56=== added file 'hooks/monitors-relation-departed'
57--- hooks/monitors-relation-departed 1970-01-01 00:00:00 +0000
58+++ hooks/monitors-relation-departed 2012-08-02 21:30:25 +0000
59@@ -0,0 +1,3 @@
60+#!/bin/bash
61+. /usr/share/charm-helpers/sh/net.sh
62+$MYSQL -e "REVOKE USAGE ON *.* FROM '${monitor_user}'@'${remote_addr}'"
63
64=== added file 'hooks/monitors-relation-joined'
65--- hooks/monitors-relation-joined 1970-01-01 00:00:00 +0000
66+++ hooks/monitors-relation-joined 2012-08-02 21:30:25 +0000
67@@ -0,0 +1,7 @@
68+#!/bin/bash
69+set -ue
70+. hooks/monitors.common.bash
71+echo "'${monitor_user}'@'${remote_addr}'" >> $revoke_todo
72+$MYSQL -e "GRANT USAGE ON *.* TO '${monitor_user}'@'${remote_addr}'"
73+
74+relation-set monitors="$(cat monitors.yaml)" target-id=${JUJU_UNIT_NAME//\//-} target-address=$(unit-get private-address)
75
76=== added file 'hooks/monitors.common.bash'
77--- hooks/monitors.common.bash 1970-01-01 00:00:00 +0000
78+++ hooks/monitors.common.bash 2012-08-02 21:30:25 +0000
79@@ -0,0 +1,8 @@
80+MYSQL="mysql -uroot -p`cat /var/lib/juju/mysql.passwd`"
81+monitor_user=monitors
82+. /usr/share/charm-helper/sh/net.sh
83+if [ -n "$JUJU_REMOTE_UNIT" ] ; then
84+ remote_addr=$(ch_get_ip $(relation-get private-address))
85+fi
86+mkdir -p data
87+revoke_todo=data/${JUJU_RELATION_ID}
88
89=== modified file 'metadata.yaml'
90--- metadata.yaml 2012-05-22 22:15:41 +0000
91+++ metadata.yaml 2012-08-02 21:30:25 +0000
92@@ -1,4 +1,5 @@
93 name: mysql
94+format: 2
95 summary: MySQL is a fast, stable and true multi-user, multi-threaded SQL database
96 maintainer: Clint Byrum <clint@ubuntu.com>
97 description: |
98@@ -17,6 +18,11 @@
99 interface: mysql-oneway-replication
100 munin:
101 interface: munin-node
102+ monitors:
103+ interface: monitors
104+ local-monitors:
105+ interface: local-monitors
106+ scope: container
107 requires:
108 slave:
109 interface: mysql-oneway-replication
110
111=== added file 'monitors.yaml'
112--- monitors.yaml 1970-01-01 00:00:00 +0000
113+++ monitors.yaml 2012-08-02 21:30:25 +0000
114@@ -0,0 +1,13 @@
115+version: '0.3'
116+monitors:
117+ local:
118+ procrunning:
119+ mysqld:
120+ name: MySQL Running
121+ min: 1
122+ max: 1
123+ executable: mysqld
124+ remote:
125+ mysql:
126+ basic:
127+ user: monitors
128
129=== modified file 'revision'
130--- revision 2012-04-25 08:23:44 +0000
131+++ revision 2012-08-02 21:30:25 +0000
132@@ -1,1 +1,1 @@
133-121
134+145

Subscribers

People subscribed via source and target branches

to all changes: