check_naf.py 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. #####################################################################
  4. # (c) 2006-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
  5. # sv@teamix.net #
  6. # #
  7. # This file is part of "team(ix) Monitoring Plugins" #
  8. # URL: http://oss.teamix.org/projects/monitoringplugins/ #
  9. # #
  10. # This file is free software: you can redistribute it and/or modify #
  11. # it under the terms of the GNU General Public License as published #
  12. # by the Free Software Foundation, either version 2 of the License, #
  13. # or (at your option) any later version. #
  14. # #
  15. # This file is distributed in the hope that it will be useful, but #
  16. # WITHOUT ANY WARRANTY; without even the implied warranty of #
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  18. # GNU General Public License for more details. #
  19. # #
  20. # You should have received a copy of the GNU General Public License #
  21. # along with this file. If not, see <http://www.gnu.org/licenses/>. #
  22. #####################################################################
  23. import os
  24. import sys
  25. try:
  26. from monitoringplugin import SNMPMonitoringPlugin
  27. except ImportError:
  28. print '=========================='
  29. print 'AIKS! Python import error!'
  30. print '==========================\n'
  31. print 'Could not find "monitoringplugin.py"!\n'
  32. print 'Did you download "%s"' % os.path.basename(sys.argv[0])
  33. print 'without "monitoringplugin.py"?\n'
  34. print 'Please go back to'
  35. print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,'
  36. print 'or even better:'
  37. print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n'
  38. sys.exit(127)
  39. class CheckNAF(SNMPMonitoringPlugin):
  40. OID = {
  41. 'Cluster_Settings': '.1.3.6.1.4.1.789.1.2.3.1.0',
  42. 'Cluster_State': '.1.3.6.1.4.1.789.1.2.3.2.0',
  43. 'Cluster_InterconnectStatus': '.1.3.6.1.4.1.789.1.2.3.8.0',
  44. 'Cluster_CannotTakeOverCause': '.1.3.6.1.4.1.789.1.2.3.3.0',
  45. 'CIFS_Connected_Users': '.1.3.6.1.4.1.789.1.7.2.9.0',
  46. 'CIFS_Total_Ops': '.1.3.6.1.4.1.789.1.7.3.1.1.1.0',
  47. 'CIFS_Total_Calls': '.1.3.6.1.4.1.789.1.7.3.1.1.2.0',
  48. 'CIFS_Bad_Calls': '.1.3.6.1.4.1.789.1.7.3.1.1.3.0',
  49. 'CIFS_Get_Attrs': '.1.3.6.1.4.1.789.1.7.3.1.1.4.0',
  50. 'CIFS_Reads': '.1.3.6.1.4.1.789.1.7.3.1.1.5.0',
  51. 'CIFS_Writes': '.1.3.6.1.4.1.789.1.7.3.1.1.6.0',
  52. 'CIFS_Locks': '.1.3.6.1.4.1.789.1.7.3.1.1.7.0',
  53. 'CIFS_Opens': '.1.3.6.1.4.1.789.1.7.3.1.1.8.0',
  54. 'CIFS_DirOps': '.1.3.6.1.4.1.789.1.7.3.1.1.9.0',
  55. 'CIFS_Others': '.1.3.6.1.4.1.789.1.7.3.1.1.10.0',
  56. 'CP': '.1.3.6.1.4.1.789.1.2.6',
  57. 'CPU_Arch': '.1.3.6.1.4.1.789.1.1.11.0',
  58. 'CPU_Time_Busy': '.1.3.6.1.4.1.789.1.2.1.3.0',
  59. 'CPU_Time_Idle': '.1.3.6.1.4.1.789.1.2.1.5.0',
  60. 'CPU_Context_Switches': '.1.3.6.1.4.1.789.1.2.1.8.0',
  61. 'Disks_Total': '.1.3.6.1.4.1.789.1.6.4.1.0',
  62. 'Disks_Active': '.1.3.6.1.4.1.789.1.6.4.2.0',
  63. 'Disks_Reconstructing': '.1.3.6.1.4.1.789.1.6.4.3.0',
  64. 'Disks_ReconstParity': '.1.3.6.1.4.1.789.1.6.4.4.0',
  65. 'Disks_Scrubbing': '.1.3.6.1.4.1.789.1.6.4.6.0',
  66. 'Disks_Failed': '.1.3.6.1.4.1.789.1.6.4.7.0',
  67. 'Disks_Spare': '.1.3.6.1.4.1.789.1.6.4.8.0',
  68. 'Disks_ZeroDisks': '.1.3.6.1.4.1.789.1.6.4.9.0',
  69. 'Disks_Failed_Descr': '.1.3.6.1.4.1.789.1.6.4.10.0',
  70. 'ExtCache_Type': '.1.3.6.1.4.1.789.1.26.1.0',
  71. 'ExtCache_SubType': '.1.3.6.1.4.1.789.1.26.2.0',
  72. 'ExtCache_Size': '.1.3.6.1.4.1.789.1.26.4.0',
  73. 'ExtCache_Usedsize': '.1.3.6.1.4.1.789.1.26.5.0',
  74. 'ExtCache_Options': '.1.3.6.1.4.1.789.1.26.7.0',
  75. 'ExtCache_Hits': '.1.3.6.1.4.1.789.1.26.8.0',
  76. 'ExtCache_Misses': '.1.3.6.1.4.1.789.1.26.9.0',
  77. 'ExtCache_Inserts': '.1.3.6.1.4.1.789.1.26.10.0',
  78. 'ExtCache_Evicts': '.1.3.6.1.4.1.789.1.26.11.0',
  79. 'ExtCache_Invalidates': '.1.3.6.1.4.1.789.1.26.12.0',
  80. 'ExtCache_MetaData': '.1.3.6.1.4.1.789.1.26.15.0',
  81. 'Global_Status': '.1.3.6.1.4.1.789.1.2.2.4.0',
  82. 'Global_Status_Message': '.1.3.6.1.4.1.789.1.2.2.25.0',
  83. 'Net_ifIndex': '.1.3.6.1.4.1.789.1.22.1.2.1.1',
  84. 'Net_ifDescr': '.1.3.6.1.4.1.789.1.22.1.2.1.2',
  85. 'Net_InBytes': ['.1.3.6.1.4.1.789.1.22.1.2.1.25', '.1.3.6.1.4.1.789.1.22.1.2.1.4', '.1.3.6.1.4.1.789.1.22.1.2.1.3',],
  86. 'Net_OutBytes': ['.1.3.6.1.4.1.789.1.22.1.2.1.31', '.1.3.6.1.4.1.789.1.22.1.2.1.16', '.1.3.6.1.4.1.789.1.22.1.2.1.15',],
  87. 'Net_InDiscards': ['.1.3.6.1.4.1.789.1.22.1.2.1.28', '.1.3.6.1.4.1.789.1.22.1.2.1.10', '.1.3.6.1.4.1.789.1.22.1.2.1.9',],
  88. 'Net_OutDiscards': ['.1.3.6.1.4.1.789.1.22.1.2.1.34', '.1.3.6.1.4.1.789.1.22.1.2.1.22', '.1.3.6.1.4.1.789.1.22.1.2.1.21',],
  89. 'Net_InErrors': ['.1.3.6.1.4.1.789.1.22.1.2.1.29', '.1.3.6.1.4.1.789.1.22.1.2.1.12', '.1.3.6.1.4.1.789.1.22.1.2.1.11',],
  90. 'Net_OutErrors': ['.1.3.6.1.4.1.789.1.22.1.2.1.35', '.1.3.6.1.4.1.789.1.22.1.2.1.24', '.1.3.6.1.4.1.789.1.22.1.2.1.23',],
  91. 'IO_DiskReadBy': ['.1.3.6.1.4.1.789.1.2.2.32.0', '.1.3.6.1.4.1.789.1.2.2.16.0', '.1.3.6.1.4.1.789.1.2.2.15.0',],
  92. 'IO_DiskWriteBy': ['.1.3.6.1.4.1.789.1.2.2.33.0', '.1.3.6.1.4.1.789.1.2.2.18.0', '.1.3.6.1.4.1.789.1.2.2.17.0',],
  93. 'IO_NetInBy': ['.1.3.6.1.4.1.789.1.2.2.30.0', '.1.3.6.1.4.1.789.1.2.2.12.0', '.1.3.6.1.4.1.789.1.2.2.11.0',],
  94. 'IO_NetOutBy': ['.1.3.6.1.4.1.789.1.2.2.31.0', '.1.3.6.1.4.1.789.1.2.2.14.0', '.1.3.6.1.4.1.789.1.2.2.13.0',],
  95. 'IO_TapeReadBy': ['.1.3.6.1.4.1.789.1.2.2.34.0', '.1.3.6.1.4.1.789.1.2.2.20.0', '.1.3.6.1.4.1.789.1.2.2.19.0',],
  96. 'IO_TapeWriteBy': ['.1.3.6.1.4.1.789.1.2.2.35.0', '.1.3.6.1.4.1.789.1.2.2.22.0', '.1.3.6.1.4.1.789.1.2.2.21.0',],
  97. 'IO_FCPReadBy': ['.1.3.6.1.4.1.789.1.17.20.0', '.1.3.6.1.4.1.789.1.17.3.0', '.1.3.6.1.4.1.789.1.17.4.0',],
  98. 'IO_FCPWriteBy': ['.1.3.6.1.4.1.789.1.17.21.0', '.1.3.6.1.4.1.789.1.17.5.0', '.1.3.6.1.4.1.789.1.17.6.0',],
  99. 'IO_iSCSIReadBy': ['.1.3.6.1.4.1.789.1.17.22.0', '.1.3.6.1.4.1.789.1.17.7.0', '.1.3.6.1.4.1.789.1.17.8.0',],
  100. 'IO_iSCSIWriteBy': ['.1.3.6.1.4.1.789.1.17.23.0', '.1.3.6.1.4.1.789.1.17.9.0', '.1.3.6.1.4.1.789.1.17.10.0',],
  101. 'NVRAM_Status': '.1.3.6.1.4.1.789.1.2.5.1.0',
  102. 'OPs_NFS': ['.1.3.6.1.4.1.789.1.2.2.27.0', '.1.3.6.1.4.1.789.1.2.2.6.0', '.1.3.6.1.4.1.789.1.2.2.5.0',],
  103. 'OPs_CIFS': ['.1.3.6.1.4.1.789.1.2.2.28.0', '.1.3.6.1.4.1.789.1.2.2.8.0', '.1.3.6.1.4.1.789.1.2.2.7.0',],
  104. 'OPs_HTTP': ['.1.3.6.1.4.1.789.1.2.2.29.0', '.1.3.6.1.4.1.789.1.2.2.10.0', '.1.3.6.1.4.1.789.1.2.2.9.0',],
  105. 'OPs_FCP': ['.1.3.6.1.4.1.789.1.17.25.0', '.1.3.6.1.4.1.789.1.17.14.0', '.1.3.6.1.4.1.789.1.17.13.0',],
  106. 'OPs_iSCSI': ['.1.3.6.1.4.1.789.1.17.24.0', '.1.3.6.1.4.1.789.1.17.12.0', '.1.3.6.1.4.1.789.1.17.11.0',],
  107. 'Snapmirror_On': '.1.3.6.1.4.1.789.1.9.1.0',
  108. 'Snapmirror_License': '.1.3.6.1.4.1.789.1.9.19.0',
  109. 'Snapmirror_Index': '.1.3.6.1.4.1.789.1.9.20.1.1',
  110. 'Snapmirror_Src': '.1.3.6.1.4.1.789.1.9.20.1.2',
  111. 'Snapmirror_Dst': '.1.3.6.1.4.1.789.1.9.20.1.3',
  112. 'Snapmirror_Status': '.1.3.6.1.4.1.789.1.9.20.1.4',
  113. 'Snapmirror_State': '.1.3.6.1.4.1.789.1.9.20.1.5',
  114. 'Snapmirror_Lag': '.1.3.6.1.4.1.789.1.9.20.1.6',
  115. 'Snapvault_On': '.1.3.6.1.4.1.789.1.19.1.0',
  116. 'Snapvault_LicensePrimary': '.1.3.6.1.4.1.789.1.19.9.0',
  117. 'Snapvault_LicenseSecondary': '.1.3.6.1.4.1.789.1.19.10.0',
  118. 'Snapvault_Index': '.1.3.6.1.4.1.789.1.19.11.1.1',
  119. 'Snapvault_Src': '.1.3.6.1.4.1.789.1.19.11.1.2',
  120. 'Snapvault_Dst': '.1.3.6.1.4.1.789.1.19.11.1.3',
  121. 'Snapvault_Status': '.1.3.6.1.4.1.789.1.19.11.1.4',
  122. 'Snapvault_State': '.1.3.6.1.4.1.789.1.19.11.1.5',
  123. 'Snapvault_Lag': '.1.3.6.1.4.1.789.1.19.11.1.6',
  124. 'Model': '.1.3.6.1.4.1.789.1.1.5.0',
  125. 'ONTAP_Version': '.1.3.6.1.4.1.789.1.1.2.0',
  126. 'df_FS_Index': '.1.3.6.1.4.1.789.1.5.4.1.1',
  127. 'df_FS_Name': '.1.3.6.1.4.1.789.1.5.4.1.2',
  128. 'df_FS_Mounted_On': '.1.3.6.1.4.1.789.1.5.4.1.10',
  129. 'df_FS_Status': '.1.3.6.1.4.1.789.1.5.4.1.20',
  130. 'df_FS_Type': '.1.3.6.1.4.1.789.1.5.4.1.23',
  131. 'df_FS_kBTotal': ['.1.3.6.1.4.1.789.1.5.4.1.29', '.1.3.6.1.4.1.789.1.5.4.1.15', '.1.3.6.1.4.1.789.1.5.4.1.14',],
  132. 'df_FS_kBUsed': ['.1.3.6.1.4.1.789.1.5.4.1.30', '.1.3.6.1.4.1.789.1.5.4.1.17', '.1.3.6.1.4.1.789.1.5.4.1.16',],
  133. 'df_FS_kBAvail': ['.1.3.6.1.4.1.789.1.5.4.1.31', '.1.3.6.1.4.1.789.1.5.4.1.19', '.1.3.6.1.4.1.789.1.5.4.1.18',],
  134. 'df_FS_INodeUsed': '.1.3.6.1.4.1.789.1.5.4.1.7',
  135. 'df_FS_INodeFree': '.1.3.6.1.4.1.789.1.5.4.1.8',
  136. 'df_FS_MaxFilesAvail': '.1.3.6.1.4.1.789.1.5.4.1.11',
  137. 'df_FS_MaxFilesUsed': '.1.3.6.1.4.1.789.1.5.4.1.12',
  138. 'df_FS_MaxFilesPossible': '.1.3.6.1.4.1.789.1.5.4.1.13',
  139. }
  140. OWC = {
  141. 'Cluster_InterconnectStatus': ( (4,), (3,), (1,2,), ),
  142. 'Cluster_Settings': ( (2,), (1,3,4,), (5,), ),
  143. 'Cluster_State': ( (2,4,), (), (1,3,), ),
  144. 'Global_Status': ( (3,), (4,), (5,6), ),
  145. 'NVRAM_Status': ( (1,9), (2,5,8), (3,4,6), ),
  146. 'Snapmirror_State': ( (2,5,), (1,4,6,), (3,), ),
  147. 'Snapvault_State': ( (2,5,7,), (1,3,4,6,), (None,), ),
  148. }
  149. Status2String = {
  150. 'Cluster_CannotTakeOverCause': { '1' : 'ok', '2' : 'unknownReason', '3' : 'disabledByOperator', '4' : 'interconnectOffline', '5' : 'disabledByPartner', '6' : 'takeoverFailed', },
  151. 'Cluster_InterconnectStatus': { '1' : 'notPresent', '2' : 'down', '3' : 'partialFailure', '4' : 'up', },
  152. 'Cluster_Settings': { '1' : 'notConfigured', '2' : 'enabled', '3' : 'disabled', '4' : 'takeoverByPartnerDisabled', '5' : 'thisNodeDead', },
  153. 'Cluster_State': { '1' : 'dead', '2' : 'canTakeover', '3' : 'cannotTakeover', '4' : 'takeover', },
  154. 'CPU_Arch' : { '1' : 'x86', '2' : 'alpha', '3' : 'mips', '4' : 'sparc', '5' : 'amd64', },
  155. 'NVRAM_Status' : { '1' : 'ok', '2' : 'partiallyDischarged', '3' : 'fullyDischarged', '4' : 'notPresent', '5' : 'nearEndOfLife', '6' : 'atEndOfLife', '7' : 'unknown', '8' : 'overCharged', '9' : 'fullyCharged', },
  156. 'df_FS_Status' : { '1' : 'unmounted', '2' : 'mounted', '3' : 'frozen', '4' : 'destroying', '5' : 'creating', '6' : 'mounting', '7' : 'unmounting', '8' : 'nofsinfo', '9' : 'replaying', '10': 'replayed', },
  157. 'df_FS_Type' : { '1' : 'traditionalVolume', '2' : 'flexibleVolume', '3' : 'aggregate', },
  158. 'Snapmirror_Status': { '1' : 'idle', '2' : 'transferring', '3' : 'pending', '4' : 'aborting', '5' : 'migrating', '6' : 'quiescing', '7' : 'resyncing', '8' : 'waiting', '9' : 'syncing', '10': 'in-sync', },
  159. 'Snapmirror_State': { '1' : 'uninitialized', '2' : 'snapmirrored', '3' : 'broken-off', '4' : 'quiesced', '5' : 'source', '6' : 'unknown', },
  160. 'Snapvault_Status': { '1' : 'idle', '2' : 'transferring', '3' : 'pending', '4' : 'aborting', '5' : 'unknown_5', '6' : 'quiescing', '7' : 'resyncing', '8' : 'unknown_8', '9' : 'unknown_9', '10': 'unknown_10', '11': 'unknown_11', '12': 'paused', },
  161. 'Snapvault_State': { '1' : 'uninitialized', '2' : 'snapvaulted', '3' : 'brokenOff', '4' : 'quiesced', '5' : 'source', '6' : 'unknown', '7' : 'restoring', },
  162. }
  163. def map_status_to_returncode(self, value, mapping):
  164. for returncode in xrange(0,3):
  165. if value in mapping[returncode]:
  166. return returncode
  167. return 3
  168. def check_cifs(self, target='', warn='', crit=''):
  169. if target == 'users':
  170. cifsConnectedUsers = long(self.SNMPGET(self.OID['CIFS_Connected_Users']))
  171. returncode = self.value_wc_to_returncode(cifsConnectedUsers, warn, crit)
  172. output = "%s connected users" % cifsConnectedUsers
  173. perfdata = [{'label':'nacifs_users', 'value':cifsConnectedUsers, 'unit':'', 'warn':warn, 'crit':crit, 'min':0},]
  174. elif target == 'stats':
  175. cifsTotalOps = self.SNMPGET(self.OID['CIFS_Total_Ops'])
  176. cifsTotalCalls = self.SNMPGET(self.OID['CIFS_Total_Calls'])
  177. cifsBadCalls = self.SNMPGET(self.OID['CIFS_Bad_Calls'])
  178. cifsGetAttrs = self.SNMPGET(self.OID['CIFS_Get_Attrs'])
  179. cifsReads = self.SNMPGET(self.OID['CIFS_Reads'])
  180. cifsWrites = self.SNMPGET(self.OID['CIFS_Writes'])
  181. cifsLocks = self.SNMPGET(self.OID['CIFS_Locks'])
  182. cifsOpens = self.SNMPGET(self.OID['CIFS_Opens'])
  183. cifsDirOps = self.SNMPGET(self.OID['CIFS_DirOps'])
  184. cifsOthers = self.SNMPGET(self.OID['CIFS_Others'])
  185. returncode = self.RETURNCODE['OK']
  186. output = 'CIFS statistics'
  187. perfdata = []
  188. perfdata.append({'label':'nacifs_totalcalls', 'value':cifsTotalCalls, 'unit':'c', 'min':'0'})
  189. perfdata.append({'label':'nacifs_badcalls', 'value':cifsBadCalls, 'unit':'c', 'min':'0'})
  190. perfdata.append({'label':'nacifs_getattrs', 'value':cifsGetAttrs, 'unit':'c', 'min':'0'})
  191. perfdata.append({'label':'nacifs_reads', 'value':cifsReads, 'unit':'c', 'min':'0'})
  192. perfdata.append({'label':'nacifs_writes', 'value':cifsWrites, 'unit':'c', 'min':'0'})
  193. perfdata.append({'label':'nacifs_locks', 'value':cifsLocks, 'unit':'c', 'min':'0'})
  194. perfdata.append({'label':'nacifs_opens', 'value':cifsOpens, 'unit':'c', 'min':'0'})
  195. perfdata.append({'label':'nacifs_dirops', 'value':cifsDirOps, 'unit':'c', 'min':'0'})
  196. perfdata.append({'label':'nacifs_others', 'value':cifsOthers, 'unit':'c', 'min':'0'})
  197. else:
  198. returncode = self.RETURNCODE['UNKNOWN']
  199. output = 'Unknown CIFS check/target: "%s"' % target
  200. perfdata = []
  201. return self.remember_check('cifs', returncode, output, perfdata=perfdata, target=target)
  202. def check_cp(self):
  203. cp = self.SNMPWALK(self.OID['CP'])
  204. output = 'Consistency Point (in progress %s seconds), Ops: Total(%s) ' % (float(cp[0])/100, cp[7])
  205. output += 'Snapshot(%s) LowWaterMark(%s) HighWaterMark(%s) LogFull(%s) CP-b2b(%s) ' % tuple(cp[2:7])
  206. output += 'Flush(%s) Sync(%s) LowVBuf(%s) CpDeferred(%s) LowDatavecs(%s)' % tuple(cp[8:13])
  207. returncode = self.RETURNCODE['OK']
  208. perfdata = []
  209. perfdata.append({'label':'nacp_progress', 'value':float(cp[0])/100, 'unit':'s'})
  210. perfdata.append({'label':'nacp_total', 'value':cp[7], 'unit':'c'})
  211. perfdata.append({'label':'nacp_snapshot', 'value':cp[2], 'unit':'c'})
  212. perfdata.append({'label':'nacp_lowwatermark', 'value':cp[3], 'unit':'c'})
  213. perfdata.append({'label':'nacp_highwatermark', 'value':cp[4], 'unit':'c'})
  214. perfdata.append({'label':'nacp_logfull', 'value':cp[5], 'unit':'c'})
  215. perfdata.append({'label':'nacp_b2b', 'value':cp[6], 'unit':'c'})
  216. perfdata.append({'label':'nacp_flush', 'value':cp[8], 'unit':'c'})
  217. perfdata.append({'label':'nacp_sync', 'value':cp[9], 'unit':'c'})
  218. perfdata.append({'label':'nacp_lowvbuf', 'value':cp[10], 'unit':'c'})
  219. perfdata.append({'label':'nacp_cpdeferred', 'value':cp[11], 'unit':'c'})
  220. perfdata.append({'label':'nacp_lowdatavecs', 'value':cp[12], 'unit':'c'})
  221. return self.remember_check('cp', returncode, output, perfdata=perfdata)
  222. def check_cpu(self, warn='', crit=''):
  223. cpu_arch = self.SNMPGET(self.OID['CPU_Arch'])
  224. cpu_timebusy = int(self.SNMPGET(self.OID['CPU_Time_Busy']))
  225. # cputimeidle = int(self.SNMPGET(self.OID['CPU_Time_Idle']))
  226. cpu_cs = self.SNMPGET(self.OID['CPU_Context_Switches'])
  227. if '%' in warn:
  228. warn = warn[:-1]
  229. if '%' in crit:
  230. crit = crit[:-1]
  231. returncode = self.value_wc_to_returncode(cpu_timebusy, warn, crit)
  232. output = 'CPU ' + str(cpu_timebusy) + '% busy, CPU architecture: ' + self.Status2String['CPU_Arch'].get(cpu_arch)
  233. perfdata = []
  234. pd = {'label':'nacpu', 'value':cpu_timebusy, 'unit':'%', 'min':0, 'max':100}
  235. if warn:
  236. pd['warn'] = warn
  237. if crit:
  238. pd['crit'] = crit
  239. perfdata.append(pd)
  240. perfdata.append({'label':'nacs', 'value':cpu_cs, 'unit':'c'})
  241. return self.remember_check('cpu', returncode, output, perfdata=perfdata)
  242. def check_cluster(self):
  243. cl_settings = int(self.SNMPGET(self.OID['Cluster_Settings']))
  244. if cl_settings == 1: # notConfigured
  245. return self.remember_check('cluster', self.RETURNCODE['WARNING'], 'No cluster configured!')
  246. cl_state = int(self.SNMPGET(self.OID['Cluster_State']))
  247. cl_interconnectstatus = int(self.SNMPGET(self.OID['Cluster_InterconnectStatus']))
  248. returncode = []
  249. returncode.append(self.map_status_to_returncode(cl_settings, self.OWC['Cluster_Settings']))
  250. returncode.append(self.map_status_to_returncode(cl_state, self.OWC['Cluster_State']))
  251. returncode.append(self.map_status_to_returncode(cl_interconnectstatus, self.OWC['Cluster_InterconnectStatus']))
  252. returncode = max(returncode)
  253. output = 'Settings: ' + self.Status2String['Cluster_Settings'][str(cl_settings)] + ', '
  254. output += 'state: ' + self.Status2String['Cluster_State'][str(cl_state)] + ', '
  255. output += 'interconnect state: ' + self.Status2String['Cluster_InterconnectStatus'][str(cl_interconnectstatus)]
  256. if cl_state == 4: # cannotTakeover
  257. cl_cannottakeovercause = self.SNMPGET(self.OID['Cluster_CannotTakeOverCause'])
  258. output = 'Cannot takeover, reason: ' + self.Status2String['Cluster_CannotTakeOverCause'][cl_cannottakeovercause] + '! ' + output
  259. return self.remember_check('cluster', returncode, output)
  260. def check_disk(self, target='failed', warn='', crit=''):
  261. di_total = int(self.SNMPGET(self.OID['Disks_Total']))
  262. di_active = int(self.SNMPGET(self.OID['Disks_Active']))
  263. di_reconstructing = int(self.SNMPGET(self.OID['Disks_Reconstructing']))
  264. di_reconstparity = int(self.SNMPGET(self.OID['Disks_ReconstParity']))
  265. # di_scrubbing = int(self.SNMPGET(self.OID['Disks_Scrubbing']))
  266. di_failed = int(self.SNMPGET(self.OID['Disks_Failed']))
  267. di_spare = int(self.SNMPGET(self.OID['Disks_Spare']))
  268. # di_zerodisks = int(self.SNMPGET(self.OID['Disks_ZeroDisks']))
  269. di_reconstr = di_reconstructing + di_reconstparity
  270. if target == 'spare':
  271. returncode = self.value_wc_to_returncode(di_spare, warn, crit)
  272. output = str(di_spare) + ' spare disk'
  273. if di_spare > 1:
  274. output += 's'
  275. else:
  276. target = 'failed' # Set to defined value
  277. returncode = self.value_wc_to_returncode(di_failed, warn, crit)
  278. if returncode == 0:
  279. output = 'No failed disks'
  280. else:
  281. output = self.SNMPGET(self.OID['Disks_Failed_Descr'])
  282. perfdata = []
  283. perfdata.append({'label':'nadisk_total', 'value':di_total, 'unit':'', 'min':0})
  284. perfdata.append({'label':'nadisk_active', 'value':di_active, 'unit':'', 'min':0})
  285. pd = {'label':'nadisk_spare', 'value':di_spare, 'unit':'', 'min':0}
  286. if warn and target=='spare':
  287. pd['warn'] = warn
  288. if crit and target=='spare':
  289. pd['crit'] = crit
  290. perfdata.append(pd)
  291. pd = {'label':'nadisk_failed', 'value':di_failed, 'unit':'', 'min':0}
  292. if warn and target=='failed':
  293. pd['warn'] = warn
  294. if crit and target=='failed':
  295. pd['crit'] = crit
  296. perfdata.append(pd)
  297. return self.remember_check('disk', returncode, output, perfdata=perfdata, target=target)
  298. def check_extcache(self):
  299. if self.options.snmpversion in [1, '1']:
  300. return self.remember_check('extcache', self.RETURNCODE['UNKNOWN'], 'Need SNMP v2c/v3 for "extcache" check!',)
  301. ec_size = long(self.SNMPGET(self.OID['ExtCache_Size']))
  302. ec_usedsize = long(self.SNMPGET(self.OID['ExtCache_Usedsize']))
  303. ec_hits = long(self.SNMPGET(self.OID['ExtCache_Hits']))
  304. # ec_meta = long(self.SNMPGET(self.OID['ExtCache_MetaData']))
  305. ec_miss = long(self.SNMPGET(self.OID['ExtCache_Misses']))
  306. ec_evict = long(self.SNMPGET(self.OID['ExtCache_Evicts']))
  307. ec_inval = long(self.SNMPGET(self.OID['ExtCache_Invalidates']))
  308. ec_insert = long(self.SNMPGET(self.OID['ExtCache_Inserts']))
  309. ec_usage = float(ec_usedsize) / float(ec_size) * 100.0
  310. ec_hitpct = float(ec_hits) / float(ec_hits + ec_miss) * 100.0
  311. ec_size_human = self.value_to_human_binary(ec_size, unit='B')
  312. output = 'Cache size %s, cache usage %5.2f%%, total hits %5.2f%% ' % (ec_size_human, ec_usage, ec_hitpct)
  313. returncode = self.RETURNCODE['OK']
  314. perfdata = []
  315. perfdata.append({'label':'nacache_usage', 'value':float('%5.2f' % ec_usage), 'unit':'%'})
  316. perfdata.append({'label':'nacache_hits', 'value':ec_hits, 'unit':'c'})
  317. perfdata.append({'label':'nacache_miss', 'value':ec_miss, 'unit':'c'})
  318. perfdata.append({'label':'nacache_evict', 'value':ec_evict, 'unit':'c'})
  319. perfdata.append({'label':'nacache_inval', 'value':ec_inval, 'unit':'c'})
  320. perfdata.append({'label':'nacache_insert', 'value':ec_insert, 'unit':'c'})
  321. return self.remember_check('extcache', returncode, output, perfdata=perfdata)
  322. def check_extcache_info(self):
  323. ec_type = self.SNMPGET(self.OID['ExtCache_Type'])
  324. ec_subtype = self.SNMPGET(self.OID['ExtCache_SubType'])
  325. ec_size = long(self.SNMPGET(self.OID['ExtCache_Size']))
  326. ec_options = self.SNMPGET(self.OID['ExtCache_Options'])
  327. ec_size_human = self.value_to_human_binary(ec_size, unit='B')
  328. output = 'Cache type: "' + ec_type + '/' + ec_subtype + '", size: ' + ec_size_human + ', options: "' + ec_options + '"'
  329. returncode = 0
  330. return self.remember_check('extcache_info', returncode, output)
  331. def check_global(self):
  332. model = self.SNMPGET(self.OID['Model'])
  333. globalstatus = int(self.SNMPGET(self.OID['Global_Status']))
  334. globalstatusmsg = self.SNMPGET(self.OID['Global_Status_Message'])[:255]
  335. returncode = self.map_status_to_returncode(globalstatus, self.OWC['Global_Status'])
  336. output = model + ': ' + globalstatusmsg
  337. return self.remember_check('global', returncode, output)
  338. def check_ifstat(self, nic):
  339. idx = self.find_in_table(self.OID['Net_ifIndex'], self.OID['Net_ifDescr'] , nic)
  340. if idx == None:
  341. return self.remember_check('ifstat:'+nic, self.RETURNCODE['UNKNOWN'], 'NIC "' + nic + '" not found!')
  342. n_bytes_in = self.SNMPGET(self.OID['Net_InBytes'], idx)
  343. n_bytes_out = self.SNMPGET(self.OID['Net_OutBytes'], idx)
  344. n_discards_in = self.SNMPGET(self.OID['Net_InDiscards'], idx)
  345. n_discards_out = self.SNMPGET(self.OID['Net_OutDiscards'], idx)
  346. n_errors_in = self.SNMPGET(self.OID['Net_InErrors'], idx)
  347. n_errors_out = self.SNMPGET(self.OID['Net_OutErrors'], idx)
  348. returncode = self.RETURNCODE['OK']
  349. output = 'Network statistics for %s' % nic
  350. perfdata = []
  351. perfdata.append({'label':'naifbyin_'+nic, 'value':n_bytes_in, 'unit':'c'})
  352. perfdata.append({'label':'naifbyout_'+nic, 'value':n_bytes_out, 'unit':'c'})
  353. perfdata.append({'label':'naifdiscin_'+nic, 'value':n_discards_in, 'unit':'c'})
  354. perfdata.append({'label':'naifdiscout_'+nic, 'value':n_discards_out, 'unit':'c'})
  355. perfdata.append({'label':'naiferrin_'+nic, 'value':n_errors_in, 'unit':'c'})
  356. perfdata.append({'label':'naiferrout_'+nic, 'value':n_errors_out, 'unit':'c'})
  357. return self.remember_check('ifstat:'+nic, returncode, output, perfdata=perfdata)
  358. def check_io(self):
  359. disk_read = self.SNMPGET(self.OID['IO_DiskReadBy'])
  360. disk_write = self.SNMPGET(self.OID['IO_DiskWriteBy'])
  361. net_in = self.SNMPGET(self.OID['IO_NetInBy'])
  362. net_out = self.SNMPGET(self.OID['IO_NetOutBy'])
  363. tape_read = self.SNMPGET(self.OID['IO_TapeReadBy'])
  364. tape_write = self.SNMPGET(self.OID['IO_TapeWriteBy'])
  365. fcp_read = self.SNMPGET(self.OID['IO_FCPReadBy'])
  366. fcp_write = self.SNMPGET(self.OID['IO_FCPWriteBy'])
  367. iscsi_read = self.SNMPGET(self.OID['IO_iSCSIReadBy'])
  368. iscsi_write = self.SNMPGET(self.OID['IO_iSCSIWriteBy'])
  369. output = 'I/O statistics'
  370. returncode = self.RETURNCODE['OK']
  371. perfdata = []
  372. perfdata.append({'label':'naio_netin', 'value':net_in, 'unit':'c'})
  373. perfdata.append({'label':'naio_netout', 'value':net_out, 'unit':'c'})
  374. perfdata.append({'label':'naio_diskread', 'value':disk_read, 'unit':'c'})
  375. perfdata.append({'label':'naio_diskwrite', 'value':disk_write, 'unit':'c'})
  376. perfdata.append({'label':'naio_taperead', 'value':tape_read, 'unit':'c'})
  377. perfdata.append({'label':'naio_tapewrite', 'value':tape_write, 'unit':'c'})
  378. perfdata.append({'label':'naio_fcpread', 'value':fcp_read, 'unit':'c'})
  379. perfdata.append({'label':'naio_fcpwrite', 'value':fcp_write, 'unit':'c'})
  380. perfdata.append({'label':'naio_iscsiread', 'value':iscsi_read, 'unit':'c'})
  381. perfdata.append({'label':'naio_iscsiwrite', 'value':iscsi_write, 'unit':'c'})
  382. return self.remember_check('io', returncode, output, perfdata=perfdata)
  383. def check_nvram(self):
  384. nvramstatus = int(self.SNMPGET(self.OID['NVRAM_Status']))
  385. returncode = self.map_status_to_returncode(nvramstatus, self.OWC['NVRAM_Status'])
  386. output = 'NVRAM battery status is "' + self.Status2String['NVRAM_Status'].get(str(nvramstatus)) + '"'
  387. return self.remember_check('nvram', returncode, output)
  388. def check_ops(self):
  389. ops_nfs = self.SNMPGET(self.OID['OPs_NFS'])
  390. ops_cifs = self.SNMPGET(self.OID['OPs_CIFS'])
  391. ops_http = self.SNMPGET(self.OID['OPs_HTTP'])
  392. ops_fcp = self.SNMPGET(self.OID['OPs_FCP'])
  393. ops_iscsi = self.SNMPGET(self.OID['OPs_iSCSI'])
  394. output = 'Total ops statistics'
  395. returncode = self.RETURNCODE['OK']
  396. perfdata = []
  397. perfdata.append({'label':'naops_nfs', 'value':ops_nfs, 'unit':'c'})
  398. perfdata.append({'label':'naops_cifs', 'value':ops_cifs, 'unit':'c'})
  399. perfdata.append({'label':'naops_http', 'value':ops_http, 'unit':'c'})
  400. perfdata.append({'label':'naops_fcp', 'value':ops_fcp, 'unit':'c'})
  401. perfdata.append({'label':'naops_iscsi', 'value':ops_iscsi, 'unit':'c'})
  402. return self.remember_check('ops', returncode, output, perfdata=perfdata)
  403. def common_sm_sv(self, what, idx, **kwa):
  404. if not 'lag' in kwa:
  405. kwa['lag'] = long(self.SNMPGET(self.OID[what+'_Lag'], idx)) / 100
  406. if not 'rc_lag' in kwa:
  407. kwa['rc_lag'] = self.value_wc_to_returncode(kwa['lag'], kwa['warn'], kwa['crit'])
  408. if not 'state' in kwa:
  409. kwa['state'] = int(self.SNMPGET(self.OID[what+'_State'], idx))
  410. if not 'rc_state' in kwa:
  411. kwa['rc_state'] = self.map_status_to_returncode(int(kwa['state']), self.OWC[what+'_State'])
  412. if not 'src' in kwa:
  413. kwa['src'] = self.SNMPGET(self.OID[what+'_Src'], idx)
  414. if not 'dst' in kwa:
  415. kwa['dst'] = self.SNMPGET(self.OID[what+'_Dst'], idx)
  416. if not 'status' in kwa:
  417. kwa['status'] = int(self.SNMPGET(self.OID[what+'_Status'], idx))
  418. returncode = self.max_returncode([kwa['rc_state'], kwa['rc_lag']])
  419. if kwa['rc_lag'] in [1,2]:
  420. max_lag = [None, kwa['warn'], kwa['crit']][kwa['rc_lag']]
  421. output = 'Lag too high (%s (%s) > %s (%s))! ' % (kwa['lag'], self.seconds_to_hms(kwa['lag']), max_lag, self.seconds_to_hms(max_lag))
  422. else:
  423. output = ''
  424. output += 'Source: "' + kwa['src'] + '", Destination: "' + kwa['dst'] + '", '
  425. output += 'State: ' + self.Status2String[what+'_State'].get(str(kwa['state'])) + ', '
  426. output += 'Status: ' + self.Status2String[what+'_Status'].get(str(kwa['status']))
  427. return (returncode, output)
  428. def check_sm_sv_all(self, what, target, warn, crit):
  429. verbose = 'VERB' in target
  430. debug = 'DEBUG' in target
  431. tagtarget = what.lower() + ':ALL'
  432. idxs = self.SNMPWALK(self.OID[what+'_Index'])
  433. lags = self.SNMPWALK(self.OID[what+'_Lag'])
  434. for i in xrange(0, len(lags)):
  435. lags[i] = long(lags[i]) / 100
  436. states = self.SNMPWALK(self.OID[what+'_State'])
  437. rcs_lag = []
  438. for lag in lags:
  439. rcs_lag.append(self.value_wc_to_returncode(lag, warn, crit))
  440. rcs_state = []
  441. for state in states:
  442. rcs_state.append(self.map_status_to_returncode(int(state), self.OWC[what+'_State']))
  443. rc_lag = self.max_returncode(rcs_lag)
  444. rc_state = self.max_returncode(rcs_state)
  445. returncode = self.max_returncode([rc_lag, rc_state])
  446. if returncode == self.RETURNCODE['OK'] and not debug:
  447. return self.remember_check(tagtarget, returncode, 'All ' + what + ' OK')
  448. srcs = self.SNMPWALK(self.OID[what+'_Src'])
  449. dsts = self.SNMPWALK(self.OID[what+'_Dst'])
  450. statuss = self.SNMPWALK(self.OID[what+'_Status'])
  451. if not( len(idxs) == len(lags) == len(states) == len(srcs) == len(dsts) == len(statuss) ):
  452. return self.remember_check(tagtarget, returncode, 'Wrong number of status informations, but sure an error!')
  453. output = []
  454. for i in xrange(0, len(idxs)):
  455. if rcs_lag[i] != self.RETURNCODE['OK'] or rcs_state != self.RETURNCODE['OK'] or (verbose or debug):
  456. (rc_thissv, output_thissv) = self.common_sm_sv(what, idxs[i], src=srcs[i], dst=dsts[i], lag=lags[i], state=states[i], status=statuss[i], rc_lag=rcs_lag[i], rc_state=rcs_state[i], warn=warn, crit=crit)
  457. if rc_thissv != self.RETURNCODE['OK'] or debug:
  458. output.append(output_thissv)
  459. output = ' / '.join(output)
  460. return self.remember_check(tagtarget, returncode, output)
  461. def check_sm_sv_one(self, what, target, warn, crit):
  462. idx = self.find_in_table(self.OID[what+'_Index'], self.OID[what+'_Src'], target)
  463. if idx == None:
  464. idx = self.find_in_table(self.OID[what+'_Index'], self.OID[what+'_Dst'], target)
  465. if idx == None:
  466. return self.remember_check(what.lower(), self.RETURNCODE['UNKNOWN'], 'No ' + what + ' with source or destination "' + target + '" found!')
  467. (returncode, output) = self.common_sm_sv(what, idx, warn=warn, crit=crit)
  468. return self.remember_check(what.lower() + ':' + target, returncode, output)
  469. def check_snapmirror(self, target, warn, crit):
  470. if self.SNMPGET(self.OID['Snapmirror_License']) != '2':
  471. return self.remember_check('snapmirror', self.RETURNCODE['CRITICAL'], 'No license for Snapmirror')
  472. if self.SNMPGET(self.OID['Snapmirror_On']) != '2':
  473. return self.remember_check('snapmirror', self.RETURNCODE['CRITICAL'], 'Snapmirror is turned off!')
  474. if not target:
  475. return self.remember_check('snapmirror', self.RETURNCODE['OK'], 'Snapmirror is turned on!')
  476. if target.startswith('ALL'):
  477. return self.check_sm_sv_all('Snapmirror', target, warn, crit)
  478. else:
  479. return self.check_sm_sv_one('Snapmirror', target, warn, crit)
  480. def check_snapvault(self, target, warn, crit):
  481. if self.SNMPGET(self.OID['Snapvault_LicensePrimary']) != '2' and self.SNMPGET(self.OID['Snapvault_LicenseSecondary']) != '2':
  482. return self.remember_check('snapvault', self.RETURNCODE['CRITICAL'], 'No license for Snapvault')
  483. if self.SNMPGET(self.OID['Snapvault_On']) != '2':
  484. return self.remember_check('snapvault', self.RETURNCODE['CRITICAL'], 'Snapvault is turned off!')
  485. if not target:
  486. return self.remember_check('snapvault', self.RETURNCODE['OK'], 'Snapvault is turned on!')
  487. if target.startswith('ALL'):
  488. return self.check_sm_sv_all('Snapvault', target, warn, crit)
  489. else:
  490. return self.check_sm_sv_one('Snapvault', target, warn, crit)
  491. def check_version(self):
  492. model = self.SNMPGET(self.OID['Model'])
  493. ontapversion = self.SNMPGET(self.OID['ONTAP_Version'])
  494. return self.remember_check('version', 0, model + ': ' + ontapversion)
  495. def common_vol_idx(self, volume):
  496. if volume.endswith('.snapshot') or volume.endswith('.snapshot/'):
  497. return (None, None)
  498. idx = self.find_in_table(self.OID['df_FS_Index'], self.OID['df_FS_Name'] , volume)
  499. if idx == None:
  500. # Retry without/with Slash
  501. if volume[-1] == '/':
  502. idx = self.find_in_table(self.OID['df_FS_Index'], self.OID['df_FS_Name'] , volume[:-1])
  503. else:
  504. idx = self.find_in_table(self.OID['df_FS_Index'], self.OID['df_FS_Name'] , volume + '/')
  505. if idx != None:
  506. sn_idx = int(idx) + 1
  507. else:
  508. sn_idx = None
  509. return (idx, sn_idx)
  510. def common_vol_shorten_target(self, target):
  511. target = target.replace('/vol/', '')
  512. if target[-1] == "/":
  513. target = target[:-1]
  514. return target
  515. def check_vol_data_one(self, volume, warn, crit):
  516. (idx, sn_idx) = self.common_vol_idx(volume)
  517. if idx == None:
  518. return self.remember_check('vol_data', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
  519. fs_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], idx)) * 1024L
  520. fs_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], idx)) * 1024L
  521. # fs_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], idx)) * 1024L
  522. sn_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], sn_idx)) * 1024L
  523. sn_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], sn_idx)) * 1024L
  524. # sn_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], sn_idx)) * 1024L
  525. mountedon = self.SNMPGET(self.OID['df_FS_Mounted_On'] + "." + idx)
  526. status = self.Status2String['df_FS_Status'].get(self.SNMPGET(self.OID['df_FS_Status'] + "." + idx))
  527. fstype = self.Status2String['df_FS_Type'].get(self.SNMPGET(self.OID['df_FS_Type'] + "." + idx))
  528. fs_pctused = float(fs_used) / float(fs_total) * 100.0
  529. warn = self.range_dehumanize(warn, fs_total, unit=['b',])
  530. crit = self.range_dehumanize(crit, fs_total, unit=['b',])
  531. returncode = self.value_wc_to_returncode(fs_used, warn, crit)
  532. output = volume + ': Used ' + self.value_to_human_binary(fs_used, 'B')
  533. output += ' (' + '%3.1f' % fs_pctused + '%)'+ ' out of ' + self.value_to_human_binary(fs_total, 'B')
  534. target = self.common_vol_shorten_target(volume)
  535. perfdata = []
  536. perfdata.append({'label':'navdu_' + target, 'value':fs_used, 'unit':'B', 'warn':warn, 'crit':crit, 'min':0})
  537. perfdata.append({'label':'navdt_' + target, 'value':fs_total, 'unit':'B'})
  538. perfdata.append({'label':'navsu_' + target, 'value':sn_used, 'unit':'B', 'min':0})
  539. perfdata.append({'label':'navst_' + target, 'value':sn_total, 'unit':'B'})
  540. return self.remember_check('vol_data', returncode, output, perfdata=perfdata, target=target)
  541. def check_vol_data(self, volume, warn, crit):
  542. if volume.startswith('ALL'):
  543. volumes = self.SNMPWALK(self.OID['df_FS_Name'])
  544. for vol in volumes:
  545. if vol.endswith('.snapshot') or vol.endswith('.snapshot/'):
  546. continue
  547. self.check_vol_data_one(vol, warn, crit)
  548. else:
  549. return self.check_vol_data_one(volume, warn, crit)
  550. def check_vol_snap_one(self, volume, warn, crit):
  551. (idx, sn_idx) = self.common_vol_idx(volume)
  552. if idx == None:
  553. return self.remember_check('vol_snap', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
  554. # fs_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], idx)) * 1024L
  555. # fs_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], idx)) * 1024L
  556. # fs_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], idx)) * 1024L
  557. sn_total = long(self.SNMPGET(self.OID['df_FS_kBTotal'], sn_idx)) * 1024L
  558. sn_used = long(self.SNMPGET(self.OID['df_FS_kBUsed'], sn_idx)) * 1024L
  559. # sn_avail = long(self.SNMPGET(self.OID['df_FS_kBAvail'], sn_idx)) * 1024L
  560. warn = self.range_dehumanize(warn, sn_total, unit=['b',])
  561. crit = self.range_dehumanize(crit, sn_total, unit=['b',])
  562. if sn_total != 0:
  563. # Snap reserve
  564. sn_pctused = float(sn_used) / float(sn_total) * 100.0
  565. else:
  566. # No snap reserve
  567. sn_pctused = 0.0
  568. returncode = self.value_wc_to_returncode(sn_used, warn, crit)
  569. output = volume + '.snapshot: Used ' + self.value_to_human_binary(sn_used, 'B')
  570. output += ' (' + '%3.1f' % sn_pctused + '%)'+ ' out of ' + self.value_to_human_binary(sn_total, 'B')
  571. target = self.common_vol_shorten_target(volume)
  572. perfdata = []
  573. perfdata.append({'label':'navsu_' + target, 'value':sn_used, 'unit':'B', 'warn':warn, 'crit':crit, 'min':0})
  574. perfdata.append({'label':'navst_' + target, 'value':sn_total, 'unit':'B'})
  575. return self.remember_check('vol_snap', returncode, output, perfdata=perfdata, target=target)
  576. def check_vol_snap(self, volume, warn, crit):
  577. if volume.startswith('ALL'):
  578. volumes = self.SNMPWALK(self.OID['df_FS_Name'])
  579. for vol in volumes:
  580. if vol.endswith('.snapshot') or vol.endswith('.snapshot/'):
  581. continue
  582. self.check_vol_snap_one(vol, warn, crit)
  583. else:
  584. return self.check_vol_snap_one(volume, warn, crit)
  585. def check_vol_inode_one(self, volume, warn, crit):
  586. (idx, sn_idx) = self.common_vol_idx(volume)
  587. if idx == None:
  588. return self.remember_check('vol_inode', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
  589. in_used = long(self.SNMPGET(self.OID['df_FS_INodeUsed'] + '.' + idx))
  590. in_free = long(self.SNMPGET(self.OID['df_FS_INodeFree'] + '.' + idx))
  591. in_total = in_used + in_free
  592. in_pctused = float(in_used) / float(in_total) * 100.0
  593. warn = self.range_dehumanize(warn, in_total)
  594. crit = self.range_dehumanize(crit, in_total)
  595. returncode = self.value_wc_to_returncode(in_used, warn, crit)
  596. output = volume + ': Used inodes ' + self.value_to_human_si(in_used)
  597. output += ' (' + '%3.1f' % in_pctused + '%)'+ ' out of ' + self.value_to_human_si(in_total)
  598. target = self.common_vol_shorten_target(volume)
  599. perfdata = []
  600. perfdata.append({'label':'naviu_' + target, 'value':in_used, 'unit':None, 'warn':warn, 'crit':crit, 'min':0})
  601. perfdata.append({'label':'navit_' + target, 'value':in_total, 'unit':None})
  602. return self.remember_check('vol_inode', returncode, output, perfdata=perfdata, target=target)
  603. def check_vol_inode(self, volume, warn, crit):
  604. if volume.startswith('ALL'):
  605. volumes = self.SNMPWALK(self.OID['df_FS_Name'])
  606. for vol in volumes:
  607. if vol.endswith('.snapshot') or vol.endswith('.snapshot/'):
  608. continue
  609. self.check_vol_inode_one(vol, warn, crit)
  610. else:
  611. return self.check_vol_inode_one(volume, warn, crit)
  612. def check_vol_files_one(self, volume, warn, crit):
  613. (idx, sn_idx) = self.common_vol_idx(volume)
  614. if idx == None:
  615. return self.remember_check('vol_files', self.RETURNCODE['UNKNOWN'], '"' + volume + '" not found!')
  616. fi_avail = long(self.SNMPGET(self.OID['df_FS_MaxFilesAvail'] + '.' + idx))
  617. fi_used = long(self.SNMPGET(self.OID['df_FS_MaxFilesUsed'] + '.' + idx))
  618. fi_possible = long(self.SNMPGET(self.OID['df_FS_MaxFilesPossible'] + '.' + idx))
  619. fi_total = fi_used + fi_avail
  620. fi_pctused = float(fi_used) / float(fi_total) * 100.0
  621. warn = self.range_dehumanize(warn, fi_total)
  622. crit = self.range_dehumanize(crit, fi_total)
  623. returncode = self.value_wc_to_returncode(fi_used, warn, crit)
  624. output = volume + ': Used files ' + self.value_to_human_si(fi_used)
  625. output += ' (' + '%3.1f' % fi_pctused + '%)'+ ' out of ' + self.value_to_human_si(fi_total)
  626. output += ', may raised to ' + self.value_to_human_si(fi_possible)
  627. target = self.common_vol_shorten_target(volume)
  628. perfdata = []
  629. perfdata.append({'label':'navfu_' + target, 'value':fi_used, 'unit':None, 'warn':warn, 'crit':crit, 'min':0})
  630. perfdata.append({'label':'navft_' + target, 'value':fi_total, 'unit':None})
  631. return self.remember_check('vol_files', returncode, output, perfdata=perfdata, target=target)
  632. def check_vol_files(self, volume, warn, crit):
  633. if volume.startswith('ALL'):
  634. volumes = self.SNMPWALK(self.OID['df_FS_Name'])
  635. for vol in volumes:
  636. if vol.endswith('.snapshot') or vol.endswith('.snapshot/'):
  637. continue
  638. self.check_vol_files_one(vol, warn, crit)
  639. else:
  640. return self.check_vol_files_one(volume, warn, crit)
  641. def main():
  642. plugin = CheckNAF(pluginname='check_naf', tagforstatusline='NAF', description=u'Monitoring NetApp(tm) FAS systems', version='0.9')
  643. plugin.add_cmdlineoption('', '--separator', 'separator', 'Separator for check/target/warn/crit', metavar=',', default=',')
  644. plugin.add_cmdlineoption('', '--subseparator', 'subseparator', 'Separator for multiple checks or targets', metavar='+', default='+')
  645. plugin.add_cmdlineoption('', '--check', 'check', 'OBSOLETE - use new syntax!', default='')
  646. plugin.add_cmdlineoption('', '--target', 'target', 'OBSOLETE - use new syntax!', default='')
  647. plugin.add_cmdlineoption('-w', '', 'warn', 'OBSOLETE - use new syntax!', default='')
  648. plugin.add_cmdlineoption('-c', '', 'crit', 'OBSOLETE - use new syntax!', default='')
  649. plugin.add_cmdlineoption('', '--snmpwalk', 'snmpwalkoid', 'DEBUG: "list" OIDs or SNMPWALK it', default=None)
  650. plugin.parse_cmdlineoptions()
  651. plugin.prepare_snmp()
  652. if plugin.options.snmpwalkoid != None:
  653. if not plugin.options.snmpwalkoid in plugin.OID:
  654. print 'List of OIDs:'
  655. oids = plugin.OID.keys()
  656. oids.sort()
  657. for key in oids:
  658. print '- %s' % key
  659. sys.exit(0)
  660. print 'Walking "%s"...' % plugin.options.snmpwalkoid
  661. result = plugin.SNMPWALK(plugin.OID[plugin.options.snmpwalkoid], exitonerror=False)
  662. if result == None:
  663. result = plugin.SNMPGET(plugin.OID[plugin.options.snmpwalkoid], exitonerror=False)
  664. for value in result:
  665. print '=> %s' % value
  666. sys.exit(0)
  667. if plugin.options.check or plugin.options.target:
  668. arguments = plugin.options.check
  669. for s in [plugin.options.target, plugin.options.warn, plugin.options.crit]:
  670. arguments += plugin.options.separator + s
  671. plugin.back2nagios(3, 'Obsolete syntax - please use new syntax: "%s %s"' % (sys.argv[0], arguments))
  672. checks = []
  673. for quad in plugin.args:
  674. quad = quad.split(plugin.options.separator)
  675. quad = (quad + ['', '', ''])[:4] # Fix length to 4, fill with ''
  676. # Convert list of checks to list
  677. if plugin.options.subseparator in quad[0]:
  678. quad[0] = quad[0].split(plugin.options.subseparator)
  679. else:
  680. quad[0] = [quad[0],]
  681. # Convert list of targets to list
  682. if plugin.options.subseparator in quad[1]:
  683. quad[1] = quad[1].split(plugin.options.subseparator)
  684. else:
  685. quad[1] = [quad[1],]
  686. for target in quad[1]:
  687. for check in quad[0]:
  688. checks.append(tuple([check, target, quad[2], quad[3]]))
  689. if len(checks) == 0:
  690. checks = [('global','','','')]
  691. for quad in checks:
  692. (check, target, warn, crit) = tuple(quad)
  693. if check == 'global' or check == 'environment':
  694. result = plugin.check_global()
  695. elif check == 'cluster':
  696. result = plugin.check_cluster()
  697. elif check == 'cifs':
  698. result = plugin.check_cifs(target=target, warn=warn, crit=crit)
  699. elif check == 'cp':
  700. result = plugin.check_cp()
  701. elif check == 'cpu':
  702. result = plugin.check_cpu(warn=warn, crit=crit)
  703. elif check == 'disk':
  704. result = plugin.check_disk(target=target, warn=warn, crit=crit)
  705. elif check == 'extcache':
  706. result = plugin.check_extcache()
  707. elif check == 'extcache_info':
  708. result = plugin.check_extcache_info()
  709. elif check == 'ifstat':
  710. result = plugin.check_ifstat(target)
  711. elif check == 'io':
  712. result = plugin.check_io()
  713. elif check == 'nvram':
  714. result = plugin.check_nvram()
  715. elif check == 'ops':
  716. result = plugin.check_ops()
  717. elif check == 'snapmirror':
  718. result = plugin.check_snapmirror(target, warn=warn, crit=crit)
  719. elif check == 'snapvault':
  720. result = plugin.check_snapvault(target, warn=warn, crit=crit)
  721. elif check == 'version':
  722. result = plugin.check_version()
  723. elif check == 'vol_data':
  724. result = plugin.check_vol_data(volume=target, warn=warn, crit=crit)
  725. elif check == 'vol_snap':
  726. result = plugin.check_vol_snap(volume=target, warn=warn, crit=crit)
  727. elif check =='vol_inode':
  728. result = plugin.check_vol_inode(volume=target, warn=warn, crit=crit)
  729. elif check =='vol_files':
  730. result = plugin.check_vol_files(volume=target, warn=warn, crit=crit)
  731. else:
  732. result = plugin.remember_check(check, plugin.RETURNCODE['UNKNOWN'], 'Unknown check "' + check + '"!')
  733. # from pprint import pprint
  734. # pprint(plugin.dump_brain())
  735. plugin.brain2output()
  736. plugin.exit()
  737. if __name__ == '__main__':
  738. main()
  739. #vim: ts=4 sw=4 foldmethod=indent