Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icidash
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Grewe
icidash
Commits
d57e76b6
Commit
d57e76b6
authored
10 years ago
by
Jan Grewe
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
icidash.js
+110
-0
110 additions, 0 deletions
icidash.js
index.html
+47
-0
47 additions, 0 deletions
index.html
with
157 additions
and
0 deletions
icidash.js
0 → 100644
+
110
−
0
View file @
d57e76b6
if
(
window
.
location
.
hostname
==
'
localhost
'
)
{
var
jsonSource
=
'
test.json
'
;
}
else
{
var
jsonSource
=
'
/cgi-bin/icinga/status.cgi?hosts=all&style=hostservicedetail&hoststatustypes=12&hostprops=2097162&servicestatustypes=28&serviceprops=2097162&nostatusheader&jsonoutput
'
}
$
(
document
).
ready
(
function
()
{
getAlerts
();
setInterval
(
function
()
{
getAlerts
();
},
10000
);
});
function
getAlerts
()
{
$
(
'
#alerts
'
).
spin
({
lines
:
13
,
length
:
20
,
width
:
10
,
radius
:
30
});
$
.
getJSON
(
jsonSource
,
function
(
data
)
{
hosts
=
data
.
status
.
host_status
;
services
=
data
.
status
.
service_status
;
alerts
=
hosts
.
concat
(
services
);
alerts
.
sort
(
durationSorter
);
alerts
.
sort
(
statusSorter
);
$
(
"
span.label-danger
"
).
trigger
(
'
stopRumble
'
);
$
(
'
#alerts
'
).
spin
(
false
).
empty
();
$
.
each
(
alerts
,
function
(
i
,
e
)
{
var
rowClass
=
''
;
switch
(
e
.
status
)
{
case
'
DOWN
'
:
var
rowClass
=
'
danger
'
;
break
;
case
'
CRITICAL
'
:
var
rowClass
=
'
danger
'
;
break
;
case
'
WARNING
'
:
var
rowClass
=
'
warning
'
;
break
;
case
'
UNKNOWN
'
:
var
rowClass
=
'
info
'
;
break
;
}
if
(
typeof
e
.
service
==
'
undefined
'
)
{
e
.
service
=
'
Host Down
'
;
}
e
.
host
=
e
.
host
.
replace
(
/
\.
magic-technik
\.
de|
\.
srv
\.
mediaways
\.
net/g
,
''
);
var
row
=
'
<tr class="
'
+
rowClass
+
'
status_main">
'
+
'
<td class="rowLabel text-center" valign="middle" rowspan="2"><span class="label label-
'
+
rowClass
+
'
">
'
+
e
.
status
+
'
</span></td>
'
+
'
<td>
'
+
e
.
host
+
'
</td>
'
+
'
<td>
'
+
e
.
service
+
'
</td>
'
+
'
</tr>
'
;
row_info
=
'
<tr class="
'
+
rowClass
+
'
status_info"><td>
'
+
e
.
duration
+
'
</td><td>
'
+
e
.
status_information
+
'
</td></tr>
'
;
$
(
'
#alerts
'
).
append
(
row
).
append
(
row_info
);
});
highlight
(
"
tr.danger.status_main td
"
);
$
(
"
span.label-danger
"
).
jrumble
({
x
:
5
,
y
:
5
,
rotation
:
10
,
speed
:
75
}).
trigger
(
'
startRumble
'
);
});
}
function
highlight
(
selector
)
{
$
(
selector
).
each
(
function
()
{
$
(
this
).
animate
(
{
color
:
"
#f00
"
},
200
).
animate
(
{
color
:
"
#000
"
},
700
,
'
linear
'
,
function
()
{
highlight
(
selector
);
});
});
}
function
getSeconds
(
str
)
{
var
sum
=
0
;
var
days
=
str
.
match
(
/
(\d
+
)
d/
);
var
hours
=
str
.
match
(
/
(\d
+
)
h/
);
var
minutes
=
str
.
match
(
/
(\d
+
)
m/
);
var
seconds
=
str
.
match
(
/
(\d
+
)
s/
);
if
(
days
)
{
sum
+=
parseInt
(
days
[
1
])
*
86400
;
}
if
(
hours
)
{
sum
+=
parseInt
(
hours
[
1
])
*
3600
;
}
if
(
minutes
)
{
sum
+=
parseInt
(
minutes
[
1
])
*
60
;
}
return
sum
;
}
var
durationSorter
=
function
(
a
,
b
)
{
var
aDur
=
getSeconds
(
a
.
duration
);
var
bDur
=
getSeconds
(
b
.
duration
);
if
(
aDur
>
bDur
)
{
return
1
;
}
else
{
return
-
1
;
}
};
var
statusSorter
=
function
(
a
,
b
)
{
if
(
a
.
status
==
'
DOWN
'
)
{
return
-
1
;
}
else
{
if
(
b
.
status
==
'
DOWN
'
)
{
return
1
;
}
else
{
if
(
a
.
status
==
'
CRITICAL
'
)
{
return
-
1
;
}
else
{
if
(
b
.
status
==
'
CRITICAL
'
)
{
return
1
;
}
if
(
a
.
status
==
'
UNKNOWN
'
)
{
return
-
1
;
}
else
{
if
(
b
.
status
==
'
UNKNOWN
'
)
{
return
1
;
}
}
}
}
}
};
This diff is collapsed.
Click to expand it.
index.html
0 → 100644
+
47
−
0
View file @
d57e76b6
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Icinga Dashboard
</title>
<link
rel=
"stylesheet"
href=
"//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
href=
"//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"
>
<style>
tr
{
font-size
:
250%
;
}
tr
.danger
{
font-size
:
400%
;
}
tr
.status_info
{
font-size
:
150%
;
}
td
{
font-weight
:
bold
;
overflow
:
hidden
;
white-space
:
nowrap
;
}
#alerts
td
{
border
:
0
;
}
#alerts
tr
.status_info
{
border-bottom
:
1px
solid
rgba
(
0
,
0
,
0
,
0.2
);
color
:
rgba
(
0
,
0
,
0
,
0.6
);
}
td
.rowLabel.text-center
{
vertical-align
:
middle
;
}
</style>
</head>
<body>
<table
class=
"table"
id=
"alerts"
></table>
<script
src=
"//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
></script>
<script
src=
"//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"
></script>
<script
src=
"//cdnjs.cloudflare.com/ajax/libs/spin.js/2.0.1/spin.min.js"
></script>
<script
src=
"//fgnass.github.io/spin.js/jquery.spin.js"
></script>
<script
src=
"//cdnjs.cloudflare.com/ajax/libs/jquery-color/2.1.2/jquery.color.min.js"
></script>
<script
src=
"//cdn.rawgit.com/jackrugile/jrumble/master/jquery.jrumble.min.js"
></script>
<script
src=
"icidash.js"
></script>
</body>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment