0

guys! I'm looking for a solution or some ideas on how to solve my task.

There is a video surveillance camera(vendor: Hikvision) with an accessible web-interface. In the web-interface, there is a field Device Name containing data I need to retrieve by means of the Zabbix server and further to use this data for renaming discovered hosts.

Since Hikvision cameras support SNMP, I've tried the SNMP agent in Zabbix. I turned out that Hikvision MIB doesn't contain data from that field. Also exploring web-interface through Developer tools in Google Chrome I stumbled upon the string Request URL: http://10.90.187.16/ISAPI/System/deviceInfo which gives such response in XML format:

<DeviceInfo xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
    <deviceName>1.5.1.1</deviceName>
    <deviceID>566eec0b-6580-11b3-81a1-1868cb48861f</deviceID>
    <deviceDescription>IPCamera</deviceDescription>
    <deviceLocation>hangzhou</deviceLocation>
    <systemContact>Hikvision.China</systemContact>
    <model>DS-2CD2155FWD-IS</model>
    <serialNumber>DS-2CD2155FWD-IS20170417AAWR749464587</serialNumber>
    <macAddress>18:68:cb:48:86:1f</macAddress>
    <firmwareVersion>V5.4.5</firmwareVersion>
    <firmwareReleasedDate>build 170124</firmwareReleasedDate>
    <encoderVersion>V7.3</encoderVersion>
    <encoderReleasedDate>build 170123</encoderReleasedDate>
    <bootVersion>V1.3.4</bootVersion>
    <bootReleasedDate>100316</bootReleasedDate>
    <hardwareVersion>0x0</hardwareVersion>
    <deviceType>IPCamera</deviceType>
    <telecontrolID>88</telecontrolID>
    <supportBeep>false</supportBeep>
    <supportVideoLoss>false</supportVideoLoss>
 </DeviceInfo>

Where the tag <deviceName>1.5.1.1</deviceName> contains required data and now the question is how to put two and two together by means of Zabbix. Digging into Zabbix documentation I've found an article about creating an Item based on HTTP agent with XML request . Unfortunately there are not any exmaples how to do it exactly.

Has somebody had such experience? Any clues will be helpful

1 Answers1

0

You can create an HTTP Agent item, set it to TEXT type and point it to http://10.90.187.16/ISAPI/System/deviceInfo (don't forget the authentication, if required!), Zabbix will retrieve the full XML.

To get the desired value you have to create a dependent item, point it to the previous item and set up a preprocessing step. Create a single XML Xpath preprocessing rule with parameter string(/DeviceInfo/DeviceName) to get the 1.5.1.1 value

If you want to get the firmware version, create another dependent item and set up the XPath to string(/DeviceInfo/FirmwareVersion) and so on for every element you need.

If you want a single value you can use a single item, adding the preprocessing rule to the http agent item. I use my solution for flexibility, maybe one day I'll need another XML element or maybe a firmware update will add some element to the page.

Dependent items are more flexible, but of course the full XML uses more storage in the database for stuff you don't need right now: it's a tradeoff, either way works!

Simone Zabberoni
  • 2,024
  • 1
  • 10
  • 15
  • Finally, I am stuck with a 401 error so the Item couldn't log into the web-interface. despite the fact, I used the username and password both in the field URL: `http://user:password@{HOST.IP}/ISAPI/System/deviceInfo` and using `HTTP authentication` parameter in the ITEM configuration. – Eugene Gorlo Jun 19 '20 at 06:46
  • You should provide user and password in the "HTTP Authentication" box of the item configuration page using Basic Authentication. If this doesn't work, check your camera documentation: I've seen some of them with Digest Auth only and Zabbix does not support it. – Simone Zabberoni Jun 19 '20 at 06:50
  • I have found something in the web-interface. I'll try it out after weekends – Eugene Gorlo Jun 19 '20 at 10:22
  • In the camera's web-interface *System/Security/Authentication*, the parameter **Web Authentication** has been changed to *digest/basic*. After that, the main Item's started working and retrieving the whole XML-tree from *URL*. I still can't get the desired value from tag **deviceName** using your suggestions. Dependent item retrieves *empty string* – Eugene Gorlo Jun 22 '20 at 06:30
  • Try without the dependend item first, using the TEST button in the preprocessor page – Simone Zabberoni Jun 22 '20 at 07:33