{ "info": { "author": "Andres Riancho", "author_email": "andres.riancho@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Natural Language :: English", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: System :: Monitoring" ], "description": "Sentinela\n=========\n\n.. image:: https://travis-ci.org/andresriancho/sentinela.png?branch=master\n :alt: Build Status\n :align: right\n :target: https://travis-ci.org/andresriancho/sentinela\n\nSentinela is a highly configurable operating system watchdog which can\ntake actions based on pre-configured rules.\n\nThe initial motivation was to create a daemon that would monitor a set\nof log files and if no activity was present shutdown the operating\nsystem. This was extremely useful for making sure my ec2 instances were\nshut down after a specified idle time.\n\nGiven Sentinela's modular nature, you can also extend it to monitor\nnetwork traffic, processes, disk usage, etc. and run any actions such as\nsending an email, send a SNMP alert, etc.\n\nBasic configuration\n===================\n\nSentinela configured using the ``config/sentinela.cfg`` file, which\nallows you to enable rules which are going to be run.\n\nRules are defined in python code and are found in the ``rules/``\ndirectory. In most cases rules use two different types of modules: \\*\n``modules/monitors/``: Once every minute read from a resource and store\nit's status. When required return ``True`` to trigger an action. \\*\n``modules/actions/``: Actions will run a command, send an email or any\nother python defined code you can imagine.\n\nRunning Sentinela\n=================\n\nTo start sentinela you need to run: ``text sudo python sentinela.py``\n\nYou can monitor all sentinela actions by reading the\n``/var/log/sentinela.log`` file. A regular sentinela log file looks like\nthis:\n\n::\n\n [2013-03-29 11:41:20,440][INFO] Successfully started\n [2013-03-29 11:41:20,441][DEBUG] Imported rules.apache_shutdown\n [2013-03-29 12:51:50,480][DEBUG] Sentinela is alive\n ...\n [2013-03-29 12:58:34,009][DEBUG] Going to execute command \"shutdown now -h\".\n\nCreating your own rules\n=======================\n\nIntroduction\n------------\n\nCreating your own rules is easy, lets say we want to create a rule that\nprints the name of the monitor to sentinela's log file when the\n``/var/log/apache2/access.log`` logfile is inactive during 10 minutes'.\nThe code will look like this:\n\n::\n\n 1: from modules.monitors.new_log_entries import NewLogEntries\n 2: from modules.actions.debug_print import DebugPrint\n 3: \n 4: apache_log = NewLogEntries('/var/log/apache2/access.log', 10)\n 5: debug_print = DebugPrint()\n 6:\n 7:\n 8: def call_every_minute():\n 9: if apache_log.call_every_minute():\n 10: debug_print.do(apache_log)\n\nSource Code Analysis\n--------------------\n\nCommon rules will have a monitor and an action, in this case they\n``NewLogEntries`` and ``DebugPrint`` (lines 1 and 2).\n\nBoth of them need to be instanciated at the module level (lines 4 and 5)\nin order to be able to keep state. If you create your monitor or action\ninstances inside the ``call_every_minute`` a new instance is going to be\ncreated each time and no state will be kept.\n\nMonitors and actions can have parameters, in this line 4 we see how the\n``NewLogEntries`` monitor takes two parameters:\n\n* The log file to monitor for changes \n* How many minutes of inactivity it will wait until returning ``True``\n\nThe ``call_every_minute`` function (line 8) needs to be defined for a\nrule to be valid. This function, as the name indicates, will be called\nevery minute by sentinela. You could define any actions to be run in\nthis context, but we decide to call the monitor's ``call_every_minute``\nmethod and based on it's return value call the action with the\n``apache_log`` instance as parameter.\n\n``apache_log.call_every_minute()`` will return ``True`` only if the file\npassed as parameter doesn't have any new entries in 10 minutes.\n\n``debug_print.do`` will print the name of the monitor passed as\nparameter.\n\nEnabling new rules\n------------------\n\nOnce you've created your own rule, you'll have to follow these steps to\nrun them:\n\n* Copy your ``.py`` file to the ``rules/`` directory in the sentinela installation\n* Update the ``config/sentinela.cfg`` to include your rule name (without the extension)\n* Restart the sentinela daemon\n\nExample rules\n-------------\n\nExample rules can be found in the\n`sentinela/rules `_\ndirectory in this repository.\n\nTesting new rules\n-----------------\n\nIn order to test your new rules before deploying them you can follow\n`these\nsteps `_.\n\nReporting bugs\n==============\n\nReport your issues and feature requests in `Sentinela's issue\ntracker `_ and I'll\nbe more than glad to fix them.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/andresriancho/sentinela/", "keywords": null, "license": "GNU General Public License v2 (GPLv2)", "maintainer": null, "maintainer_email": null, "name": "sentinela", "package_url": "https://pypi.org/project/sentinela/", "platform": "Linux", "project_url": "https://pypi.org/project/sentinela/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/andresriancho/sentinela/" }, "release_url": "https://pypi.org/project/sentinela/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "Sentinela is a highly configurable operating system watchdog which can take actions based on pre-configured rules.", "version": "0.2.2" }, "last_serial": 799413, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "0f4f8a4fc5dad4e2a4ff6d03a35d3584", "sha256": "9b2198f22e989b06813b73e216b03cb4cbfa3c0f2726c0edfa88dbfd5fc21fa4" }, "downloads": -1, "filename": "sentinela-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0f4f8a4fc5dad4e2a4ff6d03a35d3584", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8592, "upload_time": "2013-04-07T15:39:42", "url": "https://files.pythonhosted.org/packages/64/78/ea586766ad20bdc6018f218b51ff223886deba61ee7cf9164f6e8d949ddf/sentinela-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "6049acc322d26d68e326b8623213d672", "sha256": "d588d485f7e06ed0173193965473f8650948ec95b12563a26f3f7e804a0c4596" }, "downloads": -1, "filename": "sentinela-0.2.2.tar.gz", "has_sig": false, "md5_digest": "6049acc322d26d68e326b8623213d672", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9121, "upload_time": "2013-04-07T16:00:15", "url": "https://files.pythonhosted.org/packages/29/f6/9113301db69606de68680dbf97bd200eec319cd95df885c2556aeff5a1f6/sentinela-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6049acc322d26d68e326b8623213d672", "sha256": "d588d485f7e06ed0173193965473f8650948ec95b12563a26f3f7e804a0c4596" }, "downloads": -1, "filename": "sentinela-0.2.2.tar.gz", "has_sig": false, "md5_digest": "6049acc322d26d68e326b8623213d672", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9121, "upload_time": "2013-04-07T16:00:15", "url": "https://files.pythonhosted.org/packages/29/f6/9113301db69606de68680dbf97bd200eec319cd95df885c2556aeff5a1f6/sentinela-0.2.2.tar.gz" } ] }