Giter Site home page Giter Site logo

nagaconda's Introduction

Nagios has been around for quite some time, but producing output it can 
consume is something of a black art. Only the plugin documentation 
actually explains what all the extra semicolons or extended formatting 
even means.

This is especially onerous when performance consuming add-ons expect a 
specific structure before operating properly. This package strives to 
greatly simplify the process of actually generating Nagios output using 
Python.

Please see the TODO file for a very rudimentary roadmap for this
project! Development should pick up after the move to github thanks
to the increase in volunteers.

Vendor (Original): Leapfrog Online

Author (Original): Shaun Thomas <[email protected]>

Source (Original): https://github.com/bonesmoses/NagAconda

nagaconda's People

Contributors

bonesmoses avatar biutiful avatar lrupp avatar

Stargazers

Quentin L avatar Jan-Hendrik Boll avatar James Candalino avatar jasper avatar Vye avatar Kovács Bálint avatar Tom Throckmorton avatar Neil Hooey avatar Torbjörn Björklund avatar Lance French avatar Rob Guttman avatar Mike Newton avatar Ludovic Gasc avatar Terry Peppers avatar

Watchers

Terry Peppers avatar Christoph Holtermann avatar  avatar James Cloos avatar

nagaconda's Issues

NagAconda install throwing error

C:\Python33>"c:\python33\scripts\pip.exe" install NagAconda
Downloading/unpacking NagAconda
Downloading NagAconda-0.2.1.tar.gz (235kB): 235kB downloaded
Running setup.py egg_info for package NagAconda
Traceback (most recent call last):
File "", line 16, in
File "c:\users\rajars~1\appdata\local\temp\pip_build_rajarshid\NagAconda\setup.py", line 4, in
import NagAconda
File ".\NagAconda__init__.py", line 19, in
from Plugin import *
ImportError: No module named 'Plugin'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 16, in

File "c:\users\rajars~1\appdata\local\temp\pip_build_rajarshid\NagAconda\setup.py", line 4, in

import NagAconda

File ".\NagAconda__init__.py", line 19, in

from Plugin import *

ImportError: No module named 'Plugin'


Cleaning up...
Command python setup.py egg_info failed with error code 1 in c:\users\rajars~1\appdata\local\temp\pip_build_rajarshid\NagAconda
Storing complete log in C:\Users\rajarshid\pip\pip.log

C:\Python33>pause
Press any key to continue . . .

Extra print statements cause problems when alerting to SMS

When I am sending Nagios alerts to an SMS recipient, the extra print statements that show the range, etc make it so that I lose much of the content of the alert. Would it be possible to set a flag for whether or not to send them? I can fork and upload my own modified copy of Plugin.py for reference if needed (I just commented out many of the print statements). Thanks!

Can't set range

If you run this code, you will have an error.

#!/usr/bin/python

from NagAconda import Plugin

plugin = Plugin('The plugin', '0.1')
plugin.add_option('p', 'parameter', 'The parameter.')
plugin.enable_status('warning')
plugin.enable_status('critical')
plugin.start()

#have to huck the code due to a bug. It sets defaults for warning and critical to None and then try to get its len :(
# plugin._Plugin__warning = []
# plugin._Plugin__critical = []
#end of huck

plugin.set_range('warning', 1)
plugin.set_range('critical', 2, 1)


plugin.set_status_message('the message')
plugin.set_value('state', 1)

plugin.finish()
Traceback (most recent call last):
  File "nagaconda_bug.py", line 16, in <module>
    plugin.set_range('warning', 1)
  File "/Library/Python/2.6/site-packages/NagAconda/Plugin.py", line 353, in set_range
    if range_num > len(my_range):
TypeError: object of type 'NoneType' has no len()

Due to info here you can set range after start. Uncomment "huck" code it make it run.

Plugin output is multiline

Is there any way to get just the last line (see below) from the plugin output? The check works fine and Icinga isn't complaining but "output of the check plugin" field only contains "check warning" instead of "Status Ok, Records in the last 50 minute(s): 18321011".

Here's my plugin output:

checking warning
range was warning
(0.0, 250000.0, True)
18321011.0:0.0:250000.0 = True
checking critical
range was critical
(0.0, 500000.0, True)
18321011.0:0.0:500000.0 = True
Status Ok, Records in the last 50 minute(s): 18321011|num_records=18321011.0;250000;500000;;

Ranges for performance data

I wrote a little nagios_plugin to check btrfs

#!/usr/bin/python
# Von https://pythonhosted.org/NagAconda/plugin.html
from NagAconda import Plugin
import os
import subprocess
from pyparsing import *

btrfs_check = Plugin("Plugin to show disk usage of btrfs.", "0.1")
btrfs_check.add_option('m', 'mountpoint', 'mountpoint for btrfs',
    required=True)

btrfs_check.enable_status('warning')
btrfs_check.enable_status('critical')
btrfs_check.start()

btrfs_output = subprocess.check_output(["btrfs", "fi", "df", btrfs_check.options.mountpoint])

# DEBUG: 
# print btrfs_output

# PyParsing definitions
#
# Output is something like:
# Data, RAID1: total=222.72GB, used=197.44GB
# System, RAID1: total=64.00MB, used=40.00KB
# System: total=4.00MB, used=0.00
# Metadata, RAID1: total=10.00GB, used=5.40GB

