Skip to content

Commit 858f7ca

Browse files
committed
Merge branch 'dev'
2 parents 8a0ed14 + 6938d17 commit 858f7ca

File tree

10 files changed

+416
-51
lines changed

10 files changed

+416
-51
lines changed

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ NOTE: only mamonsu 2.3.4 builds for Windows.
103103
$ c:\mamonsu\service_win32.exe -install
104104
$ net start mamonsu
105105
106+
or
107+
$ pyinstaller --onefile mamonsu_win32.spec
108+
$ pyinstaller --onefile service_win32.spec
109+
106110
Build nsis installer:
107111

108112
.. code-block:: bash

mamonsu/lib/default_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class DefaultConfig(PgsqlConfig):
5050
def default_config_path():
5151
if platform.LINUX:
5252
return '/etc/mamonsu/agent.conf'
53+
elif platform.WINDOWS:
54+
return 'agent.conf'
5355

5456
@staticmethod
5557
def get_logger_level(level):
@@ -64,6 +66,6 @@ def get_logger_level(level):
6466
@staticmethod
6567
def default_report_path():
6668
if platform.WINDOWS:
67-
return 'c:\\report.txt'
69+
return 'report.txt'
6870
if platform.LINUX:
6971
return '/tmp/report.txt'

mamonsu/lib/parser.py

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
from mamonsu import __version__
44
from optparse import OptionParser, BadOptionError
55
import mamonsu.lib.platform as platform
6+
from mamonsu.lib.default_config import DefaultConfig
67

78
usage_msg = """
89
Options:
910
-a, --add-plugins <directory>
1011
-c, --config <file>
1112
-p, --pid <pid-file>
12-
-d daemonize
13-
--version output version information, then exit
13+
"""
14+
if platform.LINUX:
15+
usage_msg += """ -d daemonize
16+
"""
17+
18+
usage_msg += """ --version output version information, then exit
1419
--help show this help, then exit
1520
1621
Export example config with default variables:
@@ -19,34 +24,7 @@
1924
{prog} export config <file>
2025
Options:
2126
--add-plugins <directory>
22-
23-
Export zabbix keys for native zabbix-agent:
24-
Command: export zabbix-parameters
25-
Examples:
26-
{prog} export zabbix-parameters <file>
27-
Options:
28-
--plugin-type <plugin_type> (pg|sys|all) by default all
29-
--pg-version <pg_version> by default 10
30-
--add-plugins <directory>
31-
--config <file>
32-
HINT: Supported version numbers are 12, 10, 11, 9.6, 9.5
33-
3427
35-
Export template for native zabbix agent:
36-
Command: export zabbix-template
37-
Examples:
38-
{prog} export zabbix-template [options] <file>
39-
Options:
40-
--template-name <template name> by default PostgresPro-<platform name>
41-
--plugin-type <plugin_type> (pg|sys|all) by default all
42-
--application <application name in template> by default App-PostgresPro-<platform name>
43-
--add-plugins <directory>
44-
--config <file>
45-
--old-zabbix
46-
By default, mamonsu exports the template for Zabbix 4.4 or higher.
47-
To export a template for older Zabbix versions, use the --old-zabbix option.
48-
49-
5028
Export zabbix template with additional plugins included in config file:
5129
Command: export template
5230
Examples:
@@ -60,7 +38,6 @@
6038
HINT: By default, mamonsu exports the template for Zabbix 4.4 or higher.
6139
To export a template for older Zabbix versions, use the --old-zabbix option.
6240
63-
6441
Bootstrap DDL for monitoring:
6542
Command: bootstrap
6643
Examples:
@@ -73,7 +50,6 @@
7350
-U, --username <USERNAME>
7451
--host <PGHOST>
7552
76-
7753
Information about working mamonsu:
7854
Command: agent
7955
Examples:
@@ -83,8 +59,6 @@
8359
Options:
8460
-c, --config <file>
8561
86-
87-
8862
Zabbix API toolbox:
8963
Command: zabbix
9064
Usage:
@@ -114,7 +88,7 @@
11488
--url=http://zabbix/web/face
11589
--user=WebUser
11690
--password=WebPassword
117-
91+
11892
Export metrics to zabbix server
11993
Command: upload
12094
Example:
@@ -129,6 +103,30 @@
129103

130104
if platform.LINUX:
131105
usage_msg += """
106+
Export zabbix keys for native zabbix-agent:
107+
Command: export zabbix-parameters
108+
Examples:
109+
{prog} export zabbix-parameters <file>
110+
Options:
111+
--plugin-type <plugin_type> (pg|sys|all) by default all
112+
--pg-version <pg_version> by default 10
113+
--add-plugins <directory>
114+
--config <file>
115+
HINT: Supported version numbers are 12, 10, 11, 9.6, 9.5
116+
117+
Export template for native zabbix agent:
118+
Command: export zabbix-template
119+
Examples:
120+
{prog} export zabbix-template [options] <file>
121+
Options:
122+
--template-name <template name> by default PostgresPro-<platform name>
123+
--plugin-type <plugin_type> (pg|sys|all) by default all
124+
--application <application name in template> by default App-PostgresPro-<platform name>
125+
--add-plugins <directory>
126+
--config <file>
127+
--old-zabbix
128+
By default, mamonsu exports the template for Zabbix 4.4 or higher.
129+
To export a template for older Zabbix versions, use the --old-zabbix option.
132130
133131
Report about hardware and software:
134132
Command: report
@@ -144,8 +142,6 @@
144142
-r, --print-report
145143
-w, --report-path <path to file>
146144
147-
148-
149145
AutoTune config and system:
150146
Command: tune
151147
Options:
@@ -158,7 +154,6 @@
158154

