Saturday 13 January 2018

Icinga2 event_broker_options


verify_pnp_config.
بي بروبلمن كان داس بيرل - Script verify_pnp_config فون verify. pnp4nagios هلفن داي أكتيل ناجيوس كونفيغوراتيون زو بروفين أوند إنتسبريشيند هينويس زور لوسونغ لييفرن.
بي سوبورت أنفراجن سولت إمر داي أوسغابي ديسيس سكريبتس ميت أنجيجيبن ويردن، دا داي إنتواكلر سيتش سو إينن بيسيرن Überblick über داس فيروينديت سيستيم ماشن كونن.
* أشتونغ *: داس سكريبت ونتيرستوتزت نور ناجيوس 3.x أوند إيسينغا 1.x ألس رصد النظام.
ملاحظات، فيربيسيرونسفورسكلاج أودر بقع بيت في البريد دعم @ pnp4nagios.
داس فيريفي سكريبت ist unter verify. pnp4nagios فيرفوجبار.
داس فيريفي سكريبت بينوتيغت دري أوبتيونين أم داي فونكتيون فون PNP4Nagios زو بروفين.
داي ويكتيغست إنفوس إست دير زو بروفند مودوس، ويلشر ميت دير أوبتيون --mode أنجيجيبين ويرد.
ويترهين إست دير بفاد زور ناجيوس كونفيغ ديتي (nagios. cfg) über يموت الخيار --config زو übergeben.
Über --pnpcfg ويرد دير بفاد زوم الخ فيرزيتشنيس دير PNP4Nagios التثبيت übergeben.
بيم أوفروف فون بيرل check_pnp_config ويردن داي فيرفوجبارن أوبتيونن أوسجيبن.
بيانات الأداء.
بيجينيند ميت 0.6.19-R.37 (2018-02-17) أكزيبتيرت داس سكريبت داي أوبتيون --object (أودر - o) جيفولغت فون إينر زيتشنكيت، داي إينن هوست أوند / أودر إينن سيرفيس أنجيبت. فور دييز / s أوبجكت (e) ويردن داي بيرفورمانس-داتن أنجيجيبن (فالس فورهاندن). داي داتن ويردن فون إيكيجن كلامرن بيغرنزت، جيفولغت فوم ويرت دير ديركتيف process_performance_data (بد = n).
هوست = بيرفورمانس-إنفورماتيونين فور دن هوست المضيف زيجن.
؛ الخدمة = الأداء-خدمة المعلومات زيجن خدمة.
هوست؛ سيرفيس = بيرفورمانس-إنفورماتيونين خدمة الخدمة أوف المضيف المضيف زيجن.
داي زيشنكيتن ويردن ألس ريجولار أوسدروك أنجيسيهين (بيرل - Syntax).

