]> git.stg.codes - stg.git/commitdiff
tariffChangeUsers param added to the SMUX plugin
authorMaxim Mamontov <faust.madf@gmail.com>
Sat, 16 Jul 2011 11:53:17 +0000 (14:53 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Sat, 16 Jul 2011 11:53:17 +0000 (14:53 +0300)
projects/stargazer/plugins/other/snmp/asn1/STG-MIB.mib
projects/stargazer/plugins/other/snmp/sensors.cpp
projects/stargazer/plugins/other/snmp/sensors.h
projects/stargazer/plugins/other/snmp/snmp.cpp

index 215a0f39a9f460c093059389c1a489d512340591..cb48ecbcce7d9b1e30fe4b64bf5d268005c470cf 100644 (file)
@@ -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
index a9f8efc77af4bc9063576fa3801c112e9a237d1a..57fec93dc1da147f9bea1a5328a223567f0266b3 100644 (file)
@@ -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;
+}
index 49a08302a89c59cf11155c38c96ccac2cf83768c..767f1e147e48f674601616a6bd947bef14604b79 100644 (file)
@@ -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)
index 9e99b8ea3f6f49bad647471a6526fd756dd96528..8e1113e3448844fc869f94a044e6c0aef07e5975 100644 (file)
@@ -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);