dumb python monitoring client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jowj 29c25708b0
Fix alert.log issue where last kv pair isn't written to file.
4 years ago
.gitignore update gitignore to remove vs project bullshit. 6 years ago
README.md Update readme. 4 years ago
arke.py Fix alert.log issue where last kv pair isn't written to file. 4 years ago
arkevars.py Add a second domain to domains_to_check to prevent type issues. 4 years ago
dockerfile Fix python > python3 typo. 4 years ago
poetry.lock Update poetry.lock 4 years ago
pyproject.toml Move to poetry for dependency management. 4 years ago


python monitoring client

arke is a dumb python monitoring client i am currently working on to monitor http status and docker container runtime.

http status:

  • monitor znc server http status
  • monitor pleroma server http status

docker runtime:

  • slackbot


  • runtime file
  • vars file that points the client at my servers


  • Fix loading json from file
    • alright see "json loading" heading in this file.
  • Fix state comparison and post to only post the item that has changed since last run
    • i thought I mostly had this fixed but i'm still running into issues.
    • requires some additional digging.
  • update this readme.

json loading

confused here. in python, a dict is the key/value store that is used to map to json. all my functions return a dict:

def monitor_HttpTargets(monitoringtargets):
    responseTable = {}
    return responseTable

def monitor_DomainExpiry(targets):
    responseTable = {}
    return responseTable

def monitor_TlsExpiry(targets):
    responseTable = {}
    return responseTable

Ok so that part's straight forward. Then, i combine all of them into a single keyed dict, so I have a dict of dicts:

    datastore = {}
    datastore['http'] = monitor_HttpTargets(arkevars.httpTargets)
    datastore['certs'] = monitor_TlsExpiry(arkevars.tlsTargets)
    datastore['whois'] = monitor_DomainExpiry(arkevars.domains_to_check)

OK again, straight forward. Here's where shit gets less obvious to me. I need to convert this variable containing a dict into a json object in a file. I do this like so:

# write new results to file
with open(this_round_file, "a+", encoding="utf-8") as outfile:
	json.dump(datastore, outfile, ensure_ascii=False, sort_keys=True)

ok, so crafting the json object seems to make sense, and seems to be pretty straight forward. What about reading the 'json' object? WELL THEREIN LIES THE TALE MY GOOD BITCH

Traceback (most recent call last):
  File "arke.py", line 114, in <module>
    json_data = json.load(json_File)
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 133 (char 132)

this is where I get. loading that file doesn't work. Which seems to suggest that how I'm crafting the json string written to the file with json.dump is problematic! But I haven't figured out /why/ ugh.


oh my god i wasn't cleaning up the file after last run so previous run charactes was fucking up the file!!! aaaah!