linuxfabrik / lib Goto Github PK
View Code? Open in Web Editor NEWPython libraries used in various Linuxfabrik projects, including the Monitoring Plugins project.
Home Page: https://linuxfabrik.ch
License: The Unlicense
Python libraries used in various Linuxfabrik projects, including the Monitoring Plugins project.
Home Page: https://linuxfabrik.ch
License: The Unlicense
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'
Merges develop -> master
Release Notes at https://docs.linuxfabrik.ch/monitoring-plugins/2021101401.html
In GitLab by @markuslf on Jun 17, 2021, 16:27
So that a group of plugins may use their own cache, and not all plugins try to work with linuxfabrik-plugin-cache.db
at once.
In GitLab by @markuslf on Jul 21, 2021, 10:52
So that it we are able to check version('v3.0.7-2') < version('3.0.11')
In GitLab by @markuslf on May 4, 2021, 14:46
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
In GitLab by @sandrolf on Feb 10, 2020, 18:05
Merges develop -> master
base
imports disk
, which in turn imports psutil
. This means no check will run without psutil installed.
In GitLab by @markuslf on Apr 28, 2021, 11:24
First line:
Location Uptime
-------- ------
Büro 1m 1w
Buero, Zuerich 5h 20m
Buero, Zuerich, CH 6m 3w
In GitLab by @markuslf on Aug 30, 2021, 15:48
Add a parameter extended
, default False
(so that we can remove the unused function fetch_ext()
(no more duplicated code)).
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'
In GitLab by @markuslf on Apr 28, 2021, 13:18
Instead of "2m 2w" print "2M 2D" to increase readability (2 months, 2 days), so that one does not confuse this with "2m 2s" (2 minutes, 2 seconds).
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).
In GitLab by @markuslf on Jun 2, 2021, 15:28
In GitLab by @markuslf on Jul 28, 2021, 11:45
In GitLab by @markuslf on Jun 14, 2021, 11:18
base imports disk, which imports base - better to refactor code.
In GitLab by @markuslf on Nov 15, 2021, 15:18
In GitLab by @markuslf on Sep 14, 2021, 16:34
In GitLab by @markuslf on Jul 15, 2021, 11:41
In GitLab by @markuslf on Oct 12, 2021, 21:04
Mistakenly used enocde() instead of decode() for print()
In GitLab by @markuslf on May 28, 2020, 09:37
Merges develop -> master
Linuxfabrik Libraries for Icinga Check Plugins 2020052801
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
)
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)'
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
In GitLab by @markuslf on Jun 14, 2021, 11:23
In GitLab by @markuslf on Apr 20, 2020, 10:41
Merges develop -> master
Linuxfabrik Libraries for Icinga Check Plugins 2020042001
In GitLab by @markuslf on Aug 31, 2021, 16:02
In GitLab by @markuslf on Mar 21, 2021, 06:57
In GitLab by @markuslf on Jun 2, 2021, 14:40
In GitLab by @markuslf on Mar 11, 2021, 14:12
In GitLab by @markuslf on Sep 17, 2021, 10:49
In GitLab by @markuslf on Jun 1, 2021, 13:18
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.
In GitLab by @markuslf on Apr 28, 2021, 14:09
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?
In GitLab by @markuslf on Jun 2, 2021, 15:27
Merges develop -> master
Merges develop -> master
Linuxfabrik Libraries for Monitoring Plugins 2020102301
In GitLab by @markuslf on Oct 14, 2021, 16:04
For example, move date-time- and conversion-functions to own libraries? Do a statistic and benchmark research.
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;
In GitLab by @markuslf on Apr 28, 2021, 11:20
Each column header line should be as long as the max(col_content.length(), col_header.length()).
In GitLab by @lfchris on Oct 19, 2021, 17:07
python3 running on ubuntu 20.
Traceback (most recent call last):
File "./nginx-status", line 169, in 'module'
main()
File "./nginx-status", line 119, in main
result = result.strip().split('\n')
TypeError: a bytes-like object is required, not 'str'
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
In GitLab by @markuslf on Jun 17, 2021, 16:21
If storing "complex" (not just ascii) data into a text column, for example massive output of a shell command, this error occurs.
In GitLab by @markuslf on Jun 15, 2021, 16:07
Merges develop -> master
Release Notes at https://docs.linuxfabrik.ch/monitoring-plugins/2021061501.html
In GitLab by @markuslf on Jun 17, 2021, 17:02
Merges develop -> master
In GitLab by @markuslf on May 17, 2021, 10:37
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.