Versions Compared

    Key

    • This line was added.
    • This line was removed.
    • Formatting was changed.

    ...

    1. Create a new directory in the custom monitor repository.
    2. Create the script file. Here are two examples: 

      Modify this UNIX script for the specific process name (for example: Author, Publish, and so on).

      No Format
      lookfor="<process name 1>"
      pid=`ps aux | grep "$lookfor" | grep -v grep | tr -s " " | cut -f2 -d' '`
      count1=`lsof -p $pid | wc -l | xargs`
      
      lookfor="<process name 2>"
      pid=`ps aux | grep "$lookfor" | grep -v grep | tr -s " " | cut -f2 -d' '`
      count2=`lsof -p $pid | wc -l | xargs`
      
      echo "name=JVM|Files|<process name 1>,value="$count1
      echo "name=JVM|Files|<process name 2>,value="$count2


      Anchor
      windows-bat-example
      windows-bat-example
      The following Windows .bat example reports a metric to the Controller if it a Java process is running on the machine. 
      NOTE: To generate custom metrics on Windows, it is good practice to use PowerShell or VBasic scripts rather than .bat scripts. When a standard Windows .bat script echoes metric names, it surrounds the names with quotes. The quotes will cause the Machine Agent to ignore these metrics. PowerShell and VBasic scripts do not have this issue.

      No Format
      SETLOCAL enabledelayedexpansion
      
      REM  Check to see if there is a java process running
      TASKLIST /FI "IMAGENAME eq java.exe" 2>NUL | find /I /N "java.exe">NUL
      if "%ERRORLEVEL%"=="0" (
          SET metric="Custom Metrics|Process|java|Running,value=1"
          REM This strips the quotes that are added by the bat script
          REM so that the machine agent can understand the metric
          @echo !metric:"=!
      )


    3. Create the following monitor.xml file and point it to the UNIX script shown in step 2.

      No Format
      <monitor>
          <name>MyMonitors</name>
          <type>managed</type>
          <description>Monitor open file count </description>
          <monitor-configuration>
          </monitor-configuration>
          <monitor-run-task>
              <execution-style>continuous</execution-style>
              <name>Run</name>
              <type>executable</type>
              <task-arguments>
              </task-arguments>
              <executable-task>
                  <type>file</type>
                  <file>openfilecount.sh</file>
              </executable-task>
          </monitor-run-task>
      </monitor>

    Watch the Video

    HTML
    <style type="text/css">.vidyard_player{width: 600px; }.vidyard_player > span{max-width: 600px !important; max-height: 360px!important;margin-left:0!important;}.innerContainer{position: relative; display: block; width: 100% !important; height: 0; }</style><script type="text/javascript" id="vidyard_embed_code_SJZcgtkBiw4gjHuUdrPbMP" src="//play.vidyard.com/SJZcgtkBiw4gjHuUdrPbMP.js?v=3.1.1&type=inline&second=0"></script>

    For full-screen viewing, click Overview of Custom Extensions.