is a
JSON-encoded document with the following format:
{
"FILENAME": {
"from-start":boolean,
"from-start-if-truncated":boolean,
"delete-if-found":boolean,
"events": [
{
"label":"EVENT_NAME",
"on-create":boolean,
"on-truncate":boolean,
"pattern":"REGEXP",
"count":integer
},
{
"label":"EVENT_NAME",
...
}
]
},
"FILENAME": {
...
}
All fields but label are optional.
FILENAME: Name of a file to watch.
from-start:boolean If FILENAME exits when the monitor starts running, process from line 1. Default: false, as monitored processes may be appending to already existing files.
from-start-if-truncated If FILENAME is truncated, process from line 1. Default: true, to account for log rotations.
delete-if-found Delete FILENAME when found. Default: false
events:
label Name that identifies the snapshot. Only alphanumeric, -,
and _ characters are allowed.
on-create Take a snapshot every time the file is created. Default: false
on-truncate Take a snapshot when the file is truncated. Default: false
on-pattern Take a snapshot when a line matches the regexp pattern. Default: none
count Maximum number of snapshots for this label. Default: -1 (no limit)
The snapshots are recorded both in the main resource summary file under the key
snapshots, and as a JSON-encoded document, with the extension
.snapshot.NN, in which NN is the sequence number of the snapshot. The snapshots
are identified with the key "snapshot_name", which is a comma separated string
of label(count) elements. A label corresponds to a name that
identifies the snapshot, and the count is the number of times an event was
triggered since last check (several events may be triggered, for example, when
several matching lines are written to the log). Several events may have the same label, and exactly one of on-create, on-truncate, and on-pattern should be specified per event.
EXAMPLES
To monitor 'sleep 10', at 2 second intervals, with output to sleep-log.summary, and with a monitor alarm at 5 seconds:
% resource_monitor --interval=2 -L"wall_time: 5" -o sleep-log -- sleep 10
Execute 'date' and redirect its output to a file:
% resource_monitor --sh 'date > date.output'
It can also be run automatically from makeflow, by specifying the '-M' flag:
% makeflow --monitor=some-log-dir Makeflow
In this case, makeflow wraps every command line rule with the
monitor, and writes the resulting logs per rule in the
some-log-dir directory
Additionally, it can be run automatically from Work Queue:
q = work_queue_create_monitoring(port);
work_queue_enable_monitoring(q, some-log-dir);
wraps every task with the monitor and writes the resulting summaries in
some-log-file.
SNAPSHOTS EXAMPLES
Generate a snapshot when "my.log" is created:
{
"my.log":
{
"events":[
{
"label":"MY_LOG_STARTED",
"on-create:true
}
]
}
}
Generate snapshots every time a line is added to "my.log":
{
"my.log":
{
"events":[
{
"label":"MY_LOG_LINE",
"pattern":"^.*$"
}
]
}
}
Generate snapshots on particular lines of "my.log":
{
"my.log":
{
"events":[
{
"label":"started",
"pattern":"^# START"
},
{
"label":"end-of-start",
"pattern":"^# PROCESSING"
}
{
"label":"end-of-processing",
"pattern":"^# ANALYSIS"
}
]
}
}
A task may be setup to generate a file every time a snapshot is desired. The
monitor can detected this file, generate a snapshot, and delete the file to get
ready for the next snapshot:
{
"please-take-a-snapshot":
{
"delete-if-found":true,
"events":[
{
"label":"manual-snapshot",
"on-create":true
}
]
}
}
BUGS AND KNOWN ISSUES
- The monitor cannot track the children of statically linked executables.
- The option --snapshot-events assumes that the watched files are written by appending to them. File truncation may not be detected if between checks the size of the file is larger or equal to the size after truncation. File checks are fixed at intervals of 1 second.
COPYRIGHT
The Cooperative Computing Tools are Copyright (C) 2003-2004 Douglas Thain and Copyright (C) 2005-2015 The University of Notre Dame. This software is distributed under the GNU General Public License. See the file COPYING for details.
CCTools 6.2.0 FINAL from source released on