Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Fix README.md #2

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6e01130
Fix README.md
Mar 10, 2014
d3fbf69
Rename certcheck to check_cert
May 16, 2014
3b31282
Remove code that is already in pymisc
May 16, 2014
dc215f6
Refactor get_cert_expiration error handling
May 16, 2014
34a1291
Broken cert should be different thant ignored one
May 16, 2014
ae0c108
Fix sample configuration
May 16, 2014
e3d7e97
[doc] Fix dependencies and config info
May 16, 2014
bfcd34a
Fix tests, add more tests
May 16, 2014
dc09cc6
[test] Add exception handling testing
May 16, 2014
ddfc047
Remove unecessary imports, fix formating
May 16, 2014
ec827ee
[doc] Moar! doc.
May 17, 2014
d28365e
Move ignored/unsupported cert support out of get_cert_expiration()
May 17, 2014
eed0ca6
Add license preamble to run_tests.py
May 19, 2014
49a2e1e
Fix hasbangs to be compatible with virtualenvs
May 19, 2014
fe59f69
[doc] NRPE is not supported
May 19, 2014
bffbbc5
[doc] Fix python dependencies
May 19, 2014
427f299
Fix licensing info
May 20, 2014
d47cf80
Add *.swp and pybuild related stuff to gitignore
Sep 24, 2014
5d33ed3
Switch to pybuild debian packaging
Sep 24, 2014
8d2fc55
Make PubkeySSHGitClient._connect check if pubkey exists
Oct 6, 2014
72c841b
Logging fixes
Oct 6, 2014
6fc77dd
Provide some sane defaults for some config params
Oct 6, 2014
d3696f9
Formatting fixes
Oct 6, 2014
eca7708
Depend on pymisc >= 1.2.0
Oct 6, 2014
36ab802
Depend on python-dulwich >=0.9.7
Oct 6, 2014
0ce5fc7
Version bump
Oct 6, 2014
9ac89c8
Fix dulwich dependencies
Oct 6, 2014
8ecfa7a
Provide some info about problems with Dulwich lib
Oct 6, 2014
f21fdbb
Refactor configuration checking
Oct 6, 2014
44061de
Make script a bit more user-friendly
Oct 6, 2014
0f26d92
Changelog bump
Oct 6, 2014
f0a7290
Bump dependencies on pymisc
Oct 6, 2014
91a554f
Unittests refactoring
Jan 1, 2015
a4c0e7d
Travis-CI integration
Jan 1, 2015
9d90436
Make coverage measurements optional
Jan 1, 2015
68d2121
Drop 2.6 from travis
Jan 1, 2015
28b7bb9
Fix Travis badge
Jan 1, 2015
d442b6f
Include pymisc dependencies
Jan 1, 2015
0677356
Fix exit status of the test run script
Jan 1, 2015
ea0f210
Add icingaexchange.yml file
Jan 4, 2015
3e86382
Small fixes related to documenting/icingaexchange
Jan 4, 2015
823b0cf
Add submodule support
Jan 19, 2015
1875db1
Print stacktrace in case of problems
Jan 19, 2015
678a0da
Version bump to 0.3.3
Jan 19, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exclude_lines =
if 0:
if __name__ == .__main__.:
source =
./certcheck/
./check_cert/