# Parse Byte values with units
byteDefs=["B", "KB", "MB", "GB", "TB", "PB", "EB"]
byteDef = oneOf(byteDefs)
fnumber = Word(nums+'.').setParseAction(lambda t: float(t[0]))
bnumber = Group(fnumber('num') + Optional(byteDef('unit'), default="B"))

# Definitions for each row
row_data = "Data, " + "RAID1: " + "total=" + bnumber('bytesize_total') + "," + "used=" + bnumber('bytesize_used')
row_system1 = "System, " + "RAID1: " + "total=" + bnumber('bytesize_total') + "," + "used=" + bnumber('bytesize_used')
row_system2 = "System: " + "total=" + bnumber('bytesize_total') + "," + "used=" + bnumber('bytesize_used')
row_metadata = "Metadata, " + "RAID1: " + "total=" + bnumber('bytesize_total') + "," + "used=" + bnumber('bytesize_used')

# The whole parsing term
btrfs_output_parser = row_data('data') + row_system1('system1') + row_system2('system2') + row_metadata('metadata')

# Parse btrfs output
btrfs_output_parsed = btrfs_output_parser.parseString(btrfs_output)

# calculate values
byteUnits=[("B", 1), ("KB", 1000), ("MB", 1000000), ("GB", 1000000000), ("TB", 1000000000000), ("PB", 1000000000000000), ("EB", 1000000000000000000)]
def calc_bnumber(bnum):
        """Get float number of bytes for something like 2GB"""
        for byteSize in byteUnits:
                if byteSize[0] == bnum.unit:
                        return byteSize[1] * bnum.num
        return None

data_bytes_used_float = calc_bnumber(btrfs_output_parsed.data.bytesize_used)
data_bytes_size_float = calc_bnumber(btrfs_output_parsed.data.bytesize_total)
data_usage_percentage_float = data_bytes_used_float / data_bytes_size_float * 100.0

system1_bytes_used_float = calc_bnumber(btrfs_output_parsed.system1.bytesize_used)
system1_bytes_size_float = calc_bnumber(btrfs_output_parsed.system1.bytesize_total)

system2_bytes_used_float = calc_bnumber(btrfs_output_parsed.system2.bytesize_used)
system2_bytes_size_float = calc_bnumber(btrfs_output_parsed.system2.bytesize_total)

metadata_bytes_used_float = calc_bnumber(btrfs_output_parsed.metadata.bytesize_used)

# DEBUG:
# print btrfs_output_parsed.dump()

# set nagios output
btrfs_check.set_range('warning', 100000000000000000000000, range_num=2)
btrfs_check.set_range('critical', 200000000000000000000000, range_num=2)


btrfs_check.set_value("data_used", btrfs_output_parsed.data.bytesize_used.num, scale=btrfs_output_parsed.data.bytesize_used.unit, threshold=2)
btrfs_check.set_value("data_total", btrfs_output_parsed.data.bytesize_total.num, scale=btrfs_output_parsed.data.bytesize_total.unit, threshold=2)
btrfs_check.set_value("data_ratio", data_usage_percentage_float, scale="%", threshold=1)

btrfs_check.set_value("system1_used", btrfs_output_parsed.system1.bytesize_used.num, scale=btrfs_output_parsed.system1.bytesize_used.unit, threshold=2)
btrfs_check.set_value("system1_total", btrfs_output_parsed.system1.bytesize_total.num, scale=btrfs_output_parsed.system1.bytesize_total.unit, threshold=2)

btrfs_check.set_value("system2_used", btrfs_output_parsed.system2.bytesize_used.num, scale=btrfs_output_parsed.system2.bytesize_used.unit, threshold=2)
btrfs_check.set_value("system2_total", btrfs_output_parsed.system2.bytesize_total.num, scale=btrfs_output_parsed.system2.bytesize_total.unit, threshold=2)

btrfs_check.set_value("metadata_used", btrfs_output_parsed.metadata.bytesize_used.num, scale=btrfs_output_parsed.metadata.bytesize_used.unit, threshold=2)
btrfs_check.set_value("metadata_total", btrfs_output_parsed.metadata.bytesize_total.num, scale=btrfs_output_parsed.metadata.bytesize_total.unit, threshold=2)

btrfs_check.finish()

I'd like to only check the data_ratio with the standard warning and critical values. This actually works when adding a second range that all the other performance datas are checked against.
But the output doesn't care about this.

When being called by

nagaconda_btrfs_df.py -m /mounts/BackupRAID -w0.9 -c0.95

Status Ok|metadata_used=5400000000.0B;0.9;0.95;; data_total=222.72GB;0.9;0.95;; data_ratio=0.886494252874;0.9;0.95;; data_used=197.44GB;0.9;0.95;; system2_used=0.0B;0.9;0.95;; metadata_total=10000000000.0B;0.9;0.95;; system1_used=40.0KB;0.9;0.95;; system2_total=4000000.0B;0.9;0.95;; system1_total=64.0MB;0.9;0.95;;

I'd expect the 2nd threshold not only in the tests but also in the output

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.