-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Livestatus Host SLA Dashboard with ninja script and enabled sam…
…e in relevant config files
- Loading branch information
Showing
4 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Script to request a hosts' SLA by accessing MK Livestatus | ||
import socket | ||
import sys,splunk.Intersplunk | ||
import string | ||
from datetime import datetime, timedelta | ||
|
||
results = [] | ||
|
||
try: | ||
|
||
results,dummyresults,settings = splunk.Intersplunk.getOrganizedResults() | ||
|
||
for r in results: | ||
if "_raw" in r: | ||
if "src_host" in r: | ||
try: | ||
HOST = 'nagios1' # The remote nagios server | ||
PORT = 6557 # The remote port on the nagios server | ||
N = int(r["daysago"]) | ||
nowepoch = datetime.now() | ||
nowepoch2 = nowepoch.strftime("%s") | ||
date_N_days_ago = datetime.now() - timedelta(days=N) | ||
date_N_days_ago2 = date_N_days_ago.strftime("%s") | ||
content = [ "GET statehist\nFilter: host_name = ", (r["src_host"]), "\nFilter: service_description = ", "\nFilter: time >= ", date_N_days_ago2, "\nFilter: time < ", nowepoch2, "\nStats: sum duration_part_ok", "\n" ] | ||
query = "".join(content) | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.connect((HOST, PORT)) | ||
s.send(query) | ||
s.shutdown(socket.SHUT_WR) | ||
data = s.recv(100000000) | ||
livehostsla = string.split(data) | ||
s.close() | ||
r["livehostsla"] = livehostsla[0] | ||
except: | ||
r["livehostsla"] = "0" | ||
|
||
except: | ||
import traceback | ||
stack = traceback.format_exc() | ||
results = splunk.Intersplunk.generateErrorResults("Error : Traceback: " + str(stack)) | ||
|
||
splunk.Intersplunk.outputResults( results ) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
[capability::run_script_liveservicesla] | ||
[capability::run_script_livehostsla] | ||
|
||
[role_admin] | ||
run_script_liveservicesla = enabled | ||
run_script_livehostsla = enabled | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[liveservicesla] | ||
filename = liveservicesla.py | ||
|
||
[livehostsla] | ||
filename = livehostsla.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<view autoCancelInterval="90" isVisible="true" onunloadCancelJobs="true" template="dashboard.html"> | ||
<label>Livestatus Host SLA Dashboard</label> | ||
<module name="AccountBar" layoutPanel="appHeader"/> | ||
<module name="AppBar" layoutPanel="navigationHeader"/> | ||
<module name="Message" layoutPanel="messaging"> | ||
<param name="filter">*</param> | ||
<param name="clearOnJobDispatch">False</param> | ||
<param name="maxSize">1</param> | ||
</module> | ||
<module name="Message" layoutPanel="messaging"> | ||
<param name="filter">splunk.search.job</param> | ||
<param name="clearOnJobDispatch">True</param> | ||
<param name="maxSize">1</param> | ||
</module> | ||
<module name="TitleBar" layoutPanel="viewHeader"> | ||
<param name="actionsMenuFilter">dashboard</param> | ||
</module> | ||
|
||
<module name="HiddenSearch" layoutPanel="viewHeader"> | ||
<param name="search">index=nagios src_host="$nagiosdevice$" nagiosevent="CURRENT HOST STATE" | eval daysago=$daysago$ | dedup src_host | livehostsla | eval SLA=livehostsla*100 | table _time src_host SLA</param> | ||
|
||
<module name="SearchSelectLister"> | ||
<param name="staticFieldsToDisplay"> | ||
<list> | ||
<param name="value">*</param> | ||
<param name="label">All</param> | ||
</list> | ||
</param> | ||
<param name="search">earliest=-24h index="nagios" nagiosevent="CURRENT HOST STATE" | rex ".+CURRENT HOST STATE\: (?P<device>[^;]*)(?=;)"| stats count by device</param> | ||
<param name="selected">eping.big-data.com.au</param> | ||
<param name="label">Select a Hostname</param> | ||
<param name="settingToCreate">nagiosdevice_setting</param> | ||
<param name="searchFieldsToDisplay"> | ||
<list> | ||
<param name="value">device</param> | ||
<param name="label">device</param> | ||
</list> | ||
</param> | ||
<param name="searchWhenChanged">True</param> | ||
<module name="ConvertToIntention"> | ||
<param name="settingToConvert">nagiosdevice_setting</param> | ||
<param name="intention"> | ||
<param name="name">stringreplace</param> | ||
<param name="arg"> | ||
<param name="nagiosdevice"> | ||
<param name="default">eping.big-data.com.au</param> | ||
<param name="fillOnEmpty">True</param> | ||
<param name="value">$target$</param> | ||
</param> | ||
</param> | ||
</param> | ||
|
||
<module name="ExtendedFieldSearch"> | ||
<param name="replacementMap"> | ||
<param name="arg"> | ||
<param name="daysago"> | ||
<param name="value"></param> | ||
</param> | ||
</param> | ||
</param> | ||
<param name="field">Enter the number of days:</param> | ||
<param name="q">7</param> | ||
<param name="intention"> | ||
<param name="name">stringreplace</param> | ||
<param name="arg"> | ||
<param name="daysago"> | ||
<param name="fillOnEmpty">True</param> | ||
</param> | ||
</param> | ||
</param> | ||
|
||
<module name="TimeRangePicker"> | ||
<param name="searchWhenChanged">False</param> | ||
<module name="SubmitButton"> | ||
<param name="allowSoftSubmit">True</param> | ||
<param name="label">Search</param> | ||
<module name="Paginator" layoutPanel="panel_row1_col1"> | ||
<param name="count">20</param> | ||
<param name="entityName">results</param> | ||
<module name="EnablePreview"> | ||
<param name="enable">True</param> | ||
<param name="display">False</param> | ||
<module name="SimpleResultsTable"> | ||
<param name="count">20</param> | ||
<param name="entityName">results</param> | ||
<param name="allowTransformedFieldSelect">True</param> | ||
<param name="drilldown">row</param> | ||
<module name="Gimp"/> | ||
<module name="ConvertToDrilldownSearch"> | ||
<module name="ViewRedirector"> | ||
<param name="viewTarget">flashtimeline</param> | ||
</module> | ||
</module> | ||
</module> | ||
<module name="ViewRedirectorLink"> | ||
<param name="viewTarget">flashtimeline</param> | ||
</module> | ||
</module> | ||
</module> | ||
</module> | ||
</module> | ||
</module> | ||
</module> | ||
|
||
</module> | ||
</module> | ||
|
||
</view> | ||
|