Ok, yes the limitations are quite restricting.
For the format and the headers you can try the following GatewayScript. It worked for the tests I did in my own environment, although syslog-tcp connection seemed to time out every time. But the format seems to be correct. All the lines are not needed, the timestamp handling might be a bit crude but didn't have the time to refine all the bits and pieces.
//Load modules
var transform = require('transform');
// Get the service metadata
var sm = require('service-metadata');
// Create timestamp
var currentdate = new Date();
var datetime = currentdate.getFullYear() + '-'
+ addZero(currentdate.getMonth()) + '-'
+ addZero(currentdate.getDate()) + 'T'
+ addZero(currentdate.getHours()) + ':'
+ addZero(currentdate.getMinutes()) + ':'
+ addZero(currentdate.getSeconds()) + '.'
+ currentdate.getMilliseconds() + 'Z';
// Extract DP service name and transaction id
var service = sm.processorName;
var transactionid = sm.transactionId
//Create audit message XML
var auditmessage = '<AuditMessage><element1>some audit value 1</element1><element2><element3>some audit value 2</element3></element2></AuditMessage>';
//Create XPATH for extracting hostname
var xpathOptions = { "expression" : "//*[local-name()='device-name']/text()","xmldom" : XML.parse(sm.system.ident)};
transform.xpath(xpathOptions,function(err, devicename) {
if (err) {
session.out.write(err);
} else {
var stringifyOptions = {omitXmlDeclaration: true};
// Create the syslog message payload, 13 is for notice
// level log entry
var syslog = '<13>1 '
+ datetime + ' '
+ XML.stringify(stringifyOptions,devicename) + ' '
+ service + ' '
+ transactionid + ' '
+ transactionid + ' - '
+ auditmessage;
//Calculate size of the message
var size = Buffer.byteLength(syslog);
// Write payload into output
session.output.write(size + ' ' + syslog);
}
});
function addZero(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
#DataPower#Support#SupportMigration