Appending alert notifications to a file using JON CLI
Environment
- Red Hat JBoss Operations Network (ON) 3.3
- ON CommandLine Interface (CLI) 3.3
- With Alert notification CLI Script below:
var e = exporter
var alertDate = new Date()
e.setTarget( 'csv', '/home/a539836/JON-alerts.log' )
e.write( alertDate + ',' + alert.alertDefinition.name + ',' + alert.alertDefinition.description )
Issue
- Is there a way to append to a central log file using CLI?
Resolution
Use java.io.FileWriter instead of JBoss ON CLI exporter method:
var alertDate = new Date()
var alertNew = ( alertDate + ',' + alert.alertDefinition.name + ',' + alert.alertDefinition.description )
var filename= "/home/a539836/JON-alerts.log";
var fw = new java.io.FileWriter(filename,true);
fw.write(alertNew);
fw.close();
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
