cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
826
Views
0
Helpful
0
Replies

EEM applet for scheduled based command execution

Hi,

I have a task to create an applet which will permit certain cli command execution based on time of the day. eg: no "conf-t" during working ours.

 

I did write following applet, which kind of does the thing, but it seems not very optimal for me. So I'm sharing it to you for use or suggestion for the better one.

 

!
event manager applet nonWorkingTime
event timer cron cron-entry "* 18-08 * * *"
action 0110 context retrieve key 123 variable status
action 0120 publish-event sub-system 798 type 2 arg1 0

!
event manager applet workingTime
event timer cron cron-entry "* 09-18 * * *"
action 0110 context retrieve key 123 variable status
action 0120 publish-event sub-system 798 type 1 arg1 1

!
event manager applet cliStatus
event tag 1 application sub-system 798 type 1
event tag 2 application sub-system 798 type 2
trigger
correlate event 1 or event 2
action 0120 set status $_application_data1
action 0130 context save key 123 variable status

!
event manager applet cli
event cli pattern "show inventory" sync yes
action 0110 context retrieve key 123 variable status
action 0120 if $status eq 0
action 0130 puts "Command execution denied!"
action 0140 set _exit_status 0
action 0150 end
action 0160 if $status eq 1
action 0170 puts "Command execution Allowed!"
action 0180 set _exit_status 1
action 0190 end
action 0200 context save key 123 variable status

 

! This applet should be run at first for one time
event manager applet oneTime
event none
action 0110 set status 0
action 0120 context save key 123 variable status

0 Replies 0