Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
adding some 500 codes
Browse files Browse the repository at this point in the history
  • Loading branch information
tuwid committed Feb 7, 2016
1 parent c8c0b3e commit 5bda4cb
Show file tree
Hide file tree
Showing 6 changed files with 8,826 additions and 62 deletions.
3 changes: 2 additions & 1 deletion models/service_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function serviceData(service_id){
status: String,
status_code: String,
source: String,
message: {}
message: {},
content: String
},{ strict: false });

serviceDataSchema.plugin(mongoosePaginate);
Expand Down
76 changes: 53 additions & 23 deletions modules/checkHttpStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,43 +70,46 @@ function checkHttpStatus(data, timeout, cb) {
// internal error
switch(res.statusCode){
case 500:
messageC = 'Bad Request';
messageC = 'Internal Server Error';
break;
case 500:
messageC = 'Bad Request';
case 501:
messageC = 'Not Implemented';
break;
case 500:
messageC = 'Bad Request';
case 502:
messageC = 'Bad Gateway';
break;
case 500:
messageC = 'Bad Request';
case 503:
messageC = 'Service Unavailable';
break;
case 500:
messageC = 'Bad Request';
case 504:
messageC = 'Gateway Timeout';
break;
case 500:
messageC = 'Bad Request';
case 505:
messageC = 'HTTP Version Not Supported';
break;
case 500:
messageC = 'Bad Request';
case 506:
messageC = 'Variant Also Negotiates';
break;
case 500:
messageC = 'Bad Request';
case 507:
messageC = 'Insufficient Storage';
break;
case 500:
messageC = 'Bad Request';
case 508:
messageC = 'Loop Detected';
break;
case 500:
messageC = 'Bad Request';
case 509:
messageC = 'Unassigned';
break;
case 500:
messageC = 'Bad Request';
case 510:
messageC = 'Not Extended';
break;
case 511:
messageC = 'Network Authentication Required';
break;
default:

messageC = 'Unassigned 500 Error';
}
console.log('Not found, Got code: ', res.statusCode);
return cb({message: 'Internal Server Error ', status_code: res.statusCode, status: 'ERROR', dump : body});
return cb({message: messageC, status_code: res.statusCode, status: 'ERROR', dump : body});
}

if(res.statusCode >= 400 && res.statusCode < 500){
Expand Down Expand Up @@ -166,6 +169,33 @@ function checkHttpStatus(data, timeout, cb) {
case 417:
messageC = 'Expectation Failed';
break;
case 421:
messageC = 'Misdirected Request';
break;
case 422:
messageC = 'Unprocessable Entity';
break;
case 423:
messageC = 'Locked';
break;
case 424:
messageC = 'Failed Dependency';
break;
case 426:
messageC = 'Upgrade Required';
break;
case 428:
messageC = 'Precondition Required';
break;
case 429:
messageC = 'Too Many Requests';
break;
case 431:
messageC = 'Request Header Fields Too Large';
break;
case 451:
messageC = 'Unavailable for Legal Reasons';
break;
default:
messageC = 'Unassigned 400 ERROR';
}
Expand Down
31 changes: 6 additions & 25 deletions modules/checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,6 @@ var logger = require('../modules/logger.js')('checker', configs.logs.check
var _ = require('underscore');


// we will store these in redis later
function getStatusCodeDescription(statusCode) {
//switch(statusCode){
// case '-1':
// return 'unknown';
// break;
// case'-2' :
// break;
// case '-3' :
// return 'unknown';
// break;
// case '-4' :
// return 'unknown';
// break;
// case '-5' :
// return 'unknown';
// break;
// case '-6' :
// return 'unknown';
// default:
// return 'unknown';
//}
}

function updateAndNotify(notific,status_subject){
// TODO: add notific type to implement SMS, TWEET, push_notific and other type of notifications
Expand Down Expand Up @@ -186,13 +163,17 @@ function checker(new_data){
logger('debug', 'Checking OLD and NEW status code');
logger('debug', 'New: ' + new_data.status_code + " Old: " + last_data.status_code);
if (new_data.status_code != last_data.status_code || last_data.no_previous_data == 1 || diff.length > 0) {
var sData = new serviceData({
var serviceDataObject = {
message: new_data.message,
status: new_data.status,
status_code: new_data.status_code,
source: new_data.source
// to be ndrruar source_IP me x-forwarded-for me vone
});
};
if(new_data.content != null){
serviceDataObject.content = new_data.content;
}
var sData = new serviceData(serviceDataObject);
sData.save(function (err) {
if (!err) {
logger('info', '[checker] Event successfully saved into collection');
Expand Down
Loading

0 comments on commit 5bda4cb

Please sign in to comment.