article Agentcmd Logging Info Interferes With Custom Monitor Output

In 7.2 the agentcmd has extra logging enabled that often interferes with the regular output from a custom monitor.  It is possible to omit this extra logging output with the following steps. 

If you find your custom monitor behaves differently after upgrading to up.time 7.2, you can verify if the agentcmd logging output is the culprit by running the following command. 

<uptime_dir>/scripts/agentcmd -s -p 9998 localhost ver

If the output returned contains "Initialized AgentCommunicatorApp", then continue with the steps below to resolve.


Linux Monitoring Station:
1. Edit the agentcmd.jcnf file in the scripts directory of the monitoring station:
In the following section:
[jvm.additional.args]
-d64

Add:
-Dlog4j.configuration=file:///usr/local/uptime/log4j.properties

So should now see:
[jvm.additional.args]
-d64
-Dlog4j.configuration=file:///usr/local/uptime/log4j.properties
 
2. Create a log4j.properties file in the uptime directory and populate it with the following lines.
log4j.rootLogger=WARN, THIRDPARTY

#console logger
log4j.appender.CONSOLE=org.apache.log4j.RollingFileAppender
log4j.appender.CONSOLE.MaxFileSize=10MB
log4j.appender.CONSOLE.MaxBackupIndex=0
log4j.appender.CONSOLE.File=logs/uptime_scripts.log
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d | %p | %X{context} | %t | %c | %m%n

#third party code logger - thirdparty.log
log4j.appender.THIRDPARTY=org.apache.log4j.RollingFileAppender
log4j.appender.THIRDPARTY.MaxFileSize=10MB
log4j.appender.THIRDPARTY.MaxBackupIndex=0
log4j.appender.THIRDPARTY.File=logs/thirdparty.log
log4j.appender.THIRDPARTY.layout=org.apache.log4j.PatternLayout
log4j.appender.THIRDPARTY.layout.ConversionPattern=%d | %p | %X{context} | %t | %c | %m%n

3. Now you should be able to run the agentcmd and see only the expected output.  The new extra logging lines from agentcmd are now redirected to logs/uptime_scripts.log which will rollover whenever it reaches 10mb, so it will never exceed 10mb.



Windows Monitoring Station:
1. Create a agentcmd.l4j.ini file in the scripts directory of the up.time Monitoring Station with the following contents.

# Launch4j runtime config
-Dlog4j.configuration="file:/D:/Program Files/uptime software/uptime/log4j.properties"
## -Dlog4j.debug=true

2. Create a log4j.properties file in the uptime directory and populate it with the following lines.
log4j.rootLogger=WARN, THIRDPARTY

#console logger
log4j.appender.CONSOLE=org.apache.log4j.RollingFileAppender
log4j.appender.CONSOLE.MaxFileSize=10MB
log4j.appender.CONSOLE.MaxBackupIndex=0
log4j.appender.CONSOLE.File=logs/uptime_scripts.log
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d | %p | %X{context} | %t | %c | %m%n

#third party code logger - thirdparty.log
log4j.appender.THIRDPARTY=org.apache.log4j.RollingFileAppender
log4j.appender.THIRDPARTY.MaxFileSize=10MB
log4j.appender.THIRDPARTY.MaxBackupIndex=0
log4j.appender.THIRDPARTY.File=logs/thirdparty.log
log4j.appender.THIRDPARTY.layout=org.apache.log4j.PatternLayout
log4j.appender.THIRDPARTY.layout.ConversionPattern=%d | %p | %X{context} | %t | %c | %m%n
3. Wherever the agentcmd command is being called from (ie. your custom monitor script), update the agentcmd line to include the --l4j-debug option.  For example, if the line looked like this:

$NETCAT -p $port $hostname rexec $password $customscript

Then you will want to change it to look like this:

$NETCAT --l4j-debug -p $port $hostname rexec $password $customscript

Related Articles


Custom monitor not matching correct output

RatingViews
article

When executing your custom script from a windows monitoring station using a ".bat" file you may find that the following items need to be addressed. 1) Ensure you have "echo off" in your bat file....

By: uptime Support | Date Created: 8-13-2010 | Last Modified: 8-13-2011 | Index: 482

  1323

Using the agentcmd utility

RatingViews
article

This article provides an overview of using the agentcmd utility.

By: uptime Support | Date Created: 5-3-2007 | Last Modified: 6-29-2011 | Index: 169

  4916

Windows Event Log Monitor returns Output: Monitor failed: For inp...

RatingViews
article

This error indicates that the target agent server's up.time agent is incompatible with your monitoring station version. Please upgrade the agent on the impacted server and verify that this error is...

By: uptime Support | Date Created: 8-26-2010 | Last Modified: 8-10-2011 | Index: 497

  2694

Enabling Audit Logging in up.time

RatingViews
article

By: uptime Support | Date Created: 6-14-2006 | Last Modified: 2-27-2013 | Index: 078

  2906

Creating Custom Service Monitors with Retained Data Collection

RatingViews
article

By: uptime Support | Date Created: 5-15-2006 | Last Modified: 12-16-2011 | Index: 067

  10140

User Comments



No comments have been posted.

Copyright © 2021 IDERA, Inc.   Legal   Privacy Statement