coshsh
Posted on July 22nd, 2012 by lausser
/* Sans-serif font. */ h1, h2, h3, h4, h5, h6, div.title, caption.title, thead, p.table.header, div#toctitle, span#author, span#revnumber, span#revdate, span#revremark, div#footer { font-family: arial,helvetica,sans-serif; }
/* Serif font. */ div.sectionbody { font-family: georgia,"Times New Roman",times,serif; }
/* Monospace font. */ tt { font-size: inherit; }
body { margin: 1em 5% 1em 5%; }
a { color: blue; text-decoration: underline; } a:visited { color: fuchsia; }
em { font-style: italic; color: navy; }
strong { font-weight: bold; color: #083194; }
tt { font-size: inherit; color: navy; }
h1, h2, h3, h4, h5, h6 { color: #527bbd; margin-top: 1.2em; margin-bottom: 0.5em; line-height: 1.3; }
h1, h2, h3 { border-bottom: 2px solid silver; } h2 { padding-top: 0.5em; } h3 { float: left; } h3 + * { clear: left; }
div.sectionbody { margin-left: 0; }
hr { border: 1px solid silver; }
p { margin-top: 0.5em; margin-bottom: 0.5em; }
ul, ol, li > p { margin-top: 0; } ul > li { color: #aaa; } ul > li > * { color: black; }
pre { padding: 0; margin: 0; }
span#author { color: #527bbd; font-weight: bold; font-size: 1.1em; } span#email { } span#revnumber, span#revdate, span#revremark { }
div#footer { font-size: small; border-top: 2px solid silver; padding-top: 0.5em; margin-top: 4.0em; } div#footer-text { float: left; padding-bottom: 0.5em; } div#footer-badges { float: right; padding-bottom: 0.5em; }
div#preamble { margin-top: 1.5em; margin-bottom: 1.5em; } div.tableblock, div.imageblock, div.exampleblock, div.verseblock, div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, div.admonitionblock { margin-top: 1.0em; margin-bottom: 1.5em; } div.admonitionblock { margin-top: 2.0em; margin-bottom: 2.0em; margin-right: 10%; color: #606060; }
div.content { /* Block element content. */ padding: 0; }
/* Block element titles. */ div.title, caption.title { color: #527bbd; font-weight: bold; text-align: left; margin-top: 1.0em; margin-bottom: 0.5em; } div.title + * { margin-top: 0; }
td div.title:first-child { margin-top: 0.0em; } div.content div.title:first-child { margin-top: 0.0em; } div.content + div.title { margin-top: 0.0em; }
div.sidebarblock > div.content { background: #ffffee; border: 1px solid #dddddd; border-left: 4px solid #f0f0f0; padding: 0.5em; }
div.listingblock > div.content { border: 1px solid #dddddd; border-left: 5px solid #f0f0f0; background: #f8f8f8; padding: 0.5em; }
div.quoteblock, div.verseblock { padding-left: 1.0em; margin-left: 1.0em; margin-right: 10%; border-left: 5px solid #f0f0f0; color: #777777; }
div.quoteblock > div.attribution { padding-top: 0.5em; text-align: right; }
div.verseblock > pre.content { font-family: inherit; font-size: inherit; } div.verseblock > div.attribution { padding-top: 0.75em; text-align: left; } /* DEPRECATED: Pre version 8.2.7 verse style literal block. */ div.verseblock + div.attribution { text-align: left; }
div.admonitionblock .icon { vertical-align: top; font-size: 1.1em; font-weight: bold; text-decoration: underline; color: #527bbd; padding-right: 0.5em; } div.admonitionblock td.content { padding-left: 0.5em; border-left: 3px solid #dddddd; }
div.exampleblock > div.content { border-left: 3px solid #dddddd; padding-left: 0.5em; }
div.imageblock div.content { padding-left: 0; } span.image img { border-style: none; } a.image:visited { color: white; }
dl { margin-top: 0.8em; margin-bottom: 0.8em; } dt { margin-top: 0.5em; margin-bottom: 0; font-style: normal; color: navy; } dd > *:first-child { margin-top: 0.1em; }
ul, ol { list-style-position: outside; } ol.arabic { list-style-type: decimal; } ol.loweralpha { list-style-type: lower-alpha; } ol.upperalpha { list-style-type: upper-alpha; } ol.lowerroman { list-style-type: lower-roman; } ol.upperroman { list-style-type: upper-roman; }
div.compact ul, div.compact ol, div.compact p, div.compact p, div.compact div, div.compact div { margin-top: 0.1em; margin-bottom: 0.1em; }
div.tableblock > table { border: 3px solid #527bbd; } thead, p.table.header { font-weight: bold; color: #527bbd; } tfoot { font-weight: bold; } td > div.verse { white-space: pre; } p.table { margin-top: 0; } /* Because the table frame attribute is overriden by CSS in most browsers. */ div.tableblock > table[frame="void"] { border-style: none; } div.tableblock > table[frame="hsides"] { border-left-style: none; border-right-style: none; } div.tableblock > table[frame="vsides"] { border-top-style: none; border-bottom-style: none; }
div.hdlist { margin-top: 0.8em; margin-bottom: 0.8em; } div.hdlist tr { padding-bottom: 15px; } dt.hdlist1.strong, td.hdlist1.strong { font-weight: bold; } td.hdlist1 { vertical-align: top; font-style: normal; padding-right: 0.8em; color: navy; } td.hdlist2 { vertical-align: top; } div.hdlist.compact tr { margin: 0; padding-bottom: 0; }
.comment { background: yellow; }
.footnote, .footnoteref { font-size: 0.8em; }
span.footnote, span.footnoteref { vertical-align: super; }
footnotes {
margin: 20px 0 20px 0; padding: 7px 0 0 0; }
footnotes div.footnote {
margin: 0 0 5px 0; }
footnotes hr {
border: none; border-top: 1px solid silver; height: 1px; text-align: left; margin-left: 0; width: 20%; min-width: 100px; }
div.colist td { padding-right: 0.5em; padding-bottom: 0.3em; vertical-align: top; } div.colist td img { margin-top: 0.3em; }
@media print { div#footer-badges { display: none; } }
div#toc { margin-bottom: 2.5em; }
div#toctitle { color: #527bbd; font-size: 1.1em; font-weight: bold; margin-top: 1.0em; margin-bottom: 0.1em; }
div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { margin-top: 0; margin-bottom: 0; } div.toclevel2 { margin-left: 2em; font-size: 0.9em; } div.toclevel3 { margin-left: 4em; font-size: 0.9em; } div.toclevel4 { margin-left: 6em; font-size: 0.9em; }
coshsh Config-Generator für Shinken / Nagios /Icinga
JavaScript must be enabled in your browser to display the table of contents.
Was ist coshsh?
http://coshsh.org ist ein Framework, das bei der automatischen Erstellung von Konfigurationsdateien hilft.
Features
coshsh ist extrem schnell. (~60000 services in 10s) coshsh kann sehr einfach erweitert werden. coshsh liest nur Hosts und Applikationen. Services kommen später dazu.
Download
Support
-
Support und Beratung ist erhältlich bei www.consol.de
Changelog
Das Changelog findet man unter github.
Wie funktioniert’s?
Coshsh liest mit Hilfe von Adaptern beliebige Datenquellen, in denen Informationen über Hosts und die auf ihnen installierten Applikationen stehen. Die Host- und Servicedefinitionen werden erzeugt, indem Platzhalter in Template-Dateien ausgefüllt werden.
Grundbegriffe von coshsh
Coshsh unterscheidet sich von anderen Nagios-Config-Tools dadurch, dass Benutzer nicht interaktiv einzelne Objekte in einer Gui zusammenklicken. Bei Coshsh werden vorab Regeln erstellt und auf die zu überwachenden Objekte angewandt, welche aus sogenannten Datasources stammen.
Datasource
Die Rohdaten, die coshsh verarbeitet, stammen aus sogenannten Datasources. I.d.R. wird es pro Installation nur eine einzige Datenquelle geben. Diese kann ein Satz CSV-Dateien oder eine beliebige Datensammlung sein. Üblicherweise ist es die firmeneigene CMDB oder eine andere Datenbank, welche Hosts und Applikationen zum Zwecke des Monitorings enthält. Jeder Typ von Datasource muss auf individuelle Art ausgelesen werden. Entscheidend ist, dass der Rohdatenbestand in Listen von Host- und Applikationsobjekten umgewandelt und an coshsh geliefert wird. Dazu ist jeweils eine Datei namens datasource_<name>.py erstellt werden, die den nötigen Code enthält. Sie ist sozusagen der "Adapter", mit dessen Hilfe eine Datenquelle an coshsh angeschlossen werden kann. In der coshsh-Konfigurationsdatei werden Datasources folgendermassen beschrieben: [datasource_cmdb] type = mycmdb hostname = dbsrv1 username = cfggen password = secret
[datasource_extraapps] type = csv files = /omd/sites/gen/data
Die unterschiedlichen Parameter kommen natürlich daher, dass jede Datasource anders ist und auf andere Art geöffnet und ausgelesen wird.
Class
Im Datasource-Adapter werden Zeilen aus Datenbanktabellen oder Dateien gelesen. Diese repräsentieren Hosts und ihnen zugeordnete Applikationen. Zur weiteren Verarbeitung müssen diese in Python-Objekte umgewandelt werden. Dies geschieht, indem man die Konstruktoren Host() bzw. Application() aufruft. Für jeden Typ von Anwendung, der überwacht werden soll, muss eine Klasse definiert werden, die von der Elternklasse Application erbt.
from application import Application from templaterule import TemplateRule from util import compare_attr
def __mi_ident__(params={}):
if compare_attr("type", params, ".*applxy.*"):
return XyApp
class XyApp(Application):
template_rules = [
TemplateRule(needsattr=None,
template="app_xy_default"),
]
Template
Bei der ganzen Generierung mit coshsh geht es darum, Konfigurationsdateien für Nagios (bzw. Shinken oder Icinga) zu erzeugen. Jede Applikation wird mit einem bestimmten Satz von Services überwacht. Diese werden thematisch zusammengefasst in sogenannten tpl-Dateien. Das sind Vorlagen für die endgültigen Konfigurationsdateien, welche Platzhalter enthalten. Über die template_rules in den Klassendefinitionen wird festgelegt, welche tpl-Datei(en) die künftigen Services für einen Typ von Applikation enthalten. In den paarweise geschweiften Klammern werden die Attribute des jeweiligen Applikationsobjektes referenziert. An dieser Stelle wird dann der reale Wert (der aus der Datasource stammt) stehen.
{{ application|service("app_xy_default_check_alive") }}
host_name {{ application.host_name }}
use app_xy_default
check_command check_xy!60
}
define service {
service_description app_xy_default_check_users
host_name {{ application.host_name }}
use app_xy_default
max_check_attempts 5
check_command check_xy_users!10!20
}
Recipe
Herzstück von coshsh ist ein Recipe. Analog zu einem Kochrezept besteht es aus zutaten. Es beschreibt, welche Zutaten nötig sind, um eine Nagios-Konfiguration zu erstellen. Die wichtigste Zutat ist eine Datasource, denn ohne Applikationen und erst recht nicht ohne Hosts kann nichts generiert werden.


