Jump to content

Recommended Posts

hygorfragas
Posted

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.

hygorfragas
Posted

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?

Posted

It's sent to chrome via web socket.

 

I would check out the webhooks feature.

Posted (edited)

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
hygorfragas
Posted

uhull, great help I think this will be a great starting point for me. Any questions I can take with you?

@matty87a

Posted

If you need anything give me a shout and I'll point you in the right direction if I can

hygorfragas
Posted
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

Posted (edited)

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
Posted

Woops, my bad!

 

Glad you're on the right track

hygorfragas
Posted

Hello @@matty87a Well, I got some guidance from my network supervisor and he said: Just import the xml into your zabbix, would that be?

  • 3 weeks later...
hygorfragas
Posted

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

  • 8 months later...
Posted

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

Posted (edited)

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

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...