Menu

WMICHECK results not useful to Nagios

Help
2008-03-01
2013-04-25
  • John Rogers

    John Rogers - 2008-03-01

    I have some windows domain information that I want to collect state information from. I have identified the WMI that I want and figured out how to make it work with nc_net, but I am not sure how to get Nagios to interprest the results of my query.

    /usr/local/nagios/libexec/check_nc_nt -H $DCIP$ -v WMICHECK -t 40 -l "MicrosoftActiveDirectory&select FlatName,TrustStatus from Microsoft_DomainTrustStatus where FlatName='DOMAINA'" -w 1

    instance of Microsoft_DomainTrustStatus { FlatName = "DOMAINA"; TrustStatus = 0; };

    Nagios complains with (No output returned from plugin), but I assume that because the output is not per the Nagios plugin API standard. I am not sure how to get it that way either.

    If you can offer some advice that would be great.

    Thanks

     
    • tony

      tony - 2008-03-01

      Correct WMICHECK is for viewing WMI remotly
      this is due to many WMI Queries may be an Undetermined Size and have an undetermined amount of instances.

      while WMICAT and WMICOUNTER are for reporting to nagios

      use check_nc_net help to get the syntex

      check_nc_net --help
      check_nc_net --help=WMICAT
      check_nc_net --help=MWICOUNTER

      let us know if this resolves your issues
      TOny

       
    • John Rogers

      John Rogers - 2008-03-03

      I see. So WMICAT and WMICOUNTER do not support where statement, correct? Because of the nature of my environment Microsoft_DomainTrustStatus returns multiple instances. I created a shell wrapper for WMICHECK and it gets me the info I need. Its kind of hacky, but I am happy with the result. Thanks Tony!

      cat check_dtstat
      #!/bin/bash

      PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

      PROGNAME=`basename $0`
      PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
      REVISION=`echo '$Revision: 0.2 $' | sed -e 's/[^0-9.]//g'`

      . $PROGPATH/utils.sh

      dc=$1
      domain=$2
      dtstatus=`/usr/local/nagios/libexec/check_nc_nt -H $dc -v WMICHECK -t 40 -l "MicrosoftActiveDirectory&select FlatName,TrustStatus from Microsoft_DomainTrustStatus where FlatName='$domain'" -w 1|grep "TrustStatus ="|awk -F ";" '{print $1}'|awk '{print $3}'`

      statusmessage=`/usr/local/nagios/libexec/check_nc_nt -H $dc -v WMICHECK -t 40 -l "MicrosoftActiveDirectory&select FlatName,TrustStatusString from Microsoft_DomainTrustStatus where FlatName='$domain'" -w 1|grep "TrustStatusString ="|awk -F \" '{print $2}'`

      case "$dtstatus" in
              *)
                      if test $dtstatus -eq 0; then
                              echo "OK - $domain:$statusmessage"
                              exit 0
                      elif test $dtstatus -ne 0 ; then
                              echo "CRITICAL - $domain:$statusmessage"
                              exit 2
                      fi
                      if test $dtstatus -z; then
                              echo "CRITICAL - Invalid Data"
                              exit 2
                      else
                              echo ok
                              exit 0
                      fi
                      ;;
      esac

       
      • tony

        tony - 2008-03-04

        Actually I thought they took the same syntex as WMICHECK thus I thought the where clause was accepted.

        The WMICOUNTER should evaluate to a collection of items that are Numbers then the numbers are compared to the -w and -c values (if they were given) and the MAx/MIn value is then reported based on exact conditions of the command.

        But if the script works thats good as well, thanks for posting it.

        Tony

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.