Advertisement
Guest User

SRX Hit Counter

a guest
Sep 24th, 2013
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. /* policy-hits.slax
  2. *
  3. * Version 1.0
  4. * Ben Dale - bdale@comlinx.com.au
  5. *
  6. * Provides a summary view of all security policies configured
  7. * on an SRX or J-Series router, including the number of hits
  8. * each policy has received (provided action count has been
  9. * enabled).
  10. *
  11. * Future version should include source and destination address
  12. * and applications from each policy
  13. */
  14.  
  15. version 1.0;
  16.  
  17. ns junos = "http://xml.juniper.net/junos/*/junos";
  18. ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
  19. ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
  20.  
  21. import "../import/junos.xsl";
  22.  
  23. match / {
  24. <op-script-results> {
  25.  
  26. /* Get a list of all security policies */
  27. var $show-security-policies = {
  28. <command> "show security policies detail";
  29. }
  30. var $policies-list = jcs:invoke( $show-security-policies );
  31. <output> jcs:printf("%-20s%-20s%-30s%-10s%-5s", "Source Zone", "Destination Zone", "Policy Name", "Action", "Hits");
  32. /* Loop through the results looking for count parameters */
  33.  
  34. for-each ($policies-list/security-context/policies) {
  35. <output> jcs:printf("%-20s%-20s%-30s%-10s%-5s",
  36. ../context-information/source-zone-name,
  37. ../context-information/destination-zone-name,
  38. policy-information/policy-name,
  39. policy-information/policy-action/action-type,
  40. policy-information/policy-statistics-information/session-creations);
  41. }
  42. }
  43. }
  44.  
  45.  
  46. Use an apply-group to force counting across your existing security policies:
  47.  
  48. bdale@clx-bdr> show configuration groups
  49. COUNT-ALL {
  50. security {
  51. policies {
  52. from-zone <*> to-zone <*> {
  53. policy <*> {
  54. then {
  55. count;
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. apply-groups COUNT-ALL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement