PortSensor Monitor Configuration

From PortSensor Wiki

Jump to: navigation, search

After you've installed and configured your monitor using the command line configuration ( jre/bin/java -jar psmonitor.jar --config ) you may find that there are other more advanced things you want to monitor in addition to the defaults that were auto created for you.

To do this open the config.xml file into an text editor. You should see something like:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <settings>
    <portal_url>http://localhost/portsensor/post</portal_url>
    <monitor_guid>green.monitor</monitor_guid>
    <secret_key>Y8DA6Z19PHQWXJ32NF3C</secret_key>
  </settings>
  <!--localhost-->
  <device id="green.wgm">
    <sensor>
      <name>HTTP</name>
      <command>#PORT localhost 80</command>
      <type>text</type>
      <critical oper="eq" value="DOWN">Critical</critical>
    </sensor>
    <sensor>
      <name>Disk Space</name>
      <command>df | grep /dev/sda3 | awk '{print $5}'</command> 
      <type>decimal</type>
      <warning oper="gt" value="80.0">Low Disk</warning>
      <critical oper="gt" value="95.0">Critical Disk</critical>
    </sensor>
    <sensor>
      <name>HTTP-SSL</name>
      <command>#PORT localhost 443</command>
      <type>text</type>
      <critical oper="eq" value="DOWN">Critical</critical>
    </sensor>
    <sensor>
      <name>MySQL</name>
      <command>#PORT localhost 3306</command>
      <type>text</type>
      <critical oper="eq" value="DOWN">Critical</critical>
    </sensor>
  </device>
</configuration>

Contents

[edit] Adding a Sensor

If we want to add our own custom command line command we can do so by creating a new sensor element at the same level in the document as the other sensor elements. You can easily copy and paste the contents of one of the existing sensor elements for this purpose.

[edit] Required Sensor Elements

[edit] <name>

Set the value to any human-readable name to describe what the sensor does. This value will display in any gui or feed.

[edit] <command>

The command value can take one of two different forms. If the field starts with "#PORT" it will automatically check a given port of the server specified. The complete format for this kind of port check is: #PORT [hostname] [port-number]

Alternatively, you can set the command text to any command you want your machine to run locally at the command line. Keep in mind that it will run the command as the current user, so it's best to make a dedicated 'portsensor' user with appropriate restrictions/permissions.

[edit] <type>

The type tell PortSensor what kind of result it should expect as a result of the command entered. The possible values are "text", "number" (for whole numbers), and "decimal".

[edit] Optional sensor elements:

[edit] <warning>

The warning element allows you to create a rule that will change the status of the sensor to a warning state. When a sensor is put in a warning state it will display with a yellow icon on the PortSensor server and on the PortSensor client (although the client allows you to override this fact). The "oper" attribute of the tag is where you choose the operator for the rule you're creating. Valid operator values are:

eq 
result is equal to
neq 
result is not equal to
lt 
result is less than
gt 
result is greater than

The "value" attribute is where you specify the value that the command result will be compared against.

The text you put between the <warning> and </warning> tags should be a description of the state the sensor is in if the specified rule passes. This value will be displayed on the PortSensor Server as well as on the PortSensor client, and in the notifications.

[edit] <critical>

The critical element is like the warning element, but any rule created will change the sensor status to critical, and display a red icon on the server.

[edit] Example:

if we want to create a sensor to monitor the load of one of our devices we could create the xml element like:

<sensor>
        <!-- Any descriptive name can go here -->
	<name>Load</name> 
	
        
        <!-- command line command to run -->
        <command>cat /proc/loadavg | awk '{print $1}'</command> 
	
        <!-- we expect our load command to give a decimal result -->
        <type>decimal</type>
	
        <!-- 
        if the result load value is greater than 5, set the state of the sensor to "warning" 
        The sensor will display as yellow in the PortSensor client and the web portal
        -->
        <warning oper="gt" value="5.0">Moderate Load</warning>
	
        
        <!--
        If the result load value is greater than 15, set the state of the sensor to "critical"
        The sensor will display as red in the PortSensor client and the web portal
        -->
        <critical oper="gt" value="15.0">High Load</critical>
</sensor>
Personal tools