Question

Say I want to monitor number of concurrent user at this moment in our production server using Zabbix http://www.zabbix.com/. Can anyone let me know how can I do that? The servers are written in java.

Was it helpful?

Solution

First question to answer is: how you can query the number of users on the server? Is this something you can grep out of some log file? Or maybe your 'server written in java' allows to query the user count in some standardized way (i.e. via http)?

You might be able to use one of standard zabbix checks, but most probably you'll have to configure zabbix agent running at your server to monitor a custom User Parameter: https://www.zabbix.com/documentation/1.8/manual/config/user_parameters.


So, needed value should be parsed out of json available via http. Starting with version 2.2 you'll be able to do it with web.page.regexp[] but since it's not production ready yet you'll have to stick to custom user items.

Supposedly zabbix agent is running on linux. Open the zabbix_agentd.conf and add the following line:

UserParameter=json.query[*], value=$(curl -s $1 | grep -Eo "\"$2\":(\w*)"| cut -d: -f2); if [ -z "$value" ]; then echo "not found"; else echo $value; fi

Restart the agent. After this new user parameter json.query will become available as "Zabbix Agent" type item on this server. It takes two arguments: address of json to fetch and name of variable to extract. I was testing on the following sample:

"usercount":30

You might need to alter the regex if your json is formatted differently.

Now you need to add the new zabbix item: Configuration/Hosts/Items - Create Item

Description: Concurrent user count
Type: Zabbix Agent
Key: json.query[myserver.com/status.json,usercount]
Data Type: numeric

That's it. User count is now monitored and you can reference it in zabbix triggers the usual way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top