Monitor Ruby Processes with Monit

Monitor ruby processes with Monit

The Monit Wiki has a lot of configuration examples:

http://mmonit.com/wiki/Monit/ConfigurationExamples

Just pick a simple one and modify it according to your needs.

Update: the wrapper script should create the pid for you in this line:

echo $$ > /var/run/xyz.pid;

Did you adapt the script to your needs? Is it executable (chmod +x)? Does it have write permissions for the destination? Maybe post the wrapper you are trying to use so I can help you more.

Best Process Monitor In Ruby

I have used Eye gem now in one of our production apps and it's been running for the past 3 years. We haven't experienced any memory issues with it, although, we don't do heavy computational task with it.

Eye was inspired by God and Bluepill. So far, I haven't experienced any memory leaks with Eye. The eye process itself is super light weight. Uses just about few kilobytes of memory and less than 1% of CPU.

You also have various features with eye such as easy debugs, memory monitoring for processes, cpu monitoring, nested process configuration, mask matching etc.

Eye is awesome, I do recommend it.

God vs. Monit for process monitoring

Both solutions are good, and there are some pros and cons for both of them.

God config file is written in Ruby, so you can do basically everything Ruby allows you to do, and it's a lot of stuff. Monit has to be configured using its own syntax, it's usually OK but more restrictive. Anyway, you can also generate monit config with Ruby (as a part of your deployment strategy).

Also, monit uses less resources, so if you're on VPS or just don't have any spare memory, monit could be a better choice. Personally, I prefer god, as it's more configurable.

Here's a very good screencast on god. There's also a lot of feedback in comments to this screencast.

How can I create a monit process for a Ruby program?

Monit can check for running pid, since you're creating pid when you run task you can create a monit config which should look something like this:

check process alerts with pidfile RAILSROOT/log/process_alerts.pid
start program = "cd PATH_TO_APP; rake YOURTASK" with timeout 120 seconds
alert your@mail.com on { nonexist, timeout }

Of course RAILSROOT, PATH_TO_APP, YOURTASK should correspond to your paths/rake task.

Monit then will check for running process in system using the pidfile value and will start the process using start program command if it can't find running process.

What's the best way to monitor a large number of Ruby processes?

If you are already using Monit then M/Monit sounds like a perfect match.
"M/Monit expand upon Monit's capabilities to provide monitoring and management of all Monit enabled hosts from one simple to use web-interface. " - http://mmonit.com/

Ruby script process monitoring on windows

I found this on the forum www.ruby-forum.com and adapted it a bit you that you can see if the process (script) still runs. Restarting and reporting you can handle yourself i presume ?

require 'WIN32OLE'

procs = WIN32OLE.connect("winmgmts:\\\\.")
procs.InstancesOf("win32_process").each do |p|
puts p.commandline if p.name == 'ruby.exe'
end

Here the available attributes

class Win32_Process : CIM_Process
{
string Caption;
string CommandLine;
string CreationClassName;
datetime CreationDate;
string CSCreationClassName;
string CSName;
string Description;
string ExecutablePath;
uint16 ExecutionState;
string Handle;
uint32 HandleCount;
datetime InstallDate;
uint64 KernelModeTime;
uint32 MaximumWorkingSetSize;
uint32 MinimumWorkingSetSize;
string Name;
string OSCreationClassName;
string OSName;
uint64 OtherOperationCount;
uint64 OtherTransferCount;
uint32 PageFaults;
uint32 PageFileUsage;
uint32 ParentProcessId;
uint32 PeakPageFileUsage;
uint64 PeakVirtualSize;
uint32 PeakWorkingSetSize;
uint32 Priority;
uint64 PrivatePageCount;
uint32 ProcessId;
uint32 QuotaNonPagedPoolUsage;
uint32 QuotaPagedPoolUsage;
uint32 QuotaPeakNonPagedPoolUsage;
uint32 QuotaPeakPagedPoolUsage;
uint64 ReadOperationCount;
uint64 ReadTransferCount;
uint32 SessionId;
string Status;
datetime TerminationDate;
uint32 ThreadCount;
uint64 UserModeTime;
uint64 VirtualSize;
string WindowsVersion;
uint64 WorkingSetSize;
uint64 WriteOperationCount;
uint64 WriteTransferCount;
};


Related Topics



Leave a reply



Submit