<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>UMnieDziala.pl - Monitoring</title>
    <link>http://umniedziala.pl/</link>
    <description />
    <language>pl_PL</language>
    <copyright>Krzysztof Pietrzak</copyright>
    <lastBuildDate>Mon, 14 Nov 2005 18:27:15 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>pkrzysz@pjwstk.edu.pl</managingEditor>
    <webMaster>pkrzysz@pjwstk.edu.pl</webMaster>
    <item>
      <trackback:ping>http://umniedziala.pl/Trackback.aspx?guid=45740b43-fa1b-4a89-a3c6-0a3550c767e4</trackback:ping>
      <pingback:server>http://umniedziala.pl/pingback.aspx</pingback:server>
      <pingback:target>http://umniedziala.pl/PermaLink,guid,45740b43-fa1b-4a89-a3c6-0a3550c767e4.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://umniedziala.pl/CommentView,guid,45740b43-fa1b-4a89-a3c6-0a3550c767e4.aspx</wfw:comment>
      <wfw:commentRss>http://umniedziala.pl/SyndicationService.asmx/GetEntryCommentsRss?guid=45740b43-fa1b-4a89-a3c6-0a3550c767e4</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
   Podobnie jak poprzedni ten skrypt słuzy do monitorowania stanu hostów.
W tym celu próbuję pingnąć hosta docelowego po ICMP wykorzystując mechanizm WMI,
oraz pingnąć hosta zródłowego po ICMP korzystając z zdalnego wywołania procedury po
WMI. Jako wynik dostajemy 1 jeśli ping się powiódł , i 0 jeśli zawiódł. Oczywiście
jeśli ping nie doszedł, skrypt jeszcze raz próbuje się dostać do hosta, a jesli i
ta próba zakończy się niepowodzeniem, wysyła emaila do administratora.
</p>
        <p>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">On</span>
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Error</span>
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Resume</span>
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Next</span>
            <br />
            <br />
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> wbemFlagReturnImmediately <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> &amp;h10<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> wbemFlagForwardOnly <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> &amp;h20<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objArgs <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> WScript.Arguments<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span> objArgs.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">count</span> &gt;
0 <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">then</span><br />
    addr=objArgs(0)<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">else</span><br />
    addr <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"localhost"</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">end</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span><br /><br />
strComputer=<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"localhost"</span><br />
pingstatus=0<br />
wmistatus=0<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objWMIService <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">GetObject</span>(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"winmgmts:\\"</span> &amp;
strComputer &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"\root\CIMV2"</span>)<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> colItems <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> objWMIService.ExecQuery(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"SELECT
StatusCode FROM Win32_PingStatus where address = '"</span>&amp;addr&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"'"</span>, <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"WQL"</span>,
_<br />
wbemFlagReturnImmediately <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">+</span> wbemFlagForwardOnly)<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">For</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Each</span> objItem <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">In</span> colItems<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span> IsNull(objItem.StatusCode) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">then</span><br />
pingstatus=0<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">else</span><br />
pingstatus=1<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">end</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Next</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objWMIServiceR <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">GetObject</span>(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"winmgmts:\\"</span> &amp;
addr &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"\root\CIMV2"</span>)<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> colItemsR <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> objWMIServiceR.ExecQuery(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"SELECT
StatusCode FROM Win32_PingStatus where address = '"</span>&amp;strComputer&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"'"</span>, <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"WQL"</span>,
_<br />
wbemFlagReturnImmediately <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">+</span> wbemFlagForwardOnly)<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">For</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Each</span> objItem <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">In</span> colItemsR<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span> IsNull(objItem.StatusCode) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">then</span><br />
wmistatus=0<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">else</span><br />
wmistatus=1<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">end</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Next</span><br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span> (wmistatus=0 <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">or</span> pingstatus=0) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">then</span><br />
wmistatus=0<br />
pingstatus=0<br />
WScript.Sleep 10000<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objWMIServiceN <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">GetObject</span>(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"winmgmts:\\"</span> &amp;
strComputer &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"\root\CIMV2"</span>)<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> colItemsN <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> objWMIServiceN.ExecQuery(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"SELECT
StatusCode FROM Win32_PingStatus where address = '"</span>&amp;addr&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"'"</span>, <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"WQL"</span>,
_<br />
wbemFlagReturnImmediately <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">+</span> wbemFlagForwardOnly)<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">For</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Each</span> objItem <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">In</span> colItemsN<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span> IsNull(objItem.StatusCode) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">then</span><br />
pingstatus=0<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">else</span><br />
pingstatus=1<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">end</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Next</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objWMIServiceNR <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">GetObject</span>(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"winmgmts:\\"</span> &amp;
addr &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"\root\CIMV2"</span>)<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> colItemsNR <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> objWMIServiceNR.ExecQuery(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"SELECT
StatusCode FROM Win32_PingStatus where address = '"</span>&amp;strComputer&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"'"</span>, <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"WQL"</span>,
_<br />
wbemFlagReturnImmediately <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">+</span> wbemFlagForwardOnly)<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">For</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Each</span> objItem <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">In</span> colItemsNR<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span> IsNull(objItem.StatusCode) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">then</span><br />
wmistatus=0<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">else</span><br />
wmistatus=1<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">end</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Next</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span> (wmistatus=0 <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">or</span> pingstatus=0) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">then</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoSendUsingPickup <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 1 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Send
message using the local SMTP service pickup directory. </span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoSendUsingPort <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 2 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Send
the message using the network (SMTP over the network). </span><br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoAnonymous <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 0 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Do
not authenticate</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoBasic <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 1 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'basic
(clear-text) authentication</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoNTLM <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 2 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'NTLM</span><br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objMessage <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">CreateObject</span>(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"CDO.Message"</span>) 
<br />
objMessage.Subject <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Brak
odpowiedzi z serwera "</span> &amp; addr<br />
objMessage.From <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"""RRdTooL
Server Watch"" &lt;pkrzysz@pjwstk.edu.pl&gt;"</span><br />
objMessage.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">To</span><span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"pkrzysz@pjwstk.edu.pl;kfaz@pjwstk.edu.pl"</span><br />
objMessage.TextBody <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Serwer
"</span> &amp; addr &amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"nie
odpowiada na Pingi "</span>&amp;vbCRLF&amp;_<br /><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Trzeba
sprawdzic http://peki.pjwstk.edu.pl/rrdtool "</span>&amp;vbCRLF&amp;_<br />
         <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"zobaczyć
co się dzieje i ewentualnie zrestartować."</span><br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'==This
section provides the configuration information for the remote SMTP server.</span><br /><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/sendusing"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 2 
<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Name
or IP of Remote SMTP Server</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpserver"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"dfs2"</span><br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Type
of authentication, NONE, Basic (Base64 encoded), NTLM</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> cdoNTLM 
<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Server
port (typically 25)</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpserverport"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 25 
<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Use
SSL for the connection (False or True)</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpusessl"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">False</span><br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Connection
Timeout in seconds (the maximum time CDO will try to establish a connection to the
SMTP server)</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 60<br /><br />
objMessage.Configuration.Fields.Update<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'==End
remote SMTP server configuration section==</span><br /><br />
objMessage.Send 
<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">end</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">end</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">if</span><br /><br />
wscript.echo wmistatus<br />
wscript.echo pingstatus<br /><br />
wscript.echo <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Date</span>()
&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"
"</span> &amp; Time()<br /><br />
wscript.echo <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"WMI
ping"</span><br />
wscript.echo <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"ICMP
Ping"</span><br />
Wscript.echo cmpName<br /></span>
        </p>
        <p>
   Skrypcik oczywiście chodzi w Schedulerze co 10min, i jest podpiety
do MRTG/rrdtool generujacego statystyki - <a href="http://peki.pjwstk.edu.pl/rrdtool">http://peki.pjwstk.edu.pl/rrdtool</a></p>
        <img width="0" height="0" src="http://umniedziala.pl/aggbug.ashx?id=45740b43-fa1b-4a89-a3c6-0a3550c767e4" />
      </body>
      <title>Monitorowanie stanu hostów</title>
      <guid isPermaLink="false">http://umniedziala.pl/PermaLink,guid,45740b43-fa1b-4a89-a3c6-0a3550c767e4.aspx</guid>
      <link>http://UMnieDziala.pl/MonitorowanieStanuHost%c3%b3w.aspx</link>
      <pubDate>Mon, 14 Nov 2005 18:27:15 GMT</pubDate>
      <description>&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Podobnie jak poprzedni ten skrypt słuzy do monitorowania stanu hostów.
W tym celu próbuję&amp;nbsp;pingnąć hosta docelowego po ICMP wykorzystując mechanizm WMI,
oraz pingnąć hosta zródłowego po ICMP korzystając z zdalnego wywołania procedury po
WMI. Jako wynik dostajemy 1 jeśli ping się powiódł , i 0 jeśli zawiódł. Oczywiście
jeśli ping nie doszedł, skrypt jeszcze raz próbuje się dostać do hosta, a jesli i
ta próba zakończy się niepowodzeniem, wysyła emaila do administratora.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;On&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Error&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Resume&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Next&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; wbemFlagReturnImmediately &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &amp;amp;h10&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; wbemFlagForwardOnly &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &amp;amp;h20&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objArgs &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; WScript.Arguments&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; objArgs.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;count&lt;/span&gt; &amp;gt;
0 &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;then&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;addr=objArgs(0)&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;else&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;addr &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"localhost"&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;end&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
strComputer=&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"localhost"&lt;/span&gt;
&lt;br&gt;
pingstatus=0&lt;br&gt;
wmistatus=0&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objWMIService &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;GetObject&lt;/span&gt;(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"winmgmts:\\"&lt;/span&gt; &amp;amp;
strComputer &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"\root\CIMV2"&lt;/span&gt;)&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; colItems &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; objWMIService.ExecQuery(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"SELECT
StatusCode FROM Win32_PingStatus where address = '"&lt;/span&gt;&amp;amp;addr&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"'"&lt;/span&gt;, &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"WQL"&lt;/span&gt;,
_&lt;br&gt;
wbemFlagReturnImmediately &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;+&lt;/span&gt; wbemFlagForwardOnly)&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;For&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Each&lt;/span&gt; objItem &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;In&lt;/span&gt; colItems&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; IsNull(objItem.StatusCode) &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;then&lt;/span&gt;
&lt;br&gt;
pingstatus=0&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;else&lt;/span&gt;
&lt;br&gt;
pingstatus=1&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;end&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Next&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objWMIServiceR &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;GetObject&lt;/span&gt;(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"winmgmts:\\"&lt;/span&gt; &amp;amp;
addr &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"\root\CIMV2"&lt;/span&gt;)&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; colItemsR &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; objWMIServiceR.ExecQuery(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"SELECT
StatusCode FROM Win32_PingStatus where address = '"&lt;/span&gt;&amp;amp;strComputer&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"'"&lt;/span&gt;, &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"WQL"&lt;/span&gt;,
_&lt;br&gt;
wbemFlagReturnImmediately &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;+&lt;/span&gt; wbemFlagForwardOnly)&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;For&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Each&lt;/span&gt; objItem &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;In&lt;/span&gt; colItemsR&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; IsNull(objItem.StatusCode) &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;then&lt;/span&gt;
&lt;br&gt;
wmistatus=0&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;else&lt;/span&gt;
&lt;br&gt;
wmistatus=1&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;end&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Next&lt;/span&gt; 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; (wmistatus=0 &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;or&lt;/span&gt; pingstatus=0) &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;then&lt;/span&gt;
&lt;br&gt;
wmistatus=0&lt;br&gt;
pingstatus=0&lt;br&gt;
WScript.Sleep 10000&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objWMIServiceN &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;GetObject&lt;/span&gt;(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"winmgmts:\\"&lt;/span&gt; &amp;amp;
strComputer &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"\root\CIMV2"&lt;/span&gt;)&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; colItemsN &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; objWMIServiceN.ExecQuery(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"SELECT
StatusCode FROM Win32_PingStatus where address = '"&lt;/span&gt;&amp;amp;addr&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"'"&lt;/span&gt;, &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"WQL"&lt;/span&gt;,
_&lt;br&gt;
wbemFlagReturnImmediately &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;+&lt;/span&gt; wbemFlagForwardOnly)&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;For&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Each&lt;/span&gt; objItem &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;In&lt;/span&gt; colItemsN&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; IsNull(objItem.StatusCode) &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;then&lt;/span&gt;
&lt;br&gt;
pingstatus=0&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;else&lt;/span&gt;
&lt;br&gt;
pingstatus=1&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;end&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Next&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objWMIServiceNR &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;GetObject&lt;/span&gt;(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"winmgmts:\\"&lt;/span&gt; &amp;amp;
addr &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"\root\CIMV2"&lt;/span&gt;)&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; colItemsNR &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; objWMIServiceNR.ExecQuery(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"SELECT
StatusCode FROM Win32_PingStatus where address = '"&lt;/span&gt;&amp;amp;strComputer&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"'"&lt;/span&gt;, &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"WQL"&lt;/span&gt;,
_&lt;br&gt;
wbemFlagReturnImmediately &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;+&lt;/span&gt; wbemFlagForwardOnly)&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;For&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Each&lt;/span&gt; objItem &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;In&lt;/span&gt; colItemsNR&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; IsNull(objItem.StatusCode) &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;then&lt;/span&gt;
&lt;br&gt;
wmistatus=0&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;else&lt;/span&gt;
&lt;br&gt;
wmistatus=1&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;end&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Next&lt;/span&gt; 
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt; (wmistatus=0 &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;or&lt;/span&gt; pingstatus=0) &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;then&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoSendUsingPickup &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 1 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Send
message using the local SMTP service pickup directory. &lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoSendUsingPort &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 2 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Send
the message using the network (SMTP over the network). &lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoAnonymous &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 0 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Do
not authenticate&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoBasic &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 1 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'basic
(clear-text) authentication&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoNTLM &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 2 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'NTLM&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objMessage &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;CreateObject&lt;/span&gt;(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"CDO.Message"&lt;/span&gt;) 
&lt;br&gt;
objMessage.Subject &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Brak
odpowiedzi z serwera "&lt;/span&gt; &amp;amp; addr&lt;br&gt;
objMessage.From &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"""RRdTooL
Server Watch"" &amp;lt;pkrzysz@pjwstk.edu.pl&amp;gt;"&lt;/span&gt; 
&lt;br&gt;
objMessage.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;To&lt;/span&gt; &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"pkrzysz@pjwstk.edu.pl;kfaz@pjwstk.edu.pl"&lt;/span&gt; 
&lt;br&gt;
objMessage.TextBody &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Serwer
"&lt;/span&gt; &amp;amp; addr &amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"nie
odpowiada na Pingi "&lt;/span&gt;&amp;amp;vbCRLF&amp;amp;_&lt;br&gt;
&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Trzeba
sprawdzic http://peki.pjwstk.edu.pl/rrdtool "&lt;/span&gt;&amp;amp;vbCRLF&amp;amp;_&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"zobaczyć
co się dzieje i ewentualnie zrestartować."&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'==This
section provides the configuration information for the remote SMTP server.&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/sendusing"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 2 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Name
or IP of Remote SMTP Server&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpserver"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"dfs2"&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Type
of authentication, NONE, Basic (Base64 encoded), NTLM&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; cdoNTLM 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Server
port (typically 25)&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpserverport"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 25 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Use
SSL for the connection (False or True)&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpusessl"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;False&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Connection
Timeout in seconds (the maximum time CDO will try to establish a connection to the
SMTP server)&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 60&lt;br&gt;
&lt;br&gt;
objMessage.Configuration.Fields.Update&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'==End
remote SMTP server configuration section==&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
objMessage.Send 
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;end&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;end&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;if&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
wscript.echo wmistatus&lt;br&gt;
wscript.echo pingstatus&lt;br&gt;
&lt;br&gt;
wscript.echo &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Date&lt;/span&gt;()
&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"
"&lt;/span&gt; &amp;amp; Time()&lt;br&gt;
&lt;br&gt;
wscript.echo &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"WMI
ping"&lt;/span&gt;
&lt;br&gt;
wscript.echo &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"ICMP
Ping"&lt;/span&gt;
&lt;br&gt;
Wscript.echo cmpName&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Skrypcik oczywiście chodzi w Schedulerze co 10min, i jest podpiety
do MRTG/rrdtool generujacego statystyki - &lt;a href="http://peki.pjwstk.edu.pl/rrdtool"&gt;http://peki.pjwstk.edu.pl/rrdtool&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://umniedziala.pl/aggbug.ashx?id=45740b43-fa1b-4a89-a3c6-0a3550c767e4" /&gt;</description>
      <comments>http://umniedziala.pl/CommentView,guid,45740b43-fa1b-4a89-a3c6-0a3550c767e4.aspx</comments>
      <category>Windows</category>
      <category>Monitoring</category>
    </item>
    <item>
      <trackback:ping>http://umniedziala.pl/Trackback.aspx?guid=a40e3a73-bd8e-4359-9f98-507812fae82f</trackback:ping>
      <pingback:server>http://umniedziala.pl/pingback.aspx</pingback:server>
      <pingback:target>http://umniedziala.pl/PermaLink,guid,a40e3a73-bd8e-4359-9f98-507812fae82f.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://umniedziala.pl/CommentView,guid,a40e3a73-bd8e-4359-9f98-507812fae82f.aspx</wfw:comment>
      <wfw:commentRss>http://umniedziala.pl/SyndicationService.asmx/GetEntryCommentsRss?guid=a40e3a73-bd8e-4359-9f98-507812fae82f</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">
              <font color="#000000"> 
Po zupdetowaniu serwery się niestety muszą zrestartować. I rzadko im to wychodzi dobrze.
Dlatego zawsze warto wiedzieć kiedy serwer będzie wykonywał tą operację. W tym celu
zakładamy trigera na event log systemowy , na zdarzenie 1074, za pomocą </font>
              <font color="#008000">eventtrigger.exe
- <font color="#000000">dostępnego</font> </font>
              <font color="#000000">kazdym
systemie xp i 2k3- i podpinamy do ponizszego skryptu.</font>
            </span>
          </span>
        </p>
        <p>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">On</span>
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Error</span>
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Resume</span>
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Next</span>
            <br />
            <br />
addr <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"LSD"</span><br />
msgTo <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"kfaz@pjwstk.edu.pl;pkrzysz@pjwstk.edu.pl"</span><br />
textBody=<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Serwer
"</span> &amp; addr &amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"
wła¶nie wszedł w tryb restart/shutdown "</span>&amp; vbCRLF 
<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> wbemFlagReturnImmediately <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> &amp;h10<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> wbemFlagForwardOnly <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> &amp;h20<br />
strComputer <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"localhost"</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objWMIService <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">GetObject</span>(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"winmgmts:\\"</span> &amp;
strComputer &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"\root\CIMV2"</span>)<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> colItems <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> objWMIService.ExecQuery(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"SELECT
* FROM Win32_NTLogEvent WHERE Logfile = 'System' And EventCode=1074 "</span>, <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"WQL"</span>,
_<br />
wbemFlagReturnImmediately <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">+</span> wbemFlagForwardOnly)<br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">For</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Each</span> objItem <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">In</span> colItems<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Category:
"</span> &amp; objItem.Category &amp; vbCRLF 
<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"CategoryString:
"</span> &amp; objItem.CategoryString&amp;vbCRLF<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"ComputerName:
"</span> &amp; objItem.ComputerName&amp;vbCRLF<br />
strData <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Join</span>(objItem.Data, <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">","</span>)<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Data:
"</span> &amp; strData&amp; vbCRLF 
<br />
textBody=textBody&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"EventCode:
"</span> &amp; objItem.EventCode&amp; vbCRLF 
<br />
textBody=textBody&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"EventIdentifier:
"</span> &amp; objItem.EventIdentifier&amp; vbCRLF 
<br />
textBody=textBody&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"EventType:
"</span> &amp; objItem.EventType&amp; vbCRLF 
<br />
strInsertionStrings <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Join</span>(objItem.InsertionStrings, <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">","</span>)<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"InsertionStrings:
"</span> &amp; strInsertionStrings&amp; vbCRLF 
<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Logfile:
"</span> &amp; objItem.Logfile&amp; vbCRLF 
<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Message:
"</span> &amp; objItem.Message&amp; vbCRLF 
<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"RecordNumber:
"</span> &amp; objItem.RecordNumber&amp; vbCRLF 
<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"SourceName:
"</span> &amp; objItem.SourceName&amp; vbCRLF 
<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"TimeGenerated:
"</span> &amp; WMIDateStringToDate(objItem.TimeGenerated)&amp; vbCRLF 
<br />
textBody=textBody&amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"TimeWritten:
"</span> &amp; WMIDateStringToDate(objItem.TimeWritten)&amp; vbCRLF 
<br />
textBody=textBody&amp; vbCRLF 
<br />
textBody=textBody&amp; vbCRLF 
<br />
textBody=textBody&amp;<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"by
peki"</span>&amp; vbCRLF 
<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Exit</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">For</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Next</span><br /><br /><br />
oSendUsingPickup <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 1 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Send
message using the local SMTP service pickup directory. </span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoSendUsingPort <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 2 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Send
the message using the network (SMTP over the network). </span><br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoAnonymous <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 0 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Do
not authenticate</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoBasic <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 1 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'basic
(clear-text) authentication</span><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Const</span> cdoNTLM <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 2 <span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'NTLM</span><br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Set</span> objMessage <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">CreateObject</span>(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"CDO.Message"</span>) 
<br />
objMessage.Subject <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"Serwer
"</span> &amp; addr &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"
shutdown/restart"</span><br />
objMessage.From <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"""RRdTooL
Server Watch"" &lt;pkrzysz@pjwstk.edu.pl&gt;"</span><br />
objMessage.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">To</span><span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> msgTo 
<br />
objMessage.TextBody <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> textBody<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'==This
section provides the configuration information for the remote SMTP server.</span><br /><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/sendusing"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 2 
<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Name
or IP of Remote SMTP Server</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpserver"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"dfs2"</span><br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Type
of authentication, NONE, Basic (Base64 encoded), NTLM</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> cdoNTLM 
<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Server
port (typically 25)</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpserverport"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 25 
<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Use
SSL for the connection (False or True)</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpusessl"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">False</span><br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'Connection
Timeout in seconds (the maximum time CDO will try to establish a connection to the
SMTP server)</span><br />
objMessage.Configuration.Fields.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Item</span> _<br />
(<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span> 60<br /><br />
objMessage.Configuration.Fields.Update<br /><br /><span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;">'==End
remote SMTP server configuration section==</span><br /><br />
objMessage.Send 
<br /><br /><br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Function</span> WMIDateStringToDate(dtmDate)<br />
WScript.Echo dtm: 
<br />
    WMIDateStringToDate <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;">=</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">CDate</span>(<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Mid</span>(dtmDate,
5, 2) &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"/"</span> &amp;
_<br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Mid</span>(dtmDate,
7, 2) &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"/"</span> &amp; <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Left</span>(dtmDate,
4) _<br />
    &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"
"</span> &amp; <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Mid</span> (dtmDate,
9, 2) &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">":"</span> &amp; <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Mid</span>(dtmDate,
11, 2) &amp; <span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">":"</span> &amp; <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Mid</span>(dtmDate,13,
2))<br /><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">End</span><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">Function</span></span>
        </p>
        <p>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">
            </span>
          </span> 
</p>
        <p>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">
              <font color="#000000">Skrypt
ten wysyła emaila do administratora , ze maszyna przeszła w tryb restartu/shutdownu,
oraz podaje odpowiedni wpis z dziennika zdarzeń. Jak mozna zauwazyc, w skrypcie sa
pobierane wszystkie wartosci z logu system o id 1074, a nie tylko ostatnia - wynika
to ze w WQL brakuję prostego słowa kluczowego TOP.</font>
            </span>
          </span>
        </p>
        <p>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">
            <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;">
              <font color="#000000">
              </font>
            </span>
          </span> 
</p>
        <img width="0" height="0" src="http://umniedziala.pl/aggbug.ashx?id=a40e3a73-bd8e-4359-9f98-507812fae82f" />
      </body>
      <title>Automatyczne powiadamianie o restarcie/shutdownie</title>
      <guid isPermaLink="false">http://umniedziala.pl/PermaLink,guid,a40e3a73-bd8e-4359-9f98-507812fae82f.aspx</guid>
      <link>http://UMnieDziala.pl/AutomatycznePowiadamianieORestarcieshutdownie.aspx</link>
      <pubDate>Mon, 14 Nov 2005 18:20:50 GMT</pubDate>
      <description>&lt;p&gt;
&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;
Po zupdetowaniu serwery się niestety muszą zrestartować. I rzadko im to wychodzi dobrze.
Dlatego zawsze warto wiedzieć kiedy serwer będzie wykonywał tą operację. W tym celu
zakładamy trigera na event log systemowy , na zdarzenie 1074, za pomocą &lt;/font&gt;&lt;font color="#008000"&gt;eventtrigger.exe
- &lt;font color="#000000"&gt;dostępnego&lt;/font&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;kazdym
systemie xp i 2k3- i podpinamy do ponizszego skryptu.&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;On&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Error&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Resume&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Next&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
addr &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"LSD"&lt;/span&gt;
&lt;br&gt;
msgTo &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"kfaz@pjwstk.edu.pl;pkrzysz@pjwstk.edu.pl"&lt;/span&gt;
&lt;br&gt;
textBody=&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Serwer
"&lt;/span&gt; &amp;amp; addr &amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"
wła¶nie wszedł w tryb restart/shutdown "&lt;/span&gt;&amp;amp; vbCRLF 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; wbemFlagReturnImmediately &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &amp;amp;h10&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; wbemFlagForwardOnly &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &amp;amp;h20&lt;br&gt;
strComputer &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"localhost"&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objWMIService &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;GetObject&lt;/span&gt;(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"winmgmts:\\"&lt;/span&gt; &amp;amp;
strComputer &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"\root\CIMV2"&lt;/span&gt;)&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; colItems &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; objWMIService.ExecQuery(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"SELECT
* FROM Win32_NTLogEvent WHERE Logfile = 'System' And EventCode=1074 "&lt;/span&gt;, &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"WQL"&lt;/span&gt;,
_&lt;br&gt;
wbemFlagReturnImmediately &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;+&lt;/span&gt; wbemFlagForwardOnly)&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;For&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Each&lt;/span&gt; objItem &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;In&lt;/span&gt; colItems&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Category:
"&lt;/span&gt; &amp;amp; objItem.Category &amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"CategoryString:
"&lt;/span&gt; &amp;amp; objItem.CategoryString&amp;amp;vbCRLF&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"ComputerName:
"&lt;/span&gt; &amp;amp; objItem.ComputerName&amp;amp;vbCRLF&lt;br&gt;
strData &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Join&lt;/span&gt;(objItem.Data, &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;","&lt;/span&gt;)&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Data:
"&lt;/span&gt; &amp;amp; strData&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"EventCode:
"&lt;/span&gt; &amp;amp; objItem.EventCode&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"EventIdentifier:
"&lt;/span&gt; &amp;amp; objItem.EventIdentifier&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"EventType:
"&lt;/span&gt; &amp;amp; objItem.EventType&amp;amp; vbCRLF 
&lt;br&gt;
strInsertionStrings &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Join&lt;/span&gt;(objItem.InsertionStrings, &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;","&lt;/span&gt;)&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"InsertionStrings:
"&lt;/span&gt; &amp;amp; strInsertionStrings&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Logfile:
"&lt;/span&gt; &amp;amp; objItem.Logfile&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Message:
"&lt;/span&gt; &amp;amp; objItem.Message&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"RecordNumber:
"&lt;/span&gt; &amp;amp; objItem.RecordNumber&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"SourceName:
"&lt;/span&gt; &amp;amp; objItem.SourceName&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"TimeGenerated:
"&lt;/span&gt; &amp;amp; WMIDateStringToDate(objItem.TimeGenerated)&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"TimeWritten:
"&lt;/span&gt; &amp;amp; WMIDateStringToDate(objItem.TimeWritten)&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp; vbCRLF 
&lt;br&gt;
textBody=textBody&amp;amp;&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"by
peki"&lt;/span&gt;&amp;amp; vbCRLF 
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Exit&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;For&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Next&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
oSendUsingPickup &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 1 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Send
message using the local SMTP service pickup directory. &lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoSendUsingPort &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 2 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Send
the message using the network (SMTP over the network). &lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoAnonymous &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 0 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Do
not authenticate&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoBasic &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 1 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'basic
(clear-text) authentication&lt;/span&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Const&lt;/span&gt; cdoNTLM &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 2 &lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'NTLM&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Set&lt;/span&gt; objMessage &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;CreateObject&lt;/span&gt;(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"CDO.Message"&lt;/span&gt;) 
&lt;br&gt;
objMessage.Subject &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"Serwer
"&lt;/span&gt; &amp;amp; addr &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"
shutdown/restart"&lt;/span&gt; 
&lt;br&gt;
objMessage.From &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"""RRdTooL
Server Watch"" &amp;lt;pkrzysz@pjwstk.edu.pl&amp;gt;"&lt;/span&gt; 
&lt;br&gt;
objMessage.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;To&lt;/span&gt; &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; msgTo 
&lt;br&gt;
objMessage.TextBody &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; textBody&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'==This
section provides the configuration information for the remote SMTP server.&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/sendusing"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 2 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Name
or IP of Remote SMTP Server&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpserver"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"dfs2"&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Type
of authentication, NONE, Basic (Base64 encoded), NTLM&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; cdoNTLM 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Server
port (typically 25)&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpserverport"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 25 
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Use
SSL for the connection (False or True)&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpusessl"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;False&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'Connection
Timeout in seconds (the maximum time CDO will try to establish a connection to the
SMTP server)&lt;/span&gt;
&lt;br&gt;
objMessage.Configuration.Fields.&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Item&lt;/span&gt; _&lt;br&gt;
(&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"&lt;/span&gt;) &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; 60&lt;br&gt;
&lt;br&gt;
objMessage.Configuration.Fields.Update&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: green; font-family: Courier New; background-color: transparent;"&gt;'==End
remote SMTP server configuration section==&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
objMessage.Send 
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Function&lt;/span&gt; WMIDateStringToDate(dtmDate)&lt;br&gt;
WScript.Echo dtm: 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WMIDateStringToDate &lt;span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent;"&gt;=&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;CDate&lt;/span&gt;(&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Mid&lt;/span&gt;(dtmDate,
5, 2) &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"/"&lt;/span&gt; &amp;amp;
_&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Mid&lt;/span&gt;(dtmDate,
7, 2) &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"/"&lt;/span&gt; &amp;amp; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Left&lt;/span&gt;(dtmDate,
4) _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"
"&lt;/span&gt; &amp;amp; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Mid&lt;/span&gt; (dtmDate,
9, 2) &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;":"&lt;/span&gt; &amp;amp; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Mid&lt;/span&gt;(dtmDate,
11, 2) &amp;amp; &lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;":"&lt;/span&gt; &amp;amp; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Mid&lt;/span&gt;(dtmDate,13,
2))&lt;br&gt;
&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;End&lt;/span&gt; &lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;Function&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;&lt;font color="#000000"&gt;Skrypt
ten wysyła emaila do administratora , ze maszyna przeszła w tryb restartu/shutdownu,
oraz podaje odpowiedni wpis z dziennika zdarzeń. Jak mozna zauwazyc, w skrypcie sa
pobierane wszystkie wartosci z logu system o id 1074, a nie tylko ostatnia - wynika
to ze w WQL brakuję prostego słowa kluczowego TOP.&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;&lt;span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent;"&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://umniedziala.pl/aggbug.ashx?id=a40e3a73-bd8e-4359-9f98-507812fae82f" /&gt;</description>
      <comments>http://umniedziala.pl/CommentView,guid,a40e3a73-bd8e-4359-9f98-507812fae82f.aspx</comments>
      <category>Monitoring</category>
      <category>Windows</category>
    </item>
  </channel>
</rss>