bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/scollector/collectors/iis_windows.go (about) 1 package collectors 2 3 import ( 4 "bosun.org/metadata" 5 "bosun.org/opentsdb" 6 ) 7 8 func init() { 9 c := &IntervalCollector{ 10 F: c_iis_webservice, 11 } 12 c.init = wmiInit(c, func() interface{} { return &[]Win32_PerfRawData_W3SVC_WebService{} }, `WHERE Name <> '_Total'`, &iisQuery) 13 collectors = append(collectors, c) 14 15 c = &IntervalCollector{ 16 F: c_iis_apppool, 17 } 18 c.init = wmiInit(c, func() interface{} { return &[]Win32_PerfRawData_APPPOOLCountersProvider_APPPOOLWAS{} }, `WHERE Name <> '_Total'`, &iisQueryAppPool) 19 collectors = append(collectors, c) 20 } 21 22 var ( 23 iisQuery string 24 iisQueryAppPool string 25 ) 26 27 func c_iis_webservice() (opentsdb.MultiDataPoint, error) { 28 var dst []Win32_PerfRawData_W3SVC_WebService 29 err := queryWmi(iisQuery, &dst) 30 if err != nil { 31 return nil, err 32 } 33 var md opentsdb.MultiDataPoint 34 for _, v := range dst { 35 Add(&md, "iis.bytes", v.BytesReceivedPersec, opentsdb.TagSet{"site": v.Name, "direction": "received"}, metadata.Counter, metadata.BytesPerSecond, descIISBytesReceivedPersec) 36 Add(&md, "iis.bytes", v.BytesSentPersec, opentsdb.TagSet{"site": v.Name, "direction": "sent"}, metadata.Counter, metadata.BytesPerSecond, descIISBytesSentPersec) 37 Add(&md, "iis.requests", v.CGIRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "cgi"}, metadata.Counter, metadata.PerSecond, descIISCGIRequestsPersec) 38 Add(&md, "iis.connection_attempts", v.ConnectionAttemptsPersec, opentsdb.TagSet{"site": v.Name}, metadata.Counter, metadata.PerSecond, descIISConnectionAttemptsPersec) 39 Add(&md, "iis.requests", v.CopyRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "copy"}, metadata.Counter, metadata.PerSecond, descIISCopyRequestsPersec) 40 Add(&md, "iis.connections", v.CurrentConnections, opentsdb.TagSet{"site": v.Name}, metadata.Gauge, metadata.Count, descIISCurrentConnections) 41 Add(&md, "iis.requests", v.DeleteRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "delete"}, metadata.Counter, metadata.PerSecond, descIISDeleteRequestsPersec) 42 Add(&md, "iis.requests", v.GetRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "get"}, metadata.Counter, metadata.PerSecond, descIISGetRequestsPersec) 43 Add(&md, "iis.requests", v.HeadRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "head"}, metadata.Counter, metadata.PerSecond, descIISHeadRequestsPersec) 44 Add(&md, "iis.requests", v.ISAPIExtensionRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "isapi"}, metadata.Counter, metadata.PerSecond, descIISISAPIExtensionRequestsPersec) 45 Add(&md, "iis.errors", v.LockedErrorsPersec, opentsdb.TagSet{"site": v.Name, "type": "locked"}, metadata.Counter, metadata.PerSecond, descIISLockedErrorsPersec) 46 Add(&md, "iis.requests", v.LockRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "lock"}, metadata.Counter, metadata.PerSecond, descIISLockRequestsPersec) 47 Add(&md, "iis.requests", v.MkcolRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "mkcol"}, metadata.Counter, metadata.PerSecond, descIISMkcolRequestsPersec) 48 Add(&md, "iis.requests", v.MoveRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "move"}, metadata.Counter, metadata.PerSecond, descIISMoveRequestsPersec) 49 Add(&md, "iis.errors", v.NotFoundErrorsPersec, opentsdb.TagSet{"site": v.Name, "type": "notfound"}, metadata.Counter, metadata.PerSecond, descIISNotFoundErrorsPersec) 50 Add(&md, "iis.requests", v.OptionsRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "options"}, metadata.Counter, metadata.PerSecond, descIISOptionsRequestsPersec) 51 Add(&md, "iis.requests", v.PostRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "post"}, metadata.Counter, metadata.PerSecond, descIISPostRequestsPersec) 52 Add(&md, "iis.requests", v.PropfindRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "propfind"}, metadata.Counter, metadata.PerSecond, descIISPropfindRequestsPersec) 53 Add(&md, "iis.requests", v.ProppatchRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "proppatch"}, metadata.Counter, metadata.PerSecond, descIISProppatchRequestsPersec) 54 Add(&md, "iis.requests", v.PutRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "put"}, metadata.Counter, metadata.PerSecond, descIISPutRequestsPersec) 55 Add(&md, "iis.requests", v.SearchRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "search"}, metadata.Counter, metadata.PerSecond, descIISSearchRequestsPersec) 56 Add(&md, "iis.requests", v.TraceRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "trace"}, metadata.Counter, metadata.PerSecond, descIISTraceRequestsPersec) 57 Add(&md, "iis.requests", v.UnlockRequestsPersec, opentsdb.TagSet{"site": v.Name, "method": "unlock"}, metadata.Counter, metadata.PerSecond, descIISUnlockRequestsPersec) 58 } 59 return md, nil 60 } 61 62 const ( 63 descIISBytesReceivedPersec = "The rate that data bytes are received by the Web service." 64 descIISBytesSentPersec = "The rate data bytes are being sent by the Web service." 65 descIISCGIRequestsPersec = "The rate CGI requests are received by the Web service." 66 descIISConnectionAttemptsPersec = "The rate that connections to the Web service are being attempted." 67 descIISCopyRequestsPersec = "The rate HTTP requests using the COPY method are made. Copy requests are used for copying files and directories." 68 descIISCurrentConnections = "The current number of connections established with the Web service." 69 descIISDeleteRequestsPersec = "The rate HTTP requests using the DELETE method are made. Delete requests are generally used for file removals." 70 descIISGetRequestsPersec = "The rate HTTP requests using the GET method are made. Get requests are the most common HTTP request." 71 descIISHeadRequestsPersec = "The rate HTTP requests using the HEAD method are made. Head requests generally indicate a client is querying the state of a document they already have to see if it needs to be refreshed." 72 descIISISAPIExtensionRequestsPersec = "The rate that ISAPI Extension requests are received by the Web service." 73 descIISLockedErrorsPersec = "The rate of errors due to requests that couldn't be satisfied by the server because the requested document was locked. These are generally reported as an HTTP 423 error code to the client." 74 descIISLockRequestsPersec = "The rate HTTP requests using the LOCK method are made. Lock requests are used to lock a file for one user so that only that user can modify the file." 75 descIISMkcolRequestsPersec = "The rate HTTP requests using the MKCOL method are made. Mkcol requests are used to create directories on the server." 76 descIISMoveRequestsPersec = "The rate HTTP requests using the MOVE method are made. Move requests are used for moving files and directories." 77 descIISNotFoundErrorsPersec = "The rate of errors due to requests that couldn't be satisfied by the server because the requested document could not be found. These are generally reported as an HTTP 404 error code to the client." 78 descIISOptionsRequestsPersec = "The rate HTTP requests using the OPTIONS method are made." 79 descIISPostRequestsPersec = "The rate HTTP requests using the POST method are made." 80 descIISPropfindRequestsPersec = "The rate HTTP requests using the PROPFIND method are made. Propfind requests retrieve property values on files and directories." 81 descIISProppatchRequestsPersec = "The rate HTTP requests using the PROPPATCH method are made. Proppatch requests set property values on files and directories." 82 descIISPutRequestsPersec = "The rate HTTP requests using the PUT method are made." 83 descIISSearchRequestsPersec = "The rate HTTP requests using the SEARCH method are made. Search requests are used to query the server to find resources that match a set of conditions provided by the client." 84 descIISTraceRequestsPersec = "The rate HTTP requests using the TRACE method are made. Trace requests allow the client to see what is being received at the end of the request chain and use the information for diagnostic purposes." 85 descIISUnlockRequestsPersec = "The rate HTTP requests using the UNLOCK method are made. Unlock requests are used to remove locks from files." 86 ) 87 88 type Win32_PerfRawData_W3SVC_WebService struct { 89 BytesReceivedPersec uint64 90 BytesSentPersec uint64 91 CGIRequestsPersec uint32 92 ConnectionAttemptsPersec uint32 93 CopyRequestsPersec uint32 94 CurrentConnections uint32 95 DeleteRequestsPersec uint32 96 GetRequestsPersec uint32 97 HeadRequestsPersec uint32 98 ISAPIExtensionRequestsPersec uint32 99 LockRequestsPersec uint32 100 LockedErrorsPersec uint32 101 MkcolRequestsPersec uint32 102 MoveRequestsPersec uint32 103 Name string 104 NotFoundErrorsPersec uint32 105 OptionsRequestsPersec uint32 106 PostRequestsPersec uint32 107 PropfindRequestsPersec uint32 108 ProppatchRequestsPersec uint32 109 PutRequestsPersec uint32 110 SearchRequestsPersec uint32 111 TraceRequestsPersec uint32 112 UnlockRequestsPersec uint32 113 } 114 115 func c_iis_apppool() (opentsdb.MultiDataPoint, error) { 116 var dst []Win32_PerfRawData_APPPOOLCountersProvider_APPPOOLWAS 117 err := queryWmi(iisQueryAppPool, &dst) 118 if err != nil { 119 return nil, err 120 } 121 var md opentsdb.MultiDataPoint 122 for _, v := range dst { 123 tags := opentsdb.TagSet{"name": v.Name} 124 if v.Frequency_Object != 0 { 125 uptime := (v.Timestamp_Object - v.CurrentApplicationPoolUptime) / v.Frequency_Object 126 failtime := (v.Timestamp_Object - v.TimeSinceLastWorkerProcessFailure) / v.Frequency_Object 127 Add(&md, "iis.apppool.uptime", uptime, tags, metadata.Gauge, metadata.Second, descIISAppPoolCurrentApplicationPoolUptime) 128 Add(&md, "iis.apppool.time_since_failure", failtime, tags, metadata.Gauge, metadata.Second, descIISAppPoolTimeSinceLastWorkerProcessFailure) 129 } 130 Add(&md, "iis.apppool.state", v.CurrentApplicationPoolState, tags, metadata.Gauge, metadata.StatusCode, descIISAppPoolCurrentApplicationPoolState) 131 Add(&md, "iis.apppool.processes", v.CurrentWorkerProcesses, opentsdb.TagSet{"name": v.Name, "type": "current"}, metadata.Gauge, metadata.Count, descIISAppPoolCurrentWorkerProcesses) 132 Add(&md, "iis.apppool.processes", v.MaximumWorkerProcesses, opentsdb.TagSet{"name": v.Name, "type": "maximum"}, metadata.Gauge, metadata.Count, descIISAppPoolMaximumWorkerProcesses) 133 Add(&md, "iis.apppool.processes", v.RecentWorkerProcessFailures, opentsdb.TagSet{"name": v.Name, "type": "failed"}, metadata.Gauge, metadata.Count, descIISAppPoolRecentWorkerProcessFailures) 134 Add(&md, "iis.apppool.events", v.TotalApplicationPoolRecycles, opentsdb.TagSet{"name": v.Name, "type": "recycled"}, metadata.Counter, metadata.Event, descIISAppPoolTotalApplicationPoolRecycles) 135 Add(&md, "iis.apppool.events", v.TotalWorkerProcessesCreated, opentsdb.TagSet{"name": v.Name, "type": "created"}, metadata.Counter, metadata.Event, descIISAppPoolTotalWorkerProcessesCreated) 136 Add(&md, "iis.apppool.events", v.TotalWorkerProcessFailures, opentsdb.TagSet{"name": v.Name, "type": "failed_crash"}, metadata.Counter, metadata.Event, descIISAppPoolTotalWorkerProcessFailures) 137 Add(&md, "iis.apppool.events", v.TotalWorkerProcessPingFailures, opentsdb.TagSet{"name": v.Name, "type": "failed_ping"}, metadata.Counter, metadata.Event, descIISAppPoolTotalWorkerProcessPingFailures) 138 Add(&md, "iis.apppool.events", v.TotalWorkerProcessShutdownFailures, opentsdb.TagSet{"name": v.Name, "type": "failed_shutdown"}, metadata.Counter, metadata.Event, descIISAppPoolTotalWorkerProcessShutdownFailures) 139 Add(&md, "iis.apppool.events", v.TotalWorkerProcessStartupFailures, opentsdb.TagSet{"name": v.Name, "type": "failed_startup"}, metadata.Counter, metadata.Event, descIISAppPoolTotalWorkerProcessStartupFailures) 140 } 141 return md, nil 142 } 143 144 const ( 145 descIISAppPoolCurrentApplicationPoolState = "The current status of the application pool (1 - Uninitialized, 2 - Initialized, 3 - Running, 4 - Disabling, 5 - Disabled, 6 - Shutdown Pending, 7 - Delete Pending)." 146 descIISAppPoolCurrentApplicationPoolUptime = "The length of time, in seconds, that the application pool has been running since it was started." 147 descIISAppPoolCurrentWorkerProcesses = "The current number of worker processes that are running in the application pool." 148 descIISAppPoolMaximumWorkerProcesses = "The maximum number of worker processes that have been created for the application pool since Windows Process Activation Service (WAS) started." 149 descIISAppPoolRecentWorkerProcessFailures = "The number of times that worker processes for the application pool failed during the rapid-fail protection interval." 150 descIISAppPoolTimeSinceLastWorkerProcessFailure = "The length of time, in seconds, since the last worker process failure occurred for the application pool." 151 descIISAppPoolTotalApplicationPoolRecycles = "The number of times that the application pool has been recycled since Windows Process Activation Service (WAS) started." 152 descIISAppPoolTotalWorkerProcessesCreated = "The number of worker processes created for the application pool since Windows Process Activation Service (WAS) started." 153 descIISAppPoolTotalWorkerProcessFailures = "The number of times that worker processes have crashed since the application pool was started." 154 descIISAppPoolTotalWorkerProcessPingFailures = "The number of times that Windows Process Activation Service (WAS) did not receive a response to ping messages sent to a worker process." 155 descIISAppPoolTotalWorkerProcessShutdownFailures = "The number of times that Windows Process Activation Service (WAS) failed to shut down a worker process." 156 descIISAppPoolTotalWorkerProcessStartupFailures = "The number of times that Windows Process Activation Service (WAS) failed to start a worker process." 157 ) 158 159 type Win32_PerfRawData_APPPOOLCountersProvider_APPPOOLWAS struct { 160 CurrentApplicationPoolState uint32 161 CurrentApplicationPoolUptime uint64 162 CurrentWorkerProcesses uint32 163 Frequency_Object uint64 164 MaximumWorkerProcesses uint32 165 Name string 166 RecentWorkerProcessFailures uint32 167 TimeSinceLastWorkerProcessFailure uint64 168 Timestamp_Object uint64 169 TotalApplicationPoolRecycles uint32 170 TotalWorkerProcessesCreated uint32 171 TotalWorkerProcessFailures uint32 172 TotalWorkerProcessPingFailures uint32 173 TotalWorkerProcessShutdownFailures uint32 174 TotalWorkerProcessStartupFailures uint32 175 }