2009-03-19 8 views
11

मैंने सवाल पूछा है, "क्या आप विंडोज़ पर मोनिट चला सकते हैं?", और जब तक आप वीएम का उपयोग नहीं करना चाहते हैं, तो उत्तर नहीं दिखता है।विंडोज ओएस के लिए समकक्षों की तरह कोई भी मोनीट?

तो ... क्या वास्तव में विंडोज ओएस के लिए कोई छोटा पदचिह्न monit-like अनुप्रयोग हैं? जो मैं खोज रहा हूं वह न केवल निगरानी (जिसमें सैकड़ों ऐप्स हैं), बल्कि एक स्क्रिप्ट निष्पादित करने या सेवा को पुनरारंभ करने की क्षमता भी नहीं है। उदाहरण के लिए, किसी वेब पेज की निगरानी करें, और टॉमकैट को पुनरारंभ करें यदि वह पृष्ठ अनुत्तरदायी हो जाता है (केवल सेवा नहीं देख सकता है, क्योंकि सेवा अभी भी चल रही है लेकिन ठीक से प्रतिक्रिया नहीं दे रही है)।

यह एक छोटे से आवेदन के लिए है, न कि एक बड़ा आवेदन, इसलिए हेवीवेट/महंगी समाधान वांछित नहीं हैं।

+0

हा पुनः आरंभ नहीं किया! - एक 7 साल का सवाल और जवाब पकड़ पर रखा गया। –

उत्तर

6

मुझे अपनी जरूरतों के अनुरूप कुछ भी नहीं मिला, इसलिए मैंने थोड़ा पावरहेल स्क्रिप्टिंग सीखा और एक समाधान लुढ़का जो दूसरों के लिए भी उपयोगी होना चाहिए। विंडोज प्लेटफ़ॉर्म मानना ​​(अन्यथा मोनिट का उपयोग करें!), पावरहेल वास्तव में शक्तिशाली और आसान है।

नमूना-monitor.ps1 स्क्रिप्ट:

$webClient = new-object System.Net.WebClient 

################################################### 
# BEGIN USER-EDITABLE VARIABLES 

# the URL to ping 
$HeartbeatUrl = "http://someplace.com/somepage/" 

# the response string to look for that indicates things are working ok 
$SuccessResponseString = "Some Text" 

# the name of the windows service to restart (the service name, not the display name) 
$ServiceName = "Tomcat6" 

# the log file used for monitoring output 
$LogFile = "c:\temp\heartbeat.log" 

# used to indicate that the service has failed since the last time we checked. 
$FailureLogFile = "c:\temp\failure.log" 

# END USER-EDITABLE VARIABLES 
################################################### 

# create the log file if it doesn't already exist. 
if (!(Test-Path $LogFile)) { 
    New-Item $LogFile -type file 
} 

$startTime = get-date 
$output = $webClient.DownloadString($HeartbeatUrl) 
$endTime = get-date 

if ($output -like "*" + $SuccessResponseString + "*") { 
    # uncomment the below line if you want positive confirmation 
    #"Success`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" >> $LogFile 

    # remove the FailureLog if it exists to indicate we're in good shape. 
    if (Test-Path $FailureLogFile) { 
     Remove-Item $FailureLogFile 
    } 

} 
else { 
    "Fail`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" >> $LogFile 

    # restart the service if this is the first time it's failed since the last successful check. 
    if (!(Test-Path $FailureLogFile)) { 
     New-Item $FailureLogFile -type file 
     "Initial failure:" + $startTime.DateTime >> $FailureLogFile 
     Restart-Service $ServiceName 
    } 
} 

इस स्क्रिप्ट में केवल तर्क यह है कि यह केवल एक बार एक प्रारंभिक विफलता के बाद सेवा को पुनः आरंभ करने की कोशिश करेंगे है। यह ऐसी स्थिति को रोकने के लिए है जहां किसी सेवा को पुनरारंभ करने में कुछ समय लगता है, और जब यह पुनरारंभ होता है, तो मॉनिटर विफलता को देखता रहता है और फिर से पुन: प्रारंभ होता है (खराब अनंत लूप)। अन्यथा आप कुछ भी कर सकते हैं, जैसे ईमेल अधिसूचनाएं जोड़ें, या बस एक सेवा को पुनरारंभ करने से ज्यादा कुछ करें।

यह स्क्रिप्ट एक बार निष्पादित होगी, जिसका अर्थ है कि आपको बाहरी पुनरावृत्ति को बाहरी रूप से नियंत्रित करने की आवश्यकता होगी। आप इसे स्क्रिप्ट में एक अनंत लूप में डाल सकते हैं, लेकिन यह थोड़ा सा झटकेदार लगता है। मैंने विंडोज़ टास्क शेड्यूलर का इस्तेमाल किया, इसे इस तरह निष्पादित किया: प्रोग्राम: पावरहेल.एक्सई तर्क: -कॉम "सी: \ परियोजनाएं \ foo \ scripts \ monitor.ps1" -noprofile प्रारंभ करें: सी: \ projects \ foo \ स्क्रिप्ट

आप विजुअलक्रोन जैसे अधिक मजबूत शेड्यूलर का उपयोग कर सकते हैं, इसे विंडोज़ सेवा में प्लग कर सकते हैं, या क्वार्ट.NET जैसे अनुप्रयोग सर्वर शेड्यूलर के माध्यम से। मेरे मामले में कार्य शेड्यूलर ठीक काम करता है।

0

मैं आरजीई इंक (http://www.ipsentry.com/) से ipsentry का उपयोग कर रहा हूं।

कई वर्षों से इसका उपयोग कर रहा है, मुझे कई बार बचाया गया है।

उनके साथ कोई संबद्धता नहीं, यह एक विज्ञापन नहीं है, केवल एक संतुष्ट ग्राहक से जानकारी है।

0

यह सेवा नियंत्रण प्रबंधक का उपयोग करके कम से कम आंशिक रूप से पूरा किया जा सकता है जो विंडोज के साथ जहाज है। यह सेवा अनुप्रयोगों की निगरानी करता है और स्वचालित रूप से उन्हें बूट पर प्रारंभ कर सकता है, क्रैश होने पर उन्हें पुनरारंभ कर सकता है, आदि। सेवा के रूप में अपना आवेदन लिखना एक विकल्प है, लेकिन यदि आप सेवा के रूप में एप्लिकेशन नहीं लिख सकते हैं तो आप प्रक्रिया को लपेटने का प्रयास कर सकते हैं विंडोज संसाधन किट में srvany.exe का उपयोग करना।

एक सेवा लिखने के बारे में अधिक जानकारी: https://support.microsoft.com/en-us/kb/137890

वास्तविक सुविधाओं की निगरानी के लिए के रूप में, मैं पूरी तरह से यकीन है कि क्या उपलब्ध है, या एससीएम की क्षमताओं का विस्तार नहीं कर रहा हूँ।

1

मैं एक छोटे से दान टान्नर स्क्रिप्ट समायोजित जब वह कनेक्ट नहीं हो सका, एक त्रुटि से पता चला है और सेवा

$webClient = new-object System.Net.WebClient 

################################################### 
# BEGIN USER-EDITABLE VARIABLES 

# the URL to ping 
$HeartbeatUrl = "http://localhost:8080/" 

# the response string to look for that indicates things are working ok 
$SuccessResponseString = "Apache" 

# the name of the windows service to restart (the service name, not the display name) 
$ServiceName = "Tomcat6" 

# the log file used for monitoring output 
$LogFile = "c:\temp\log.log" 

# used to indicate that the service has failed since the last time we checked. 
$FailureLogFile = "c:\temp\log2.log" 

# END USER-EDITABLE VARIABLES 
################################################### 

# create the log file if it doesn't already exist. 
if (!(Test-Path $LogFile)) { 
    New-Item $LogFile -type file 
} 

$startTime = get-date 
try { 
    $output = $webClient.DownloadString($HeartbeatUrl) 
    $endTime = get-date 

    if ($output -like "*" + $SuccessResponseString + "*") { 
     # uncomment the below line if you want positive confirmation 
     #"Success`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" >> $LogFile 

     # remove the FailureLog if it exists to indicate we're in good shape. 
     if (Test-Path $FailureLogFile) { 
      Remove-Item $FailureLogFile 
     } 

    } 
    else { 
     "Fail`t`t" + $startTime.DateTime + "`t`t" + ($endTime - $startTime).TotalSeconds + " seconds" >> $LogFile 

     # restart the service if this is the first time it's failed since the last successful check. 
     if (!(Test-Path $FailureLogFile)) { 
      New-Item $FailureLogFile -type file 
      "Initial failure:" + $startTime.DateTime >> $FailureLogFile 
      Restart-Service $ServiceName 
     } 
    } 
    }catch [Net.WebException] { 
     New-Item $FailureLogFile -type file 
     "Initial failure:" + $startTime.DateTime + $_.Exception.ToString() >> $FailureLogFile 
     Restart-Service $ServiceName 
} 
संबंधित मुद्दे