إخطارات مرنة.
1. نظام الإخطار المرن Check_MK.
اعتبارا من الإصدار 1.2.1i2 Check_MK يقدم نظاما جديدا ومرنا جدا لإرسال الإخطارات. هذا النظام لديه بعض المزايا على الطريقة الكلاسيكية ناجيوس من القيام بذلك:
يمكن أن يكون لكل مستخدم طرق إعلام متعددة مع مرشحات منفصلة. بهذه الطريقة يمكنك على سبيل المثال إرسال رسائل البريد الإلكتروني دائما، ولكن سمز فقط لخدمات معينة أو في تيمبيريودس معينة - دون إنشاء جهات اتصال متعددة لكل مستخدم! التغييرات في تكوين الإخطار لا تحتاج إلى أي إعادة تشغيل الأساسية الرصد. يمكن للمستخدمين تغيير إعداداتهم الشخصية أنفسهم عبر مولتيسيت. إضافة البرامج النصية الإخطار الخاصة (للرسائل القصيرة، ونظم التذاكر، وما إلى ذلك) هو بسيط جدا ولا تحتاج إلى أي تحديد الأمر أو إعلان مماثل. يمكن بسهولة أن يتم التكوين عن طريق واتو - ولكن أيضا مع محرر النص الخاص بك.
2 - المبدأ الأساسي.
الفكرة الأساسية هي أننا نتحرك الأشياء المعقدة من جوهر المراقبة (ناجيوس، إيسينغا، وما إلى ذلك). إذا حدث تنبيه ثم نترك الأساسية تقرر فقط من أن يخطر - ولكن ليس كيف. لكل إخطار جوهر يدعو ببساطة check_mk --notify مع توفير جميع المعلومات الضرورية حول التنبيه.
check_mk --notify ثم قراءة الإعدادات الشخصية للمستخدم إخطار وتقرر كيفية إبلاغ. هنا يتم إجراء فلاتر إضافية حتى يتم إسقاط الإشعار على الإطلاق. كما يمكن للمستخدم أن يكون طرق متعددة للإخطارات في نفس الوقت.
إعدادات الإعلام الشخصية يمكن تحريرها من قبل المشرف أو المستخدم نفسه (إذا كنت لا تسمح هذا) عبر مولتيسيت / واتو.
3. إعداد الإخطارات بشكل عام.
إعداد الإخطارات يأخذ بعض الرعاية. إذا كنت تفوت واحدة من الخطوات التالية ثم الحالة الأكثر احتمالا هو أن ببساطة لا شيء سيحدث. يجب القيام بما يلي:
إنشاء مجموعة جهات اتصال. مستخدمي واتو: يتم ذلك مع وحدة الاتصال مجموعات الاتصال. هام: ضع بعض المضيفين / الخدمات في مجموعة الاتصال هذه. واتو: هوست & أمب؛ معلمات الخدمة / تجميع / تعيين المضيف / الخدمات لمجموعات الاتصال. إنشاء مستخدم ووضعه في مجموعة الاتصال هذه. تمكين الإشعارات لهذا المستخدم. ادخل عنوان البريد الإلكتروني. واتو: وسرس & أمب؛ اتصالات تأكد من إعداد خادم المراقبة بشكل صحيح بحيث يمكن إرسال رسائل البريد الإلكتروني. اختبار هذا مع.
4. اختبار وتصحيح الأخطاء.
عند التعامل مع الإخطارات من المهم أن نعرف كيفية اختبار وتصحيح الإعداد الخاص بك. وهناك طريقة سهلة جدا لإرسال الإخطارات الاختبار هو اختيار خدمة عشوائية التي ترد في مجموعة الاتصال العليا، افتح مربع الحوار الأوامر وحدد إعلام مخصص:
إذا كان لديك إعداد جهات الاتصال الخاصة بك ومجموعة الاتصال بشكل صحيح، ثم يجب أن تشاهد إدخال الإخطار في سجل مراقبة ناجيوس الخاص بك:
طالما أنك لا تحصل على هذه إدخالات السجل فإنه لا يجعل أي معنى للمضي قدما في تكوين محرك إعلام Check_MK ل. للحصول على واحد لاحق يمكنك تشغيل تصحيح الأخطاء في الإعدادات العالمية. أصدقاء سطر الأوامر وضع هذا في main. mk بهم:
يجد مستخدمي واتو هذا الإعداد في الإعدادات العامة / الإشعارات / إشعارات التصحيح. ملف السجل الناتج في الدليل يخطر أدناه دليل فار Chequ_MK. المستخدمين أومد العثور على الملف في.
/var/log/notify. log. أليس من الرائع أن يكون لها مسارات ثابتة في أومد، بالمناسبة؟
هنا هو إخراج المثال لإعلام مرن من هيرني المستخدم:
5. باستخدام إعلام عادي البريد الإلكتروني.
قبل الإصدار 1.2.1i2 إخطار البريد الإلكتروني العادي كان الطريق الوحيد للذهاب (دون تعديل الخاصة لتكوين ناجيوس). لا يزال هذا هو الافتراضي. إذا كنت قد فعلت الخطوات العليا ثم كل شيء يجب أن تعمل الآن. يمكن تخصيص الموضوع والجسم للبريد الإلكتروني في الإعدادات العالمية.
ملاحظة: الإعدادات القيام به هنا (تمكين، تيمبيريود الإخطار والتي الأحداث لإخطار) السيطرة، والتي وعندما ناجيوس لا ترسل الإخطارات للمستخدم. أي تغيير هنا يحتاج إلى إعادة تشغيل الأساسية. لا يمكن للمستخدم تغيير الإعدادات. إذا كنت تستخدم إخطارات مرنة ثم أسهل طريقة هي اختيار الإعدادات التالية:
تمكين الإشعارات الوقت: دائما تمكين جميع أنواع الأحداث.
وبهذه الطريقة يمكنك التأكد من أن الإخطارات جعله من جوهر وإلى نظام الإخطار Check_MK ل. ويمكن بعد ذلك القيام بالترشيح بطريقة أكثر مرونة باستخدام Check_MK، كما سنرى لاحقا.
6. كتابة مخطوطات الإخطار.
الخطوة التالية في استخدام الإخطارات المرنة هي كتابة البرامج النصية للإشعارات الخاصة بك. وضع البرامج النصية الخاصة بك في الإخطارات الدليل. وهو موجود بالتوازي مع الشيكات. إذا كان هذا الدليل غير موجود ثم من المرجح أن يكون لديك نسخة قديمة جدا من Check_MK. إذا كنت تستخدم أومد ثم أفضل استخدام الدليل.
/ لوكال / شير / check_mk / نوتيفيكاتيونس إن ذي سيت.
سوف تنظر Check_MK في كل ملف قابل للتنفيذ في هذا الدليل كنص برمجي للإشعار. يمكنك استخدام أي لغة برمجة تريدها. إذا كنت تستخدم لغة البرمجة النصية (شل، بيرل، بيثون، وما إلى ذلك)، يمكنك استخدام تعليق في السطر الثاني لإعطاء اسم البرنامج النصي. سيتم استخدام هذا الاسم في التكوين الرسومي ويكون مرئيا للمستخدم. هنا مثال لرئيس مثل هذا السيناريو:
الرجاء التأكد من أن هذا البرنامج النصي قابل للتنفيذ (تشمود + x). سوف أتحدث عن محتويات النص في وقت لاحق. بالنسبة للاختبار الأول يكون المثال الأعلى كافيا.
الجديد في الإصدار 1.2.6: عند كتابة البرامج النصية بيثون تحتاج في بعض الأحيان إلى تلميح الترميز في السطر الثاني. اكتب العنوان في السطر الثالث ثم:
7. تكوين تكوينات مرنة في واتو.
بمجرد أن يكون لديك نص برمجي إعلام واحد على الأقل يمكنك البدء بالتهيئة. ويتم ذلك على أساس قاعدة لكل مستخدم عن طريق تعيين أسلوب الإشعار على الإخطارات المخصصة مرنة. يمكن لكل مستخدم الحصول على عدد تعسفي من إدخالات التكوين. في كل مرة يتم تشغيل الإشعار بواسطة جوهر كل هذه الإدخالات قيد المعالجة. وقد ينتج عن ذلك إخطار فعلي واحد أو أكثر. يظهر لقطة الشاشة التالية جدول مع إدخال واحد فقط باستخدام (شحنها) إعلام النصي التصحيح الإخطارات. يسجل هذا البرنامج النصي فقط قيم كل متغيرات السياق في سجل الإشعارات (إذا كان ممكنا).
لديك خيارات التهيئة التالية:
7.1. إعلام البرنامج المساعد.
النص البرمجي للاتصال - إذا كنت قد قدمت عنوان في تعليق في السطر الثاني من البرنامج النصي ثم سيتم عرض هذا بدلا من اسم البرنامج النصي الفعلي.
7.2. معاق.
عن طريق تحديد هذا المربع سيتم تعطيل إدخال وأي إعلام القيام به. تماما مثل جميع الإعدادات الأخرى في الجدول مرنة لا ناجيوس إعادة تشغيل ضروري. بعد حفظ الإعدادات سوف تحصل على الفور نشطة.
7.3. فترة زمنية.
هنا يمكنك تقييد الإخطارات إلى تيمبيريود رصد معين. يمكن تعريف تيمبيريودس جديدة مع تيمبوريودس وحدة واتو. ملاحظة: يمكنك فقط تحديد تيمبيريودس التي يتم تعريفها مع واتو هنا. إذا كنت تفعل التكوين اليدوي (انظر لاحقا)، يمكنك استخدام جميع أنواع تيمبيريودس.
7.4. تقييد إشعار n'th إلى m (التصعيد)
عند تمكين الإخطارات المتكررة (عن طريق تعيين notification_interval إلى قيمة غير الصفر) ثم هل يمكن أن يكون هذا الإدخال التعامل فقط مع بعض التكرار من الإخطار. وبهذه الطريقة يمكن أن يكون لديك على سبيل المثال أول اثنين يتم إرسالها عبر البريد الإلكتروني وإشعارات أخرى عبر الرسائل القصيرة (تحتاج اثنين من إدخالات في الجدول لهذا).
7.5. الأحداث الأحداث / خدمة المضيف.
يتيح لك هذا تمكين / تعطيل الإشعارات لأنواع معينة من الأحداث. إذا كان لديك نظرة فاحصة ثم سترى أن هنا يمكنك أيضا تعطيل الإخطارات عن شكر - حتى لو ناجيوس لا تسمح لتعطيلها. يرجى ملاحظة أنه يجب تمكين نوع الحدث في إعدادات الإشعارات العامة للمستخدم أيضا.
7.6. قم بالحد من المضيفات التالية.
هنا يمكنك تعيين المضيفين لهذا الإخطار. يجب تحديد المضيفين كمطابقة تامة وتكون حساسة لحالة الأحرف. يرجى ملاحظة أن المستخدم لا يمكن الحصول على إخطار عن أي مضيف انه ليس جهة اتصال ل - بغض النظر عن ما تكوين هنا. إذا لم تقم باستخدام هذا الخيار لا تكوين نمط واحد على الأقل ثم سيتم تطبيق أي مرشح على اسم المضيف.
7.7. الحد من الخدمات التالية.
وهذا يوفر وسيلة سهلة لتحديد الخدمات الهامة ليتم إعلامك في بعض الطرق الخاصة. كما هو الحال في تكوين واتو الآخر، حدد قائمة بالتعبيرات العادية التي تطابق بداية أوصاف الخدمة. يرجى ملاحظة أنه لا يمكن للمستخدم الحصول على إخطار عن أية خدمة ليس جهة اتصال لها - بغض النظر عن ما تهيئه هنا. إذا كنت لا تستخدم هذا الخيار لا تكوين نمط واحد على الأقل ثم سيتم تطبيق أي مرشح على اسم الخدمة.
7.8. وسيطات المساعد.
يتم توفير النصوص التي يتم إدخالها هنا إلى البرنامج النصي الإخطار في شكل وحدات الماكرو بيئة. ويتيح لك ذلك توفير معلومات إضافية، على سبيل المثال. رقم الهاتف المحمول. ما هي الحجج المطلوبة وأي معنى لها يعتمد على النصي الإخطار.
8. العالم الحقيقي مخطوطات إعلام.
الخطوة الأخيرة والأخيرة هي كتابة الإخطارات الحقيقية البرامج النصية. أنت حر في إرسال رسائل البريد الإلكتروني، والرسائل القصيرة، مكان المكالمات الهاتفية عن طريق النجمة والقيام أشياء أخرى يتوهم. البرنامج النصي أو البرنامج يتلقى جميع البيانات الهامة في متغيرات البيئة، والتي يتم مسبوقة مع NOTIFY_. يظهر برنامج تصحيح الأخطاء الذي تم شحنه لك المتغيرات التي يتم تعريفها. هنا مثال إخراج السجل. يتم تقديم وسيطات البرنامج المساعد المذكورة كقائمة مفصولة بمسافة في NOTIFY_PARAMETERS وأيضا في متغيرات متميزة في NOTIFY_PARAMETER_1، NOTIFY_PARAMETER_2،.
يرجى ملاحظة أنه تمت إزالة البرنامج النصي لإشعار التصحيح في الإصدار 1.2.7i4. الآن يمكنك تكوين البرنامج النصي إعلام هتمل لإخراج كافة المتغيرات.
9. حزم Check_MK (مكب)
يمكن حزم البرامج النصية إعلام في حزم Check_MK (مكبس). ببساطة إرسالها، ووضعها في الدليل الصحيح وسوف حزمة العثور عليها.

