Popular recipes tagged "monitor"http://code.activestate.com/recipes/tags/monitor/2014-05-30T01:10:53-07:00ActiveState Code RecipesMonitor Progress of File Descriptors of Another Process (Python)
2014-05-30T01:10:53-07:00Alfehttp://code.activestate.com/recipes/users/4182236/http://code.activestate.com/recipes/578882-monitor-progress-of-file-descriptors-of-another-pr/
<p style="color: grey">
Python
recipe 578882
by <a href="/recipes/users/4182236/">Alfe</a>
(<a href="/recipes/tags/file_descriptor/">file_descriptor</a>, <a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/prediction/">prediction</a>, <a href="/recipes/tags/proc/">proc</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/watch/">watch</a>).
</p>
<p>This tool (inspired by azat@stackoverflow, see <a href="http://stackoverflow.com/a/16082562/1281485" rel="nofollow">http://stackoverflow.com/a/16082562/1281485</a>) allows to watch the progress of the file descriptors of another process. This can be used, for example, if you transfer a file to another host and the transferring program does not show any progress indication itself. Instead of waiting blindly until the routine is done, with this tool you can use Linux's proc file system to monitor the progress of the other process while it walks through the file.</p>
<p>The tool continuously monitors the position in and the size of the files the given process's file descriptors point to. For growing (or shrinking, but that's very unusual) files, a time when it was (or will be) empty is computed ("emptyTime"), for moving file descriptors (the typical case), the time when it started at position 0 ("startTime"), the time when it will reach the current size of the file ("reachTime") and when it will meet with the end of a growing (or shrinking) file is computed ("meetTime").</p>
<p>For fixed-size files the meetTime will be the same as the reachTime of course. The meetTime only makes sense in case a file is growing and at the same time read (e. g. when a movie is downloaded to a file by one process and converted by a different process; using this tool can tell you when the converter process might run dry on the input because the download wasn't fast enough, and in this case you maybe can pause the converter to prevent this situation).</p>
<p>The tool is designed as a library; the display of the information is independent from the gathering of the data. Please feel free to create more fancy displays, add percentage output etc.</p>
Log watcher (tail -F *.log) (Python)
2014-04-04T15:54:03-07:00Giampaolo RodolĂ http://code.activestate.com/recipes/users/4178764/http://code.activestate.com/recipes/577968-log-watcher-tail-f-log/
<p style="color: grey">
Python
recipe 577968
by <a href="/recipes/users/4178764/">Giampaolo RodolĂ </a>
(<a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/log/">log</a>, <a href="/recipes/tags/logging/">logging</a>, <a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/rotate/">rotate</a>, <a href="/recipes/tags/rotations/">rotations</a>, <a href="/recipes/tags/tail/">tail</a>).
Revision 10.
</p>
<p>A python class which "watches" a directory and calls a callback(filename, lines) function every time one of the files being watched gets written, in real time.</p>
<p>Practically speaking, this can be compared to <em>"tail -F *.log"</em> UNIX command, but instead of having lines printed to stdout a python function gets called.</p>
<p>Similarly to tail, it takes care of "watching" new files which are created after initialization and "unwatching" those ones which are removed in the meantime. This means you'll be able to "follow" and support also rotating log files.</p>
<p><strong>History</strong></p>
<ul>
<li>rev5 (2013-04-05):
<ul>
<li>sizehint parameter</li>
</ul></li>
<li>rev4 (2013-03-16):
<ul>
<li>python 3 support (also dropped support for python <= 2.5)</li>
<li>windows support</li>
<li>unit tests</li>
<li>main class can also be used as a context manager</li>
</ul></li>
<li>rev3 (2012-01-13): initial release</li>
</ul>
DistCC 'top' (Python)
2013-12-01T11:19:56-08:00Mike 'Fuzzy' Partinhttp://code.activestate.com/recipes/users/4179778/http://code.activestate.com/recipes/577933-distcc-top/
<p style="color: grey">
Python
recipe 577933
by <a href="/recipes/users/4179778/">Mike 'Fuzzy' Partin</a>
(<a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/curses/">curses</a>, <a href="/recipes/tags/distcc/">distcc</a>, <a href="/recipes/tags/distributed/">distributed</a>, <a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/pack/">pack</a>, <a href="/recipes/tags/struct/">struct</a>, <a href="/recipes/tags/top/">top</a>, <a href="/recipes/tags/unpack/">unpack</a>).
Revision 3.
</p>
<p>A small recipe for a curses based, 'top'-like monitor for DistCC. I know there is already distccmon-text, but I don't like it, and much prefer this sytle of monitoring. Note that I don't keep hosts around in the list like distccmon-gui/gnome. The screen is drawn for exactly what is currently in state. The terminal size is respected at initialization time, however resize events aren't handled. There is color designation of job types.</p>
Nagios plugin for monitoring database servers (Python)
2011-08-23T22:12:20-07:00Matt Keranenhttp://code.activestate.com/recipes/users/38288/http://code.activestate.com/recipes/577599-nagios-plugin-for-monitoring-database-servers/
<p style="color: grey">
Python
recipe 577599
by <a href="/recipes/users/38288/">Matt Keranen</a>
(<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/nagios/">nagios</a>).
Revision 4.
</p>
<p>An example implementation of a Nagios script in Python for monitoring database servers via ODBC queries. The example tests contained are for checking the status of MS SQL Server replication and log shipping, but any status check that can be performed by a query can be implemented. This method is not considered a replacement for SNMP monitoring, but to implement custom logic checks.</p>
<p>New tests are implemented by adding an @nagios_test decorator, and called by the -t parameter with the function name. Usage text list available tests.</p>
"tail -f" with inode monitor (Python)
2010-09-21T07:37:38-07:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/577398-tail-f-with-inode-monitor/
<p style="color: grey">
Python
recipe 577398
by <a href="/recipes/users/57155/">Denis Barmenkov</a>
(<a href="/recipes/tags/inode/">inode</a>, <a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/tail/">tail</a>).
Revision 3.
</p>
<p>Sometimes tail -f launched for log file miss the point when program recreates log file.
Script in this recipe monitors inode changes for specified file and restarts tail if needed.</p>
Monitor standby (C++)
2009-05-14T02:23:53-07:00kjahdksadsahd ahdsahdandhttp://code.activestate.com/recipes/users/4170243/http://code.activestate.com/recipes/576752-monitor-standby/
<p style="color: grey">
C++
recipe 576752
by <a href="/recipes/users/4170243/">kjahdksadsahd ahdsahdand</a>
(<a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/on_off/">on_off</a>).
</p>
<p>Monitor On/Off</p>