Coder Social home page Coder Social logo

mcktr / check_fritz Goto Github PK

View Code? Open in Web Editor NEW
31.0 8.0 9.0 391 KB

Check plugin written in Go to monitor a Fritz!Box

License: GNU General Public License v2.0

Go 98.02% Makefile 1.98%
avm fritz fritzbox icinga icinga2 monitoring monitoring-plugins golang go

check_fritz's People

Contributors

andreasscherbaum avatar mcktr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

check_fritz's Issues

Remove deprecated smart device functions

In 1.1.0 we invented a new handling for smart device indexes. We decided to support both ways (old handling via index and new handling via AIN) for one release.

In 1.2.0 we should remove the old handling via index. The functions were marked deprecated in 1.1.0.

UNKNOWN - Unexpected response status code: 500

Since the update of Fritz! OS to version 7.25, the error mentioned in the title appears under Icinga2 or the command line. Settings in the monitoring or the Fritzbox were not made. The data of the version of the check command used are:

  • Version 1.2.2
  • Architecture: Linux AMD64
  • Fritz!OS 7.25
  • No settings changed

Output debug informations:

---
Frist SOAP Response:
---
<?xml version="1.0"?>
 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring>UPnPError</faultstring>
<detail>
<UPnPError xmlns="urn:dslforum-org:control-1-0">
<errorCode>401</errorCode>
<errorDescription>invalid action</errorDescription>
</UPnPError>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
---
UNKNOWN - Unexpected response status code: 500

Zero thresholds should be ignore

Since we set zero as default threshold we should ignore them as this would break warning/critical calculation.

