Skip to content

Commit 7130bcd

Browse files
author
Martin Rusev
committed
Installation fixes
1 parent dda9345 commit 7130bcd

File tree

8 files changed

+29
-21
lines changed

8 files changed

+29
-21
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
1.2
2+
==============
3+
4+
* Fix installation - install both setuptools and pip
5+
* Don't break the agent if the plugin directories doesn't exist (/etc/amoagent/plugins)
6+
17
1.1
28
==============
39

amon-agent

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ class AmonAgentDaemon(Daemon):
4747
while True:
4848
stats = {
4949
'system': runner.system(),
50-
'processes': runner.processes(),
50+
'processes': runner.processes(),
5151
'plugins': runner.plugins()
5252
}
5353
remote = Remote()
5454
remote.save_system_stats(stats)
5555

56-
# Checks the system every 60 seconds
5756
time.sleep(settings.SYSTEM_CHECK_PERIOD)
5857

5958
if __name__ == "__main__":

amonagent/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.1'
1+
__version__ = '1.2'

amonagent/plugin.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,21 @@ def discover_plugins(plugin_paths=[]):
123123
future extension which will permit searching for plugins in
124124
user defined directories
125125
"""
126-
127-
# Find all enabled plugins
128-
for filename in os.listdir(ENABLED_PLUGINS_PATH):
129-
plugin_name, ext = os.path.splitext(filename)
130-
if ext == ".conf":
131-
# Configuration file OK, load the plugin
132-
full_plugin_path = "{0}/{1}".format(AVAILABLE_PLUGINS_PATH, plugin_name)
133-
134-
for filename in os.listdir(full_plugin_path):
135-
modname, extension = os.path.splitext(filename)
136-
if extension == '.py':
137-
_file, path, descr = imp.find_module(modname, [full_plugin_path])
138-
if _file:
139-
# Loading the module registers the plugin in
140-
if modname not in ['base', '__init__']:
141-
mod = imp.load_module(modname, _file, path, descr)
126+
if os.path.exists(ENABLED_PLUGINS_PATH):
127+
# Find all enabled plugins
128+
for filename in os.listdir(ENABLED_PLUGINS_PATH):
129+
plugin_name, ext = os.path.splitext(filename)
130+
if ext == ".conf":
131+
# Configuration file OK, load the plugin
132+
full_plugin_path = "{0}/{1}".format(AVAILABLE_PLUGINS_PATH, plugin_name)
133+
134+
for filename in os.listdir(full_plugin_path):
135+
modname, extension = os.path.splitext(filename)
136+
if extension == '.py':
137+
_file, path, descr = imp.find_module(modname, [full_plugin_path])
138+
if _file:
139+
# Loading the module registers the plugin in
140+
if modname not in ['base', '__init__']:
141+
mod = imp.load_module(modname, _file, path, descr)
142142

143143
return AmonPlugin.plugins

amonagent/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _post(self, url, data, headers=None):
3232
headers = headers if headers else self.headers
3333

3434
try:
35-
r = requests.post(url, data, headers=headers, timeout=5, stream=False)
35+
r = requests.post(url, data, headers=headers, timeout=10, stream=False)
3636
except Exception:
3737
log.error("Can't connect to the Amon API")
3838

amonagent/runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ def system(self):
3131
'cpu': get_cpu_utilization(),
3232
'disk': get_disk_usage(),
3333
'network': get_network_traffic(),
34-
'loadavg': get_load_average()
34+
'loadavg': get_load_average(),
3535
}
3636

3737

3838
return system_data_dict
3939

40+
4041
def processes(self):
4142
return processes_data_collector.collect()
4243

packaging/debian/postinst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44

55
case "$1" in
66
configure)
7+
curl --silent --show-error --retry 5 -L https://bootstrap.pypa.io/ez_setup.py -o - | python
78
curl --silent --show-error --retry 5 -L https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python
89
pip install --upgrade 'amonagent>=1.0'
910
update-rc.d amon-agent defaults

packaging/rpm/postinst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# start
2+
curl --silent --show-error --retry 5 -L https://bootstrap.pypa.io/ez_setup.py -o - | python
23
curl --silent --show-error --retry 5 -L https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python
34
pip install --upgrade 'amonagent>=1.0'
45
sh -c "echo '{\"server_key\": \"test\"}' > /etc/amon-agent.conf"

0 commit comments

Comments
 (0)