159155
if platform.WINDOWS:
160156
usage_msg += """
161-
162157
AutoTune config and system:
163158
Command: tune
164159
Options:
@@ -179,7 +174,6 @@ class MissOptsParser(OptionParser):
179174
def print_help(self, **kwargs):
180175
print("""
181176
182-
183177
Export example config with default variables:
184178
Command: export
185179
Examples:
@@ -248,7 +242,7 @@ def parse_args():
248242
usage=usage_msg,
249243
version='%prog {0}'.format(__version__))
250244
parser.add_option(
251-
'-c', '--config', dest='config_file', default='/etc/mamonsu/agent.conf')
245+
'-c', '--config', dest='config_file', default=DefaultConfig.default_config_path())
252246
# pid
253247
parser.add_option(
254248
'-p', '--pid', dest='pid', default=None)

mamonsu/lib/runner.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from mamonsu.lib.plugin import Plugin
1414
from mamonsu.lib.zbx_template import ZbxTemplate
1515
from mamonsu.lib.get_keys import GetKeys
16-
from mamonsu.plugins.system.linux.scripts import Scripts
16+
17+
if platform.LINUX:
18+
from mamonsu.plugins.system.linux.scripts import Scripts
1719

1820

1921
def start():
@@ -79,6 +81,9 @@ def quit_handler(_signo=None, _stack_frame=None):
7981
if not len(commands) == 2 and not len(commands) == 3:
8082
print_total_help()
8183
if commands[1] == 'zabbix-parameters':
84+
if platform.WINDOWS:
85+
print("Export of zabbix keys for native zabbix-agent is not supported on Windows systems")
86+
sys.exit(10)
8287
# zabbix agent keys generation
8388
Plugin.Type = 'agent' # change plugin type for template generator
8489
plugins = []
@@ -149,6 +154,9 @@ def quit_handler(_signo=None, _stack_frame=None):
149154
print(" {0} ".format(e))
150155
sys.exit(2)
151156
elif commands[1] == 'zabbix-template':
157+
if platform.WINDOWS:
158+
print("Export of template for native zabbix agent is not supported on Windows systems")
159+
sys.exit(10)
152160
Plugin.Type = 'agent' # change plugin type for template generator
153161
if len(commands) == 2:
154162
commands.append('postgrespro_agent.xml')

