diff --git a/README.md b/README.md index b776c8f..15e4833 100644 --- a/README.md +++ b/README.md @@ -96,38 +96,4 @@ There other options how I/O where you can define a file log for check errors if All's done!, you can init your service with **nssm start MonitService** and let's go. -# Developing plugins. - -You can add simple python scripts how plugins for add new collections to your data. - -The python scripts need have the next structure: - -```python -def stat(obj_stats): - - obj_stats['test_data']={'pos': 0} - - return obj_stats -``` - -You define a function with name *stat* and arguments *obj_stats* - -*obj_stats* is a python dictionary. You can add new data or manipulate original collected data for your own proposites. The function returns *obj_stats* modified. - -Next, you need modify your configuration with this line: - -``` - -``` - -``` -[DEFAULT] - -url_server=http://url_server_collect_data/ -group=server-group -modules=path.to.script, path.to.script2 -``` - -"path.to.script" is the python script path for import it into pastafaristats. You can use many scripts, but if you need many stats, is recommendable use stats collectors how collectd, netdata, etc. - diff --git a/pastafaristats/send_info_daemon.py b/pastafaristats/send_info_daemon.py index e1dad49..ef2310d 100644 --- a/pastafaristats/send_info_daemon.py +++ b/pastafaristats/send_info_daemon.py @@ -17,7 +17,6 @@ import argparse import datetime import sched, time -from importlib import import_module #url="http://url/to/info" @@ -26,8 +25,6 @@ user_home=str(Path.home()) hostname=getfqdn() -modules_imported={} - def load_config(): yes_config=False @@ -77,21 +74,6 @@ def load_config(): if 'group' in config['DEFAULT']: group=config['DEFAULT']['group'] - - modules={} - - if 'modules' in config['DEFAULT']: - arr_modules=config['DEFAULT']['modules'].split(',') - - #load modules - - for module in arr_modules: - - if not module in modules_imported: - - modules_imported[module]=import_module(module) - - return url, group @@ -121,12 +103,7 @@ def run(url, group=''): mem_info=psutil.virtual_memory() - obj_stats={'net_info': network_info, 'cpu_idle': cpu_idle, 'cpus_idle': cpus_idle, 'cpu_number': cpu_number, 'disks_info': partitions, 'mem_info': mem_info, 'hostname': hostname, 'group': group} - - for module in modules_imported.values(): - obj_stats=module.stat(obj_stats) - - json_info=json.dumps(obj_stats) + json_info=json.dumps({'net_info': network_info, 'cpu_idle': cpu_idle, 'cpus_idle': cpus_idle, 'cpu_number': cpu_number, 'disks_info': partitions, 'mem_info': mem_info, 'hostname': hostname, 'group': group}) data = urllib.parse.urlencode({'data_json': json_info}) @@ -190,8 +167,6 @@ def start(): #Wait seconds to - print('Syncing time collection...') - while True: sleep(2) diff --git a/pastafaristats/utils/__init__.py b/pastafaristats/utils/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pastafaristats/utils/apache.py b/pastafaristats/utils/apache.py deleted file mode 100644 index e82f441..0000000 --- a/pastafaristats/utils/apache.py +++ /dev/null @@ -1,30 +0,0 @@ -import requests - -def stat(obj_stats): - - #new_obj_stats['apache_data']={'status': 1} - - url='http://127.0.0.1/server-status?auto' - - try: - - r=requests.get(url) - - data=r.text.split("\n") - - final_data={v.split(':')[0].strip():v.split(':')[1].strip() for v in data if v.find(':')!=-1} - - final_data['status']=1 - - obj_stats['apache_data']=final_data - - except: - obj_stats['apache_data']['status']=0 - - return obj_stats - -if __name__=='__main__': - - print(stat({})) - - diff --git a/pastafaristats/utils/test.py b/pastafaristats/utils/test.py deleted file mode 100644 index f7bc77e..0000000 --- a/pastafaristats/utils/test.py +++ /dev/null @@ -1,6 +0,0 @@ - -def stat(obj_stats): - - obj_stats['test_data']={'pos': 0} - - return obj_stats diff --git a/setup.py b/setup.py index 28d255e..e8618cf 100644 --- a/setup.py +++ b/setup.py @@ -5,16 +5,20 @@ import os from setuptools import setup, find_packages -if sys.version_info < (3, 6): - raise NotImplementedError("Sorry, you need at least Python 3.6 for use pastafaristats.") +if sys.version_info < (3, 5): + raise NotImplementedError("Sorry, you need at least Python 3.5 for use pastafaristats.") + +#import paramecio +# Pillow should be installed after if you need ImageField +# If you install passlib and bcrypt, the password system will use bcrypt by default, if not, will use native crypt libc setup(name='pastafaristats', - version='1.0.2', + version='1.0.0', description='Simple scripts for send basic data of a server how complement to other stats solutions more complex.', author='Antonio de la Rosa Caballero', author_email='antonio.delarosa@coesinfo.com', url='https://bitbucket.org/paramecio/pastafaristats/', - packages=['pastafaristats', 'pastafaristats.utils'], + packages=['pastafaristats'], include_package_data=True, install_requires=['psutil'], entry_points={'console_scripts': [ @@ -30,7 +34,6 @@ setup(name='pastafaristats', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10' + 'Programming Language :: Python :: 3.9' ], )