[html]
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.pyc
/.coverage
/build*
certcheck.egg-info/*
check_cert.egg-info/*
debian/files
*.swp
debian/check-cert*
.pybuild/
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: python
python:
- "2.7"
install: "pip install -r requirements.txt --use-mirrors"
script: "./run_tests.py"
before_script:
- wget https://github.com/vespian/pymisc/archive/1.2.0.tar.gz -O /tmp/pymisc-1.2.0.tar.gz
- tar -xvf /tmp/pymisc-1.2.0.tar.gz -C /tmp/
- cd /tmp/pymisc-1.2.0/
- pip install -r ./requirements.txt --use-mirrors
- ./setup.py install
- cd $TRAVIS_BUILD_DIR
107 changes: 63 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# _Certchecker_
# _check_cert_

_Certchecker is a certificate expiration check capable of scanning GIT repos
and sending data on expiring/expired certificates back to the monitoring system
(currently only Riemann)._
[![Build
Status](https://travis-ci.org/vespian/check-cert.svg?branch=master)](https://travis-ci.org/vespian/check-cert)

_check_cert is a certificate expiration check capable of scanning GIT repos
and sending data on expiring/expired certificates back to the monitoring system._

## Project Setup

In order to run certchecker you need to following dependencies installed:
- Bernhard - Riemann client library (https://github.com/banjiewen/bernhard)
- Google's protobuf library
- yaml bindings for python (http://pyyaml.org/)
- Dulwich - python implementation of GIT (https://www.samba.org/~jelmer/dulwich/docs/)
- ssh command in your PATH
- argparse library
In order to run check_cert you need to have following dependencies installed:
* Dulwich - python implementation of GIT (https://www.samba.org/~jelmer/dulwich/docs/)
* *ssh* command in your PATH
* argparse library
* pyOpenSSL (https://launchpad.net/pyopenssl/)
* pymisc (https://github.com/vespian/pymisc)
* python 2.6 or 2.7
* dulwich library

You can also use debian packaging rules from debian/ directory to build a deb
package.

Unfortunatelly, dulwich library is broken on wheezy:

https://bugs.launchpad.net/dulwich/+bug/1326213

so the script depends on the newest version (0.9.7) even though 0.8.5 is
sufficient when it comes to functionality.

## Usage

### Configuration
Expand All @@ -25,7 +35,7 @@ Actions taken by the script are determined by its command line and the
configuration file. The command line has a build-in help system:

```
usage: certcheck [-h] [--version] -c CONFIG_FILE [-v] [-s] [-d]
usage: check_cert [-h] [--version] -c CONFIG_FILE [-v] [-s] [-d]

Simple certificate expiration check

Expand All @@ -45,9 +55,12 @@ The configuration file is a plain YAML document. It's syntax is as follows:

```
---
lockfile: /tmp/certcheck.lock
warn_treshold: 30
critical_treshold: 15
#Global
lockfile: /tmp/check_cert.lock

#Riemann related:
riemann_enabled: False
riemann_ttl: 60
riemann_hosts:
static:
- 192.168.122.16:5555:udp
Expand All @@ -57,19 +70,28 @@ riemann_hosts:
- _riemann._udp
riemann_tags:
- production
- class::certcheck
repo_host: git.example.net
- class::check_cert

#Nagios related:
nrpe_enabled: True

#Repository related:
repo_host: git.example.com
repo_port: 22
repo_url: /example-repo
repo_url: /sample-repo
repo_masterbranch: refs/heads/production
repo_localdir: /tmp/certcheck-temprepo
repo_user: certcheck
repo_pubkey: ./certcheck_id_rsa
# format - dict, hash as a key, and value as a comment
# sha1sum ./certificate_to_be_ignored
repo_localdir: /tmp/check_cert-temprepo
repo_user: check_cert
repo_pubkey: /home/vespian/work/tmp_tickets/cert_check/check_cert_id_rsa

#Check related:
warn_treshold: 30
critical_treshold: 15
# sha1sum ./certificate_to_be_ignored
# format - dict, hash as a key, and value as a comment
ignored_certs:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: "some VPN key"
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: "some unused certificate"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: "cert a"
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: "cert b"
```

### Operation
Expand All @@ -84,9 +106,9 @@ The connection is established using the $repo_pubkey pubkey, and the $repo_user
itself should have very limited privileges.

Next, the repository is scanned in search of files ending with one of the
certcheck:CERTIFICATE_EXTENSIONS extensions. Currently all possible
check_cert:CERTIFICATE_EXTENSIONS extensions. Currently all possible
certificate extensions are listed but only ['pem', 'crt', 'cer'] are currently
supported (see certcheck:get_cert_expiration method). For the remaing ones
supported (see check_cert:get_cert_expiration method). For the remaing ones
only a warning is issued.

For each certificate found a sha1sum is computed, and if the result is found in
Expand All @@ -99,33 +121,30 @@ $warn_tresh but more than $critical_tresh - a "warning" partial status is gene-
rated. Unsuported certificate yields an 'unknown' state and expired ones of
course the 'critical'.

All the 'partial status' updates are agregated and each message can only ele-
vate up the final status of the metric send to Riemann. Currently, the hierar-
chy is as follows:
All the 'partial status' updates are agregated by the 'pymisc' library and
each message can only elevate up the final status of the metric send to
monitoring system. Currently, the hierarchy is as follows:

(lowest)ok->warn->critical->unknown(highest)

script errors, exceptions and unexcpected conditions result in imidiate elevation
to 'unknown' status and sending the metric to monitoring system ASAP if only
possible.

IP addresses/ports of the Riemann instances can be defined in two ways:
* statically, by providing a list of riemann instances in $riemann_servers
var. The format of the list entry is hostname:port:proto. 'proto' can be one
of 'udp' or 'tcp'.
* by providing a SRV record, i.e. '_riemann._udp'. All the values
(host, port) will be resolved automatically. Protocol is chosen basing on
the SRV entry itself.

The final metric is send to *all* Riemann instances with TTL equal to
certcheck:DATA_TTL == 25 hours.
Interfacing with monitoring system is done by pymisc. Following options are
passed directly to the library. Please see pymisc's documentation for
information on their meaning:
* $riemann_enabled
* $riemann_ttl
* $riemann_hosts
* $riemann_tags
* $nrpe_enabled

### Maintenance

In order to not to let the "$repo_tmpdir/repository" repository grow endlessly
a 'git gc' command should be executed once a day by i.e. a cronjob. It should
a 'git gc' command should be executed once a day by i.e. a cronjob. It will
repack all the packs and remove dangling objects.
Please see the doc/USAGE.md file for details.

## Contributing

Expand All @@ -144,7 +163,7 @@ test/ directory you can find:
Unittests can be started either by using *nosetest* command:

```
certcheck/ (master✗) # nosetests
check_cert/ (master✗) # nosetests
[20:33:02]
......
----------------------------------------------------------------------
Expand All @@ -156,7 +175,7 @@ OK
or by issuing the *run_tests.py* command:

```
certcheck/ (master✗) # run_tests.py
check_cert/ (master✗) # run_tests.py
[20:33:04]
Created test certificate expired_3_days.pem
Created test certificate expire_6_days.pem
Expand Down
6 changes: 3 additions & 3 deletions bin/certcheck → bin/check_cert
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations under
# the License.

import certcheck
import check_cert


if __name__ == '__main__':
args_dict = certcheck.parse_command_line()
args_dict = check_cert.parse_command_line()

certcheck.main(**args_dict)
check_cert.main(**args_dict)
Loading