التحقق من التثبيت.
إذا كان كل شيء على ما يرام حتى الآن يمكنك محاولة الاتصال بنب باستخدام متصفح الويب الخاص بك. عند استخدام التثبيت مع القيم الافتراضية يجب أن يسمى بنب باستخدام & لوت؛ اسم الخادم & غ؛ / pnp4nagios /. في المرة الأولى سترى صفحة "اختبارات البيئة PNP4Nagios" الذي يتضمن عمليات فحص مختلفة من المكونات الضرورية. من الواضح أن جميع الشيكات يجب أن يتم تمرير بنجاح قبل أن تتمكن من المضي قدما. يرجى اتباع التعليمات الواردة في هذه الصفحة.
إذا مرت جميع الاختبارات * بنجاح * ملف pnp4nagios / حصة / install. php يمكن حذف أو إعادة تسميته. وليس حتى ذلك الحين واجهة الويب يمكن الوصول إليها.
بدلا من ذلك يمكنك إنشاء ملف يسمى pnp4nagios / حصة / install. ignore الذي سيمنع دعوة المثبت بعد مزيد من التحديثات.
إذا تلقيت الرسالة "يتم تجاهل فب magic_quotes_gpc" ثم الرجاء تحديد موقع php. ini الخاص بك وتعيين القيمة إلى إيقاف.
يطلق عليه دون أي وسيطات يبحث بنب عن ملفات رد و شمل في pnp4nagios / فار / بيرفاتا ويعرض جميع الرسوم البيانية للمضيف الأول.
تنبيه: مباشرة بعد (إعادة) بدء ناجيوس بعد تمكين معالجة بيانات الأداء ستحصل على رسائل خطأ في المتصفح الخاص بك لأنه يجب جمع بيانات الأداء وتخزينها في ملفات رد. اعتمادا على الفاصل الزمني الاختيار الذي تستخدمه عليك أن تنتظر بعض الوقت قبل أن تتمكن من عرض الرسوم البيانية الأولى.
تصحيح الأخطاء لوغفيل.
دعوة جعل تثبيت-التكوين أثناء التثبيت سيخلق نموذج ملف التكوين الخ / process_perfdata. cfg عينة. القيم في ملف العينة تتوافق مع الافتراضات المستخدمة من قبل process_perfdata. pl لذلك عادة لم يكن لديك ملف يسمى process_perfdata. cfg أثناء تشغيل الإجراء.
ومع ذلك يمكنك التأثير على طريقة process_perfdata. pl يعمل عن طريق تغيير الخيارات التي يجب تحديدها في process_perfdata. كفغ.
أهم الخيارات إطلاق بنب هي LOG_LEVEL و LOG_FILE. نوصي بتعيين قيمة LOG_LEVEL إلى "2" حتى تتمكن من تتبع ما سيقوم به process_perfdata. pl. على الأرجح سوف نطلب مقتطفات من perfdata. log إذا قمت بفتح طلب دعم على القوائم البريدية وكذلك إخراج البرنامج النصي check_pnp_config لذا يرجى تقديمها.
أثناء التشغيل العادي يجب تعيين مستوى تصحيح الأخطاء إلى 0 لتجنب مشكلات الأداء بسبب الإدخالات غير الضرورية في ملف السجل.
هناك خطأ ما.
يجب فحص بعض الإعدادات الأساسية.
1. هل تم إنشاء أي ملفات رد و شمل؟ سيقوم process_perfdata. pl بإنشاء دليل جديد تحت بنب / بيرفداتا لكل مضيف. في هذا الدليل سيتم إنشاء قاعدة بيانات رد وملف شمل لكل خدمة. سيتم تخزين بيانات المضيف في _HOST_.xml و _HOST_.rrd على التوالي.
إذا توقفت الرسوم البيانية فجأة ثم افتح ملف شمل المناسب. هناك علامتان تسمى & لوت؛ أرسي & غ؛ و & لوت؛ تكست & غ ؛. العلامة & lt؛ & RC GT. يظهر رمز العودة لتحديث ردتول و & لوت؛ تكست & غ؛ وصف نصي.
في بعض الأحيان يجب عليك تحديد خيارات إضافية بحيث يتم إنتاج بيانات الأداء. في بعض الحالات قد يساعد النص البرمجي المجمع.
ومع ذلك لا توفر جميع الشيكات بيانات الأداء. وهذا ينطبق - من بين أمور أخرى - إلى "check_ping" على النقيض من "check_icmp" الذي يوفر البيانات (بدءا من ناجيوس المساعد الإصدار 1.4.12 check_ping لا توفر بيانات الأداء).
باستخدام واجهة الويب المعلومات التفصيلية من المضيفين / الخدمات يظهر حقل "بيانات الأداء". إذا كان فارغا لا توجد بيانات متوفرة بحيث يتم كتابة أي ملفات إلى الدليل المناسب وهذا هو السبب بنب لا توفر لك مع الرسوم البيانية!
توضح الصورة التالية معلومات خدمة "بينغ". ويحيط الإخراج من البرنامج المساعد من قبل الحدود الزرقاء، وبيانات الأداء من قبل واحد أحمر.
2. هل دعا ناجيوس process_perfdata. pl؟ في ملف التكوين ل process_perfdata. pl (إتك / process_perfdata. كفغ) يمكنك زيادة مستوى التصحيح. سيتم تسجيل معالجة البيانات في فار / perfdata. log.
3. يتم عرض الرسوم البيانية دون نص؟ إلقاء نظرة على المتطلبات.

