Page 1 of 1

USB Device monitoring

Posted: Fri Feb 23, 2018 3:10 am
by DamienVIX
Hi.

I am looking for a way to monitor USB device i.e NFC card readers and POS receipt printers on Windows 7 computers.
I want to check whether the device are connected or disconnected.

Thanks

Re: USB Device monitoring

Posted: Fri Feb 23, 2018 11:08 am
by lmiltchev
Do you have an agent installed on the Windows computers? You could monitor USBs via NCPA. Here's an example of a check, run from the command line:

Code: Select all

[root@main-nagios-xi libexec]# /usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -t 'mytoken' -P 5693 -M 'disk/logical/F:|/used_percent' -w 70 -c 90
OK: Used_percent was 14.20 % | 'used_percent'=14.20%;70;90;
[root@main-nagios-xi libexec]# echo $?
0
Here's our documentation on NCPA: https://www.nagios.org/ncpa/help.php

There is one thing that you need to keep in mind - when the USB is ejected, the check will return UNKNOWN instead of CRITICAL. Example:

Code: Select all

[root@main-nagios-xi libexec]# /usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -t 'mytoken' -P 5693 -M 'disk/logical/F:|/used_percent' -w 70 -c 90
The node (F:|) requested does not exist.
[root@main-nagios-xi libexec]# echo $?
3
If this is an issue for you, you could always use the negate plugin to change the output:

Code: Select all

[root@main-nagios-xi libexec]# /usr/local/nagios/libexec/negate -u CRITICAL -s /usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -t 'mytoken' -P 5693 -M 'disk/logical/F:|/used_percent' -w 70 -c 90
The node (F:|) requested does not exist.
[root@main-nagios-xi libexec]# echo $?
2
For more information on the negate plugin, please review our documentation on the topic here:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

As far as the POS receipt printers, they could be probably monitored via SNMP (if available).

Hope this helps.