Search code examples
pythonpython-3.xchecksum

Smart way of error reporting into database


I'm developing a computerCheck program, it's Python based (for now). The programs basically checks some Windows OS status, e.g. if the correct AV is running, if bitlocker is activated and so on.... The result of the check OK or NOT OK is reported into the database. However, since it's about 10 checks...I would like to report in a smart way back to the database. I don't want to have an entry for every check in the record, because this would be a problem when the number of checks change. So I would like to send a "smart" kind of checksum... The checksum should give which of the checks are NOT OK (e.g. check nr.1 is false, check nr.4 is false) and preferable a reason...like nr 1. status 2 (2 represents e.g. service not running..)

Now, the big question is, is it possible to do it that way, so e.g. always sending a x character long code to the database and when reading the code back, you can "unpack" it to something human readible again....

I hope it's clear what I'm looking for...

Thanks in advance! /Jasper


Solution

  • You could create a string where every index represents one check. You will have more than enough chars to use as states. For example:
    "0120" -> check0 ok, check1 error state 1, check2 error state 2...

    New checks can simply be appended to the string, removed checks need to be marked as no more existent:
    "0X200" -> check1 doesn't exist anymore and one new check appended at the end.