hygorfragas 5 Posted December 21, 2019 Posted December 21, 2019 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.
Luke 40064 Posted December 21, 2019 Posted December 21, 2019 Hi, there's a mention of zabbix here in case it helps: https://emby.media/community/index.php?/topic/73134-solved-emby-apach-vhost/?fromsearch=1
hygorfragas 5 Posted December 22, 2019 Author Posted December 22, 2019 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?
Luke 40064 Posted December 22, 2019 Posted December 22, 2019 It's sent to chrome via web socket. I would check out the webhooks feature.
matty87a 6 Posted December 22, 2019 Posted December 22, 2019 (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 December 22, 2019 by matty87a 1
hygorfragas 5 Posted December 22, 2019 Author Posted December 22, 2019 uhull, great help I think this will be a great starting point for me. Any questions I can take with you? @matty87a
matty87a 6 Posted December 23, 2019 Posted December 23, 2019 If you need anything give me a shout and I'll point you in the right direction if I can
hygorfragas 5 Posted December 23, 2019 Author Posted December 23, 2019 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
Thuzad 48 Posted December 23, 2019 Posted December 23, 2019 (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 December 23, 2019 by Floflobel
matty87a 6 Posted December 23, 2019 Posted December 23, 2019 Woops, my bad! Glad you're on the right track
hygorfragas 5 Posted December 24, 2019 Author Posted December 24, 2019 Hello @@matty87a Well, I got some guidance from my network supervisor and he said: Just import the xml into your zabbix, would that be?
matty87a 6 Posted December 29, 2019 Posted December 29, 2019 @@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
hygorfragas 5 Posted January 16, 2020 Author Posted January 16, 2020 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
francescoc 5 Posted September 24, 2020 Posted September 24, 2020 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
Neminem 886 Posted September 26, 2020 Posted September 26, 2020 (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 September 26, 2020 by jaycedk
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now