You've already forked prometheus-fail2ban-exporter
feat: export new version metric (#12)
Add a new `f2b_version` metric that includes the version of the fail2ban server and the exporter. Add a new socket command to get back the fail2ban server version.
This commit is contained in:
@ -118,6 +118,20 @@ func (s *Fail2BanSocket) GetJailStats(jail string) (JailStats, error) {
|
||||
return stats, newBadFormatError(statusCommand, response)
|
||||
}
|
||||
|
||||
func (s *Fail2BanSocket) GetServerVersion() (string, error) {
|
||||
response, err := s.sendCommand([]string{versionCommand})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if lvl1, ok := response.(*types.Tuple); ok {
|
||||
if versionStr, ok := lvl1.Get(1).(string); ok {
|
||||
return versionStr, nil
|
||||
}
|
||||
}
|
||||
return "", newBadFormatError(versionCommand, response)
|
||||
}
|
||||
|
||||
func newBadFormatError(command string, data interface{}) error {
|
||||
return fmt.Errorf("(%s) unexpected response format - cannot parse: %v", command, data)
|
||||
}
|
||||
|
Reference in New Issue
Block a user