mamonsu/tools/agent/start.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import urllib.request as urllib
1111
from urllib.error import URLError, HTTPError
12+
from mamonsu.lib.default_config import DefaultConfig
1213

1314

1415
def run_agent():
@@ -32,7 +33,7 @@ def print_help():
3233
usage=usage_msg,
3334
version='%prog agent {0}'.format(__version__))
3435
parser.add_option(
35-
'-c', '--config', dest='config', default='/etc/mamonsu/agent.conf',
36+
'-c', '--config', dest='config', default=DefaultConfig.default_config_path(),
3637
help=optparse.SUPPRESS_HELP)
3738
args, commands = parser.parse_args()
3839

mamonsu_win32.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python
2+
3+
from mamonsu.lib.runner import start
4+
5+
if __name__ == '__main__':
6+
start()

mamonsu_win32.spec

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
block_cipher = None
4+
5+
6+
a = Analysis(['mamonsu_win32.py'],
7+
pathex=['C:\\Projects\\Extensions\\mamonsu'],
8+
binaries=[],
9+
datas=[],
10+
hiddenimports=[
11+
'mamonsu.plugins.pgsql.archive_command',
12+
'mamonsu.plugins.pgsql.bgwriter',
13+
'mamonsu.plugins.pgsql.cfs',
14+
'mamonsu.plugins.pgsql.checkpoint',
15+
'mamonsu.plugins.pgsql.connections',
16+
'mamonsu.plugins.pgsql.databases',
17+
'mamonsu.plugins.pgsql.health',
18+
'mamonsu.plugins.pgsql.instance',
19+
'mamonsu.plugins.pgsql.oldest',
20+
'mamonsu.plugins.pgsql.pg_buffercache',
21+
'mamonsu.plugins.pgsql.pg_locks',
22+
'mamonsu.plugins.pgsql.pg_stat_statement',
23+
'mamonsu.plugins.pgsql.pg_wait_sampling',
24+
'mamonsu.plugins.pgsql.plugin',
25+
'mamonsu.plugins.pgsql.pool',
26+
'mamonsu.plugins.pgsql.prepared_transaction',
27+
'mamonsu.plugins.pgsql.relations_size',
28+
'mamonsu.plugins.pgsql.xlog',
29+
'mamonsu.plugins.system.windows.cpu',
30+
'mamonsu.plugins.system.windows.disk_stats',
31+
'mamonsu.plugins.system.windows.helpers',
32+
'mamonsu.plugins.system.windows.memory',
33+
'mamonsu.plugins.system.windows.network',
34+
'mamonsu.lib.senders.log',
35+
'mamonsu.lib.senders.zbx',
36+
'mamonsu.tools.agent.agent',
37+
'mamonsu.tools.agent.start',
38+
'mamonsu',
39+
'mamonsu.plugins',
40+
'mamonsu.plugins.pgsql',
41+
'mamonsu.plugins.system.windows',
42+
'mamonsu.tools.agent',
43+
'mamonsu.tools.bootstrap',
44+
'mamonsu.tools.report',
45+
'mamonsu.tools.sysinfo',
46+
'mamonsu.tools.tune',
47+
'mamonsu.tools.zabbix_cli',
48+
'mamonsu.plugins.common.health',
49+
'mamonsu.plugins.common',
50+
'win32timezone'
51+
],
52+
hookspath=[],
53+
runtime_hooks=[],
54+
excludes=[],
55+
win_no_prefer_redirects=False,
56+
win_private_assemblies=False,
57+
cipher=block_cipher,
58+
noarchive=False)
59+
pyz = PYZ(a.pure, a.zipped_data,
60+
cipher=block_cipher)
61+
exe = EXE(pyz,
62+
a.scripts,
63+
a.binaries,
64+
a.zipfiles,
65+
a.datas,
66+
[],
67+
name='mamonsu',
68+
debug=False,
69+
bootloader_ignore_signals=False,
70+
strip=False,
71+
upx=True,
72+
upx_exclude=[],
73+
runtime_tmpdir=None,
74+
console=True )

0 commit comments

Comments
 (0)