Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

EEM Script to monitor Cellular RSSI , write to file for inspect of result

Hi, can some-one please assist with suggestions for an EEM script to monitor the Cellular RSSI which the results can be checked by the script for IP routes to be removed and added for traffic to be sent to the same end-point for an IPsec tunnel but through alternate paths.

 

I have a c9141 router connecting Cellular and establishing an IPsec tunnel to an ASA. If the NextG signal fails, I wish the connection to fail over to a Satellite path but still to the same end point.

 

Many Thanks

 

David

11 REPLIES
Community Member

This is what I have so far :

This is what I have so far :

 

event manager applet watch-signal
 event timer watchdog time 120
 action 001  cli command "enable"
 action 002  cli command "show cell 0 radio"
 action 003  regexp "Current RSSI = dBm" "$_cli_result" match dBm
 action 004  if $_regexp_result eq 1
 action 005   if $dBm le 90
 action 006    cli command "ip route 0.0.0.0 0.0.0.0 cellular 0/0/0"
 action 007    cli command "ip route 203.8.129.90 255.255.255.255 cellular 0/0/0"
 action 008   else
 action 009    cli command "ip route 0.0.0.0 0.0.0.0 192.168.5.1"
 action 010    cli command "ip route 203.8.129.90 255.255.255.255 192.168.5.1"
 action 011   end
 action 012   end
 action 013   end

but I can't get it to work

Cisco Employee

 Action 002 you have "cell 0"

 Action 002 you have "cell 0" while other actions call out "cellular 0/0/0".    What error messages are returned when you run the policy?

Cisco Employee

Another item to note is that

  1. Another item to note is that RSSI is expressed in negative dBM (i.e. -72 dBM).    You will need to update action 005 to be "ge -90".
  2. action 003 needs to be updated to from "Current RSSI = dBm" to "Current RSSI = (-[0-9]+) dBm $_cli_result  dBm"
Community Member

Hi Daniel,Firstly, thank you

Hi Daniel,

Firstly, thank you for taking the time to reply. I had spotted the Cell 0 mistake and that had subsequently been updated.

The script now looks like this :

event manager applet watch-signal
 event timer watchdog time 60 maxrun 120
 action 001  cli command "enable"
 action 002  cli command "show cellular 0/0/0 all | inc Current RSSI"
 action 003  regexp "Current RSSI = (-[0-9]+)dBm" "$_cli_result dBm
 action 004  if $_regexp_result le 90
 action 005   if $dBm le -90
 action 006 cli command "configure terminal"
 action 007    cli command "ip route 0.0.0.0 0.0.0.0 cellular 0/0/0"
 action 008    cli command "ip route 203.8.129.90 255.255.255.255 cellular 0/0/0"
 action 009   else
 action 010 if $dBm ge -90
 action 011    cli command "ip route 0.0.0.0 0.0.0.0 192.168.5.1"
 action 012    cli command "ip route 203.8.129.90 255.255.255.255 192.168.5.1"
 action 013   end
 action 014   end
 action 015   end

 

If I run a debug event manager all, the below are the results with what appear to be and end with normal exit and no errors. The script simply closes without moving onto action 006 thru 008 which I expect to do:

