Here is what is happening:

[EMAIL PROTECTED]:/home/InterMapper/InterMapper_Settings/Tools$ ./wmi-service.sh
monza2 MSExchangeMTA Running domain administrator password
Running

So the script outputs the word Running as a result.

----------------------------------

Here is the script (I was just trying your stdout tip):

#!/bin/sh
# Expects wmi-service.sh ${ADDRESS} ${Service Name} ${State} ${Domain}
${Username} ${Password}

result=`wmic -U $4/$5%$6 //$1 "Select Name,State from Win32_Service where
name='$2'" | awk -F\| -v msx=$2 '$0 ~ msx {print $2}'`

echo $result

#echo "\{ \$service := \"$2\",\$realstate := \"$result\", \$addr := \"$1\"
}"

So we know for fact that $Result equals "Running"

-------------------------------

Here is the probe:

[EMAIL PROTECTED]:/home/InterMapper/InterMapper_Settings/Probes$ cat
com.i2c.cli.wmi 
<!--
        WMI Command line probe  (com.i2c.cli.wmi)
        created on 9/11/08 by Andrey Gordon
-->

<header>
        "type"          =       "cmd-line"
        "package"       =       "com.i2c"
        "probe_name"    =       "cli.wmi"
        "human_name"    =       "CLI WMI"
        "version"       =       "1.0"
        "address_type"  =       "IP"
        "display_name"  =       "Servers-Proprietary/Microsoft/Service
Status"

</header>

<description>
\b0\WMI Service Status Probe\p0\

This probe uses debian wmi-client package to poll windows based target for
specified service status.

\i0\Service Name\p0\ is the name of the service that needs to be monitored.
The service name can be found under service properties on the general tab..

\i0\State\p0\ is the state of the service that needs to be maintainted to
keep the probe in OK status.

\i0\Domain\p0\ is the domain name that the probe will login with.

\i0\Username\p0\ is the username the probe will login with.

\i0\Password\p0\ is the password that the probe will login with.

</description>

<parameters>
        "Service Name"  =       "SMTPSVC"
        "State"         =       "Running"
        "Domain"        =       ""
        "Username"      =       "Administrator"
        "Password"      =       ""
</parameters>

<command-line>
path = ""
cmd = "wmi-service.sh ${ADDRESS} ${Service Name} ${State} ${Domain}
${Username} ${Password}"
</command-line>

<command-exit>
down: ${EXIT_CODE} = 2
alarm: ${EXIT_CODE} = 1
okay: ${EXIT_CODE} = 0
</command-exit>

<command-display>
\b5\Service Status\0p\
  \4\Service:\0\   ${Service Name} is ${RealState} on ${addr}
${^stdout}
</command-display>

And here is the Status Window:

Device Status
       Name: monza2
   DNS Name: monza2.i2c.com.
  WINS Name: MONZA2
    Address: 10.1.0.16
     Status: UP 
      Probe: CLI WMI
    Up Time: n/a
  Availability:            100 % (of 17 hours, 6 minutes, 32 seconds)
  Packet Loss:             0.0 % (of 0 total attempts)
  Short-term Packet Loss:  0.0 % (of 0 last attempts) [Reset]
  Recent Loss:  None
  Response time:  128 msec

  Retention Policy: 1m6m1y2y (-2), Exportable

Service Status
  Service:   MSExchangeMTA is  on 10.1.0.16

Last updated Sep 12, 11:31:52; interval: 30 seconds

-------------------------------

What's strange is even ${^stdout} does not produce results, you can see an
empty line where the output of that should be.

Another interesting thig is that the content of the variables that are
commented out in the script for testing purposes (the last echo line) are
still displaying. So I think it caches the contents of those variables or
something?

__________________________________________________________
Andrey Gordon | Integrity Interactive | Network Engineer | +1.781.398.3518




____________________________________________________________________
List archives: 
http://www.mail-archive.com/intermapper-talk%40list.dartware.com/
To unsubscribe: send email to: [EMAIL PROTECTED]

Reply via email to