check_fritz (master) $ go run cmd/check_fritz/*.go --hostname 192.168.178.1 --password [###] --method downstream_current
CRITICAL - Current Downstream: 0.00 Mbit/s 
exit status 2

Implement timeout parameter

Sometimes checks run for a unusual long time.

  • Evaluate if this is an error in the check implementation or the response from the Fritz!Box takes to long.
  • Implement a timeout condition

Implement threshold ranges

Hi,
I noticed, that thresholds are not supported in the uptime checks. Imho, I should be able to get an alert, when -c < -w < value.
E.g. critical when uptime < 10m ; warning when uptime < 15m

Cheers,
Marcus

execvpe(/usr/lib64/nagios/plugins/check_fritz) failed: Permission denied

Hi,

I just set up a new Icinga2 monitoring instance and began adding hosts starting with my Fritz!Box 5490. This is when I came across this amazing plugin. I installed it according to the "Installtion" chapter in the docs without any issues, but as soon as I restart the icinga2 service I am getting the above error displayed for the check on my IcingaWeb2 dashboard.

The icinga2 log (/var/log/icinga2/icinga2.log) shows the following recurring entry:
[2020-06-30 08:16:00 +0200] warning/PluginCheckTask: Check command for object 'FRITZBox 5490!WAN Status' (PID: 143277, arguments: '/usr/lib64/nagios/plugins/check_fritz' '--method' 'connection_status' '--password' 'xxxxxxxx' '--username' 'icinga2') terminated with exit code 128, output: execvpe(/usr/lib64/nagios/plugins/check_fritz) failed: Permission denied

So I thought I messed up my file permission which look like this:

[root@z25-icinga-mstr admin]# ls -la /usr/lib64/nagios/plugins/
insgesamt 14100
drwxr-xr-x. 3 root root      4096 29. Jun 14:58 .
drwxr-xr-x. 3 root root        21 29. Aug 2019  ..
-rwxr-xr-x. 1 root root     34136 24. Mai 23:03 check_dummy
-rwxr-xr-x. 1 root root      5066 24. Mai 23:03 check_file_age
-rwxr-xr-x. 1 root root      6504 24. Mai 23:03 check_flexlm
-rwsr-x---. 1 root nagios   59784 24. Mai 23:03 check_fping
-rwxr-xr-x. 1 root icinga 7499745 29. Jun 14:57 check_fritz
...

Note that I added the "icinga" group while debugging it used to be root like almost all file in the plugins directory.

To be sure it is not a permission issue I tried running the check manually as the "icinga" user, which works fine:
[root@xxxxxx xxxx]# sudo -H -u icinga '/usr/lib64/nagios/plugins/check_fritz' '--method' 'connection_status' '--password' 'xxxxxxxx' '--username' 'icinga2' OK - Connection Status: Connected; External IP: 89.245.xxx.xxx

Any suggestion on what might be wrong here?

Edit: Just found another clue. The error seems to be caused by SELinux:

[root@xxxxxxx xxxxxx]# tail -f /var/log/audit/audit.log
type=AVC msg=audit(1593502140.290:2579): avc:  denied  { execute } for  pid=144517 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502200.290:2580): avc:  denied  { execute } for  pid=144531 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502260.290:2581): avc:  denied  { execute } for  pid=144546 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502320.290:2582): avc:  denied  { execute } for  pid=144560 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502380.290:2583): avc:  denied  { execute } for  pid=144575 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502440.290:2584): avc:  denied  { execute } for  pid=144589 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502500.290:2585): avc:  denied  { execute } for  pid=144603 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502560.290:2586): avc:  denied  { execute } for  pid=144618 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502620.290:2587): avc:  denied  { execute } for  pid=144633 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502680.290:2588): avc:  denied  { execute } for  pid=144652 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=AVC msg=audit(1593502740.290:2589): avc:  denied  { execute } for  pid=144673 comm="icinga2" name="check_fritz" dev="dm-0" ino=100855371 scontext=system_u:system_r:icinga2_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0

cable speed seems to be incorrectly reported

I use an FB 6591 Cable with Fritz!OS 7.12. On the overview page, the cable speed is shown as 57,5 MBit don / 53 MBit up; nevertheless, the plugin reports downstream_max as 62,48 MBit/s and upstream_max as 34,24 MBit

Indexes are changed after a reboot

Problem

I recently updated and rebooted my Fritz!Box. After everything was back up I looked at the configured services for my Fritz!Box and noticed that the checks for the smart devices are somehow broken.

For example:

The check for my kitchen temperature now checks the temperature of my living room.
image

I guess after the update and/or the reboot the indexes got changed for the smart devices.

Solution

  • find out if this happens on a reboot or only after an upgrade.
  • find another way to identify the smart devices, e.g by name

Do not require a password

Currently we enforce to set a password but it is totally valid, that a user haven't set a password on their Fritz!Box.

Add development informations

Add information for further development/contributions, which clarify how the plugin works and where to get information about the Fritz!Box API.

Implement debug mode

In order to debug things properly we should introduce a debug mode to collect the raw information that are provided by the Fritz!Box.

Get data from Online Meter

It would be great to get the usage from the Online Meter (under Internet - Online Monitor) for monitoring purpose, but also for warning notification for those with a limited volume.

Flexible Minimum value for Graphs

When creating graphs, it's a bit annoying that the check seems to return a range minimum of 0, which prevents icinga2 (in my case) to calculate it dynamically itself.
Looks like this:
grafik
...but i would prefer it like this:
grafik
Maybe make that configurable via a parameter?

Implement function that checks if current is more than x% of max

Let's say we want to monitor if the current up or downstream is more than 80% of the total available bandwidth. It would be nice to have a check where I can provide crit and warn value and the app calculates that automatically.

./check_fritz -m downstream_usage -c 80

OK - Current Downstream is 34.47 Mbit/s of 97.46 Mbit/s (35.37% utilization) | perfdata

Document smart_status function

The smart_status function is part of v1.1.0 (not released yet), but currently the method is not documented.

Reminder to add the documentation for it.

No WARNING or CRITICAL status for device and connection status

Hi,
this is my first GitHub issue. Sorry if I did do something wrong.

The methods connection_uptime and device_uptime always return OK. Since I want to monitor the status, I need Warning and Critical also.

Example for connection_uptime:
$ ./check_fritz -p <password> -m connection_uptime -w 252000 -c 259200 OK - Connection Uptime: 252765 seconds (2d 22h 12m 45s) | 'uptime'=252765.000000s;;;;

Expected output:
CRITICAL - Connection Uptime: 252765 seconds (2d 22h 12m 45s) | 'uptime'=252765.000000s;252000.000000s;259200.000000s;;

Am I doing something wrong here or is this a check plugin bug?

Improve the help output

For example currently the methods are not shown in the help text output. At least this should be added.

Wrong value for max upstream/downstream

The following methods use values from the X_AVM-DE_GetOnlineMonitor action, these values does not contain the max link up-/downstream but the max measured up-/downstream.

  • downstream_usage
  • downstream_max
  • upstream_usage
  • upstream_max

X_AVM-DE_GetOnlineMonitor:

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:X_AVM-DE_GetOnlineMonitorResponse xmlns:u="urn:dslforum-org:service:WANCommonInterfaceConfig:1">
<NewTotalNumberSyncGroups>1</NewTotalNumberSyncGroups>
<NewSyncGroupName>sync_dsl</NewSyncGroupName>
<NewSyncGroupMode>VDSL</NewSyncGroupMode>
<Newmax_ds>14263750</Newmax_ds>
<Newmax_us>4369625</Newmax_us>
<Newds_current_bps>318355,354445,466082,72462,367271,356612,319050,371373,324781,575806,439400,554,444307,12,388651,1181,380154,415292,318132,362875</Newds_current_bps>
<Newmc_current_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newmc_current_bps>
<Newus_current_bps>7303,11744,10270,2332,8847,9818,8671,10040,8214,13005,9518,860,13997,36,8787,491,9167,10795,6995,9456</Newus_current_bps>
<Newprio_realtime_bps>124,3317,26,149,704,1813,1549,1679,530,38,33,705,4355,7,42,148,651,887,0,1180</Newprio_realtime_bps>
<Newprio_high_bps>7076,7322,10124,1826,8109,7769,6873,8010,7295,12650,9459,15,9438,0,8320,31,8365,9247,6953,7946</Newprio_high_bps>
<Newprio_default_bps>103,1105,120,357,34,236,249,351,389,317,26,140,204,29,425,312,151,661,42,330</Newprio_default_bps>
<Newprio_low_bps>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0</Newprio_low_bps>
</u:X_AVM-DE_GetOnlineMonitorResponse>
</s:Body>
</s:Envelope>

Possible successor:

GetCommonLinkProperties

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetCommonLinkPropertiesResponse xmlns:u="urn:dslforum-org:service:WANCommonInterfaceConfig:1">
<NewWANAccessType>DSL</NewWANAccessType>
<NewLayer1UpstreamMaxBitRate>35782000</NewLayer1UpstreamMaxBitRate>
<NewLayer1DownstreamMaxBitRate>126287000</NewLayer1DownstreamMaxBitRate>
<NewPhysicalLinkStatus>Up</NewPhysicalLinkStatus>
</u:GetCommonLinkPropertiesResponse>
</s:Body>
</s:Envelope>

#83 (comment)

refs #83

Crashing smart_heatertemperatur

Just experimenting with the plugin. Basic things arw working, but:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x21fc7c]

goroutine 1 [running]:
main.CheckSpecificSmartHeaterTemperatur(0xc665e8, 0xc665f0, 0xc665f8, 0xc66600, 0xc66608, 0x0, 0x0, 0x0, 0x0, 0xc7e254, ...)
/home/travis/gopath/src/github.com/mcktr/check_fritz/cmd/check_fritz/check_smart.go:61 +0x1d4
main.main()
/home/travis/gopath/src/github.com/mcktr/check_fritz/cmd/check_fritz/main.go:212 +0x1e70

Did i possibly do something wrong?

FritzBox 6890 LTE

Hi check_fritz developers,

i have an FritzBox 6890 LTE in use and would like to monitor it with check_fritz. I use an external IP Modem to connect via fiber to the WWW.
When i use the following command: ./check_fritz --hostname 192.168.*.* --username user --password password
i get the following error: -bash: !fritzbox: event not found

I guess my FritzBox is not supported? Maybe you could help me, to find out why it's not working.

Thanks in advance.

Kind Regards
j-lutz

Support for the Fritz!Box cable versions

Implement support for the Fritz!Box cable versions. The only methods where this matters should be the method where we check the link connection (connection_status, connection_uptime).

While the implementation should be fairly easy, the testing is difficult since I don't have a Fritz!Box cable version at hand.

panic when no AIN is set and a method that expects one is used

michael@metis ~/go/src/github.com/mcktr/check_fritz (master) $ build/check_fritz.linux.amd64 -H 192.168.178.1 -p secret -m smart_heatertemperatur
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x77aabb]

goroutine 1 [running]:
main.CheckSpecificSmartHeaterTemperatur(0xc00018fc68, 0xc00018fc28, 0xc00018fc18, 0xc00018fc38, 0xc00018fc58, 0x0, 0x0, 0x0, 0xc00018fbe8, 0xc00018fc48, ...)
	/home/michael/go/src/github.com/mcktr/check_fritz/cmd/check_fritz/check_smart.go:61 +0x2fb
main.checkMain(0xc00002ac40, 0xc00000f000, 0x16)
	/home/michael/go/src/github.com/mcktr/check_fritz/cmd/check_fritz/main.go:175 +0xa58
github.com/urfave/cli/v2.(*App).RunContext(0xc000001980, 0x8a9580, 0xc0000160d8, 0xc000012070, 0x7, 0x7, 0x0, 0x0)
	/home/michael/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:315 +0x70d
github.com/urfave/cli/v2.(*App).Run(...)
	/home/michael/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:215
main.main()
	/home/michael/go/src/github.com/mcktr/check_fritz/cmd/check_fritz/main.go:301 +0xb39

Typo in help output

build/check_fritz.linux.amd64 --help
NAME:

  check_fritz - Check plugin to monitor a Fritz!Box

USAGE:
   check_fritz [options...]

OPTIONS:

  --hostname value, -H value  Specifies the hostname. (default: fritz.box)
  --port value, -P value      Specifies the SSL port. (default: 49443)
  --username value, -u value  Specifies the username. (default: dslf-config)
  --password value, -p value  Specifies the password.
  --method value, -m value    Specifies the check method. (default: connection_status)
  --ain value, -a value       Specifies the AIN for smart devices.
  --timeout value, -t value   Specifies the timeout for requests. (default: 90)
  --modelgroup value          Specifies the Fritz!Bpx model group (DSL or Cable). (default: DSL)
  --warning value, -w value   Specifies the warning threshold. (default: 0)
  --critical value, -c value  Specifies the critical threshold. (default: 0)
  --debug, -d                 Outputs debug information (default: false)
  --help, -h                  show help (default: false)
  --version, -V               print the version (default: false)
  

METHODS:
  connection_status       WAN connection status,
  connection_uptime       WAN connection uptime (in seconds),
  device_uptime           device uptime (in seconds),
  device_update           update state,
  downstream_max          maximum downstream,
  upstream_max            maximum downstream,
  downstream_current      current downstream,
  upstream_current        current upstream,
  downstream_usage        current downstream usage,
  upstream_usage          current upstream usage,
  smart_heattemperatur    current temperature of a a radiator thermostat (requires AIN),
  smart_socketpower       current power consumption of a socket switch (requires AIN),
  smart_status            current smart device status (requires AIN)

The method is called smart_heatertemperatur and not smart_heattemperatur.

Path in sha256-file do not match the documentation

Example SHA256:
https://exchange.icinga.com/mcktr/check_fritz/files/12691/check_fritz.linux.amd64.sha256

Content:

069397e83e52bade2291002b9435e0f32ae1ad10a684f1282470cdcde0f2ec1a  build/check_fritz.linux.amd64

But documentation (https://exchange.icinga.com/mcktr/check_fritz) expects that sha256-file and binary-file are in the same directory:

$ wget [DOWNLOAD URL CURRENT RELEASE]]/check_fritz.linux.amd64
$ wget [DOWNLOAD URL CURRENT RELEASE]]/check_fritz.linux.amd64.sha256

$ sha256sum -c check_fritz.linux.amd64.sha256
check_fritz.linux.amd64: OK

Please fix the sha256-files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.