sensu-plugins-mongodb-boutetnico 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/check-mongodb.py +5 -12
- data/lib/sensu-plugins-mongodb/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ffc709ffc7e8052e326a4e74a4a4382039f07eb4
         | 
| 4 | 
            +
              data.tar.gz: 5d4c88516eda7175370e534a68469a105ae02829
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 22bd4b61fca8b1665f2bf44650b082a9d25369c721e5d70e6a38778b1a17ef00539bdcbc6e653f10dec8eee251379b9abdd6dded4602c5e970d921b0591c8e6d
         | 
| 7 | 
            +
              data.tar.gz: ef2f19166c6f4e633c20cfd99d45492cdddc5191724f4680bc6320e473f98905ccfe87ce9cec0560ad0775d6dffd7c92303d8248683f20392a06485c5e2b965e
         | 
    
        data/bin/check-mongodb.py
    CHANGED
    
    | @@ -152,7 +152,6 @@ def main(argv): | |
| 152 152 | 
             
                p.add_option('-M', '--mongoversion', action='store', type='choice', dest='mongo_version', default='2', help='The MongoDB version you are talking with, either 2 or 3',
         | 
| 153 153 | 
             
                  choices=['2','3'])
         | 
| 154 154 | 
             
                p.add_option('-a', '--authdb', action='store', type='string', dest='authdb', default='admin', help='The database you want to authenticate against')
         | 
| 155 | 
            -
                p.add_option('--insecure', action='store_true', dest='insecure', default=False, help="Don't verify SSL/TLS certificates")
         | 
| 156 155 | 
             
                p.add_option('--ssl-ca-cert-file', action='store', type='string', dest='ssl_ca_cert_file', default=None, help='Path to Certificate Authority file for SSL')
         | 
| 157 156 | 
             
                p.add_option('-f', '--ssl-cert-file', action='store', type='string', dest='cert_file', default=None, help='Path to PEM encoded key and cert for client authentication')
         | 
| 158 157 | 
             
                p.add_option('-m','--auth-mechanism', action='store', type='choice', dest='auth_mechanism', default=None, help='Auth mechanism used for auth with mongodb',
         | 
| @@ -184,7 +183,6 @@ def main(argv): | |
| 184 183 | 
             
                database = options.database
         | 
| 185 184 | 
             
                ssl = options.ssl
         | 
| 186 185 | 
             
                replicaset = options.replicaset
         | 
| 187 | 
            -
                insecure = options.insecure
         | 
| 188 186 | 
             
                ssl_ca_cert_file = options.ssl_ca_cert_file
         | 
| 189 187 | 
             
                cert_file = options.cert_file
         | 
| 190 188 | 
             
                auth_mechanism = options.auth_mechanism
         | 
| @@ -198,7 +196,7 @@ def main(argv): | |
| 198 196 | 
             
                # moving the login up here and passing in the connection
         | 
| 199 197 | 
             
                #
         | 
| 200 198 | 
             
                start = time.time()
         | 
| 201 | 
            -
                err, con = mongo_connect(host, port, ssl, user, passwd, replicaset, authdb,  | 
| 199 | 
            +
                err, con = mongo_connect(host, port, ssl, user, passwd, replicaset, authdb, ssl_ca_cert_file, cert_file)
         | 
| 202 200 |  | 
| 203 201 | 
             
                if err != 0:
         | 
| 204 202 | 
             
                    return err
         | 
| @@ -215,7 +213,7 @@ def main(argv): | |
| 215 213 | 
             
                elif action == "replication_lag":
         | 
| 216 214 | 
             
                    return check_rep_lag(con, host_to_check, port_to_check, warning, critical, False, perf_data, max_lag, user, passwd)
         | 
| 217 215 | 
             
                elif action == "replication_lag_percent":
         | 
| 218 | 
            -
                    return check_rep_lag(con, host_to_check, port_to_check, warning, critical, True, perf_data, max_lag, user, passwd, ssl,  | 
| 216 | 
            +
                    return check_rep_lag(con, host_to_check, port_to_check, warning, critical, True, perf_data, max_lag, user, passwd, ssl, ssl_ca_cert_file, cert_file)
         | 
| 219 217 | 
             
                elif action == "replset_state":
         | 
| 220 218 | 
             
                    return check_replset_state(con, perf_data, warning, critical)
         | 
| 221 219 | 
             
                elif action == "memory":
         | 
| @@ -285,18 +283,13 @@ def main(argv): | |
| 285 283 | 
             
                    return check_connect(host, port, warning, critical, perf_data, user, passwd, conn_time)
         | 
| 286 284 |  | 
| 287 285 |  | 
| 288 | 
            -
            def mongo_connect(host=None, port=None, ssl=False, user=None, passwd=None, replica=None, authdb="admin",  | 
| 286 | 
            +
            def mongo_connect(host=None, port=None, ssl=False, user=None, passwd=None, replica=None, authdb="admin", ssl_ca_cert_file=None, ssl_cert=None, auth_mechanism=None):
         | 
| 289 287 | 
             
                from pymongo.errors import ConnectionFailure
         | 
| 290 288 | 
             
                from pymongo.errors import PyMongoError
         | 
| 291 | 
            -
                import ssl as SSL
         | 
| 292 289 |  | 
| 293 290 | 
             
                con_args = dict()
         | 
| 294 291 |  | 
| 295 292 | 
             
                if ssl:
         | 
| 296 | 
            -
                    if insecure:
         | 
| 297 | 
            -
                        con_args['ssl_cert_reqs'] = SSL.CERT_NONE
         | 
| 298 | 
            -
                    else:
         | 
| 299 | 
            -
                        con_args['ssl_cert_reqs'] = SSL.CERT_REQUIRED
         | 
| 300 293 | 
             
                    con_args['ssl'] = ssl
         | 
| 301 294 | 
             
                    if ssl_ca_cert_file:
         | 
| 302 295 | 
             
                        con_args['ssl_ca_certs'] = ssl_ca_cert_file
         | 
| @@ -412,7 +405,7 @@ def check_connections(con, warning, critical, perf_data): | |
| 412 405 | 
             
                    return exit_with_general_critical(e)
         | 
| 413 406 |  | 
| 414 407 |  | 
| 415 | 
            -
            def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_lag, user, passwd, ssl=None,  | 
| 408 | 
            +
            def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_lag, user, passwd, ssl=None, ssl_ca_cert_file=None, cert_file=None):
         | 
| 416 409 | 
             
                # Get mongo to tell us replica set member name when connecting locally
         | 
| 417 410 | 
             
                if "127.0.0.1" == host:
         | 
| 418 411 | 
             
                    if not "me" in list(con.admin.command("ismaster","1").keys()):
         | 
| @@ -521,7 +514,7 @@ def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_la | |
| 521 514 | 
             
                            lag = float(optime_lag.seconds + optime_lag.days * 24 * 3600)
         | 
| 522 515 |  | 
| 523 516 | 
             
                        if percent:
         | 
| 524 | 
            -
                            err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), ssl, user, passwd, None, None,  | 
| 517 | 
            +
                            err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), ssl, user, passwd, None, None, ssl_ca_cert_file, cert_file)
         | 
| 525 518 | 
             
                            if err != 0:
         | 
| 526 519 | 
             
                                return err
         | 
| 527 520 | 
             
                            primary_timediff = replication_get_time_diff(con)
         |