diff options
author | Vu Tran <vu.tran@windriver.com> | 2014-09-30 12:22:12 -0400 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-09-30 14:30:18 -0400 |
commit | b4d666ff63acd269b0acb2c4419643863c683750 (patch) | |
tree | f22e20ee845a0cca1fe0f7837d92a652325ba036 /meta-openstack/classes | |
parent | 1b8a298689a95c1943f18d8d9c24589e64bbc7b7 (diff) | |
download | meta-cloud-services-b4d666ff63acd269b0acb2c4419643863c683750.tar.gz |
add generic monitor framework
Instead of having a central file or group of files to
describe what data resources should be monitored. The
content of these files will depend on what core system
monitoring is used ((e.g. Nagios or Monasca).
It's desirable to have each recipe describes what
it wants be monitored in generic way such that various system
monitors can understand and convert these into their format.
If a recipe wishes to register itself to system monitor, it
inherits monitor bbclass and use MONITOR_SERVICE_PACKAGES and
MONITOR_SERVICE_<package name> to indicate what processes
should should be monitored. Also MONITOR_CHECKS_<package name>
variale can be used to pass list of scripts which will be run
on target and if any of these scripts fail then will report.
Eventually monitor.bbclass will be expanded to allow recipe
to describe more complicated information passed down to
system monitor (e.g. Nagios or Monasca)
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'meta-openstack/classes')
-rw-r--r-- | meta-openstack/classes/monitor.bbclass | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/meta-openstack/classes/monitor.bbclass b/meta-openstack/classes/monitor.bbclass new file mode 100644 index 0000000..83aaea2 --- /dev/null +++ b/meta-openstack/classes/monitor.bbclass | |||
@@ -0,0 +1,107 @@ | |||
1 | MONITOR_STAGING_DIR="${STAGING_DIR}/monitor" | ||
2 | MONITOR_STAGING_SERVICES_DIR="${MONITOR_STAGING_DIR}/services" | ||
3 | MONITOR_STAGING_CHECKS_DIR="${MONITOR_STAGING_DIR}/checks" | ||
4 | MONITOR_CONFIG_DIR="${IMAGE_ROOTFS}/etc/monitor" | ||
5 | MONITOR_CONFIG_SERVICES_DIR="${MONITOR_CONFIG_DIR}/services" | ||
6 | MONITOR_CONFIG_CHECKS_DIR="${MONITOR_CONFIG_DIR}/checks" | ||
7 | |||
8 | addtask monitor_install before do_package after do_install | ||
9 | addtask monitor_clean before do_clean | ||
10 | |||
11 | |||
12 | def copy_check_files(d, check_var_name, src, dest): | ||
13 | import shutil | ||
14 | |||
15 | mon_checks = bb.data.getVar(check_var_name, d, 1) | ||
16 | if mon_checks != None: | ||
17 | if not os.path.exists(dest): | ||
18 | os.makedirs(dest) | ||
19 | for check in mon_checks.split(): | ||
20 | if os.path.exists(src + "/" + check): | ||
21 | shutil.copy(src + "/" + check, dest) | ||
22 | os.chmod(dest + "/" + check, 0755) | ||
23 | |||
24 | python do_monitor_install() { | ||
25 | import shutil | ||
26 | |||
27 | if base_contains('OPENSTACK_EXTRA_FEATURES', 'monitoring', "0", "1", d) == "1": | ||
28 | bb.debug(1, 'OpenStack monitoring feature is disabled, skipping do_monitor_install') | ||
29 | return | ||
30 | |||
31 | mon_dir = bb.data.getVar('MONITOR_STAGING_DIR', d, 1) | ||
32 | mon_services_dir = bb.data.getVar('MONITOR_STAGING_SERVICES_DIR', d, 1) | ||
33 | mon_checks_dir = bb.data.getVar('MONITOR_STAGING_CHECKS_DIR', d, 1) | ||
34 | if not os.path.exists(mon_dir): | ||
35 | os.makedirs(mon_dir) | ||
36 | if not os.path.exists(mon_services_dir): | ||
37 | os.makedirs(mon_services_dir) | ||
38 | if not os.path.exists(mon_checks_dir): | ||
39 | os.makedirs(mon_checks_dir) | ||
40 | workdir = d.getVar('WORKDIR', True) | ||
41 | |||
42 | # Process monitor SERVICE catagory | ||
43 | mon_service_pkgs = bb.data.getVar('MONITOR_SERVICE_PACKAGES', d, 1) | ||
44 | if mon_service_pkgs != None: | ||
45 | for pkg in mon_service_pkgs.split(): | ||
46 | f_name = os.path.join(mon_services_dir, pkg + '.service') | ||
47 | if os.path.exists(f_name): | ||
48 | os.remove(f_name) | ||
49 | data = bb.data.getVar('MONITOR_SERVICE_' + pkg, d, 1) | ||
50 | if data != None: | ||
51 | f = open(f_name, 'w') | ||
52 | f.write(d.getVar('MONITOR_SERVICE_' + pkg)) | ||
53 | |||
54 | # Process monior CHECKS catagory | ||
55 | packages = (d.getVar('PACKAGES', True) or "").split() | ||
56 | if len(packages) >= 1 and os.path.exists(mon_checks_dir): | ||
57 | for pkg in packages: | ||
58 | copy_check_files(d, 'MONITOR_CHECKS_' + pkg, workdir, mon_checks_dir + '/' + pkg) | ||
59 | } | ||
60 | |||
61 | python do_monitor_clean() { | ||
62 | import shutil | ||
63 | |||
64 | mon_dir = bb.data.getVar('MONITOR_STAGING_DIR', d, 1) | ||
65 | mon_services_dir = bb.data.getVar('MONITOR_STAGING_SERVICES_DIR', d, 1) | ||
66 | mon_checks_dir = bb.data.getVar('MONITOR_STAGING_CHECKS_DIR', d, 1) | ||
67 | if not os.path.exists(mon_dir): | ||
68 | return | ||
69 | |||
70 | # Clean up monitor SERVICE catagory | ||
71 | mon_service_pkgs = bb.data.getVar('MONITOR_SERVICE_PACKAGES', d, 1) | ||
72 | if mon_service_pkgs != None and os.path.exists(mon_services_dir): | ||
73 | for pkg in mon_service_pkgs.split(): | ||
74 | f_name = os.path.join(mon_services_dir, pkg + '.service') | ||
75 | if os.path.exists(f_name): | ||
76 | os.remove(f_name) | ||
77 | |||
78 | # Process monior CHECKS catagory | ||
79 | packages = (d.getVar('PACKAGES', True) or "").split() | ||
80 | if len(packages) >= 1 and os.path.exists(mon_checks_dir): | ||
81 | for pkg in packages: | ||
82 | if bb.data.getVar('MONITOR_CHECKS_' + pkg, d, 1) != None: | ||
83 | shutil.rmtree(mon_checks_dir + "/" + pkg, True) | ||
84 | } | ||
85 | |||
86 | monitor_rootfs_postprocess() { | ||
87 | if ${@base_contains('OPENSTACK_EXTRA_FEATURES', 'monitoring', "false", "true", d)}; then | ||
88 | echo "OpenStack monitoring feature is disabled, skipping monitor_rootfs_postprocess" | ||
89 | exit | ||
90 | fi | ||
91 | |||
92 | mkdir -p ${MONITOR_CONFIG_DIR} > /dev/null 2>&1 | ||
93 | mkdir -p ${MONITOR_CONFIG_SERVICES_DIR} > /dev/null 2>&1 | ||
94 | mkdir -p ${MONITOR_CONFIG_CHECKS_DIR} > /dev/null 2>&1 | ||
95 | |||
96 | # Process monitor SERVICE catagory | ||
97 | files_list=`find ${MONITOR_STAGING_SERVICES_DIR} -type f` | ||
98 | for f in ${files_list}; do | ||
99 | cat $f >> ${MONITOR_CONFIG_SERVICES_DIR}/service_list.cfg | ||
100 | echo >> ${MONITOR_CONFIG_SERVICES_DIR}/service_list.cfg | ||
101 | done | ||
102 | |||
103 | # Process monior CHECKS catagory | ||
104 | cp -rf ${MONITOR_STAGING_CHECKS_DIR}/* ${MONITOR_CONFIG_CHECKS_DIR} | ||
105 | } | ||
106 | |||
107 | ROOTFS_POSTPROCESS_COMMAND += "monitor_rootfs_postprocess ; " | ||