مك ليفيستاتوس.
1. كيفية الوصول إلى بيانات حالة ناجيوس.
1.1. الوصول إلى بيانات الحالة اليوم.
الطريقة الكلاسيكية للوصول إلى الوضع الحالي من المضيفين والخدمات الخاصة بك هي من خلال قراءة وتحليل الوضع file. dat، الذي تم إنشاؤه من قبل ناجيوس على أساس منتظم. يتم تكوين الفاصل الزمني للتحديث عبر status_update_interval في nagios. cfg. القيمة النموذجية هي 10 ثوان. إذا كان التثبيت الخاص بك هو الحصول على أكبر، قد تضطر إلى زيادة هذه القيمة من أجل تقليل استخدام وحدة المعالجة المركزية والقرص إو. تستخدم واجهة ويب ناجيوس status. dat لعرض بياناتها.
تحليل الحالة. dat ليست شعبية جدا بين مطوري أدونز. الكثير من استخدام نهج آخر: ندو. هذه هي وحدة نيب التي يتم تحميلها مباشرة في عملية ناجيوس ويرسل كل تحديثات الحالة عبر مأخذ أونيكس لعملية مساعد. عملية المساعد بإنشاء عبارات سكل وتحديث الجداول المختلفة في قاعدة بيانات ميسكل أو بوستغريزل. هذا النهج لديه العديد من المزايا على status. dat:
يتم تحديث البيانات إمدياتلي، وليس فقط كل 10 أو 20 ثانية. التطبيقات لديها سهولة الوصول إلى البيانات عبر سكل. ليس هناك حاجة إلى محلل ل status. dat. في المنشآت الكبيرة وصول أدونس إلى البيانات أسرع ثم قراءة status. dat.
لسوء الحظ، ومع ذلك، ندو لديه أيضا بعض أوجه القصور الشديدة:
أنه يحتوي على الإعداد المعقدة. وهي تحتاج إلى قاعدة بيانات (سريعة النمو) تدار. فإنه يأكل جزء كبير من رسسورسز وحدة المعالجة المركزية الخاصة بك، فقط من أجل الحفاظ على قاعدة البيانات ما يصل إلى تاريخ. يمكن للتدبير المنزلي المنتظم لقاعدة البيانات شنق ناجيوس لدقائق أو حتى ساعة واحدة في اليوم.
1.2. المستقبل.
منذ الإصدار 1.1.0، Check_MK يقدم نهجا جديدا تماما للوصول إلى الحالة والبيانات التاريخية أيضا: ليفيستاتوس. تماما كما ندو، ليفيستاتوس الاستفادة من ناجيوس الحدث وسيط أبي وتحميل وحدة ثنائية في عملية ناجيوس الخاص بك. ولكن البعض ثم ندو، ليفيستاتوس لا يكتب بنشاط البيانات. بدلا من ذلك، فإنه يفتح مأخذ الذي البيانات يمكن استرجاعها عند الطلب.
مأخذ يسمح لك بإرسال طلب للحصول على المضيفين والخدمات أو غيرها من أجزاء من البيانات والحصول على إجابة فورية. يتم قراءة البيانات مباشرة من هياكل البيانات الداخلية ناجيوس. ليفستاتوس لا تخلق نسخة خاصة بها من تلك البيانات. بدءا من الإصدار 1.1.2 كنت أيضا قادرة على استرداد البيانات التاريخية من ملفات سجل ناجيوس عبر ليفيستاتوس.
هذا ليس فقط نهج بسيط مذهل، ولكن أيضا واحدة سريعة للغاية. بعض المزايا هي:
على عكس ندو، باستخدام ليفستاتوس يفرض أي عبء يمكن قياسه على وحدة المعالجة المركزية الخاصة بك على الإطلاق. فقط عند معالجة الاستفسارات هناك حاجة إلى كمية صغيرة جدا من وحدة المعالجة المركزية. ولكن هذا لن يمنع حتى ناجيوس. ليفستاتوس تنتج صفر القرص إو عند التجميع بيانات الحالة. الوصول إلى البيانات أسرع بكثير ثم تحليل الحالة. دات أو الاستعلام عن قاعدة بيانات سكل. لا حاجة إلى تكوين، لا حاجة إلى قاعدة بيانات. لا توجد إدارة ضرورية. ليفستاتوس موازين جيدا للمنشآت الكبيرة، حتى بعد 50.000 الخدمات. ليفيستاتوس يتيح لك الوصول إلى بيانات ناجيوس محددة غير متوفرة لأي طريقة أخرى للوصول إلى الحالة المتاحة - على سبيل المثال المعلومات ما إذا كان المضيف هو حاليا في فترة الإشعار.
وفي الوقت نفسه، يوفر ليفيستاتوس لغة الاستعلام الخاصة بها التي هي بسيطة لفهم، ويقدم معظم المرونة من سكل وأكثر من ذلك في بعض الحالات. انها بروتوكول سريع، خفيفة الوزن ولا تحتاج إلى عميل ثنائي. يمكنك حتى الحصول على الوصول من قذيفة دون أي برنامج المساعد.
1.3. الحاضر.
ليفيستاتوس لا يزال التكنولوجيا الشباب، ولكن بالفعل العديد من أدونز دعم ليفستاتوس كمصدر البيانات أو حتى يقترح أنها الافتراضي. هنا هو قائمة (غير مكتملة) من أدونز مع ليفستاتوس الدعم: ناغفيس - ناغفيس ناجيسبب - بب-addon. monitoringexchange ثروك - ثروك كوفيسينت - فانيوسدن / جافا / كوفيسينت / ريلوبينزيت - ريالوبينزيت وبالطبع: Check_MK مولتيسيت!
يرجى مراسلتنا إذا كنت تعتقد أن هذه القائمة غير مكتملة.
2. إعداد واستخدام ليفستاتوس.
2.1. الإعداد التلقائي.
الطريقة النموذجية لإعداد ليفستاتوس هو فقط للرد نعم عندما يطلب من إعداد Check_mk. تحتاج إلى أن يكون لديك كافة الأدوات المثبتة التي تحتاجها لتجميع برامج C ++. هذه هي على الأقل: غنو C ++ مترجم (تعبئتها ك g + في دبيان) الأداة المساعدة تجعل (تعبئتها كما جعل) ملفات تطوير ليبك (libc6-ديف) ملفات تطوير مكتبة C ++ القياسية (ليبستدك ++ 6-ديف )
البرنامج النصي setup. sh يجمع وحدة تسمى livestatus. o ونسخها في / أسر / ليب / check_mk (إذا لم تقم بتغيير هذا المسار). كما أنه يضيف سطرين إلى nagios. cfg، التي تحتاجها لتحميل الوحدة النمطية. بعد ذلك تحتاج فقط إلى إعادة تشغيل ناجيوس ومقبس أونيكس مع اسم الحية يجب أن تظهر في نفس الدليل كما كنت ناجيوس الأمر الأوامر.
2.2. إعداد يدوي.
هناك العديد من الحالات التي يكون فيها الإعداد اليدوي أفضل، على سبيل المثال: إذا كنت لا تريد استخدام Check_MK، ولكن ليفستاتوس فقط إذا كان الإعداد التلقائي لا يعمل بشكل صحيح (وهو أمر مستبعد ولكن ليس مستحيلا). إذا كنت ترغب في إجراء تغييرات على شفرة المصدر ليفيستاتوس.
لإعداد ليفيستاتوس يدويا، يمكنك تحميل شفرة المصدر مستقلة من Check_MK في صفحة التنزيل. فك القطران في مكان مناسب والتغيير إلى الدليل الذي تم إنشاؤه حديثا:
الآن دعونا تجميع وحدة نمطية. ليفستاتوس يستخدم معيار تكوين - script ويتم تجميعها مع ./configure && جعل.
إذا كنت تقوم بتشغيل على وحدة المعالجة المركزية متعددة النواة يمكنك تسريع تجميع عن طريق إضافة - j 4 أو - j 8 لجعل:
. وما إلى ذلك وهلم جرا. . بعد تثبيت ناجح، تثبيت تثبيت سيتم تثبيت ملف واحد يدعى livestatus. o في / أسر / لوكال / ليب / مك ليفيستاتوس و ونيكسكات برنامج صغير في / أسر / لوكال / بن (كالمعتاد، يمكنك تغيير مسارات مع خيارات قياسية لتكوين ):
مهمتك الأخيرة هي تحميل livestatus. o إلى ناجيوس. يقال ناجيوس لتحميل تلك الوحدة وإرسال كافة أحداث تحديث الحالة إلى وحدة نمطية بواسطة السطرين التاليين في nagios. cfg:
والحجة الإلزامية الوحيدة هي المسار الكامل لمقبس أونيكس الذي يقوم ليفيستاتوس بإنشائه (/ فار / ليب / ناجيوس / رو / ليف في مثالنا). يرجى تغيير ذلك إذا لزم الأمر. الأفضل هو ربما لوضعه في نفس الدليل كما ناجيوس الأنابيب. تماما كما ناجيوس يفعل مع الأنبوب، ليفيستاتوس يخلق مأخذ مع أذونات 0660. إذا كان الدليل الذي يوجد فيه المقبس في بت سغيد لمجموعة مجموعة (تشمود g + s)، ثم سوف تكون مملوكة مأخذ من قبل نفس المجموعة مثل الدليل.
بعد إعداد ليفيستاتوس - إما عن طريق setup. sh أو يدويا - إعادة تشغيل ناجيوس. يجب أن يحدث أمران الآن: يتم إنشاء ملف المقبس. يظهر سجل ناجيوس أن الوحدة قد تم تحميلها:
2.3. خيارات nagios. cfg.
ليفستاتوس يفهم العديد من الخيارات، والتي يمكن أن تضاف إلى السطر بدءا من broker_module:
في ما يلي مثال لكيفية إضافة المعلمات:
3. استخدام ليفستاتوس.
وبمجرد إعداد وحدة ليفيستاتوس وتشغيلها، يمكنك استخدام مقبس أونيكس لاسترجاع بيانات الحالة المباشرة. كل لغة برمجة ذات صلة على لينكس لديها طريقة لفتح مثل هذا المقبس. وسوف تظهر كيفية الوصول إلى مأخذ مع قذيفة ومع بايثون. وتترك لغات البرمجة الأخرى كممارسة للقارئ.
3.1. الوصول إلى ليفستاتوس مع قذيفة.
مقبس أونيكس يشبه إلى حد كبير أنبوب اسمه، ولكن لديه اختلافات هامة: يمكنك قراءة وكتابة من وإلى ذلك (في حين أن أنبوب هو أحادي الاتجاه). لا يمكنك الوصول إليه مع صدى أو القط.
سفن ليفستاتوس مع أداة صغيرة تسمى ونيكسكات التي يمكن التواصل عبر مقبس أونيكس. يرسل جميع البيانات يقرأ من ستدين في مأخذ ويكتب جميع البيانات القادمة من مأخذ إلى ستدوت.
يظهر الأمر التالي كيفية إرسال أمر إلى المقبس واسترداد الإجابة - في هذه الحالة جدول جميع المضيفين:
إذا كنت تحصل على هذا الإخراج، كل شيء يعمل بشكل جيد وكنت قد ترغب في مواصلة القراءة مع الفصل ليفيستاتوس الاستعلام اللغة.
3.2. الوصول إلى ليفستاتوس مع بيثون.
الوصول من داخل بيثون لا يحتاج إلى أداة خارجية. يوضح المثال التالي كيفية إرسال استعلام، واسترداد الجواب وتحليله في جدول بيثون. بعد تثبيت check_mk تجد هذا البرنامج في الدليل / أسر / شير / دوك / check_mk:
4. لقل - لغة الاستعلام ليفيستاتوس.
لقل - وضوحا "ليكيل" كما هو الحال في "السائل" - هي لغة بسيطة لقول ليفيستاتوس ما البيانات التي تريد وكيف ينبغي تنسيقها. أنها تفعل الكثير من نفس سكل ولكن يفعل ذلك بطريقة أخرى، أبسط. ويعكس بناء الجملة (غير متوافق مع) هتب.
يتكون كل استعلام من: أمر يتكون من كلمة جيت واسم جدول. عدد تعسفي من خطوط رأسية تتألف من كلمة رئيسية ونقطتين وسيطات. خط فارغ أو نهاية الإرسال (أي يغلق العميل اتجاه إرسال المقبس)
جميع الكلمات الرئيسية بما في ذلك جيت حساسة لحالة الأحرف. يتم إنهاء الخطوط بواسطة سطر واحد (لا & لوت؛ كر & غ؛). النسخة الحالية من ليفيستاتوس تنفذ الجداول التالية: المضيفين - ناجيوس الخاص بك يستضيف الخدمات - خدمات ناجيوس الخاص بك، انضم مع جميع البيانات من المضيفين المضيفين - أنت ناجيوس هوستغروس سيرفيسغروس - أنت ناجيوس سيرفيسغروس كونتاكتغروس - أنت ناجيوس مجموعات الاتصال سيرفيسزبيغروب - جميع الخدمات مجمعة حسب الخدمة خدمات المجموعات التي يتم تجميعها من قبل المجموعات المضيفة هوستسبيغروب - كل مجموعة المضيفين من قبل مجموعات المضيف جهات الاتصال - أوامر الاتصالات ناجيوس الخاص بك - أوامر محددة ناجيوس الخاص بك تيمبيريودس - تعريفات الفترة الزمنية (الاسم الوحيد حاليا والاسم المستعار) توقف - جميع المضيف المقرر والخدمة المهجورة، انضم مع بيانات من المضيفين والخدمات. تعليقات - كل المضيف وسجل تعليقات الخدمة - وصول شفاف إلى سجلات السجل ناجيوس (تشمل تلك المحفوظة) حالة تلك - الأداء العام ومعلومات الحالة. يحتوي هذا الجدول على مجموعة بيانات واحدة بالضبط. أعمدة - قائمة كاملة من جميع الجداول والأعمدة المتاحة عبر ليفستاتوس، بما في ذلك الوصف! ستاتهيست - 1.2.1i2 إحصاءات سلا للمضيفين والخدمات، جنبا إلى جنب مع البيانات من المضيفين والخدمات والسجل.
كما هو الحال في قاعدة بيانات سكل جميع الجداول تتكون من عدد من الأعمدة. إذا قمت باستعلام الجدول دون أي معلمات، يمكنك استرداد كافة الأعمدة المتاحة بترتيب أبجدي. يحتوي السطر الأول من الإجابة على أسماء الأعمدة. يرجى ملاحظة أن الأعمدة المتاحة ستتغير من الإصدار إلى الإصدار. وبالتالي يجب أن لا تعتمد على ترتيب معين من الأعمدة!
مثال: استرداد جميع جهات الاتصال:
4.1. تحديد الأعمدة التي سيتم استردادها.
عند كتابة تطبيق باستخدام ليفستاتوس، ربما تحتاج المعلومات فقط من الأعمدة المحددة. إضافة رأس الأعمدة لتحديد الأعمدة التي سيتم استردادها. وهذا يحدد أيضا ترتيب الأعمدة في الإجابة. المثال التالي يسترد فقط اسم الأعمدة واسم مستعار:
إذا كنت ترغب في اختبار هذا مع ونيكسكات، طريقة بسيطة هي وضع الاستعلام الخاص بك إلى استعلام ملف نصي وقراءة ذلك في استخدام & لوت؛ :
كما كنت قد لاحظت في هذا المثال: إذا كنت تستخدم الأعمدة: ثم لن يتم إخراج رؤوس الأعمدة. أنت لا تحتاج إليها - كما كنت قد حددت لهم أنفسكم. هذا يجعل تحليل أبسط.
4.2. المرشحات.
مفهوم مهم ل ليفستاتوس هو قدرته على تصفية البيانات بالنسبة لك. هذا ليس فقط أكثر ملاءمة من مجرد استرجاع جميع البيانات وتحديد الخطوط ذات الصلة نفسك. كما أنها أسرع بكثير. تذكر أن ليفستاتوس لديه إمكانية الوصول المباشر إلى كل من البيانات الداخلية ناجيوس 'ويمكن الوصول إليها بسرعة C.
تتم إضافة الفلاتر باستخدام فيلتر: هيدرس. يحتوي هذا الرأس على ثلاث حجج: اسم عمود، عامل تشغيل وقيمة مرجعية - كل ذلك مفصول بمسافات. قد تحتوي القيمة المرجعية - وهي القيمة الأخيرة في السطر - على مسافات. مثال:
هذا الاستعلام يحصل على كافة الخدمات مع الحالة الحالية 2 (حرجة). إذا أضفت المزيد فلتر: رؤوس، سترى فقط البيانات التي تمرير كل من الفلتر الخاص بك. المثال التالي ينتج جميع الخدمات الهامة التي هي حاليا ضمن فترة الإخطار:
تتوفر الشركات الثمانية التالية:
بعض الملاحظات: المشغلين.
4.3. مطابقة التعبير العادي.
4.4. قوائم المطابقة.
بعض الأعمدة لا تحتوي على أرقام أو نصوص، ولكن قوائم الكائنات. مثال على ذلك هو جهات الاتصال العمود من المضيفين أو الخدمات التي تحتوي على كافة جهات الاتصال المعينة إلى كائن البيانات. والمشغلون المتاحون في أعمدة قيم القامئة هم:
مثال: ارجع بعض المعلومات عن الخدمات حيث "هاري" هي إحدى جهات الاتصال المعينة:
مثال آخر: إعادة اسم جميع المضيفين الذين ليس لديهم الآباء:
هناك حالة خاصة عند إجراء التصفية على الأعضاء أو أعمدة members_with_state من جدول مجموعات الخدمة: يجب أن يكون للقيمة المطابقة تطابق اسم المضيف | وصف الخدمة .
4.5. قوائم السمات المطابقة.
الإصدار 1.1.4 من ليفيستاتوس يتيح لك الوصول إلى قائمة سمات معدلة من المضيفين والخدمات وجهات الاتصال. بهذه الطريقة يمكنك الاستعلام عن السمات التي تم تغييرها ديناميكيا من قبل المستخدم وبالتالي تختلف عن السمات التي تم تكوينها في ملفات الكائن ناجيوس.
تأتي هذه الأعمدة الجديدة في متغيرين: edit_attributes و edit_attributes_list. يخرج المتغير الأول عددا صحيحا يمثل تركيبة بيتية للأرقام الداخلية ناجيوس. ينتج المتغير الثاني قائمة بأسماء الخصائص، مثل notification_enabled أو active_checks_enabled. عند تعريف عامل تصفية، يتم التعامل مع كل من متغيرات العمود بالطريقة نفسها تماما، وكلاهما يسمح باستخدام رقم أو تمثيل قائمة مفصولة بفواصل.
المثال 1: البحث عن جميع المضيفين الذين لديهم سمات معدلة:
مثال 2: البحث عن المضيفين حيث تم تعطيل الإشعار بشكل فعال:
مثال 3: البحث عن المضيفين حيث تم إجراء فحوصات نشطة أو سلبية:
4.6. الجمع بين مرشحات مع و، أو ونفي.
يجب أن تمر كل مجموعة بيانات افتراضية في كل الفلاتر ليتم عرضها. بدلا من ذلك، يمكنك الجمع بين عدد من الفلاتر مع عملية منطقية "أو" باستخدام رأس أو:. يأخذ هذا الرأس عدد صحيح X كوسيطة ويجمع بين مرشحات X الأخيرة في فلتر جديد باستخدام عملية "أو". المثال التالي يختار جميع الخدمات التي هي في حالة 1 أو في حالة 3:
يعرض المثال التالي جميع الخدمات غير موافق التي تكون ضمن وقت توقف مجدولة أو التي تكون على مضيف مع وقت توقف مجدول:
ومن الممكن أيضا الجمع بين المرشحات مع وتشغيل. هذا ضروري فقط إذا كنت ترغب في مجموعة المرشحات معا قبل "أو"-لهم. إذا، على سبيل المثال، كنت ترغب في الحصول على جميع الخدمات التي هي حاسمة والاعتراف أو موافق، وهذا هو كيفية القيام بذلك:
و: 2 - رأس يجمع بين المرشحين الأولين إلى مرشح واحد جديد، والذي هو ثم "أو" إد مع المرشح الثالث.
في الإصدار 1.1.11i2 رأس جديد نيجات: تم عرضه. وهذا ينفي منطقيا أحدث فلتر. يعرض المثال التالي جميع المضيفات التي لا تحتوي على اسم أو لا:
5. الإحصائيات والتهم.
5.1. لماذا العد؟
يحتوي سكل على عبارة "سيليكت كونت (*) فروم." والتي تحسب عدد الصفوف التي تطابق معايير معينة. احصائيات لقل: - Header يسمح شيء مماثل. وبالإضافة إلى ذلك فإنه يمكن استرداد العديد من التهم في وقت واحد.
إحصائيات: - Header لديه نفس التركيب كما تصفية: ولكن معنى آخر: بدلا من تصفية الكائنات التي تهمهم. في أقرب وقت واحد على الأقل احصائيات: رأس يستخدم، يتم عرض أية بيانات بعد الآن. بدلا من ذلك، يتم إخراج صف واحد من البيانات مع عمود واحد لكل إحصائيات:، مع توضيح عدد الصفوف المطابقة لمعاييرها.
المثال التالي يخرج أرقام الخدمات التي هي موافق، وارن، كريت أو أننوين:
يظهر مثال للإخراج على النحو التالي:
هل تريد تقييد الإخراج إلى الخدمات التي يتم تعيين جهة الاتصال هاري إليها؟ لا توجد مشكلة، فقط إضافة فلتر: رأس:
5.2. الجمع مع و / أو.
تماما مثل رؤوس التصفية، الإحصائيات - يمكن دمجها مع و / أو العمليات. المهم أن نعرف، أنها تشكل كومة الخاصة بهم. يمكنك الجمع بينهما مع ستاتساند و ستاتسور. في ما يلي استعلام أكثر تعقيدا إلى حد ما يقوم بمسح كافة الخدمات لنوافذ مجموعة الخدمات التي تقع ضمن فترة الإشعار ولا تكون ضمن مضيف أو توقف خدمة. It computes seven counts: The number of services with the hard state OK The number of unacknowledged services in hard state WARNING The number of acknowledged services in hard state WARNING The number of unacknowledged services in hard state CRITICAL The number of acknowledged services in hard state CRITICAL The number of unacknowledged services in hard state UNKNOWN The number of acknowledged services in hard state UNKNOWN.
In version 1.1.11i2 the new header StatsNegate: has been introduced. It takes no arguments and logically negates the most recent stats-Filter.
5.3. Grouping.
Letting Livestatus count items is nice and fast. But in our examples so far the answer was restricted to one line of numbers for a predefined set of filters. In some situations you want to get statistics for each object from a certain set. You might want to display a list of hosts, and for each of these hosts the number of services which are OK, WARN, CRIT or UNKNOWN.
In such situations you can add the Columns: header to your query. There is a simple and yet mighty notion behind it: You specify a list of columns of your table. The stats are computed and displayed separately for each different combination of values of these columns.
The following query counts the number of services in the various states for each host in the host group windows :
The output looks like this:
As you can see, an additional column was prepended to the output holding the value of the group column. Here is another example that counts the total number of services grouped by the check command (the dummy filter expression is always true, so each service is counted).
Here is an example output of that query:
A third example shows another way for counting the total number of services grouped by their states without an explicit Stat - header for each state:
In that example none of the services was in the state UNKNOWN. Hence no count for that state was displayed.
One last note about grouping: the current implementation allows only columns of the types string or in to be used for grouping. Also you are limited to one group column.
Note: prior to version 1.1.10 there was the header StatsGroupBy: instead of Columns: . That header is deprecated, though still working.
6. Sum, Minimum, Maximum, Average, Standard Deviation.
Starting from version 1.1.2 Livestatus supports some basis statistical operations. They allow you, for example, to query the average check execution time or the standard deviation of the check latency of all checks.
These operations are using one of the keywords sum , min , max , avg , std , suminv or avginv . The following query displays the minimum, maximum and average check execution time of all service checks in state OK:
As with the "normal" stats-headers, the output can be grouped by one column, for example by the host_name :
In version 1.1.13i1 we introduced the aggregation functions suminv and avginv . They compute the sum or the average of the inverse of the values. For example the inverse of the check_interval of a service is the number of times it is checked per minute. The suminv over all services is the total number of checks that should be executed per minute, if no checks are being delayed.
6.1. Performance Data.
As of version 1.1.11i2 , MK Livestatus now supports aggregation of Nagios performance data. Performance data is additional information output by checks, formatted as a string like user=6.934;;;; system=6.244;;;; wait=0.890;;;; . If you create a Stats-query using sum , min , max , avg or std on several services with compatible performance data, Livestatus will now aggregate these values into a new performance data string. Look at the following examples. First, a query of two services without aggregation:
Let's assume it produces the following output:
Here is the same query, but aggregating the data using the average:
وهذه هي النتيجة:
7. Output formatting and character encoding.
Livestatus supports the output formats CSV, JSON and Python, with CSV being the default.
7.1. CSV output.
CSV output comes in two flavors: csv (lowercase) and CSV (uppercase). For backwards compatibility reasons, the lowercase variant is the default, but it has quite a few quirks. The recommendation is to use the uppercase variant, and when you really need more structure in your data. you are much better off with JSON or Python.
csv output (broken)
Datasets are separated by Linefeeds (ASCII 10), fields are separated by semicolons (ASCII 59), list elements (such as in contacts) are separated by commas (ASCII 44) and combinations of host name and service description are separated by a pipe symbol (ASCII 124).
In order to avoid problems with the default field separator semicolon appearing in values (such as performance data), it is possible to replace the separator characters with other symbols. This is done by specifying four integer numbers after the Separators: header. Each of those is the ASCII code of a separator in decimal. The four numbers mean:
The dataset separator (default is 10 : linefeed) The column separator (default is 59 : semicolon) The separator for lists such as contacts in the hosts table (default is 44 : comma) The separator for hosts and services in service lists (default is 124 : vertical bar)
It is even possible to use non-printable characters as separators. The following example uses bytes with the values 0, 1, 2 and 3 as separators:
CSV output.
This is the "real" CSV format (see RFC 4180) which is similar to the lowercase variant above, but with correct quoting and CR/LF as the dataset separator. Because of the quoting, there is no need for the Separators: header, so it is ignored for this format.
7.2. JSON output.
You can get your output in JSON format if you add the header OutputFormat: json , as in the following example:
Like CSV, JSON is a text based format, and it is valid JavaScript code. In order to avoid redundancy and keep the overhead as low as possible, the output is not formatted as a list of objects (with key/value pairs), but as a list of lists (arrays in JSON speak). This is the recommended format in general, as it makes it extremely easy to handle structured data, and JSON parsers are available for basically every programming language out there.
7.3. Python output.
The Python format is very similar to the JSON format, but not 100% compatible. There are tiny difference in string prefixes and how characters are escaped, and this is even different in Python 2 and Python 3. Therefore, two Pythonic formats are offered: python for Python 2 and python3 for, well, Python 3. You can directly eval() the Python output, but be aware of the potential security issues then. When in doubt, use JSON and json. loads from the standard json module.
7.4. Character encoding.
Livestatus output in most cases originates from configuration files of Nagios (the object configuration). Nagios does not impose any restrictions on how these files have to be encoded (UTF-8, Latin-1, etc). If you select CSV output, then Livestatus simply returns the data as it is contained in the configuration files - with the same encoding.
When using JSON or Python - however - non-ASCII-characters need to be escaped and properly encoded. Up to version 1.1.11i1 , Livestatus automatically detects 2-Byte UTF-8 sequences and assumes all other non-ASCII characters to be Latin-1 encoded. While this works well for western languages and to a certain degree "auto-detects" the encoding, it does not support languages using other characters then those used in Latin-1. Even the €-Symbol is not working.
As of version 1.1.11i2 , Livestatus' behaviour is configurable with the option data_encoding and defaults now to UTF-8 encoding. Three different settings are valid:
7.5. Column headers.
Per default, if there is no Columns - header in your query, MK Livestatus displays the names of all columns as a first line of the output. With the header OutputColumns you can explicitely switch column headers on or off . The output to the following query will include column headers:
7.6. Limitting the number of datasets.
The Limits - header allows you to limit the number of datasets being displayed. Since MK Livestatus currently does not support sorting, you'll have to live with the Nagios-internal natural sorting of objects. Hosts, for example, are sorted according to their host names - just as in the standard CGIs. The following example will output just the first 10 hosts:
Please note that the Limit - header is also applied when doing Stats. I'm not sure if there is any use for that, but thats the way MK Livestatus behaves. The following example will count how many of the 10 first hosts are up:
If using filters, the Limit - header limits the number of datasets actually being output. The following query outputs the first 10 hosts which are down:
8. Authorization.
Since version 1.1.3, Livestatus supports addon developers by helping to implement authorization. You can let Livestatus decide whether a certain contact may see data or not. This is very simple to use. All you need to do is to add an AuthUser header to your query with the name of a Nagios contact as single argument. If you do that, Livestatus will only display data that name is a contact for - either directly or via a contact group. مثال:
In certain cases it would be possible to replace AuthUser with a Filter header. But that does not work (precisely) in all situations.
8.1. ترتيب.
If your addon uses AuthUser , the administrator has a way to configure authentication details via nagios. cfg - and thus can do this uniformely across all addons using Livestatus. Currently two configuration options are available. Both can be set either to strict or loose :
Please note that Nagios makes all services that do not have any contact at all inherit all contacts of the host - regardless whether this option is set to strict or loose .
8.2. Tables supporting AuthUser.
The following tables support the AuthUser header (others simply ignore it): hosts , services , hostgroups , servicegroup and log . The log - table applies the AuthUser only to entries of the log classes 1 (host and service alerts), 3 (notifications) and 4 (passive checks). All other classes are not affected.
8.3. محددات.
Currently the AuthUser - header only controls which rows of data are output and has no impact on list columns, such as the groups column in the table services . This means that this column also lists service groups the contact might not be a contact for. This might be changed in a future version of Livestatus.
Starting with version 1.1.3 Livestatus has a new and still experimental feature: Waiting. Waiting allows developers of addons to delay the execution of a query until a certain condition becomes true or a Nagios event happens. This allows the implementation of a new class of features in addons, for example:
An immediate update of a status display as soon as the status of any or one specific Nagios object changes. A logfile ticker showing new log messages immediately. An action button for rescheduling the next check of a service which displays the service not sooner than after it has been checked.
All that can be implemented without polling - and in a very simple way. All you have to do is to make up some new query headers:
Specifying multiple condition headers is allowed: All conditions are combined with a boolean and (just as with the Filter header).
The following triggers are available for the WaitTrigger - Header: check - a service or host check has been executed state - the state of a host or service has changed log - a new message has been logged into nagios. log downtime - a downtime has been set or removed comment - a comment has been set or removed command - an external command has been executed program - a change in a global program setting, like enable_notifications all - any of the upper events happen (this is the default)
9.1. أمثلة.
Retrieve log messages since a certain timestamp, but wait until at least one new log message appeares:
The same, but do not wait longer than 2 seconds:
Retrieve the complete data about the host xabc123 , but wait until its state is critical:
Get data about the service Memory used on host xabc123 as soon as it has been checked some time after 1265062900:
10. Compensating timezone differences.
When doing multi-national distributed monitoring with Livestatus you might have to deal with situations where your monitoring servers are running in different time zones. In an ordinary setup all servers will have the same system time but different configured time zones. You can check this by calling on each monitoring server:
This command should output the same value on all servers. If not, you've probably set your system to a wrong time zone. MK Livestatus can help to compensate the time difference in such situations. If you add the header.
to your query with your current local time (the output of date +%s ) as an argument, Livestatus will compare its local time against that of the caller and convert all timestamps accordingly.
Please note that Livestatus assumes that a difference in time is not due to clock inaccuracy but due to timezone differences. The delta time computed for compensating will be rounded to the nearest half hour .
11. Response Header.
If your request is not valid or some other error appears, a message is printed to the logfile of Nagios. If you want to write an API that displays error message to the user, you need information about errors as a part of the response.
You can get such behaviour by using the header ResponseHeader . It can be set to off (default) or to fixed16 :
Other types of response headers might be implemented in future versions. The fixed16 - header has the advantage that it is exactly 16 bytes long. This makes it easy to program an API. You simply can read in 16 bytes and need not scan for a newline or stuff like that. Here is a complete example session with response headers being activated:
The fixed16 response header has the following format: Bytes 1-3: status code Byte 4: a single space Byte 5-15: the length of the response as an ASCII coded integer number, padded with spaces Byte 16: a linefeed character (ASCII 10)
These are the possible values of the status code:
The reponse contains the queried data only if the status code is 200 . In all other cases the reponse contains the error message. In that case the length field gives the length of the error message including the trailing linefeed. It is not JSON-encoded, even if you set that in the OutputFormat - header.
12. Keep alive (persistent connections)
MK Livestatus allows you to keep open a connection and reuse it for several requests. I order to do that you need to add the following header:
Livestatus will keep open the connection after sending its response and wait for a new query in that case. You probably also will activate a response header in that case, since only this allows you to exactly determine the length of the response (without KeepAlive you can simply read until end of file).
Please note that keeping up a connection permanently occupies ressources within the Nagios process. In the current version Livestatus is limited to ten parallel persistent connections. This is different from the way persistent database connections are handled.
The proposed way to use persistent connections in web applications is to keep the connection open only during the current request and close it after the complete result page has been rendered. The reason is that bringing up a database connection is a much more costly operation than connecting to MK Livestatus.
13. Access to Logfiles.
Since version 1.1.1 Livestatus provides transparent access to your Nagios logfiles, i. e. nagios. log and the rotated files in archives (you might have defined an alternative directory in nagios. cfg). Livestatus keeps an index over all log files and remembers which period of time is kept in which log file. Please note that Livestatus does not depend on the name of the log files (while Nagios does). This way Livestatus has no problem if the log file rotation interval is changed.
The Livestatus table log is your access to the logfiles. Every log message is represented by one row in that table.
13.1. Performance issues.
If your monitoring system is running for a couple of years, the number of log files and entries can get very large. Each Livestatus query to the table log has the potential of scanning all historic files (although an in-memory cache tries to avoid reading files again and again). It is thus crucial that you use Filter: in order to restrict:
The time interval The log classes in question.
If you set no filter on the column time , then all logfiles will be loaded - regardless of other filters you might have set.
Setting a filter on the column class restricts the types of messages loaded from disk. The following classes are available:
0 - All messages not in any other class 1 - host and service alerts 2 - important program events (program start, etc.) 3 - notifications 4 - passive checks 5 - external commands 6 - initial or current state entries 7 - program state change.
14. RRD Files of PNP4Nagios.
New in 1.1.9i3 : In order to improve the integration between Multisite and PNP4Nagios, Livestatus introduces the new column pnpgraph_present in the tables hosts and services (and all other tables containing host_ or service_ columns). That column can have three possible values:
Livestatus cannot detect the base directory to your RRD files automatically, so you need to configure it with the module option pnp_path :
In order to determine Livestatus the availability of the PNP graph it checks for the existance of PNPs. xml file.
A note for OMD users: OMD automatically configures this option correctly in etc/mk-livestatus/nagios. cfg . You need at least a daily snapshot of 2018-12-17 or later for using the new feature.
15. Expansion of macros.
Nagios allows you to embed macros within your configuration. For example it is usual to embed $HOSTNAME$ and $SERVICEDESC$ into your action_url or notes_url when configuring links to a graphing tool.
As of version 1.1.1 Livestatus supports expansion of macros in several columns of the table hosts and services . Those columns - for example notes_url_expanded - bear the same name as the unexpanded columns but with _expanded suffixed.
Since macro expansion is very complex in Nagios. And unfortunately the Nagios code for that is not thread safe, so Livestatus has its own implementation of macros, which does not support all features of Nagios, but (nearly) all that are needed for visualization addons. Livestatus supports the following macros:
for hosts and services: HOSTNAME , HOSTDISPLAYNAME , HOSTALIAS , HOSTADDRESS , HOSTOUTPUT , LONGHOSTOUTPUT , HOSTPERFDATA , HOSTCHECKCOMMAND for services: SERVICEDESC , SERVICEDISPLAYNAME , SERVICEOUTPUT , LONGSERVICEOUTPUT , SERVICEPERFDATA , SERVICECHECKCOMMAND all custom macros on hosts and services (beginning with _HOST or _SERVICE ) all $USER. $ macros.
16. Remote access to Livestatus via SSH or xinetd.
16.1. Livestatus via SSH.
Livestatus current does not provide a TCP socket. Another (and more secure) way for remote accessing the unix socket is using SSH. The following example sends a query via SSH. The only priviledge the remote user needs, is write access to the unix socket:
16.2. Livestatus via xinetd.
Using xinetd and unixcat you can bind the socket of Livestatus to a TCP socket. Here is an example configuration for xinetd:
You can access your socket for example with netcat :
17. Timeouts.
In version 1.1.7i3 the handling of timeouts has changed. There are now two configurable timeouts which protect Livestatus from broken clients hanging on the line for ever (remember that the maximum number of parallel connections is configurable but limited):
idle_timeout - Limits the time Livestatus waits for a (the next) query query_timeout - Limits the time a query needs to be read.
A Livestatus connection has two states: either Livestatus is waiting for a query. This is the case just after the client has connected, but also in KeepAlive - mode after the response has been sent. The client has now at most idle_timeout ms for starting the next query. The default is set to 300000 (300 seconds, i. e. 5 minutes). If a client is idle for more then that, Livestatus simply closes the connection.
As soon as the first byte of a query has been read, Livestatus enters the state "reading query" and uses a much shorter timeout: the query_timeout . Its default value is 10000 (10 secs). If the client does not complete the query within this time, the client is regarded dead and the connection is closed.
Both timeout values can be configured by Nagios module options in nagios. cfg . A timeout can be disable by setting its value to 0 . But be warned: Broken clients can hang connections for ever and thus block Livestatus threads.
18. Sending commands via Livestatus.
MK Livestatus supports sending Nagios commands. This is very similar to the Nagios command pipe, but very useful for accessing a Nagios instance via a remote connection.
You send commands via the basic request COMMAND followed by a space and the command line in exactly the same syntax as needed for the Nagios pipe. No further header fields are required nor allowed.
Livestatus keeps the connection open after a command and waits for further commands or GET - requests. It behaves like GET with KeepAlive: set to yes . That way you can send a bunch of commands in one connection - just as with the pipe. Here is an example of sending a command from the shell via unicat :
Just as with GET , a query is terminated either by closing the connection or by sending a newline. COMMAND automatically implies keep alive and behave like GET when KeepAlive is set to on . That way you can mix GET and COMMAND quries in one connection.
19. Stability and Performance.
19.1. المزيد.
While early versions of MK Livestatus experienced some stability issues - not unusual for evolving software - nowadays it can be considered rock solid. There are no known problems with performance, crashes or a hanging Nagios, as long as two important requirements are fullfilled: Environment macros have to be disabled in nagios. cfg . This is done with:
19.2. أداء.
Livestatus behaves with respect to your CPU and disk ressources. It doesn't do any disk IO at all, in fact - as long as the table log is not accessed, which needs read access to the Nagios' log files. CPU is only consumed during actual and queries and even for large queries we rather speek of micro seconds then of milli seconds of CPU usage. Furthermore, Livestatus does not block Nagios during the execution of a query but is running totally in parallel - and scales to all available CPU cores if neccessary. 1.1.9i3 Timeperiod transitions">
20. 1.1.9i3 Timeperiod transitions.
Version 1.1.9i3 introduces a new little feature, that does not really have something to do with status queries but is very helpful for creating availability reports and was easy to implement in Livestatus (due to its timeperiod cache).
Each time a timeperiod changes from active to not active or vice versa, an entry in the Nagios logfile is being created. At start of Nagios the initial states of all timeperiods are also logged. This looks like this:
When a transition occurs one line is logged (here the state changed from 1 (in) to 0 (out).
With that information, it is later possible to determine, which timeperiods were active when an alert happened. That way you can make availability reports reflect only certain time periods.
21. Host and Service Availability.
21.1. المقدمة.
Version 1.2.1i2 introduces the new table statehist which supports availability queries - providing statistical information for hosts and service. Beside the state information, this table returns duration information regarding the length of the state. In addition the duration percentage in respect to the query timeframe can be returned.
Each change creates an output line with the respective duration. Additional columns show the part (percentage) of this duration in comparison to the queried timeframe. To get the overall percentage of a specific state you can use the Stats: header to accumulate the percentage fields of multiple lines.
21.2. Absence of host and services.
To identify the absence of host and services within the queried timeperiod correctly it is necessary to set the following parameter.
Setting this parameter to 1 results that the initial state of each host and service is logged during the programs startup. By evaluating each startup it is possible to detect if a host or service is no longer monitored by the system. It is even possible to detect if this host or service was temporarily removed from monitoring for a specific time. The absence of a host or service is reflected in the output line within the state column as -1 (UNMONITORED)
The setting log_initial_states=1 is the default parameter as of version 1.2.1i2.
Disabling this parameter lead to less logfile entries on the programs startup, but limits the correct detection of the UNMONITORED state.
21.3. Table statehist.
Querying the table statehist results in an output which shows the a hosts/services states as mentioned above and in addition how long this host/service resided in this state.
A query always requires a filter for the start time. Otherwise livestatus would parse all available logfiles from the beginning, which might add up to several hundred megabytes.
Outputs a list where the state of this service has changed joined with the duration information.
By using the Stats: header these lines can be accumulated and allows the output of distinct stats duration and their duration_part in respect to the queried timeframe.
Using the columns duration_part_ok, duration_part_warning, duration_part_critical allows to output the entire state information within a single line.
Converting the part values into percentages the SLA information for this service is 70.1% OK 3.8% WARNING 26.1% CRITICAL.

Icinga2 event_broker_options


Mit check_vmware_snapshots lassen sich Alter und Anzahl der Snapshots überwachen, die in einer ESXi/vSphere-Umgebung vorhanden sind. Der Check wird dabei direkt ans vCenter gerichtet und hangelt sich durch alle virtuellen Maschinen; je nach gewähltem Plugin Modus (age/count) wird dabei entweder alarmiert, wenn entweder das Alter eines/mehrerer Snapshots oder die Anzahl der erlaubten Snapshots pro VM überschritten wird.
Das Plugin fuГџt auf der Idee von Sebastian Kayser, der eine erste Version des Scriptes hier auf ConSol Labs vorgestellt hat.
Version 0.12 ermöglicht es, mit White/Blacklisting-Ausdrücken VMs von der Prüfung auszuschließen oder nur eine Teilmenge zu prüfen.
Mit Version 0.13 kam der Parameter –separator hinzu, mit welchem/n Zeichen zum Verketten der einzelnen Snapshot/VM-Meldungen angegeben werden, um z. B. der besseren Übersicht wegen Zeilenumbrüche einzubauen.
Version 0.15 ermöglicht es nun, über den Parameter –match_snapshot_names das Black/Whitelisting auch auf die Snapshot namen auszuweiten.
Weitere Vorschläge nehme ich gerne entgegen!
فريف.
Service “Snapshot Alter”:
Service “Snapshot Count”:
Service “Snapshot Count for all DWH VMs”:
Service “Snapshot Count for all but not dev and test machines”:
Service “Snapshot Count, excluding QA snapshots”.

No comments:

Post a Comment