"Fossies" - the Fresh Open Source Software Archive

Member "netxms-3.8.166/src/server/drivers/rittal/rittal.h" (23 Feb 2021, 3324 Bytes) of package /linux/misc/netxms-3.8.166.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rittal.h" see the Fossies "Dox" file reference documentation.

    1 /**
    2  * NetXMS - Network Management System
    3  * Driver for Rittal CMC and LCP devices
    4  * Copyright (C) 2017-2020 Raden Solutions
    5  *
    6  * This program is free software; you can redistribute it and/or modify
    7  * it under the terms of the GNU Lesser General Public License as published by
    8  * the Free Software Foundation; either version 3 of the License, or
    9  * (at your option) any later version.
   10  *
   11  * This program is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU Lesser General Public License
   17  * along with this program; if not, write to the Free Software
   18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   19  *
   20  * File: rittal.h
   21  */
   22 
   23 #ifndef _rittal_h_
   24 #define _rittal_h_
   25 
   26 #include <nddrv.h>
   27 
   28 #define RITTAL_DEBUG_TAG   _T("ndd.rittal")
   29 
   30 /**
   31  * Metric information
   32  */
   33 struct RittalMetric
   34 {
   35    UINT32 index;
   36    TCHAR name[MAX_OBJECT_NAME];
   37    TCHAR description[MAX_DB_STRING];
   38    int dataType;
   39    UINT32 oid[15];
   40 };
   41 
   42 /**
   43  * Device information
   44  */
   45 struct RittalDevice
   46 {
   47    UINT32 index;
   48    UINT32 bus;
   49    UINT32 position;
   50    TCHAR name[MAX_OBJECT_NAME];
   51    TCHAR alias[MAX_OBJECT_NAME];
   52    ObjectArray<RittalMetric> *metrics;
   53 
   54    RittalDevice(UINT32 _index, UINT32 _bus, UINT32 _position, const SNMP_Variable *_name, const SNMP_Variable *_alias)
   55    {
   56       index = _index;
   57       bus = _bus;
   58       position = _position;
   59       _name->getValueAsString(name, MAX_OBJECT_NAME);
   60       _alias->getValueAsString(alias, MAX_OBJECT_NAME);
   61       metrics = new ObjectArray<RittalMetric>(32, 32, Ownership::True);
   62    }
   63 
   64    ~RittalDevice()
   65    {
   66       delete metrics;
   67    }
   68 };
   69 
   70 /**
   71  * Device data
   72  */
   73 class RittalDriverData : public HostMibDriverData
   74 {
   75 private:
   76    ObjectArray<RittalDevice> m_devices;
   77    time_t m_cacheTimestamp;
   78    MUTEX m_cacheLock;
   79 
   80    UINT32 deviceInfoWalkCallback(SNMP_Variable *v, SNMP_Transport *snmp);
   81    UINT32 metricInfoWalkCallback(SNMP_Variable *v, SNMP_Transport *snmp);
   82    void updateDeviceInfoInternal(SNMP_Transport *snmp);
   83    RittalDevice *getDevice(UINT32 index);
   84    RittalDevice *getDevice(UINT32 bus, UINT32 position);
   85 
   86 public:
   87    RittalDriverData();
   88    virtual ~RittalDriverData();
   89 
   90    void updateDeviceInfo(SNMP_Transport *snmp);
   91    void registerMetrics(ObjectArray<AgentParameterDefinition> *metrics);
   92    bool getMetric(const TCHAR *name, SNMP_Transport *snmp, RittalMetric *metric);
   93 };
   94 
   95 /**
   96  * Driver's class
   97  */
   98 class RittalDriver : public NetworkDeviceDriver
   99 {
  100 public:
  101     virtual const TCHAR *getName() override;
  102     virtual const TCHAR *getVersion() override;
  103 
  104     virtual int isPotentialDevice(const TCHAR *oid) override;
  105     virtual bool isDeviceSupported(SNMP_Transport *snmp, const TCHAR *oid) override;
  106    virtual void analyzeDevice(SNMP_Transport *snmp, const TCHAR *oid, NObject *node, DriverData **driverData) override;
  107    virtual bool hasMetrics() override;
  108    virtual DataCollectionError getMetric(SNMP_Transport *snmp, NObject *node, DriverData *driverData, const TCHAR *name, TCHAR *value, size_t size) override;
  109    virtual ObjectArray<AgentParameterDefinition> *getAvailableMetrics(SNMP_Transport *snmp, NObject *node, DriverData *driverData) override;
  110 };
  111 
  112 #endif