003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/salt/returners
usr
/
local
/
lib
/
python3.8
/
site-packages
/
salt
/
returners
/
📁
..
📄
__init__.py
(5.98 KB)
📁
__pycache__
📄
appoptics_return.py
(6.11 KB)
📄
carbon_return.py
(8.24 KB)
📄
cassandra_cql_return.py
(15.17 KB)
📄
cassandra_return.py
(2.07 KB)
📄
couchbase_return.py
(8.91 KB)
📄
couchdb_return.py
(10.35 KB)
📄
django_return.py
(2.27 KB)
📄
elasticsearch_return.py
(12.18 KB)
📄
etcd_return.py
(6.32 KB)
📄
highstate_return.py
(15.59 KB)
📄
influxdb_return.py
(8.03 KB)
📄
kafka_return.py
(2.12 KB)
📄
librato_return.py
(4.29 KB)
📄
local.py
(541 B)
📄
local_cache.py
(17.1 KB)
📄
mattermost_returner.py
(4.08 KB)
📄
memcache_return.py
(5.72 KB)
📄
mongo_future_return.py
(10.08 KB)
📄
mongo_return.py
(6.11 KB)
📄
multi_returner.py
(2.82 KB)
📄
mysql.py
(18.61 KB)
📄
nagios_nrdp_return.py
(4.92 KB)
📄
odbc.py
(7.77 KB)
📄
pgjsonb.py
(17.18 KB)
📄
postgres.py
(10.2 KB)
📄
postgres_local_cache.py
(10.73 KB)
📄
pushover_returner.py
(6.55 KB)
📄
rawfile_json.py
(2.23 KB)
📄
redis_return.py
(8.52 KB)
📄
sentry_return.py
(5.3 KB)
📄
slack_returner.py
(6.02 KB)
📄
slack_webhook_return.py
(11.22 KB)
📄
sms_return.py
(2.64 KB)
📄
smtp_return.py
(8.2 KB)
📄
splunk.py
(6.69 KB)
📄
sqlite3_return.py
(7.73 KB)
📄
syslog_return.py
(5.26 KB)
📄
telegram_return.py
(1.92 KB)
📄
xmpp_return.py
(4.85 KB)
📄
zabbix_return.py
(2.45 KB)
Editing: rawfile_json.py
""" Take data from salt and "return" it into a raw file containing the json, with one line per event. Add the following to the minion or master configuration file. .. code-block:: yaml rawfile_json.filename: <path_to_output_file> Default is ``/var/log/salt/events``. Common use is to log all events on the master. This can generate a lot of noise, so you may wish to configure batch processing and/or configure the :conf_master:`event_return_whitelist` or :conf_master:`event_return_blacklist` to restrict the events that are written. """ import logging import salt.returners import salt.utils.files import salt.utils.json log = logging.getLogger(__name__) # Define the module's virtual name __virtualname__ = "rawfile_json" def __virtual__(): return __virtualname__ def _get_options(ret): """ Returns options used for the rawfile_json returner. """ defaults = {"filename": "/var/log/salt/events"} attrs = {"filename": "filename"} _options = salt.returners.get_returner_options( __virtualname__, ret, attrs, __salt__=__salt__, __opts__=__opts__, defaults=defaults, ) return _options def returner(ret): """ Write the return data to a file on the minion. """ opts = _get_options(ret) try: with salt.utils.files.flopen(opts["filename"], "a") as logfile: salt.utils.json.dump(ret, logfile) logfile.write("\n") except Exception: # pylint: disable=broad-except log.error("Could not write to rawdata_json file %s", opts["filename"]) raise def event_return(events): """ Write event data (return data and non-return data) to file on the master. """ if len(events) == 0: # events is an empty list. # Don't open the logfile in vain. return opts = _get_options({}) # Pass in empty ret, since this is a list of events try: with salt.utils.files.flopen(opts["filename"], "a") as logfile: for event in events: salt.utils.json.dump(event, logfile) logfile.write("\n") except Exception: # pylint: disable=broad-except log.error("Could not write to rawdata_json file %s", opts["filename"]) raise
Upload File
Create Folder