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

Monitor the byte count over 4G Cellular interface(s)

LTE subscription plans tend to provide for an amount of monthly traffic that can be sent and received as part of the monthly rate plan. When that amount of traffic is exceeded within a monthly period, overage charges may be applied, or those bytes may be subtracted from a pool of bytes allowed for an organization with multiple subscriptions.


An organization may wish to track and be advised when an LTE attached device approaches the byte count provided with that device’s monthly subscription. This may be simply for informational purposes, or to allow for a change to the routing policy. This could include using an alternate last mile access for communications for the remainder of the period.


This “Byte Count Monitor” EEM sample solution provides a way to track monthly usage of 4G LTE interfaces on an ISR. The script logs (to syslog and console) the amount of traffic sent and received on an LTE interface at the end of each monthly period. Also, if the amount of traffic within the monthly period exceeds a configurable threshold (percentage) of the monthly usage plan, a (syslog/console) message is logged on the ISR. 

The app has been enhanced to optionally reroute traffic from the cellular interface (by automatically “shutting” the cell interface) if the monthly data usage plan has been exceeded.  This option would be available if there is an alternate WAN interface.  On the date of the month that the subscription’s byte count refreshes, the interface would be re-enabled automatically by the app.  If this option is not enabled, the app will operate as described above.


If the app is enabled along with the "commandoversms" app (allows out-of-band ISR management via text message available here:, texting the word "usage" to the ISR returns the current number of bytes used during the current monthly subscription period and the percentage of the byte plan used.


The attached zip file includes the TCL file and a word document that explains the details of the logic used to monitor the amount of traffic over a 4G interface and present alarms when the byte count percentage goes over a  given threshold. 


Version 3.1

Community Member

Hello and thanks for this.

I test it with our C819G-4G-NA-K9, however in the flash:Cellular0.txt always shows 0 bytes.

The configuration is according to your document.. i don´t know why isn´t working.. Can you give me some guidance.

Here are some of the outputs:

RO_4G#sh run | s event man
event manager environment _bytes_allowed 1000000000
event manager environment _dom 29
event manager directory user policy "flash:/"
event manager policy byte_counter.tcl type user
RO_4G#sh clock
00:30:18.211 GMT Fri Jan 29 2016

RO_4G#sh event man pol reg
No. Class Type Event Type Trap Time Registered Name
1 script user timer cron Off Thu Jan 28 14:50:11 2016 byte_counter.tcl
name {byte_counter.tcl} cron entry {0,30 * * * *}
nice 0 queue-priority normal maxrun 55.000 scheduler rp_primary Secu none



Cisco Employee

I believe 0 bytes is expected based on what you have shared.   The day of the month (DOM) is the 29th and at 00:00 on DOM the counters are reset and the Cellular0.txt is also reset to zero to begin the new month.   Your time is 00:18 and the policy will not run until 00:30 and if there are bytes on the interface that should be reflected in Cellular0.txt at 00:30.

Community Member

Hi Daniel, thanks for your response.

I have this question:

If i issue the clear counters command on cellular 0 interface, the actual input kb is send to Cellular0.txt immediately or in a later time?


Cisco Employee

Cellular0.txt is updated when the policy runs and in your setup every 30 minutes.   Clear counters will not update Cellular0.txt file immediately or later.

Community Member

Hi Daniel,

Thank you for this... Now i see that the script is working as expected. 


Community Member



I configured it but seems  there is an issue when we clear the counter (or reboot)


Dec 28 15:20:01.489 gmt: %HA_EM-6-LOG: byte_counter.tcl: (598874565.0 + 868529266.0 ) - 0
Dec 28 15:20:01.489 gmt: %HA_EM-6-LOG: byte_counter.tcl: totalbytes = 1467403831.0


It's OK. I downloaded for 1.4 Gbytes.


Dec 28 15:20:51.675 gmt: %CLEAR-5-COUNTERS: Clear counter on all interfaces by admin on vty0 (
Dec 28 15:30:01.474 gmt: %HA_EM-6-LOG: byte_counter.tcl: (9932251.0 + 1467403831.0 ) - 598874565.0
Dec 28 15:30:01.474 gmt: %HA_EM-6-LOG: byte_counter.tcl: totalbytes = 878461517.0


After that only 878Mbytes was counted.