-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.php
95 lines (83 loc) · 4.6 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/*
ex: set tabstop=4 shiftwidth=4 autoindent:
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2024 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
function plugin_maint_version() {
global $config;
$info = parse_ini_file($config['base_path'] . '/plugins/maint/INFO', true);
return $info['info'];
}
function plugin_maint_install() {
api_plugin_register_hook('maint', 'config_arrays', 'maint_config_arrays', 'setup.php');
api_plugin_register_hook('maint', 'draw_navigation_text', 'maint_draw_navigation_text', 'setup.php');
api_plugin_register_hook('maint', 'is_device_in_maintenance', 'plugin_maint_check_cacti_host', 'functions.php');
api_plugin_register_realm('maint', 'maint.php', 'Maintenance Schedules', 1);
maint_setup_database();
}
function plugin_maint_uninstall() {
}
function plugin_maint_check_config() {
return true;
}
function plugin_maint_upgrade() {
return false;
}
function maint_config_arrays() {
global $menu;
$menu[__('Management')]['plugins/maint/maint.php'] = __('Maintenance Schedules', 'maint');
if (function_exists('auth_augment_roles')) {
auth_augment_roles(__('System Administration'), array('maint.php'));
}
}
function maint_draw_navigation_text ($nav) {
$nav['maint.php:'] = array('title' => __('Maintenance Schedules', 'maint'), 'mapping' => 'index.php:', 'url' => 'maint.php', 'level' => '1');
$nav['maint.php:edit'] = array('title' => __('(edit)', 'maint'), 'mapping' => 'index.php:', 'url' => 'maint.php', 'level' => '2');
$nav['maint.php:actions'] = array('title' => __('(actions)', 'maint'), 'mapping' => 'index.php:', 'url' => 'maint.php', 'level' => '2');
return $nav;
}
function maint_setup_database() {
$data = array();
$data['columns'][] = array('name' => 'id', 'type' => 'int(11)', 'NULL' => false, 'auto_increment' => true);
$data['columns'][] = array('name' => 'enabled', 'type' => 'varchar(3)', 'NULL' => false, 'default' => 'on');
$data['columns'][] = array('name' => 'name', 'type' => 'varchar(128)', 'NULL' => true);
$data['columns'][] = array('name' => 'mtype', 'type' => 'int(11)', 'NULL' => false);
$data['columns'][] = array('name' => 'stime', 'type' => 'int(22)', 'NULL' => false);
$data['columns'][] = array('name' => 'etime', 'type' => 'int(22)', 'NULL' => false);
$data['columns'][] = array('name' => 'minterval', 'type' => 'int(11)', 'NULL' => false);
$data['primary'] = 'id';
$data['keys'][] = array('name' => 'mtype', 'columns' => 'mtype');
$data['keys'][] = array('name' => 'enabled', 'columns' => 'enabled');
$data['type'] = 'InnoDB';
$data['comment'] = 'Maintenance Schedules';
api_plugin_db_table_create ('maint', 'plugin_maint_schedules', $data);
$data = array();
$data['columns'][] = array('name' => 'type', 'type' => 'int(6)', 'NULL' => false);
$data['columns'][] = array('name' => 'host', 'type' => 'int(12)', 'NULL' => false);
$data['columns'][] = array('name' => 'schedule', 'type' => 'int(12)', 'NULL' => false);
$data['primary'] = 'type`,`schedule`,`host';
$data['keys'][] = array('name' => 'type', 'columns' => 'type');
$data['keys'][] = array('name' => 'schedule', 'columns' => 'schedule');
$data['type'] = 'InnoDB';
$data['comment'] = 'Maintenance Schedules Hosts';
api_plugin_db_table_create ('maint', 'plugin_maint_hosts', $data);
}