Monitor TP-Link Smart Plug in check_mk

By | April 21, 2019

Objective: to integrate TP-Link Smart Plug into check_mk (for data history and for fun)
Pre-requisite: Check_MK is installed and you have created check_mk site. check_mk installation tutorial will not be covered under this post.

Install software dependencies

apt-get install nodejs npm

Install TP-Link Smart Home API

Switch to OMD site

OMD[home]:~/local/bin$ npm install tplink-smarthome-api

Install TP-Link power monitoring plugin

OMD[home]:~/tmp/wget https://mathias-kettner.com/check_mk-exchange-file.php?&file=tp-link-cmk-1.0.mkp

OMD[home]:~/mkp install /tmp/tp-link-cmk-1.0.mkp

Create monitoring host

Go to WATO > Host & Service Parameters > Datasource Programs

Go to Individual program call instead of agent access

Create new rule. You may insert the rule description and comments as needed (optional). Specify this command under INDIVIDUAL PROGRAM CALL INSTEAD OF AGENT ACCESS.
tp-link-power.js $HOSTNAME$

To be safe during test, you may hardcode explicitly the smart plug ip address.

Create new host, enter hostname and IP address and click “Save & Finish”. Edit again this node and click Parameters on top.

Expand DATASOURCE PROGRAM and select the custom check from here. Click “Individual program call instead of agent access” and make sure the check is here and valid.

Wait for few minutes and check the service graph.

References:

https://github.com/bmachek/tp-link-cmk
https://mathias-kettner.com/check_mk-exchange-file.php?&file=tp-link-cmk-1.0.mkp
https://mathias-kettner.com/download/Marco_Reale_Check_MK_Beginner_guide.pdf
https://www.npmjs.com/package/tplink-smarthome-api
https://mathias-kettner.com/cms_datasource_programs.html

Loading