*May 15 09:02:53.465: Popping tag <fh_fd_publish_none_spec> off stack
*May 15 09:02:53.465: close tag is </fh_fd_publish_none_spec>
*May 15 09:02:53.465: Popping tag <fh_publish_event_spec> off stack
*May 15 09:02:53.465: close tag is </fh_publish_event_spec>
*May 15 09:02:53.465: EEM: policy_dir xml builtin: name:_event_type value:131
*May 15 09:02:53.465: EEM: policy_dir xml builtin: name:_event_type_string value:none
*May 15 09:02:53.465: EEM: policy_dir xml builtin: name:_event_severity value:severity-normal
*May 15 09:02:53.465: EEM: policy_dir xml builtin: name:_none_argc value:0
*May 15 09:02:53.465: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : CTL : cli_open called.
*May 15 09:02:53.465: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : OUT : reeve000mwwr01#
*May 15 09:02:53.465: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : IN  : reeve000mwwr01#enable
*May 15 09:02:53.465: cli_history_entry_add: free_hist_list size=0, hist_list size=7
*May 15 09:02:53.465: eem_no_scan flag set, skipping scan of command_string=check_eem_cli_policy_handler
*May 15 09:02:53.477: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : OUT : reeve000mwwr01#
*May 15 09:02:53.477: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : IN  : reeve000mwwr01#show cellular 0/0/0 all | inc Current RSSI
*May 15 09:02:53.481: cli_history_entry_add: free_hist_list size=0, hist_list size=7
*May 15 09:02:53.481: eem_no_scan flag set, skipping scan of command_string=check_eem_cli_policy_handler
*May 15 09:02:53.489: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : OUT : Current RSSI = -76 dBm
*May 15 09:02:53.489: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : OUT : reeve000mwwr01#
*May 15 09:02:53.489: %HA_EM-6-LOG: watch-signal : DEBUG(cli_lib) : : CTL : cli_close called.
*May 15 09:02:53.489: fh_server: fh_io_msg: received msg FH_MSG_CALLBACK_DONE from client 2930 pclient 2
*May 15 09:02:53.489: fh_io_msg: EEM callback policy watch-signal has ended with normal exit status of 0x0
*May 15 09:02:53.489: EEM fms_remote_chkpt_add_event_hist(), data_len = 2980, buf_size = 2992
*May 15 09:02:53.489: fh_send_none_fd_msg: msg_type=18
*May 15 09:02:53.489: fh_fd_none_publish_done: rc=0, re=280C71D4
*May 15 09:02:53.489: fh_fd_none_publish_done: rc=0, publish_expired=0
*May 15 09:02:53.489:   sid=51, ptp=0x280C6314, connp=0x2802D32C
*May 15 09:02:53.489: none_conn_tm_remove: re=0x280C71D4, ptp=0x280C6314
*May 15 09:02:53.489: fh_fd_none_conn_tm_free: ptp=0x280C6314
*May 15 09:02:53.489: fh_send_none_fd_msg: sval=0
*May 15 09:02:53.489: EEM: server decrements in use thread: jobid=2928 rule id=3 in use thread=0.
*May 15 09:02:53.489: fh_schedule_callback: fh_schedule_callback: cc=313D0DC0 prev_epc=30050C0C; epc=0
*May 15 09:02:53.489: EEM server schedules callbacks: policy_type: 2
*May 15 09:02:53.489: fh_schedule_policy: prev_epc=0x0; epc=0x0
*May 15 09:02:53.489: EEM server schedules scripts
*May 15 09:02:53.489: fh_server: fh_io_msg: received msg FH_MSG_API_CLOSE from client 2930 pclient 2
*May 15 09:02:53.489: fh_io_msg: received FH_MSG_API_CLOSE client=2930
*May 15 09:02:53.489: fh_fd_match_event: re=0x280C71D4, policyname=watch-signal, parameters=, get_tty=1
*May 15 09:03:00.001: fh_fd_timer_process_async
*May 15 09:03:00.001: cron_tick: num_matches 0

 

Cisco Employee

Still not quite right.   Try

Still not quite right.   Try this.

 

event manager applet watch-signal
 event timer watchdog time 60 maxrun 120
 action 001  cli command "enable"
 action 002  cli command "show cellular 0/0/0 all | inc Current RSSI"
 action 003  regexp "Current RSSI = (-[0-9]+) dBm" $_cli_result  dBm

 action 005 cli command "configure terminal"
 action 006   if $dBm le -90

 action 007    cli command "ip route 0.0.0.0 0.0.0.0 cellular 0/0/0"
 action 008    cli command "ip route 203.8.129.90 255.255.255.255 cellular 0/0/0"
 action 009   else

 action 011    cli command "ip route 0.0.0.0 0.0.0.0 192.168.5.1"
 action 012    cli command "ip route 203.8.129.90 255.255.255.255 192.168.5.1"
 action 013   end
 

Community Member

did you actually get this to

did you actually get this to work? I am seeing issue in evaluating the (-) value. It doesn't seem to matter whether we use le or ge the negative number. I am using this to determine which SIM/provider to use via route injection.

