check_systemd 2.0.1__tar.gz → 2.0.2__tar.gz

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.
@@ -0,0 +1,2 @@
1
+ include LICENSE
2
+ prune test
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: check_systemd
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: A simple nagios plugin that detects failed systemd units.
5
5
  Home-page: https://github.com/Josef-Friedrich/check_systemd
6
- Author: Andrea Briganti
7
- Author-email: kbytesys@gmail.com
6
+ Author: Josef Friedrich
7
+ Author-email: josef@friedrich.rocks
8
8
  License: GNU LGPL v2
9
- Description: [![Build Status](https://travis-ci.org/Josef-Friedrich/check_systemd.svg?branch=master)](https://travis-ci.org/Josef-Friedrich/check_systemd)
9
+ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https://pypi.python.org/pypi/check_systemd)
10
+ [![Build Status](https://travis-ci.org/Josef-Friedrich/check_systemd.svg?branch=master)](https://travis-ci.org/Josef-Friedrich/check_systemd)
10
11
 
11
12
  # check_systemd
12
13
 
@@ -1,3 +1,4 @@
1
+ [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https://pypi.python.org/pypi/check_systemd)
1
2
  [![Build Status](https://travis-ci.org/Josef-Friedrich/check_systemd.svg?branch=master)](https://travis-ci.org/Josef-Friedrich/check_systemd)
2
3
 
3
4
  # check_systemd
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: check-systemd
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: A simple nagios plugin that detects failed systemd units.
5
5
  Home-page: https://github.com/Josef-Friedrich/check_systemd
6
- Author: Andrea Briganti
7
- Author-email: kbytesys@gmail.com
6
+ Author: Josef Friedrich
7
+ Author-email: josef@friedrich.rocks
8
8
  License: GNU LGPL v2
9
- Description: [![Build Status](https://travis-ci.org/Josef-Friedrich/check_systemd.svg?branch=master)](https://travis-ci.org/Josef-Friedrich/check_systemd)
9
+ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https://pypi.python.org/pypi/check_systemd)
10
+ [![Build Status](https://travis-ci.org/Josef-Friedrich/check_systemd.svg?branch=master)](https://travis-ci.org/Josef-Friedrich/check_systemd)
10
11
 
11
12
  # check_systemd
12
13
 
@@ -8,6 +8,4 @@ check_systemd.egg-info/PKG-INFO
8
8
  check_systemd.egg-info/SOURCES.txt
9
9
  check_systemd.egg-info/dependency_links.txt
10
10
  check_systemd.egg-info/requires.txt
11
- check_systemd.egg-info/top_level.txt
12
- test/test_mock.py
13
- test/test_subprocess.py
11
+ check_systemd.egg-info/top_level.txt
@@ -11,7 +11,7 @@ import argparse
11
11
 
12
12
  import nagiosplugin
13
13
 
14
- __version__ = '2.0.1'
14
+ __version__ = '2.0.2'
15
15
 
16
16
 
17
17
  class SystemdStatus(nagiosplugin.Resource):
@@ -4,8 +4,9 @@ from setuptools import setup, find_packages
4
4
 
5
5
  HERE = os.path.abspath(os.path.dirname(__file__))
6
6
 
7
+
7
8
  def read(*parts):
8
- with open(os.path.join(HERE, *parts), 'r') as fp:
9
+ with open(os.path.join(HERE, *parts), 'r', encoding='utf-8') as fp:
9
10
  return fp.read()
10
11
 
11
12
 
@@ -21,6 +22,7 @@ def find_version(*file_paths):
21
22
 
22
23
  raise RuntimeError("Unable to find version string.")
23
24
 
25
+
24
26
  setup(
25
27
  name='check_systemd',
26
28
  packages=find_packages(),
@@ -32,8 +34,8 @@ setup(
32
34
  description='A simple nagios plugin that detects failed systemd units.',
33
35
  long_description=read('README.md'),
34
36
  long_description_content_type='text/markdown',
35
- author='Andrea Briganti',
36
- author_email='kbytesys@gmail.com',
37
+ author='Josef Friedrich',
38
+ author_email='josef@friedrich.rocks',
37
39
  url='https://github.com/Josef-Friedrich/check_systemd',
38
40
  keywords=['nagios', 'systemd'],
39
41
  license='GNU LGPL v2',
@@ -41,7 +43,8 @@ setup(
41
43
  'Development Status :: 5 - Production/Stable',
42
44
  'Environment :: Plugins',
43
45
  'Intended Audience :: System Administrators',
44
- 'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)',
46
+ 'License :: OSI Approved :: GNU Lesser General Public License v2 '
47
+ '(LGPLv2)',
45
48
  'Programming Language :: Python',
46
49
  'Programming Language :: Python :: 2',
47
50
  'Programming Language :: Python :: 3',
@@ -49,5 +52,3 @@ setup(
49
52
  'Topic :: System :: Networking :: Monitoring'
50
53
  ],
51
54
  )
52
-
53
-
@@ -1 +0,0 @@
1
- include LICENSE
@@ -1,25 +0,0 @@
1
- import unittest
2
- from unittest import mock
3
- import check_systemd
4
-
5
-
6
- def mock_main(argv=['check_systemd.py'], stdout=None, stderr=None):
7
- with mock.patch('sys.exit') as sys_exit, \
8
- mock.patch('check_systemd.subprocess.Popen') as Popen, \
9
- mock.patch('sys.argv', argv):
10
- process = Popen.return_value
11
- process.communicate.return_value = (stdout, stderr)
12
- check_systemd.main()
13
-
14
- return {'sys_exit': sys_exit}
15
-
16
-
17
- class TestMock(unittest.TestCase):
18
-
19
- def test_ok(self):
20
- result = mock_main()
21
- result['sys_exit'].assert_called_with(0)
22
-
23
-
24
- if __name__ == '__main__':
25
- unittest.main()
@@ -1,142 +0,0 @@
1
- import unittest
2
- import os
3
- import subprocess
4
-
5
-
6
- class AddBin(object):
7
- """
8
- :param string bin_path: Path relative to the test folder.
9
- """
10
-
11
- def __init__(self, bin_path):
12
- self.bin_path = bin_path
13
- self.old_path = os.environ['PATH']
14
-
15
- def __enter__(self):
16
- BIN = os.path.abspath(os.path.join(os.path.dirname(__file__),
17
- self.bin_path))
18
- os.environ['PATH'] = BIN + ':' + os.environ['PATH']
19
-
20
- def __exit__(self, exc_type, exc_value, traceback):
21
- os.environ['PATH'] = self.old_path
22
-
23
-
24
- class TestSubprocess(unittest.TestCase):
25
-
26
- def test_ok(self):
27
- with AddBin('bin/ok'):
28
- process = subprocess.run(
29
- ['./check_systemd.py'],
30
- encoding='utf-8',
31
- stdout=subprocess.PIPE,
32
- )
33
- self.assertEqual(process.returncode, 0)
34
- self.assertEqual(process.stdout, 'SYSTEMD OK - all\n')
35
-
36
- def test_ok_verbose(self):
37
- with AddBin('bin/ok'):
38
- process = subprocess.run(
39
- ['./check_systemd.py', '--verbose'],
40
- encoding='utf-8',
41
- stdout=subprocess.PIPE,
42
- )
43
- self.assertEqual(process.returncode, 0)
44
- self.assertEqual(process.stdout, 'SYSTEMD OK - all\nok: all\n')
45
-
46
- def test_failure(self):
47
- with AddBin('bin/failure'):
48
- process = subprocess.run(
49
- ['./check_systemd.py'],
50
- encoding='utf-8',
51
- stdout=subprocess.PIPE,
52
- )
53
- self.assertEqual(process.returncode, 2)
54
- self.assertEqual(process.stdout,
55
- 'SYSTEMD CRITICAL - test.service: failed\n')
56
-
57
- def test_failure_verbose(self):
58
- with AddBin('bin/failure'):
59
- process = subprocess.run(
60
- ['./check_systemd.py', '-v'],
61
- encoding='utf-8',
62
- stdout=subprocess.PIPE,
63
- )
64
- self.assertEqual(process.returncode, 2)
65
- self.assertEqual(
66
- process.stdout,
67
- 'SYSTEMD CRITICAL - test.service: failed\n'
68
- 'critical: test.service: failed\n'
69
- 'ok: all\n'
70
- )
71
-
72
- def test_failure_multiple(self):
73
- with AddBin('bin/multiple_failure'):
74
- process = subprocess.run(
75
- ['./check_systemd.py'],
76
- encoding='utf-8',
77
- stdout=subprocess.PIPE,
78
- )
79
- self.assertEqual(process.returncode, 2)
80
- self.assertEqual(
81
- process.stdout,
82
- 'SYSTEMD CRITICAL - test1.service: failed, '
83
- 'test2.service: failed\n'
84
- )
85
-
86
- def test_failure_multiple_verbose(self):
87
- with AddBin('bin/multiple_failure'):
88
- process = subprocess.run(
89
- ['./check_systemd.py', '--verbose'],
90
- encoding='utf-8',
91
- stdout=subprocess.PIPE,
92
- )
93
- self.assertEqual(process.returncode, 2)
94
- self.assertEqual(
95
- process.stdout,
96
- 'SYSTEMD CRITICAL - test1.service: failed, '
97
- 'test2.service: failed\n'
98
- 'critical: test1.service: failed\n'
99
- 'critical: test2.service: failed\n'
100
- 'ok: all\n'
101
- )
102
-
103
- def test_exclusive_group(self):
104
- process = subprocess.run(
105
- ['./check_systemd.py', '-s', 'test1.service', '-e',
106
- 'test2.service'],
107
- encoding='utf-8',
108
- stderr=subprocess.PIPE
109
- )
110
- self.assertEqual(process.returncode, 2)
111
- self.assertIn(
112
- 'error: argument -e/--exclude: not allowed with argument '
113
- '-s/--service',
114
- process.stderr,
115
- )
116
-
117
- def test_option_exclude_known_service(self):
118
- with AddBin('bin/failure'):
119
- process = subprocess.run(
120
- ['./check_systemd.py', '-e', 'test.service'],
121
- encoding='utf-8',
122
- stdout=subprocess.PIPE
123
- )
124
- self.assertEqual(process.returncode, 0)
125
- self.assertEqual(process.stdout, 'SYSTEMD OK - all\n')
126
-
127
- def test_option_exclude_unknown_service(self):
128
- with AddBin('bin/failure'):
129
- process = subprocess.run(
130
- ['./check_systemd.py', '-e', 'testX.service'],
131
- encoding='utf-8',
132
- stdout=subprocess.PIPE
133
- )
134
- self.assertEqual(process.returncode, 2)
135
- self.assertEqual(
136
- process.stdout,
137
- 'SYSTEMD CRITICAL - test.service: failed\n'
138
- )
139
-
140
-
141
- if __name__ == '__main__':
142
- unittest.main()
File without changes
File without changes