$(document).ready(function (){ var config = { uptimerobot: { api_keys: ['m776590650-e291a9a509ce82dc719350d6', 'm776590666-a657ffa8828aea401e337879', 'm776590648-36bde29bdc0b551f8ea18b88', 'm778556460-a25f70740ba97f693ea2ac5d', 'm776590646-e51287a02018f0947feda64a'] , logs: 1} , github: { org: 'flybaseio', repo: 'status'} } ; var status_text = { 'operational': 'operational', 'investigating': 'investigating', 'major outage': 'outage', 'degraded performance': 'degraded'} ; var monitors = config.uptimerobot.api_keys; for (var i in monitors){ var api_key = monitors[i]; $.post('https://api.uptimerobot.com/v2/getMonitors', { "api_key": api_key, "format": "json", "logs": config.uptimerobot.logs} , function (response){ status(response); } , 'json'); } function status(data){ data.monitors = data.monitors.map(function (check){ check["class"] = check.status === 2? 'label-success': 'label-danger'; _AN_Write_text('text', check, false , check.status === 2? 'operational': 'major outage'); if (check.status !== 2 && !check.lasterrortime) { check.lasterrortime = Date.now(); } if (check.status === 2 && Date.now() - (check.lasterrortime * 1000) <= 86400000) { check["class"] = 'label-warning'; _AN_Write_text('text', check, false , 'degraded performance'); } return check; } ); var status = data.monitors.reduce(function (status, check){ return check.status !== 2? 'danger': 'operational'; } , 'operational'); if (!$('#panel').data('incident')) { $('#panel').attr('class', (status === 'operational'? 'panel-success': 'panel-warning')); $('#paneltitle').html(status === 'operational'? 'All systems are operational.': 'One or more systems inoperative'); } data.monitors.forEach(function (item){ var name = item.friendly_name; var clas = item["class"] ; var text = item.text; $('#services').append('
' + '' + text + '' + '

' + name + '

' + '
'); } ); } ; $.getJSON('https://api.github.com/repos/' + config.github.org + '/' + config.github.repo + '/issues?state=all').done(message); function message(issues){ issues.forEach(function (issue){ var status = issue.labels.reduce(function (status, label){ if (/^status:/.test(label.name)) { return _AN_Call_replace('replace', label.name, 'status:', ''); } else { return status; } } , 'operational'); var systems = issue.labels.filter(function (label){ return /^system:/.test(label.name); } ).map(function (label){ return _AN_Call_replace('replace', label.name, 'system:', ''); } ); if (issue.state === 'open') { $('#panel').data('incident', 'true'); $('#panel').attr('class', (status === 'operational'? 'panel-success': 'panel-warn')); $('#paneltitle').html('' + issue.title + ''); } var html = '
\n'; html += '
\n'; if (issue.state === 'closed') { html += '
'; } else { html += '
'; } html += '
\n'; html += '' + datetime(issue.created_at) + '\n'; if (issue.state === 'closed') { html += 'closed'; } else { html += ''; html += "open"; html += '\n'; } for (var i = 0; i < _AN_Read_length('length', systems); i++ ){ html += '' + systems[i] + ''; } html += '

' + issue.title + '

\n'; html += '
\n'; html += '

' + issue.body + '

\n'; if (issue.state === 'closed') { html += '

Updated ' + datetime(issue.closed_at) + '
'; html += 'The system is back in normal operation.

'; } html += '
'; html += '
'; html += '
'; $('#incidents').append(html); } ); function datetime(string){ var datetime = string.split('T'); var date = datetime[0]; var time = _AN_Call_replace('replace', datetime[1], 'Z', ''); return date + ' ' + time; } ; } ; } );