vitess.io/vitess@v0.16.2/go/cmd/vttablet/status.go (about)

     1  /*
     2  Copyright 2019 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreedto in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package main
    18  
    19  import (
    20  	"vitess.io/vitess/go/vt/servenv"
    21  	_ "vitess.io/vitess/go/vt/status"
    22  	"vitess.io/vitess/go/vt/topo"
    23  	"vitess.io/vitess/go/vt/vttablet/tabletmanager/vreplication"
    24  	"vitess.io/vitess/go/vt/vttablet/tabletserver"
    25  )
    26  
    27  var (
    28  	// tabletTemplate contains the style sheet and the tablet itself.
    29  	// This template is a slight duplicate of the one in go/vt/vttablet/tabletserver/status.go.
    30  	tabletTemplate = `
    31  <style>
    32    table {
    33      border-collapse: collapse;
    34    }
    35    td, th {
    36      border: 1px solid #999;
    37      padding: 0.5rem;
    38    }
    39    .time {
    40      width: 15%;
    41    }
    42    .healthy {
    43      background-color: LightGreen;
    44    }
    45    .unhealthy {
    46      background-color: Salmon;
    47    }
    48    .unhappy {
    49      background-color: Khaki;
    50    }
    51  </style>
    52  <table width="100%" border="" frame="">
    53    <tr border="">
    54      <td width="25%" border="">
    55        Alias: {{github_com_vitessio_vitess_vtctld_tablet .Tablet.AliasString}}<br>
    56        Keyspace: {{github_com_vitessio_vitess_vtctld_keyspace .Tablet.Keyspace}} Shard: {{github_com_vitessio_vitess_vtctld_shard .Tablet.Keyspace .Tablet.Shard}} Tablet Type: {{.Tablet.Type}}<br>
    57        SrvKeyspace: {{github_com_vitessio_vitess_vtctld_srv_keyspace .Tablet.Alias.Cell .Tablet.Keyspace}}<br>
    58        Replication graph: {{github_com_vitessio_vitess_vtctld_replication .Tablet.Alias.Cell .Tablet.Keyspace .Tablet.Shard}}<br>
    59        {{if .DeniedTables}}
    60          DeniedTables: {{range .DeniedTables}}{{.}} {{end}}<br>
    61        {{end}}
    62      </td>
    63      <td width="25%" border="">
    64        <a href="/schemaz">Schema</a></br>
    65        <a href="/debug/tablet_plans">Schema&nbsp;Query&nbsp;Plans</a></br>
    66        <a href="/debug/query_stats">Schema&nbsp;Query&nbsp;Stats</a></br>
    67        <a href="/queryz">Query&nbsp;Stats</a></br>
    68      </td>
    69      <td width="25%" border="">
    70        <a href="/debug/consolidations">Consolidations</a></br>
    71        <a href="/querylogz">Current&nbsp;Query&nbsp;Log</a></br>
    72        <a href="/txlogz">Current&nbsp;Transaction&nbsp;Log</a></br>
    73        <a href="/twopcz">In-flight&nbsp;2PC&nbsp;Transactions</a></br>
    74      </td>
    75      <td width="25%" border="">
    76        <a href="/healthz">Health Check</a></br>
    77        <a href="/debug/health">Query Service Health Check</a></br>
    78        <a href="/livequeryz/">Real-time Queries</a></br>
    79        <a href="/debug/status_details">JSON Status Details</a></br>
    80        <a href="/debug/env">View/Change Environment variables</a></br>
    81      </td>
    82    </tr>
    83  </table>
    84  `
    85  )
    86  
    87  func addStatusParts(qsc tabletserver.Controller) {
    88  	servenv.AddStatusPart("Tablet", tabletTemplate, func() any {
    89  		return map[string]any{
    90  			"Tablet":       topo.NewTabletInfo(tm.Tablet(), nil),
    91  			"DeniedTables": tm.DeniedTables(),
    92  		}
    93  	})
    94  	qsc.AddStatusPart()
    95  	vreplication.AddStatusPart()
    96  }