GithubHelp home page GithubHelp logo

linuxfabrik / lib Goto Github PK

View Code? Open in Web Editor NEW
13.0 6.0 7.0 501 KB

Python libraries used in various Linuxfabrik projects, including the Monitoring Plugins project.

Home Page: https://linuxfabrik.ch

License: The Unlicense

Python 100.00%
python python3 python2 monitoring-plugins icinga monitoring linuxfabrik libraries nagios

lib's People

Contributors

brianneoberson avatar markuslf avatar navidsassan avatar paasi6666 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lib's Issues

base2: AttributeError: 'exceptions.ValueError' object has no attribute 'encode'

In GitLab by @markuslf on Oct 11, 2021, 17:50

Traceback (most recent call last):
  File "./feed2", line 284, in 'module'
    main()
  File "./feed2", line 256, in main
    feed_item = lib.base2.coe(fetch_feed_todays_item(args.FEED_URL, args.INSECURE, args.NO_PROXY, args.TIMEOUT))
  File "/home/markus.frei/git/linuxfabrik/monitoring-plugins/check-plugins/feed/lib/base2.py", line 142, in coe
    print(result[1].encode('utf-8', 'replace'))
AttributeError: 'exceptions.ValueError' object has no attribute 'encode'

db_sqlite: Add REGEXP function

In GitLab by @markuslf on Sep 29, 2021, 17:35

The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If an application-defined SQL function named "regexp" is added at run-time, then the "X REGEXP Y" operator will be implemented as a call to "regexp(Y,X)".

import sqlite3
import re

def regexp(expr, item):
    reg = re.compile(expr)
    return reg.search(item) is not None

conn = sqlite3.connect(':memory:')
conn.create_function("REGEXP", 2, regexp)
cursor = conn.cursor()
cursor.execute('SELECT bar FROM foo WHERE bar REGEXP ?',['"test"'])

https://stackoverflow.com/questions/5365451/problem-with-regexp-python-and-sqlite/5365533#5365533

args2: AttributeError: 'int' object has no attribute 'lower'

In GitLab by @markuslf on May 4, 2021, 14:44

Traceback (most recent call last):
  File "./users2", line 170, in <module>
    main()
  File "./users2", line 99, in main
    WARN_TTY = lib.args2.int_or_none(args.WARN[0])
  File "/home/markus.frei/git/linuxfabrik/monitoring-plugins/check-plugins/users/lib/args2.py", line 38, in int_or_none
    if arg is None or str(arg.lower()) == 'none':
AttributeError: 'int' object has no attribute 'lower'

hashlib.md5() on FIPS compliant systems

which is used in base, causing:

File "/usr/lib64/nagios/plugins/disk-io", line 283,
    in main() File "/usr/lib64/nagios/plugins/disk-io", line 138,
    in main lib.base2.coe(lib.db_sqlite2.create_index(conn, 'name'))

File "/usr/lib64/nagios/plugins/lib/db_sqlite2.py", line 109,
    in create_index index_name = 'idx_{}'.format(base2.md5sum(table + column_list))

File "/usr/lib64/nagios/plugins/lib/base2.py", line 641,
    in md5sum return hashlib.md5(string).hexdigest() ValueError: error:060800A3:digital envelope routines:EVP_DigestInit_ex:disabled for fips

redhat implemented a usedforsecurity=False parameter, which was also integrated into python >= 3.9 (see https://bugzilla.redhat.com/show_bug.cgi?id=1744670).

this could be implemented as a fallback. the other question is, how do we handle this if usedforsecurity is not available.

can be replicated on a system according to https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/chap-federal_standards_and_regulations (the 'After the System Installation'-steps are enough).

disk: Problems with read_csv()

In GitLab by @markuslf on Jul 8, 2021, 16:58

snmp2 check is unable to use the function read_csv(). read_csv() contains Python 3 code, and checking for empty rows does not work as expected (unknown variable l)

Improve the output.state_to_string function

Implement this interface:

def state_to_string(value, state, parenthesis=True, return_ok=False)

expected outputs

state_to_string(123, STATE_CRIT, parenthesis=True): '123 (CRIT)'
state_to_string(123, STATE_OK, parenthesis=True): '123'
state_to_string(123, STATE_OK, parenthesis=True, return_ok=True): '123 (OK)'

Support pydoc

In GitLab by @markuslf on Aug 26, 2021, 10:33

Consider being in git/linuxfabrik/lib and running pydoc -b (starting the webserver for surfing the documentation), most of the modules fail with pydoc.ErrorDuringImport: problem in net3 - ImportError: attempted relative import with no known parent package. Is there a way to get around this?

Also see #5

url: Identify as Linuxfabrik Monitoring-Plugin

In GitLab by @markuslf on Jul 8, 2021, 14:26

Some services send mails for example if an Access Token had to be updated, including the accessing user agent. Currently, the Linuxfabrik Monitoring-Plugins using lib.url are recognized as Library (Python-urllib/unknown) - Unknown location. Maybe it is possible to set something like Linuxfabrik Monitoring Plugin to better identify the client.

Mail from Metabase:

We've noticed a new login on your Metabase account.

Hi Metabase,

We noticed a login on your Metabase account from a new device.

Library (Python-urllib/unknown) - Unknown location

July 8, 2021 10:40:51 AM (GMT)

If this was you, you can safely disregard this email. If this wasn't you, you should change your password immediately.

fail2ban check always unknown on Ubuntu 16+20

In GitLab by @phyti1 on Sep 2, 2020, 16:44

When using the fail2ban check on Ubuntu 20 and Ubuntu 16 servers after doing apt install fail2ban on each server I get the following error:
Problem while testing if the fail2ban server is alive. Status unknown.
Output of

lib.base.shell_exec(cmd + ' ping')" on line 73 is: 
"Permission denied to socket: /var/run/fail2ban/fail2ban.sock, (you must be root)".

As a workaround I did chown nagios:root /var/run/fail2ban/fail2ban.sock which worked.
Can this be resolved?

librenms-alerts2: --lengthy causes error

only the python2 variant (v2021110401).

the traceback is generated using print_exc() in the lib.base2.get_table (line 437).

Traceback (most recent call last):
  File "git/lf/monitoring-plugins/check-plugins/librenms-alerts/lib/base2.py", line 433, in get_table
    data[idx][col] = unicode(row[col]).strip()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
Everything is ok.

Unknown column "location"|'device_count'=3;;;0; 'alert_count'=0;;;0;

net: chunk = s.recv(1024) timeout: timed out

In GitLab by @markuslf on Jun 23, 2021, 08:32

Traceback (most recent call last):
  File "/usr/lib64/nagios/plugins/starface-backup-status", line 232, in <module>
    main()
  File "/usr/lib64/nagios/plugins/starface-backup-status", line 158, in main
    data = lib.base2.coe(lib.net2.fetch(args.HOSTNAME, args.PORT, timeout=args.TIMEOUT))
  File "/usr/lib64/nagios/plugins/lib/net2.py", line 147, in fetch
    chunk = s.recv(1024)
timeout: timed out

Error in librenms3.py

In GitLab by @markuslf on Jul 15, 2021, 12:03

File "/usr/lib64/nagios/plugins/lib/librenms3.py", line 17, in from globals3 import STATE_OK, STATE_UNKNOWN, STATE_WARN, STATE_CRIT ModuleNotFoundError: No module named 'globals3'

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.