0

I am trying to merge different branches to create a new version of munin-node-win32.

I am currently tying to get this fork working. https://github.com/hugohallqvist/munin-node-win32/tree/hugodevel

But I get the following error.

src\core\MuninPluginManager.cpp(135): error C2259: 'PerfCounterCustomMuninNodePlugin': cannot instantiate abstract class
src\core\MuninPluginManager.cpp(135): note: due to following members:
src\core\MuninPluginManager.cpp(135): note: 'bool MuninNodePlugin::AutoConf(void)': is abstract
c:\users\username\projekte\munin-node-win3264\src\core\MuninNodePlugin.h(14): note: see declaration of 'MuninNodePlugin::AutoConf'

I think these are the important code snippets.

MuninNodePlugin.h

class MuninNodePlugin {
public:
  virtual ~MuninNodePlugin() {};

  /// This method should always be thread-safe
  virtual bool IsLoaded() = 0;
  /// This method should also always be thread-safe
  virtual const char *GetName() = 0;
  virtual bool AutoConf() = 0;
  virtual int GetConfig(char *buffer, int len) = 0;
  virtual int GetValues(char *buffer, int len) = 0;  
  virtual bool IsThreadSafe();
};

MuninPluginManager.cpp

// Add all the PerfCounterCustom Plugins
  {
    const char *perfPrefix = PerfCounterCustomMuninNodePlugin::SectionPrefix;
    size_t perfPrefixLen = strlen(perfPrefix);
    for (size_t i = 0; i < g_Config.GetNumKeys(); i++) {
      std::string keyName = g_Config.GetKeyName(i);
      if (keyName.compare(0, perfPrefixLen, perfPrefix) == 0) {
        PerfCounterCustomMuninNodePlugin *plugin = new PerfCounterCustomMuninNodePlugin(keyName);
        if (plugin->IsLoaded()) {
          AddPlugin(plugin);
        } else {
          _Module.LogError("Failed to load Custom PerfCounter plugin: [%s]", keyName.c_str());
          delete plugin;
        }
      }
    }
  }

I know almost nothing about C++, so I do not understand the already posted solutions for this error. I would prefer a quick fix like "change this line and it should work".

The strange thing is that this code directly above the other block does not throw an error, even it is almost identicly. :/

  // Add all the regular PerfCounter Plugins
  {
    const char *perfPrefix = PerfCounterMuninNodePlugin::SectionPrefix;
    size_t perfPrefixLen = strlen(perfPrefix);
    for (size_t i = 0; i < g_Config.GetNumKeys(); i++) {
      std::string keyName = g_Config.GetKeyName(i);
      if (keyName.compare(0, perfPrefixLen, perfPrefix) == 0) {
        PerfCounterMuninNodePlugin *plugin = new PerfCounterMuninNodePlugin(keyName);
        if (plugin->IsLoaded()) {
          AddPlugin(plugin);
        } else {
          _Module.LogError("Failed to load PerfCounter plugin: [%s]", keyName.c_str());
          delete plugin;
        }
      }
    }
  }

PerfCounterCustomMuninNodePlugin.h

#pragma once
#include "core/MuninNodePlugin.h"

struct Field {
  std::string name;
  std::string preParsedArgs;

  // PerfCounter API params
  struct Counter {
    std::string path;
    HCOUNTER handle;
    DWORD format;
    double multiply;
  } counter;
};

class PerfCounterCustomMuninNodePlugin : public MuninNodePluginHelper
{
public:

  /// \param sectionName The INI File section name for this plugin
  PerfCounterCustomMuninNodePlugin(const std::string &sectionName);
  virtual ~PerfCounterCustomMuninNodePlugin();

  virtual int GetConfig(char *buffer, int len);
  virtual int GetValues(char *buffer, int len);
  virtual bool IsLoaded() { return m_Loaded; };

  static const char *SectionPrefix;
private:
  bool OpenCounter();

  bool m_Loaded;
  std::string m_SectionName;

  HQUERY m_PerfQuery;

  // All the fields are represented here
  std::map<std::string, Field> m_Fields;

  // Precomputed graph parameters
  std::string m_GraphParameters;
};

0 Answers0