Monitoring NAT
Configuring NAT Session Logs
You can configure session logs for NAT from the CLI. By default, session open and close logs are produced. However, you can request that only one type of log be produced.
To configure NAT session logs:
See Also
Monitoring NAT Pool Usage
Purpose
Use the show services nat pool detail
command
to find global NAT statistics related to pool usage. This command
is frequently used in conjunction with the show services stateful-firewall
statistics
command.
Action
user@host# show services nat pool detail Interface: ms-1/0/0, Service set: s1 NAT pool: dest-pool, Translation type: DNAT-44 Address range: 10.10.10.2-10.10.10.2 NAT pool: napt-pool, Translation type: NAPT-44 Address range: 50.50.50.1-50.50.50.254 Port range: 1024-63487, Ports in use: 0, Out of port errors: 0, Max ports used: 0 NAT pool: source-dynamic-pool, Translation type: DYNAMIC NAT44 Address range: 40.40.40.1-40.40.40.254 Out of address errors: 0, Addresses in use: 0 NAT pool: source-static-pool, Translation type: BASIC NAT44 Address range: 30.30.30.1-30.30.30.254
See Also
Using the Enterprise-Specific Utility MIB
- Using the Enterprise-Specific Utility MIB
- Populating the Enterprise-Specific Utility MIB with Information
- Stopping the SLAX Script with the CLI
- Clearing the Utility MIB
- Recovering from an Abnormal SLAX Script Exit or a SLAX Script Exit with the CLI
Using the Enterprise-Specific Utility MIB
The enterprise-specific Utility MIB enables you to add SNMP-compliant applications information to the enterprise-specific Utility MIB. The application information includes:
NAT mappings
Carrier-grade NAT (CGNAT) pools
Service set CPU utilization
Service set memory usage
Service set summary information
Service set packet drop information
Service set memory zone information
Multiservices PIC CPU and memory utilization
Stateful firewall flow counters
Session application connection information
Session analysis information
Subscriber analysis information
Traffic Load Balancer information
You use a delivered Stylesheet Language Alternative Syntax (SLAX) script to place applications information into the enterprise-specific Utility MIB. The script is invoked based on event policies (such as reboot of the router or switchover of Routing Engines) defined in an event script. The script can also be invoked from the command line as an op script. The script only runs on the primary Routing Engine. After the script is invoked, it polls data from the specified components at regular intervals using the XML-RPC API and writes the converted data to the Utility MIB as SNMP variables. The script automatically restarts after a configured polling cycle elapses.
Populating the Enterprise-Specific Utility MIB with Information
To use a SLAX script to populate the enterprise-specific Utility MIB with information:
Enable the services-oids-slax script.
user@host# set system scripts op file services-oids.slax
Configure the maximum amount of memory for the data segment during the execution of the script.
user@host# set event-options event-script max-database 512m
Enable the script.
user@host# set event-options event-script file services-oids-ev-policy.slax
(Optional) Enable the log-stats argument to allow sys logging of stateful firewall rate statistics when the event-script is run.
Display the event policies and the arguments that can be used.
user@host> show event-options event-scripts polices
event-options { policy services-oids-done { events system; attributes-match { system.message matches "Completed polling cycle normally. Exiting"; } then { event-script services-oids.slax { arguments { max-polls 30; interval 120; } } } } policy system-started { events system; attributes-match { system.message matches "Starting of initial processes complete"; } then { event-script services-oids.slax { arguments { max-polls 30; interval 120; } } } } } event-options { policy services-oids-done { events system; attributes-match { system.message matches "Completed polling cycle normally. Exiting"; } then { event-script services-oids.slax { arguments { max-polls 30; interval 120; } } } } policy system-started { events system; attributes-match { system.message matches "Starting of initial processes complete"; } then { event-script services-oids.slax { arguments { max-polls 30; interval 120; } } } } }
The
log-stats
argument does not appear, so you must enable it.Start the Linux shell.
user@host> start shell
%
Open the /var/db/scripts/event/services-oids-eve-policy.slax file for editing.
<event-options> { /* * This policy detects when the services-oids.slax script ends, then restarts it. */ <policy> { <name> "services-oids-done"; <events> "system"; <attributes-match> { <from-event-attribute> "system.message"; <condition> "matches"; <to-event-attribute-value> "Completed polling cycle normally. Exiting"; } <then> { <event-script> { <name> "services-oids.slax"; <arguments> { <name>"max-polls"; <value>"30"; } <arguments> { <name>"interval"; <value>"120"; } /* <arguments> { <name>"log-stats"; <value>"yes"; } */ } } } /* * This policy detects when the system has booted and kicks off the services-oids.slax script. * This policy hooks the 'system started' event */ <policy> { <name> "system-started"; <events> "system"; <attributes-match> { <from-event-attribute> "system.message"; <condition> "matches"; <to-event-attribute-value> "Starting of initial processes complete"; } <then> { <event-script> { <name> "services-oids.slax"; <arguments> { <name>"max-polls"; <value>"30"; } <arguments> { <name>"interval"; <value>"120"; } /* <arguments> { <name>"log-stats"; <value>"yes"; } */ } } } }
Remove the comment enclosures (
/*
and*/
) surrounding the<arguments>
tags containing“log-stats”
.Exit the Linux shell and return to the CLI.
% exit
Load the changes you made to the event script file.
user@host>request system scripts event-scripts reload
The
log-stats
argument is available the next time the event script restarts.
Set up the script logging file services-oids.log.
user@host# set system syslog file services-oids.log any info user@host# set system syslog file services-oids.log match cscript
Synchronize scripts between Routing Engines so that when a switchover of Routing Engine occurs, the event policy starts on the new primary.
To synchronize on a per-commit basis:
user@host# commit synchronize scripts
To synchronize scripts every time you execute a commit synchronize:
[edit system scripts] user@host# set synchronize user@host# commit synchronize
The script starts automatically at system boot, but you can manually start it with the CLI.
user@host> op services-oids arguments
Table 1 describes the arguments that you can use.
Table 1: Arguments for services-oids.slax Script Argument
Description
clean
A value of 1 clears all Utility MIB OIDs. Use this only to clean OID tables.
clear-semaphore
A value of 1 resets the semaphore in the Utility MIB to recover from an abnormal script exit or from a manual script exit.
debug
Prints debug messages on console.
detail
Displays detailed output.
interval
Sets the number of seconds between poll cycles (default is 120).
invoke-debugger
Invokes script in debugger mode.
log-stats
Yes value enables sys logging of stateful firewall rate statistics (default is no).
max-polls
Sets the number of poll cycles before exiting the script (default is 30).
one-cycle-only
Value of 1 quits after one cycle of polling. Event policy does not restart the script. Use this option for testing only. The default is 0.
signal-stop
A value of 1 stops the script and sets the semaphore, which causes the next iteration to exit.
silent
Prints trace messages on console if it is unset. Set it to zero-length string (“ ”) to unset it. Default is 1.
|
Pipes through a command.
Check the status of the script from the log file.
router> show /var/log/services-oids.log | no-more
Jun 27 19:51:47 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] Beginning polling cycle. Jun 27 19:51:47 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing traffic load-balance statistics Jun 27 19:51:48 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing cgnat pool detail Jun 27 19:51:48 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing cgnat mappings summary Jun 27 19:51:48 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing service-sets summary Jun 27 19:51:48 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing service-sets cpu-usage Jun 27 19:51:48 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing service-sets mem-usage Jun 27 19:51:49 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing stateful firewall statistics Jun 27 19:51:49 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing stateful firewall flow-analysis Jun 27 19:51:49 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing stateful firewall flows counts Jun 27 19:51:49 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing FW policy connections/second Jun 27 19:51:49 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing FW/NAT app connections Jun 27 19:51:51 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing service-set packet-drops Jun 27 19:51:51 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing service-set memory-usage zone Jun 27 19:51:51 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing service-set policy throughput stats Jun 27 19:51:52 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] processing ms-pic CPU amd Memory utilization stats Jun 27 19:51:52 wf-cheesypoofs cscript: services-oids.slax(v0.14):[info] 1/30 Sleeping for 110 seconds.
Verify that you are getting Utility MIB OID updates.
router> show snmp mib walk jnxUtil ascii
. . . jnxUtilCounter64Value."services10tcp-errors09CGN-SET-1" = 0 jnxUtilCounter64Value."services10tcp-errors09CGN-SET-2" = 0 jnxUtilCounter64Value."services10tcp-errors09CGN-SET-3" = 0 jnxUtilCounter64Value."services10udp-errors09CGN-SET-1" = 1119 jnxUtilCounter64Value."services10udp-errors09CGN-SET-2" = 0 . . .
To exclude the timestamp information, use
router> show snmp mib walk jnxUtil ascii | match Value
Stopping the SLAX Script with the CLI
To stop the SLAX script from the CLI:
user@host> op services-oids signal-stop 1
Clearing the Utility MIB
To clear all the utility MIB OIDs:
user@host> op services-oids clean 1
Recovering from an Abnormal SLAX Script Exit or a SLAX Script Exit with the CLI
To recover from an abnormal SLAX script exit or an SLAX script exit with the CLI:
user@host> op services-oids clear-semaphore 1