Cisco Employee

I had a typo above.  Updated

I had a typo above.  Updated with this policy.

=================

event manager applet watch-signal

event timer watchdog time 60 maxrun 120

action 010 cli command "enable"

action 020 cli command "show cellular 0/0/0 all | inc Current RSSI"

action 030 regexp "Current RSSI = (-[0-9]+) dBm" "$_cli_result" match dBm

action 040 cli command "configure terminal"

action 050 if $dBm ge "-90"

action 055  puts "DBM = $dBm, match >= -90"

action 070  cli command "ip route 203.8.129.90 255.255.255.255 cellular 0/0/0"

action 080 else

action 085  puts "DBM = $dBm, match < -90"

action 100  cli command "ip route 203.8.129.90 255.255.255.255 192.168.5.1"

action 110 end

===========================

When policy runs it displays a message with the value of RSSI.

Nov 22 18:14:07: %HA_EM-6-LOG: watch-signal: DBM = -62, match >= -90

C1921#sh run | inc  203.8.129.90

ip route 203.8.129.90 255.255.255.255 Cellular0/0/0

Community Member

Thanks for the response. The

Thanks for the response. The platform I am working on is a little different as it has two internal modems that are active/active (IR829). We are trying to pick an RSSI value to go with and impact traffic paths via static routes. Obviously we will change the run times, but are still hitting an issue where the second variable doesn't seem to populate; therefore the comparison cannot happen. Any ideas or obvious things stick out here? We also put some cleanup commands in so you don't end up with two floating static routes. I was also trying to find the OID for RSSI per modem on this platform, but can't find it online anywhere.

event manager applet BESTRSSI
event timer watchdog time 60 maxrun 120
action 010 cli command "enable"
action 020 cli command "show cellular 0/0 all | inc Current RSSI"
action 030 regexp "Current RSSI = (-[0-9]+) dBm" "$_cli_result" match VZW
action 040 puts "RSSI for cellular 0/0 $VZW"
action 050 cli command "show cellular 1/0 all | inc Current RSSI"
action 060 regexp "Current RSSI = (-[0-9]+) dBm" "$_cli_result" match ATT
action 070 puts "RSSI for cellular 1/0  $ATT"
action 080 cli command "configure terminal"
action 090 if $ATT le $VZW
action 100  cli command "ip route 0.0.0.0 0.0.0.0 cellular 0/0"
action 110  cli command "no ip route 0.0.0.0 0.0.0.0 cellular 1/0"
action 120 else
action 130  cli command "ip route 0.0.0.0 0.0.0.0 cellular 1/0"
action 140  cli command "no ip route 0.0.0.0 0.0.0.0 cellular 0/0 "
action 150 end

Cisco Employee

Nothing stands out, and looks

Nothing stands out, and looks like it should work.  ATT RSSI is not getting populated?  

Enable "debug event manager all" and run the EEM policy.

Community Member

you got it Daniel. For some

you got it Daniel. For some reason I get a message about "unable to find variable ATT" or something similar. I will post again tomorrow when I am back on the gear.

Community Member

Did this actually worked? Tried the script suggested but...

Did this actually worked?

Tried the script suggested but I am getting this error:

 

%HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: dBm

 

 

event manager applet watch-signal
event timer watchdog time 60 maxrun 120
action 001 cli command "enable"
action 002 cli command "show cellular 0 all | inc Current RSSI"
action 003 regexp "Current RSSI(RSCP) = (-[0-9]+) dBm" "$_cli_result" match dBm
action 004 if $dBm ge "-93"
action 005 puts "DBM = $dBm, match >= -93"
action 006 cli command "configure terminal"
action 007 cli command "show cell 0 all | inc SIM"
action 008 regexp "Active SIM = ([0-9])" $_cli_result match slot
action 009 if $slot eq 1
action 010 cli command "cellular 0 lte sim activate slot 0"
action 011 else
action 012 cli command "cellular 0 lte sim activate slot 1"
action 013 end
action 014 end

786
Views
5
Helpful
11
Replies
CreatePlease to create content