instead of waiting for an event to happen you can generate an event using the logger command from the cli.
First you need to get the attribute of the event if you want to pass an argument to the script. Use "help syslog <command>"
jnpr@router> help syslog UI_CHILD_EXITED
Name: UI_CHILD_EXITED
Message: Child exited: PID <pid>, status <return-value><core-dump-status>, command '<command>'
Help: Child process of mgd exited
In help syslog the attribute will be displayed inside the <> bracket.
pid, return-value, core-dump-status, and command are the attributes
jnpr@router# show event-options
policy test {
events ui_child_exited;
then {
event-script test.slax {
arguments {
mib "{$UI_CHILD_EXITED.pid}";
}
output-filename ARG;
destination local;
}
}
}
destinations {
local {
archive-sites {
"ftp://user:password@192.168.1.1";
}
}
}
go into shell as root and then issue the logger command
logger [-e event-id/tag] [-p priority] [-d daemon] [-a attr=value]
[message]
root@router% logger -e UI_CHILD_EXITED -a "pid=111" test-syslog-message
jnpr@router# run show log messages
Jun 30 23:57:45 router clear-log[6242]: logfile cleared
Jun 30 23:58:01 router logger: UI_CHILD_EXITED: test-syslog-message
Jun 30 23:58:02 router root: invoke-commands: Executed /tmp/evt_cmd_k0dUOC, output to /tmp/evt_op_YRuPs6 in text format
Jun 30 23:58:02 router ftpd[6259]: connection from 192.168.1.1 (192.168.1.1)
Jun 30 23:58:02 router ftpd[6259]: FTP LOGIN FROM 192.168.1.1 as user
Jun 30 23:58:02 router root: transfer-file: Transferred /tmp/evt_op_YRuPs6
[edit]
jnpr@router# run file show router_ARG_20090701_065802
root@router> op test.slax mib "111"
111
------------------
script
------------------
root@router% more test.slax
version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
var $arguments = <argument> {
<name> "mib";
}
param $mib;
match / {
<op-script-results> {
<output method = "text"> {
expr $mib;
<xsl:document href = "/var/home/jnpr/text.txt"> {
copy-of $mib;
}
}
}
No comments:
Post a Comment