SHARE
TWEET

rest-mgmt-tm-vcmp-guest-stats.ind

a guest Dec 1st, 2017 10 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! META
  2. name: f5-rest-mgmt-tm-vcmp-guest-stats
  3. description: Extract status of deployed vCMP guests
  4. type: monitoring
  5. monitoring_interval: 10 minutes
  6. requires:
  7.     vendor: "f5"
  8.     product: "load-balancer"
  9.     rest-api: "true"
  10.     vsx: "true"
  11.     shell: "bash"
  12.  
  13. #! COMMENTS
  14. vs-state:
  15.     why: |
  16.        Keeping track of vCMP guest states will enable alerting for when a VM has failed.
  17.     how: |
  18.        This script uses the F5 iControl REST API to retrieve the current status of vCMP guests.
  19.     without-indeni: |
  20.        This metric is available by logging into the device with SSH, entering TMSH and executing "show vcmp guest".
  21.     can-with-snmp: false
  22.     can-with-syslog: false
  23. uptime-seconds:
  24.     why: |
  25.        Keeping track of vCMP guest uptimes can help trigger alerts if they are suddenly restarted due to a system failure.
  26.     how: |
  27.        This script uses the F5 iControl REST API to retrieve the current uptime of vCMP guests.
  28.     without-indeni: |
  29.        This metric is available by logging into the device with SSH, entering TMSH and executing "show vcmp guest".
  30.     can-with-snmp: false
  31.     can-with-syslog: false
  32.  
  33. #! REMOTE::HTTP
  34. url: /mgmt/tm/sys/clock
  35. protocol: HTTPS
  36.  
  37. #! PARSER::JSON
  38.  
  39. _dynamic_vars:
  40.     _temp:
  41.         "fullDate":
  42.             _value: "$.entries.*.nestedStats.entries.fullDate.description"
  43.     _transform:
  44.         _dynamic:
  45.             "currentTime": |
  46.                {
  47.                
  48.                     strCurrentTime = temp("fullDate")
  49.                    
  50.                     #2016-12-01T07:55:34Z
  51.                     gsub(/[^\d-:]/, " ", strCurrentTime)
  52.                    
  53.                     #2016-12-01 07:55:34
  54.                     split(strCurrentTime, dateTimeArr, /\s/)
  55.                    
  56.                     strDate = dateTimeArr[1]
  57.                     strTime = dateTimeArr[2]
  58.                    
  59.                     #2016-12-01
  60.                     split(strDate, dateArr, /-/)
  61.                    
  62.                     year = dateArr[1]
  63.                     month = dateArr[2]
  64.                     day = dateArr[3]
  65.                    
  66.                     #07:55:34
  67.                     split(strTime, timeArr, /:/)
  68.                    
  69.                     hour = timeArr[1]
  70.                     minute = timeArr[2]
  71.                     second = timeArr[3]
  72.                    
  73.                     secondsSinceEpoch = datetime(year, month, day, hour, minute, second)
  74.                    
  75.                     print secondsSinceEpoch
  76.                 }
  77.  
  78. #! REMOTE::HTTP
  79. url: /mgmt/tm/vcmp/guest/stats
  80. protocol: HTTPS
  81.  
  82. #! PARSER::JSON
  83.  
  84. _metrics:
  85.    - #vs-state OK
  86.         _groups:
  87.             "$.entries.*.nestedStats.entries.[?(@.requestedState.description == 'deployed' && @.requestComplete.description == 'true' && @.vmStatus.description == 'running')]":
  88.                 _tags:
  89.                     "im.name":
  90.                         _constant: "vs-state"    
  91.                     "name":
  92.                         _value: "tmName.description"
  93.                 _value.double:
  94.                     _constant: "1"
  95.     - #vs-state not OK
  96.         _groups:
  97.             "$.entries.*.nestedStats.entries.[?(@.vmStatus.description == 'failed')]":
  98.                 _tags:
  99.                     "im.name":
  100.                         _constant: "vs-state"    
  101.                     "name":
  102.                         _value: "tmName.description"
  103.                 _value.double:
  104.                     _constant: "0"
  105.     - #Guest uptime
  106.         _groups:
  107.             "$.entries.*.nestedStats.entries.[?(@.requestedState.description == 'deployed' && @.requestComplete.description == 'true')]":
  108.                 _tags:
  109.                     "im.name":
  110.                         _constant: "uptime-seconds"    
  111.                     "vs.name":
  112.                         _value: "tmName.description"
  113.                 _temp:
  114.                     "uptime":
  115.                         _value: "uptime.description"
  116.         _transform:
  117.             _value.double: |
  118.                {
  119.                     strUptime = temp("uptime")
  120.                    
  121.                     #2016-12-01T07:55:34Z
  122.                     gsub(/[^\d-:]/, " ", strUptime)
  123.                    
  124.                     #2016-12-01 07:55:34
  125.                     split(strUptime, dateTimeArr, /\s/)
  126.                    
  127.                     strDate = dateTimeArr[1]
  128.                     strTime = dateTimeArr[2]
  129.                    
  130.                     #2016-12-01
  131.                     split(strDate, dateArr, /-/)
  132.                    
  133.                     year = dateArr[1]
  134.                     month = dateArr[2]
  135.                     day = dateArr[3]
  136.                    
  137.                     #07:55:34
  138.                     split(strTime, timeArr, /:/)
  139.                    
  140.                     hour = timeArr[1]
  141.                     minute = timeArr[2]
  142.                     second = timeArr[3]
  143.                    
  144.                     secondsSinceEpoch = datetime(year, month, day, hour, minute, second)
  145.                    
  146.                     uptime = dynamic("currentTime") - secondsSinceEpoch
  147.                    
  148.                     print uptime
  149.                 }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top