Tagarchief: Nagios

How to check connection between windows and anywhere usb with nagios

The easiest way to monitor the connection between your Digi Anywhere USB device and a server is to monitor the USB device connected it. I use Nagios to monitor several indicators in each server, and the following script can be used to monitor if USB devices are connected:

strComputer = "."
 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDevices = objWMIService.ExecQuery ("Select * From Win32_USBControllerDevice")
 
For Each objDevice in colDevices
    strDeviceName = objDevice.Dependent
    strQuotes = Chr(34)
    strDeviceName = Replace(strDeviceName, strQuotes, "")
    arrDeviceNames = Split(strDeviceName, "=")
    strDeviceName = arrDeviceNames(1)
    Set colUSBDevices = objWMIService.ExecQuery ("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'")
    For Each objUSBDevice in colUSBDevices
        'Wscript.Echo objUSBDevice.Description
        If objUSBDevice.Description="SCR3311 USB Smart Card Reader" Then
           WScript.Echo "OK - Card reader detected"
           WScript.Quit 0
        End If
    Next
Next
 
WScript.Echo "WARNING - No card reader detected"
WScript.Quit 1

In my case, I monitor a card reader that identifies as "SCR3311 USB Smart Card Reader". You should type the exact name of the device you're monitoring at that spot. If you don't know the exact name of the device, uncomment the line
'Wscript.Echo objUSBDevice.Description
and then execute
cscript //nologo //t:10 "check_cardreader.vbs"

Put above file in c:\program files (x86)\nrpe\check_cardreader.vbs and update nrpe.cfg to contain:
command[check_cardreader]=cscript //nologo //t:10 "c:\program files (x86)\nrpe\check_cardreader.vbs"

After restarting the NRPE service, you're ready to monitor the USB device.

© GeekLabInfo How to check connection between windows and anywhere usb with nagios is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

How to monitor a Konica-Minolta printer’s settings using Nagios

For some reason, some users seem not to be able to keep their hands off the settings of my KonicaMinolta Bizhub 283. They keep changing the paper format for tray 2 to PlainPaper, causing all kinds of problems. Since there is no way to lock the settings, I started to monitor them and report them.

This is my Nagios script:

#!/usr/bin/python
 
import os
import pycurl
import cStringIO
import re
import random
import time
import tempfile
import sys
 
from lxml import etree
 
newcookiefile = tempfile.NamedTemporaryFile()
 
if len(sys.argv)!=2:
        print "Usage: "+sys.argv[0]+" [printer ip or hostname]"
        sys.exit(1)
 
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://"+sys.argv[1]+"/wcd/index.html")
c.setopt(pycurl.COOKIEFILE, newcookiefile.name)
c.setopt(pycurl.COOKIEJAR, newcookiefile.name)
c.setopt(pycurl.WRITEFUNCTION, buf.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.ENCODING, "")
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
c.setopt(pycurl.USERAGENT, "Something")
c.perform()
curlData = buf.getvalue()
buf.close()
 
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://"+sys.argv[1]+"/wcd/system.xml")
c.setopt(pycurl.COOKIEFILE, newcookiefile.name)
c.setopt(pycurl.COOKIEJAR, newcookiefile.name)
c.setopt(pycurl.WRITEFUNCTION, buf.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.ENCODING, "")
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
c.setopt(pycurl.USERAGENT, "Something")
c.perform()
curlData = buf.getvalue()
buf.close()
 
#print curlData
 
tree = etree.fromstring(curlData)
root = etree.Element("root")
paperformat=tree.xpath('/MFP/DeviceInfo/Input/TrayList/Tray/TrayID[text()="Tray2"]/../CurrentPaper/MediaType')[0].text
 
if "PlainPaper" == paperformat:
        print "Someone touched the settings - again!"
        sys.exit(2)
 
print "OK"
sys.exit(0)
© GeekLabInfo How to monitor a Konica-Minolta printer's settings using Nagios is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Fedora 15: Nagios errors

Installation of Nagios on Fedora 15 is easy as yum install nagios nagios-plugins* php nrpe. I only found one problem: Error: Could not read object configuration data!

The webserver runs as user apache, which cannot access /etc/nagios/objects by default. Chmod or chown the directory to fix it, or add user apache to the group nagios.

You may also want to check the selinux settings, which can be restored by typing restorecon /etc/nagios

© GeekLabInfo Fedora 15: Nagios errors is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info
1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5,00 out of 5)
Loading...