]> git.stg.codes - stg.git/commitdiff
Admin, service and corporation sesnsors added for SUMX
authorMaxim Mamontov <faust.madf@gmail.com>
Sat, 13 Aug 2011 12:43:58 +0000 (15:43 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Sat, 13 Aug 2011 12:43:58 +0000 (15:43 +0300)
projects/stargazer/plugins/other/smux/STG-MIB.mib
projects/stargazer/plugins/other/smux/sensors.h
projects/stargazer/plugins/other/smux/smux.cpp
projects/stargazer/plugins/other/smux/smux.h

index d41edc529bafb9563730e0cb03e7018a08776ebf..4d9179bf98774529218884c689283c8e2bce78a8 100644 (file)
@@ -183,4 +183,31 @@ totalTariffs OBJECT-TYPE
     DEFVAL { 0 }
     ::= { tariffs 1 }
 
+totalAdmins OBJECT-TYPE
+    SYNTAX      Integer32
+    MAX-ACCESS  read-only
+    STATUS      current
+    DESCRIPTION
+       "Total admins registered in the billing"
+    DEFVAL { 0 }
+    ::= { admins 1 }
+
+totalServices OBJECT-TYPE
+    SYNTAX      Integer32
+    MAX-ACCESS  read-only
+    STATUS      current
+    DESCRIPTION
+       "Total services registered in the billing"
+    DEFVAL { 0 }
+    ::= { services 1 }
+
+totalCorporations OBJECT-TYPE
+    SYNTAX      Integer32
+    MAX-ACCESS  read-only
+    STATUS      current
+    DESCRIPTION
+       "Total corporations registered in the billing"
+    DEFVAL { 0 }
+    ::= { corporations 1 }
+
 END
index f284063658251b2d8dd5425e8ef92d84504d17f4..16331b15fcaedfde179a230a515a7032039d1c1e 100644 (file)
@@ -178,6 +178,66 @@ class TotalTariffsSensor : public Sensor {
         const TARIFFS & tariffs;
 };
 
+class TotalAdminsSensor : public Sensor {
+    public:
+        TotalAdminsSensor(const ADMINS & a) : admins(a) {}
+        virtual ~TotalAdminsSensor() {}
+
+        bool GetValue(ObjectSyntax_t * objectSyntax) const
+        {
+        ValueToOS(admins.GetAdminsNum(), objectSyntax);
+        return true;
+        }
+
+#ifdef DEBUG
+        std::string ToString() const
+        { std::string res; x2str(admins.GetAdminsNum(), res); return res; }
+#endif
+
+    private:
+        const ADMINS & admins;
+};
+
+class TotalServicesSensor : public Sensor {
+    public:
+        TotalServicesSensor(const SERVICES & s) : services(s) {}
+        virtual ~TotalServicesSensor() {}
+
+        bool GetValue(ObjectSyntax_t * objectSyntax) const
+        {
+        ValueToOS(services.GetServicesNum(), objectSyntax);
+        return true;
+        }
+
+#ifdef DEBUG
+        std::string ToString() const
+        { std::string res; x2str(services.GetServicesNum(), res); return res; }
+#endif
+
+    private:
+        const SERVICES & services;
+};
+
+class TotalCorporationsSensor : public Sensor {
+    public:
+        TotalCorporationsSensor(const CORPORATIONS & c) : corporations(c) {}
+        virtual ~TotalCorporationsSensor() {}
+
+        bool GetValue(ObjectSyntax_t * objectSyntax) const
+        {
+        ValueToOS(corporations.GetCorporationsNum(), objectSyntax);
+        return true;
+        }
+
+#ifdef DEBUG
+        std::string ToString() const
+        { std::string res; x2str(services.GetCorporationsNum(), res); return res; }
+#endif
+
+    private:
+        const CORPORATIONS & corporations;
+};
+
 template <typename T>
 class ConstSensor : public Sensor {
     public:
index 79e9d208587b0398fa85ac86ee84f717b054b368..ac77ce6ec6203e784f631011019e19943c991083 100644 (file)
 
 #include "stg/common.h"
 #include "stg/plugin_creator.h"
+#include "stg/users.h"
+#include "stg/tariffs.h"
+#include "stg/admins.h"
+#include "stg/services.h"
+#include "stg/corporations.h"
 
 #include "smux.h"
 #include "utils.h"
@@ -89,6 +94,9 @@ SMUX::SMUX()
     : PLUGIN(),
       users(NULL),
       tariffs(NULL),
+      admins(NULL),
+      services(NULL),
+      corporations(NULL),
       running(false),
       stopped(true),
       sock(-1)
@@ -145,6 +153,12 @@ sensors[OID(".1.3.6.1.4.1.38313.1.1.11")] = new FreeMbUsersSensor(*users);
 sensors[OID(".1.3.6.1.4.1.38313.1.1.12")] = new TariffChangeUsersSensor(*users);
 // Tariffs
 sensors[OID(".1.3.6.1.4.1.38313.1.2.1")] = new TotalTariffsSensor(*tariffs);
+// Admins
+sensors[OID(".1.3.6.1.4.1.38313.1.3.1")] = new TotalAdminsSensor(*admins);
+// Services
+sensors[OID(".1.3.6.1.4.1.38313.1.4.1")] = new TotalServicesSensor(*services);
+// Corporations
+sensors[OID(".1.3.6.1.4.1.38313.1.5.1")] = new TotalCorporationsSensor(*corporations);
 
 // Table data
 tables[".1.3.6.1.4.1.38313.1.1.6"] = new TariffUsersTable(".1.3.6.1.4.1.38313.1.1.6", *users);
index 08e23c38faf6617c385ef811729122a33a4d3c5b..7ab603dfd095b9c53f41a85e0d33f2aed54d10ad 100644 (file)
@@ -12,8 +12,6 @@
 #include "stg/os_int.h"
 #include "stg/plugin.h"
 #include "stg/module_settings.h"
-#include "stg/users.h"
-#include "stg/tariffs.h"
 
 #include "sensors.h"
 #include "tables.h"
@@ -24,6 +22,10 @@ extern "C" PLUGIN * GetPlugin();
 class USER;
 class SETTINGS;
 class SMUX;
+class USERS;
+class TARIFFS;
+class SERVICES;
+class CORPORATIONS;
 
 typedef bool (SMUX::*SMUXPacketHandler)(const SMUX_PDUs_t * pdus);
 typedef bool (SMUX::*PDUsHandler)(const PDUs_t * pdus);
@@ -56,7 +58,9 @@ public:
 
     void SetUsers(USERS * u) { users = u; }
     void SetTariffs(TARIFFS * t) { tariffs = t; }
-    void SetAdmins(ADMINS *) {}
+    void SetAdmins(ADMINS * a) { admins = a; }
+    void SetServices(SERVICES * s) { services = s; }
+    void SetCorporations(CORPORATIONS * c) { corporations = c; }
     void SetTraffcounter(TRAFFCOUNTER *) {}
     void SetStore(STORE *) {}
     void SetStgSettings(const SETTINGS *) {}
@@ -93,6 +97,9 @@ private:
 
     USERS * users;
     TARIFFS * tariffs;
+    ADMINS * admins;
+    SERVICES * services;
+    CORPORATIONS * corporations;
 
     mutable std::string errorStr;
     SMUX_SETTINGS smuxSettings;