-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-61121] Add diagnostics data to the Support Packet (#1131)
Co-authored-by: kshitij katiyar <kshitij.katiyar@brightscout.com>
- Loading branch information
1 parent
6a7a70f
commit a8d2403
Showing
4 changed files
with
123 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package main | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/hashicorp/go-multierror" | ||
"github.com/pkg/errors" | ||
"gopkg.in/yaml.v3" | ||
|
||
"github.com/mattermost/mattermost/server/public/model" | ||
"github.com/mattermost/mattermost/server/public/plugin" | ||
) | ||
|
||
type SupportPacket struct { | ||
Version string `yaml:"version"` | ||
|
||
InstanceCount int `yaml:"instance_count"` | ||
ServerInstanceCount int `yaml:"server_instance_count"` | ||
CloudInstanceCount int `yaml:"cloud_instance_count"` | ||
SubscriptionCount int `yaml:"subscription_count"` | ||
ConnectedUserCount int `yaml:"connected_user_count"` | ||
} | ||
|
||
func (p *Plugin) GenerateSupportData(_ *plugin.Context) ([]*model.FileData, error) { | ||
var result *multierror.Error | ||
|
||
connectedUserCount, err := p.userCount() | ||
if err != nil { | ||
result = multierror.Append(result, errors.Wrap(err, "failed to get the number of connected users for Support Packet")) | ||
} | ||
|
||
serverICount, cloudICount, err := p.instanceCount() | ||
if err != nil { | ||
result = multierror.Append(result, errors.Wrap(err, "failed to get the number of instances for Support Packet")) | ||
} | ||
|
||
subscriptionCount, err := p.subscriptionCount() | ||
if err != nil { | ||
result = multierror.Append(result, errors.Wrap(err, "failed to get the number of subscriptions for Support Packet")) | ||
} | ||
|
||
diagnostics := SupportPacket{ | ||
Version: manifest.Version, | ||
InstanceCount: serverICount + cloudICount, | ||
ServerInstanceCount: serverICount, | ||
CloudInstanceCount: cloudICount, | ||
SubscriptionCount: subscriptionCount, | ||
ConnectedUserCount: connectedUserCount, | ||
} | ||
body, err := yaml.Marshal(diagnostics) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to marshal diagnostics") | ||
} | ||
|
||
return []*model.FileData{{ | ||
Filename: filepath.Join(manifest.Id, "diagnostics.yaml"), | ||
Body: body, | ||
}}, result.ErrorOrNil() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters