From: Maxim Mamontov Date: Sat, 16 Jul 2011 11:53:17 +0000 (+0300) Subject: tariffChangeUsers param added to the SMUX plugin X-Git-Tag: 2.408-alpha~87 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/4421aa6a60965483085dbb95d969a1674434126a?ds=inline;hp=426ffd5a37073aa0b52640ba9ff9284b2a56bfd9 tariffChangeUsers param added to the SMUX plugin --- diff --git a/projects/stargazer/plugins/other/snmp/asn1/STG-MIB.mib b/projects/stargazer/plugins/other/snmp/asn1/STG-MIB.mib index 215a0f39..cb48ecbc 100644 --- a/projects/stargazer/plugins/other/snmp/asn1/STG-MIB.mib +++ b/projects/stargazer/plugins/other/snmp/asn1/STG-MIB.mib @@ -165,6 +165,15 @@ freeMbUsers OBJECT-TYPE DEFVAL { 0 } ::= { users 11 } +tariffChangeUsers OBJECT-TYPE + SYNTAX Integer32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of users changing tariff next month" + DEFVAL { 0 } + ::= { users 12 } + totalTariffs OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only diff --git a/projects/stargazer/plugins/other/snmp/sensors.cpp b/projects/stargazer/plugins/other/snmp/sensors.cpp index a9f8efc7..57fec93d 100644 --- a/projects/stargazer/plugins/other/snmp/sensors.cpp +++ b/projects/stargazer/plugins/other/snmp/sensors.cpp @@ -192,3 +192,23 @@ users.CloseSearch(handle); Int2OS(objectSyntax, count); return true; } + +bool TariffChangeUsersSensor::GetValue(ObjectSyntax_t * objectSyntax) +{ +int handle = users.OpenSearch(); +if (!handle) + return false; + +USER_PTR user; +size_t count = 0; +while (!users.SearchNext(handle, &user)) + { + if (!user->GetProperty().nextTariff.ConstData().empty()) + ++count; + } + +users.CloseSearch(handle); + +Int2OS(objectSyntax, count); +return true; +} diff --git a/projects/stargazer/plugins/other/snmp/sensors.h b/projects/stargazer/plugins/other/snmp/sensors.h index 49a08302..767f1e14 100644 --- a/projects/stargazer/plugins/other/snmp/sensors.h +++ b/projects/stargazer/plugins/other/snmp/sensors.h @@ -152,6 +152,19 @@ class FreeMbUsersSensor : public Sensor { USERS & users; }; +class TariffChangeUsersSensor : public Sensor { + public: + TariffChangeUsersSensor(USERS & u) + : users(u) + {} + virtual ~TariffChangeUsersSensor() {} + + bool GetValue(ObjectSyntax_t * objectSyntax); + + private: + USERS & users; +}; + class TotalTariffsSensor : public Sensor { public: TotalTariffsSensor(const TARIFFS & t) diff --git a/projects/stargazer/plugins/other/snmp/snmp.cpp b/projects/stargazer/plugins/other/snmp/snmp.cpp index 9e99b8ea..8e1113e3 100644 --- a/projects/stargazer/plugins/other/snmp/snmp.cpp +++ b/projects/stargazer/plugins/other/snmp/snmp.cpp @@ -400,6 +400,7 @@ sensors[".1.3.6.1.4.1.38313.1.1.8"] = new DisabledUsersSensor(*users); sensors[".1.3.6.1.4.1.38313.1.1.9"] = new PassiveUsersSensor(*users); sensors[".1.3.6.1.4.1.38313.1.1.10"] = new CreditUsersSensor(*users); sensors[".1.3.6.1.4.1.38313.1.1.11"] = new FreeMbUsersSensor(*users); +sensors[".1.3.6.1.4.1.38313.1.1.12"] = new TariffChangeUsersSensor(*users); // Tariffs sensors[".1.3.6.1.4.1.38313.1.2.1"] = new TotalTariffsSensor(*tariffs);