/usr/share/shinken/htdocs/js/shinken-actions.js is in shinken-module-broker-webui 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | /*Copyright (C) 2009-2012 :
Gabes Jean, naparuba@gmail.com
Gerhard Lausser, Gerhard.Lausser@consol.de
Gregory Starck, g.starck@gmail.com
Hartmut Goebel, h.goebel@goebel-consult.de
Andreas Karfusehr, andreas@karfusehr.de
This file is part of Shinken.
Shinken is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Shinken 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Shinken. If not, see <http://www.gnu.org/licenses/>.
*/
/* ************************************* Message raise part ******************* */
function raise_message_ok(text){
$.meow({
message: text,
icon: '/static/images/ok_medium.png'
});
}
function raise_message_error(text){
$.meow({
message: text,
icon: '/static/images/down_medium.png'
});
}
/* React to an action return of the /action page. Look at status
to see if it's ok or not */
function react(response){
//alert('In react'+ response+response.status);
//alert(response.status == 200);
if(response.status == 200){
raise_message_ok(response.text);
}else{
raise_message_error(response.text);
}
}
function manage_error(response){
//alert('In manage_error'+response);
//alert(response.status);
//alert(response.responseText);
raise_message_error(response.responseText);
}
/* ************************************* Launch the request ******************* */
function launch(url){
// this code will send a data object via a GET request and alert the retrieved data.
//alert('Try to get' + url+'?callback=?');
$.jsonp({
"url": url+'?callback=?',
"success": react,
"error": manage_error
});
}
/* ************************************* Commands ******************* */
function get_elements(name){
var elts = name.split('/');
var elt = {type : 'UNKNOWN',
namevalue : 'NOVALUE'
};
/* 1 element mean HOST*/
if (elts.length == 1){
elt.type = 'HOST';
elt.type_long = 'HOST';
elt.namevalue = elts[0];
elt.nameslash = elts[0];
}else{ // 2 means Service
elt.type = 'SVC';
elt.type_long = 'SERVICE';
elt.namevalue = elts[0]+';'+elts[1];
elt.nameslash = elts[0]+'/'+elts[1];
// And now for all elements, change the / into a $SLASH$ macro
for(var i=2; i<elts.length; i++){
elt.namevalue = elt.namevalue+ '$SLASH$'+ elts[i];
elt.nameslash = elt.nameslash+ '$SLASH$'+ elts[i];
}
}
return elt
}
/* The command that will launch an event handler */
function try_to_fix(name) {
var elts = get_elements(name);
var url = '/action/LAUNCH_'+elts.type+'_EVENT_HANDLER/'+elts.namevalue;
// We can launch it :)
launch(url);
}
function do_acknowledge(name, text, user){
var elts = get_elements(name);
var url = '/action/ACKNOWLEDGE_'+elts.type+'_PROBLEM/'+elts.nameslash+'/1/0/1/'+user+'/'+text;
launch(url);
}
function do_remove(name, text, user){
var elts = get_elements(name);
/* A Remove is in fact some several commands :
DISABLE_SVC_CHECK
DISABLE_PASSIVE_SVC_CHECKS
DISABLE_SVC_NOTIFICATIONS
DISABLE_SVC_EVENT_HANDLER
PROCESS_SERVICE_CHECK_RESULT
*/
disable_notifications(elts);
disable_event_handlers(elts);
submit_check(name, 0, text);
// WARNING : Disable passive checks make the set not push,
// so we only disable active checks
disable_checks(elts, false);
// And later after (10s), we push a full disable, so passive too
setTimeout(function(){disable_checks(elts, true);}, 10000);
}
//# SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
function do_schedule_downtime(name, start_time, end_time, user, comment){
var elts = get_elements(name);
var url = '/action/SCHEDULE_'+elts.type+'_DOWNTIME/'+elts.nameslash+'/'+start_time+'/'+end_time+'/1/0/0/'+user+'/'+comment;
launch(url);
}
function submit_check(name, return_code, output){
var elts = get_elements(name);
var url = '/action/PROCESS_'+elts.type_long+'_CHECK_RESULT/'+elts.nameslash+'/'+return_code+'/'+output;
//alert('Try to submit check' + url);
// We can launch it :)
launch(url);
}
/* The command that will launch an event handler */
function recheck_now(name) {
var elts = get_elements(name);
//alert('Try to fix' + hname);
var now = '$NOW$';
var url = '/action/SCHEDULE_FORCED_'+elts.type+'_CHECK/'+elts.nameslash+'/'+now;
// We can launch it :)
launch(url);
}
/* For some commands, it's a toggle/un-toggle way */
/* We to the active AND passive in the same way, and the services
in the same time */
function toggle_checks(name, b){
//alert('toggle_active_checks::'+hname+b);
var elts = get_elements(name);
// Inverse the active check or not for the element
if(b){ // go disable
disable_checks(elts, true);
}else{ // Go enable, passive too
enable_checks(elts, true);
}
}
function enable_checks(elts, passive_too){
var url = '/action/ENABLE_'+elts.type+'_CHECK/'+elts.nameslash;
launch(url);
if(passive_too){
var url = '/action/ENABLE_PASSIVE_'+elts.type+'_CHECKS/'+elts.nameslash;
launch(url);
}
// Disable host services only if it's an host ;)
if(elts.type == 'HOST'){
var url = '/action/ENABLE_HOST_SVC_CHECKS/'+elts.nameslash;
launch(url);
}
}
function disable_checks(elts, passive_too){
var url = '/action/DISABLE_'+elts.type+'_CHECK/'+elts.nameslash;
launch(url);
if(passive_too){
var url = '/action/DISABLE_PASSIVE_'+elts.type+'_CHECKS/'+elts.nameslash;
launch(url);
}
// Disable host services only if it's an host ;)
if(elts.type == 'HOST'){
var url = '/action/DISABLE_HOST_SVC_CHECKS/'+elts.nameslash;
launch(url);
}
}
function toggle_notifications(name, b){
var elts = get_elements(name);
//alert('toggle_active_checks::'+hname+b);
// Inverse the active check or not for the element
if(b){ // go disable
disable_notifications(elts);
}else{ // Go enable
enable_notifications(elts);
}
}
function disable_notifications(elts){
var url = '/action/DISABLE_'+elts.type+'_NOTIFICATIONS/'+elts.nameslash;
launch(url);
}
function enable_notifications(elts){
var url = '/action/ENABLE_'+elts.type+'_NOTIFICATIONS/'+elts.nameslash;
launch(url);
}
function toggle_event_handlers(name, b){
var elts = get_elements(name);
//alert('toggle_active_checks::'+hname+b);
// Inverse the active check or not for the element
if(b){ // go disable
disable_event_handlers(elts);
}else{ // Go enable
enable_event_handlers(elts);
}
}
function enable_event_handlers(elts){
var url = '/action/ENABLE_'+elts.type+'_EVENT_HANDLER/'+elts.nameslash;
launch(url);
}
function disable_event_handlers(elts){
var url = '/action/DISABLE_'+elts.type+'_EVENT_HANDLER/'+elts.nameslash;
launch(url);
}
function toggle_flap_detection(name, b){
var elts = get_elements(name);
//alert('toggle_flap::'+name+b);
// Inverse the active check or not for the element
if(b){ //go disable
var url = '/action/DISABLE_'+elts.type+'_FLAP_DETECTION/'+elts.nameslash;
launch(url);
}else{ // Go enable
var url = '/action/ENABLE_'+elts.type+'_FLAP_DETECTION/'+elts.nameslash;
launch(url);
}
}
//ADD_SVC_COMMENT;<host_name>;<service_description>;<persistent>;<author>;<comment>
// We add a persistent comment
function add_comment(name, user, comment){
var elts = get_elements(name);
var url = '/action/ADD_'+elts.type+'_COMMENT/'+elts.nameslash+'/1/'+user+'/'+comment;
// We can launch it :)
launch(url);
}
/* The command that will launch an event handler */
function delete_comment(name, i) {
var elts = get_elements(name);
var url = '/action/DEL_'+elts.type+'_COMMENT/'+i;
// We can launch it :)
launch(url);
}
/* The command that will launch an event handler */
function delete_all_comments(name) {
var elts = get_elements(name);
var url = '/action/DEL_ALL_'+elts.type+'_COMMENTS/'+elts.nameslash;
// We can launch it :)
launch(url);
}
/* The command that will launch an event handler */
function delete_downtime(name, i) {
var elts = get_elements(name);
var url = '/action/DEL_'+elts.type+'_DOWNTIME/'+i;
// We can launch it :)
launch(url);
}
/* The command that will launch an event handler */
function delete_all_downtimes(name) {
var elts = get_elements(name);
var url = '/action/DEL_ALL_'+elts.type+'_DOWNTIMES/'+elts.nameslash;
// We can launch it :)
launch(url);
}
|