Jump to content

Zabbix


hygorfragas

Recommended Posts

hygorfragas

hello, i was wondering how can i get emby metrics on my zabbix server! I want to gather information of new content and several others.

Link to comment
Share on other sites

hygorfragas

hello @@Luke thanks for your time I already looked at this link, but there is nothing I can use! can you answer me if emby works snmp? or which one? I wanted to collect notifications of new content that he sends and notify on zabbix. How does he send this notification to chrome?

Link to comment
Share on other sites

matty87a

You need to create your own template and UserParameters.

 

The Template is an xml file you import through the zabbix ui.

 

The UserParameters are placed in the zabbix config folder - usually /etc/zabbix/zabbix-agentd.d

 

Below are some very basic userparameters I used to use to pull the following into zabbix:

 

- Number of Items Playing

- Number of Items Transcoding

- Number of Items Direct Playing

- Current Emby Version

- Available Upstream Emby Version

 

For these to work you need to pass the Emby API key in the zabbix item - for example, if your API key was 12345 the zabbix item would like something like:

 

emby.nowplaying[12345]

 

Also - these are based on having JQ installed (this can be done via apt on debian systems).

UserParameter=emby.nowplaying[*],curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | wc -l
UserParameter=emby.transcode[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | grep Direct | wc -l
UserParameter=emby.direct[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | grep Direct | wc -l
UserParameter=emby.version[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/System/Info?api_key=$1" -H "accept:application/json" |jq -r '.' | cat | grep -i version | sed 's/[^0-9.]//g'
UserParameter=emby.update[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/System/Info?api_key=$1" -H "accept:application/json" | jq . | grep -i hasupdateavailable | sed -e 's/false/0/' | sed -e 's/true/1/' | sed 's/[^0-9.]//g'

The above are very crude curl manipulations, i know for a fact theres nicer ways to do it and I would recommend writing something using python requests instead, but hopefully this givesa you a jumping off point!

Edited by matty87a
  • Like 1
Link to comment
Share on other sites

hygorfragas
Hi @@matty87a, I tried every way I could. but an error occurs to me in zabbix-agent.

I believe this is very advanced for me, but I need this data! i'm new to zabbix so i have difficulty, would i have any quick tutorial to do this? could you help me with a step by step? I would appreciate it very much very much

Link to comment
Share on other sites

You need to create your own template and UserParameters.

 

The Template is an xml file you import through the zabbix ui.

 

The UserParameters are placed in the zabbix config folder - usually /etc/zabbix/zabbix-agentd.d

 

Below are some very basic userparameters I used to use to pull the following into zabbix:

 

- Number of Items Playing

- Number of Items Transcoding

- Number of Items Direct Playing

- Current Emby Version

- Available Upstream Emby Version

 

For these to work you need to pass the Emby API key in the zabbix item - for example, if your API key was 12345 the zabbix item would like something like:

 

emby.nowplaying[12345]

 

Also - these are based on having JQ installed (this can be done via apt on debian systems).

UserParameter=emby.nowplaying[*],curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | wc -l
UserParameter=emby.transcode[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | grep Direct | wc -l
UserParameter=emby.direct[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | grep Direct | wc -l
UserParameter=emby.version[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/System/Info?api_key=$1" -H "accept:application/json" |jq -r '.' | cat | grep -i version | sed 's/[^0-9.]//g'
UserParameter=emby.update[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/System/Info?api_key=$1" -H "accept:application/json" | jq . | grep -i hasupdateavailable | sed -e 's/false/0/' | sed -e 's/true/1/' | sed 's/[^0-9.]//g'

The above are very crude curl manipulations, i know for a fact theres nicer ways to do it and I would recommend writing something using python requests instead, but hopefully this givesa you a jumping off point!

 

Woh ! Can you share your zabbix template ? 

Thank for these information !

 

Edit: I managed to make a template thanks to your UserParameters, I saw an error here:

UserParameter=emby.transcode[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | grep Direct | wc -l

to

UserParameter=emby.transcode[*], curl 2>/dev/null -X get "http://127.0.0.1:8096/emby/Sessions?api_key=$1" -H "accept:application/json" | jq -r '.[]' | cat | grep -i playmethod | grep Transcode | wc -l
Edited by Floflobel
Link to comment
Share on other sites

matty87a

@@hygorfragas

 

The template is in XML format, but you need to set up the userparameters on the host running the zabbix agent.

 

It might be worth running through the docs first to get an understanding of how the agent works: https://www.zabbix.com/documentation/3.0/manual/config/items/userparameters

 

Then what I've wrote above will probably be a bit clearer

Link to comment
Share on other sites

  • 3 weeks later...
hygorfragas

hello @@matty87a sorry to bother again, I've been searching but unsuccessfully. maybe i can pay for your tutorial or your xml to import. if it interests you, please pass me the price

Link to comment
Share on other sites

  • 8 months later...
francescoc

I don't know if this is still useful but for posterity, here is my emby.conf:

UserParameter=emby.sessions[*],curl -s "http://[::1]:8096/emby/Sessions?api_key=<api key>" -H "accept:application/json" | jq -r '[.[].PlayState | select(.PlayMethod == "$1")] | length'
UserParameter=emby.version,curl -s "http://[::1]:8096/emby/System/Info?api_key=<api key>" -H "accept:application/json" | jq -r '.Version'
UserParameter=emby.update,curl -s "http://[::1]:8096/emby/System/Info?api_key=<api key>" -H "accept:application/json" | jq -r '.HasUpdateAvailable'
UserParameter=emby.ping,curl -sX "POST" "http://[::1]:8096/emby/System/Ping" -d ""

There are multiple ways to insert the api key, I prefer to just hardcode it. Attached is also the template. It simply provides status checking, update and version, and session breakdown by type + total streams. As long as the emby api provides it, it is very simple to add more stuff to Zabbix.

template_app_emby.xml

Link to comment
Share on other sites

jaycedk

Thank you for this :)

Just trying to get this to work on windows.

I have installed curl on windows :)

I have installed jq on windows :)

And that works, the only thing I cant get to work is

UserParameter=emby.sessions[*],curl -s "http://[::1]:8096/emby/Sessions?api_key=<api key>" -H "accept:application/json" | jq -r '[.[].PlayState | select(.PlayMethod == "$1")] | length'

Zabbix error.

Value of type "string" is not suitable for value type "Numeric (float)". Value "jq: error: DirectPlay/0 is not defined at <top-level>, line 1:
[.[].PlayState | select(.PlayMethod == DirectPlay)] | length
jq: 1 compile error"

Tbh I have no idea on how to correct this error.

So that i works with windows 10.

Edited by jaycedk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...