From: Maxim Mamontov Date: Sat, 13 Aug 2011 12:43:58 +0000 (+0300) Subject: Admin, service and corporation sesnsors added for SUMX X-Git-Tag: 2.408-alpha~36 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/82ede2a92a721d1c8f0e3fd109a2594f2096306e?ds=sidebyside Admin, service and corporation sesnsors added for SUMX --- diff --git a/projects/stargazer/plugins/other/smux/STG-MIB.mib b/projects/stargazer/plugins/other/smux/STG-MIB.mib index d41edc52..4d9179bf 100644 --- a/projects/stargazer/plugins/other/smux/STG-MIB.mib +++ b/projects/stargazer/plugins/other/smux/STG-MIB.mib @@ -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 diff --git a/projects/stargazer/plugins/other/smux/sensors.h b/projects/stargazer/plugins/other/smux/sensors.h index f2840636..16331b15 100644 --- a/projects/stargazer/plugins/other/smux/sensors.h +++ b/projects/stargazer/plugins/other/smux/sensors.h @@ -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 class ConstSensor : public Sensor { public: diff --git a/projects/stargazer/plugins/other/smux/smux.cpp b/projects/stargazer/plugins/other/smux/smux.cpp index 79e9d208..ac77ce6e 100644 --- a/projects/stargazer/plugins/other/smux/smux.cpp +++ b/projects/stargazer/plugins/other/smux/smux.cpp @@ -15,6 +15,11 @@ #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); diff --git a/projects/stargazer/plugins/other/smux/smux.h b/projects/stargazer/plugins/other/smux/smux.h index 08e23c38..7ab603df 100644 --- a/projects/stargazer/plugins/other/smux/smux.h +++ b/projects/stargazer/plugins/other/smux/smux.h @@ -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;