diff --git a/README.md b/README.md index 07885e2..e67d262 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Modem Statistics Parser -A utility to read and parse channel diagnostics information from DOCSIS and -VDSL modems. +A utility to read and parse channel diagnostics information from DOCSIS modems. This package is intended to be used within a Telegraf instance to be fed into InfluxDB. A Prometheus endpoint can also be exposed for collection. @@ -176,12 +175,6 @@ Ziggo Connectbox:** * `ROUTER_USER` or `--username=admin` (defaults to `admin`) * `ROUTER_PASS` or `--password=password` (defaults to `admin`) -**Sky Hub 2:** - * `ROUTER_TYPE=skyhub2` - * `ROUTER_IP` or `--ip=x.x.x.x` (defaults to `192.168.0.1`) - * `ROUTER_USER` or `--username=admin` (defaults to `admin`) - * `ROUTER_PASS` or `--password=password` (defaults to `sky`) - **Ubee UBC1318:** * `ROUTER_TYPE=ubee` * `ROUTER_IP` or `--ip=x.x.x.x` (defaults to `192.168.100.1`) diff --git a/main.go b/main.go index 3b71301..a72e6a0 100644 --- a/main.go +++ b/main.go @@ -10,12 +10,11 @@ import ( flags "github.com/jessevdk/go-flags" "github.com/msh100/modem-stats/modems/comhemc2" - "github.com/msh100/modem-stats/modems/skyhub2" "github.com/msh100/modem-stats/modems/superhub3" "github.com/msh100/modem-stats/modems/superhub4" "github.com/msh100/modem-stats/modems/superhub5" - "github.com/msh100/modem-stats/modems/ubee" "github.com/msh100/modem-stats/modems/tc4400" + "github.com/msh100/modem-stats/modems/ubee" "github.com/msh100/modem-stats/outputs" "github.com/msh100/modem-stats/utils" ) @@ -70,14 +69,6 @@ func main() { Username: utils.Getenv("ROUTER_USER", commandLineOpts.Username), Password: utils.Getenv("ROUTER_PASS", commandLineOpts.Password), } - case "skyhub2": - modem = &skyhub2.Modem{ - IPAddress: utils.Getenv("ROUTER_IP", commandLineOpts.ModemIP), - Stats: body, - FetchTime: fetchTime, - Username: utils.Getenv("ROUTER_USER", commandLineOpts.Username), - Password: utils.Getenv("ROUTER_PASS", commandLineOpts.Password), - } case "superhub3": modem = &superhub3.Modem{ IPAddress: utils.Getenv("ROUTER_IP", commandLineOpts.ModemIP), diff --git a/modems/skyhub2/skyhub2.go b/modems/skyhub2/skyhub2.go deleted file mode 100644 index 6bc9e56..0000000 --- a/modems/skyhub2/skyhub2.go +++ /dev/null @@ -1,122 +0,0 @@ -package skyhub2 - -import ( - "fmt" - "regexp" - "strconv" - - "github.com/msh100/modem-stats/utils" -) - -type Modem struct { - IPAddress string - Stats []byte - FetchTime int64 - Username string - Password string -} - -func (sky2 *Modem) ClearStats() { - sky2.Stats = nil -} - -func (sky2 *Modem) Type() string { - return utils.TypeVDSL -} - -func (sky2 *Modem) fetchURL() string { - if sky2.Username == "" { - sky2.Username = "admin" - } - if sky2.Password == "" { - sky2.Password = "sky" - } - if sky2.IPAddress == "" { - sky2.IPAddress = "192.168.0.1" - } - return fmt.Sprintf( - "http://%s:%s@%s/Now_TV_system.html", - sky2.Username, - sky2.Password, - sky2.IPAddress, - ) -} - -func (sky2 *Modem) ParseStats() (utils.ModemStats, error) { - if sky2.Stats == nil { - var err error - sky2.Stats, sky2.FetchTime, err = utils.SimpleHTTPFetch(sky2.fetchURL()) - if err != nil { - return utils.ModemStats{}, err - } - } - - syncRegex := regexp.MustCompile("Connection Speed \\(Kbps\\)<\\/td>([0-9]+)<\\/td>([0-9]+)") - syncRate := syncRegex.FindStringSubmatch(string(sky2.Stats)) - - downSync, _ := strconv.Atoi(syncRate[1]) - upSync, _ := strconv.Atoi(syncRate[2]) - - configs := []utils.ModemConfig{ - { - Config: "upstream", - Maxrate: upSync, - }, - { - Config: "downstream", - Maxrate: downSync, - }, - } - - downChannelRegex := regexp.MustCompile("DS([0-9]*):([0-9]*).([0-9]*)") - upChannelRegex := regexp.MustCompile("US([0-9]*):([0-9]*).([0-9]*)") - - attenuationRegex := regexp.MustCompile("Line Attenuation \\(dB\\)<\\/td>.+?") - attenuationData := attenuationRegex.FindStringSubmatch(string(sky2.Stats)) - - noiseRegex := regexp.MustCompile("Noise Margin \\(dB\\)<\\/td>.+?") - noiseData := noiseRegex.FindStringSubmatch(string(sky2.Stats)) - - downAttenuation := downChannelRegex.FindAllStringSubmatch(attenuationData[0], -1) - downNoise := downChannelRegex.FindAllStringSubmatch(noiseData[0], -1) - upAttenuation := upChannelRegex.FindAllStringSubmatch(attenuationData[0], -1) - upNoise := upChannelRegex.FindAllStringSubmatch(noiseData[0], -1) - - var downChannels []utils.ModemChannel - var upChannels []utils.ModemChannel - - for _, v := range downAttenuation { - channelID, _ := strconv.Atoi(v[1]) - attenuation, _ := strconv.Atoi(fmt.Sprintf("%s%s", v[2], v[3])) - downChannels = append(downChannels, utils.ModemChannel{ - ChannelID: channelID, - Attenuation: attenuation, - }) - } - for _, v := range downNoise { - channelID, _ := strconv.Atoi(v[1]) - noise, _ := strconv.Atoi(fmt.Sprintf("%s%s", v[2], v[3])) - downChannels[channelID-1].Noise = noise - } - for _, v := range upAttenuation { - channelID, _ := strconv.Atoi(v[1]) - attenuation, _ := strconv.Atoi(fmt.Sprintf("%s%s", v[2], v[3])) - upChannels = append(upChannels, utils.ModemChannel{ - ChannelID: channelID, - Attenuation: attenuation, - }) - } - for _, v := range upNoise { - channelID, _ := strconv.Atoi(v[1]) - noise, _ := strconv.Atoi(fmt.Sprintf("%s%s", v[2], v[3])) - upChannels[channelID].Noise = noise - } - - return utils.ModemStats{ - Configs: configs, - DownChannels: downChannels, - UpChannels: upChannels, - FetchTime: sky2.FetchTime, - ModemType: utils.TypeVDSL, - }, nil -}