HowTo: Monitoring if a specific user is logged on with Zabbix

Sometimes you face the problem, that a software vendor depends on logged on user sessions, instead of windows services. We had the case, that a partner constantly complained, that we logged of his service user. To have a history about the logged on state, I added a Zabbix item through the possibility to add custom UserParameter. The CMD line utility qwinsta is able to check if a specific user is logged on.


First of all, an example of the output qwinsta can give you:

True:

marco.hofmann@XENWORKSTATION C:\Users\Marco.Hofmann
> qwinsta marco.hofmann
 SITZUNGSNAME      BENUTZERNAME             ID  STATUS  TYP         GERÄT
>console           marco.hofmann             1  Aktiv

False:

marco.hofmann@XENWORKSTATION C:\Users\Marco.Hofmann
> qwinsta administrator
Für administrator ist keine Sitzung vorhanden

This helped me to write the Zabbix UserParameter entry:

UserParameter=xenadmin.qwinsta[*],c:\Windows\System32\qwinsta.exe "$1"

After this I was able to get the value I need via zabbix_get:

root@zabprox:~# zabbix_get -s server.domain.local -k xenadmin.qwinsta[testuser]
 SITZUNGSNAME      BENUTZERNAME             ID  STATUS  TYP         GERÄT
 rdp-tcp#5         testuser                  1  Aktiv

Now I was able to create the Zabbix Item:

And this led me to the last step, the trigger expression:

Zabbix Latest Data now shows every 10 minutes the logged on state, the Trigger informs us, if the session would be logged of.

Author: Marco

Marco is an IT-System administrator and IT-Consultant with 10+ years experience. He is specialized in the delivery of virtual Apps and Desktops with Citrix solutions. In 2017 he has been awarded Citrix Technology Advocate by Citrix for his community work (#CTA). His second core area is availability & performance monitoring with Zabbix, a leading open-source solution. His employer is the German IT-Company ANAXCO, which is developing a Transport Management Software (TMS) based on Microsoft Dynamics AX. More about Marco

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.