-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNagiosStatus.m
59 lines (39 loc) · 1.13 KB
/
NagiosStatus.m
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
//
// HostsStatus.m
// iMonitor
//
// Created by Sylvain Gizard on 15/02/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "NagiosStatus.h"
int const HOST_UP = 0;
int const HOST_DOWN = 1;
int const SERVICE_UP = 0;
int const SERVICE_WARNING = 1;
int const SERVICE_CRITICAL = 2;
int const SERVICE_PENDING = 3;
@implementation NagiosStatus
@synthesize resultsByStatus;
@synthesize results;
- (id) initWithNagiosData:(NSArray*)nagiosResults{
self = [super init];
self.results = nagiosResults;
NSMutableDictionary* sortByStatus = [[NSMutableDictionary alloc] init];
for (NSDictionary* entity in results) {
NSNumber* currentState = [NSNumber numberWithInt:[[entity objectForKey:@"current_state"] intValue]];
NSMutableArray* statusArray = [sortByStatus objectForKey:currentState];
if (statusArray==nil) {
statusArray = [[NSMutableArray alloc]init];
[sortByStatus setObject:statusArray forKey:currentState];
}
resultsByStatus = sortByStatus;
[statusArray addObject:entity];
}
return self;
}
- (void)dealloc {
[super dealloc];
[results release];
[resultsByStatus release];
}
@end