I want to monitor my ruby script process remotely on windows. I do know how to do it on unix based system, with god or similar monitoring framework, but the issue is that I want to have it for windows.
Basically, I want to do a couple of things:
Maybe someone can suggest it.
Please note that I would prefer to have the monitoring solution written in ruby, so I could expand it further.
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;
};