lists.netmrg.net lists.netmrg.net
NetMRG discussion and support
 
FAQ :: Search :: Memberlist :: Usergroups :: Register
Profile :: Log in to check your private messages :: Log in

No more spikes after machine reboot

 
Post new topic   Reply to topic    lists.netmrg.net Forum Index -> Development
Author Message
pjf
Beginner


Joined: 08 Jul 2005
Posts: 2

PostPosted: Sat Jul 09, 2005 9:59 am    Post subject: No more spikes after machine reboot Reply with quote

What would you say for such a patch?

Code:

Index: netmrg/www/webfiles/updater.php
===================================================================
--- netmrg/www/webfiles/updater.php     (revision 1162)
+++ netmrg/www/webfiles/updater.php     (working copy)
@@ -199,11 +199,15 @@
                array(
                        "name" => "Increase size of view.pos",
                        "query" => "ALTER TABLE view MODIFY pos INT NOT NULL;"
-                       )
+                       ),
                array(
                        "name" => "Windows CPU Internal Test",
                        "query" => "INSERT INTO tests_internal VALUES (8,'Windows CPU Load');"
-                       )
+                       ),
+               array(
+                       "name" => "Reboot detection Option",
+                       "query" => "ALTER TABLE `devices` ADD `reboot_detection` TINYINT DEFAULT '1' NOT NULL;"
+                       ),
        ), // end 0.19

 ); // end $dbupdates;
Index: netmrg/www/webfiles/devices.php
===================================================================
--- netmrg/www/webfiles/devices.php     (revision 1162)
+++ netmrg/www/webfiles/devices.php     (working copy)
@@ -83,6 +83,7 @@
                if (!isset($_REQUEST["disabled"])) { $_REQUEST["disabled"] = 0; }
                if (!isset($_REQUEST["snmp_version"])) { $_REQUEST["snmp_version"] = 0; }
                if (!isset($_REQUEST["no_snmp_uptime_check"])) { $_REQUEST["no_snmp_uptime_check"] = 0; }
+               if (!isset($_REQUEST["reboot_detection"])) { $_REQUEST["reboot_detection"] = 1; }
                db_update("$db_cmd devices SET
                        name='{$_REQUEST['dev_name']}',
                        ip='{$_REQUEST['dev_ip']}',
@@ -94,7 +95,8 @@
                        snmp_port='{$_REQUEST['snmp_port']}',
                        snmp_timeout='{$_REQUEST['snmp_timeout']}',
                        snmp_retries='{$_REQUEST['snmp_retries']}',
-                       no_snmp_uptime_check='{$_REQUEST['no_snmp_uptime_check']}'
+                       no_snmp_uptime_check='{$_REQUEST['no_snmp_uptime_check']}',
+                       reboot_detection='{$_REQUEST['reboot_detection']}'
                        $db_end");

                if ($_REQUEST["dev_id"] == 0)
@@ -193,6 +195,7 @@
                $dev_row["snmp_timeout"] = 1000000;
                $dev_row["snmp_retries"] = 3;
                $dev_row["no_snmp_uptime_check"] = 0;
+               $dev_row["reboot_detection"] = 1;
        }

        make_edit_table("Edit Device");
@@ -205,6 +208,7 @@
        make_edit_select_from_array("SNMP Support:", "snmp_version", $GLOBALS["SNMP_VERSIONS"], $dev_row["snmp_version"]);
        make_edit_text("SNMP Read Community:", "snmp_read_community", 50, 200, $dev_row["snmp_read_community"]);
        make_edit_select_from_array("Recaching Method:", "snmp_recache_method", $GLOBALS["RECACHE_METHODS"], $dev_row["snmp_recache_method"]);
+       make_edit_checkbox("Avoid spikes after machine reboot", "reboot_detection", $dev_row["reboot_detection"] == 1);
        make_edit_group("Advanaced SNMP Options");
        make_edit_checkbox("Disable SNMP Uptime Check", "no_snmp_uptime_check", $dev_row["no_snmp_uptime_check"] == 1);
        make_edit_text("SNMP UDP Port", "snmp_port", 5, 5, $dev_row["snmp_port"]);
Index: netmrg/src/include/types.h
===================================================================
--- netmrg/src/include/types.h  (revision 1162)
+++ netmrg/src/include/types.h  (working copy)
@@ -66,6 +66,8 @@
        int test_type;
        int test_id;

+       int rebooted;
+
        string name;
        string ip;
        string subdevice_name;
@@ -108,6 +110,8 @@
                test_id                 = -1;
                //test_params   = "";

+               rebooted                = 0;
+
                delta_time              = 0;

                curr_val                = "U";
Index: netmrg/src/devices.cpp
===================================================================
--- netmrg/src/devices.cpp      (revision 1162)
+++ netmrg/src/devices.cpp      (working copy)
@@ -209,7 +209,8 @@
                        string("snmp_port, ")                   + // 7
                        string("snmp_timeout, ")                + // 8
                        string("snmp_retries, ")                + // 9
-                       string("no_snmp_uptime_check ") + // 10
+                       string("no_snmp_uptime_check, ")        + // 10
+                       string("reboot_detection ")     + // 11
                        string("FROM devices ")                 +
                        string("WHERE id=") + inttostr(dev_id);

@@ -236,6 +237,7 @@
                info.snmp_retries                       = strtoint(mysql_row[9]);
                int  snmp_recache_method        = strtoint(mysql_row[4]);
                int  check_snmp_uptime          = strtoint(mysql_row[10]) ? 0 : 1;
+               int  reboot_detection                   = strtoint(mysql_row[11]) ? 1 : 0;

                // add SNMP parameters to list
                info.parameters.push_front(ValuePair("snmp_read_community", mysql_row[3]));
@@ -269,7 +271,7 @@
                }
                else
                {
-                       if (snmp_recache_method >= 1)
+                       if (snmp_recache_method >= 1 || reboot_detection)
                        {
                                // we care about SNMP agent restarts

@@ -278,14 +280,15 @@
                                        if (strtoint(mysql_row[5]) == 0)
                                        {
                                                // device came back from the dead
-                                               info.snmp_recache = 1;
+                                               if (snmp_recache_method >= 1) info.snmp_recache = 1;
                                                debuglogger(DEBUG_DEVICE, LEVEL_NOTICE, &info, "Device has returned from SNMP-death.");
                                        }

                                        if (info.snmp_uptime < strtoint(mysql_row[5]))
                                        {
                                                // uptime went backwards
-                                               info.snmp_recache = 1;
+                                               if (snmp_recache_method >= 1) info.snmp_recache = 1;
+                                               if (reboot_detection) info.rebooted = 1;
                                                debuglogger(DEBUG_SNMP, LEVEL_NOTICE, &info, "SNMP Agent Restart.");
                                        }
                                }
Index: netmrg/src/monitors.cpp
===================================================================
--- netmrg/src/monitors.cpp     (revision 1162)
+++ netmrg/src/monitors.cpp     (working copy)
@@ -355,8 +355,13 @@

        info.parameters.push_front(ValuePair("parameters", info.test_params));

-       switch (info.test_type)
+       if (info.rebooted)
        {
+               info.curr_val = "U";
+               debuglogger(DEBUG_MONITOR, LEVEL_INFO, &info, "Ignoring real value because device rebooted");
+       }
+       else switch (info.test_type)
+       {
                case  1:        info.curr_val = process_script_monitor(info, mysql);
                                        break;

Index: netmrg/share/netmrg.mysql
===================================================================
--- netmrg/share/netmrg.mysql   (revision 1162)
+++ netmrg/share/netmrg.mysql   (working copy)
@@ -103,6 +103,7 @@
   snmp_port smallint(5) unsigned NOT NULL default '161',
   status smallint(6) NOT NULL default '0',
   no_snmp_uptime_check tinyint(4) NOT NULL default '0',
+  reboot_detection tinyint(4) NOT NULL default '1',
   PRIMARY KEY  (id),
   KEY disabled (disabled)
 ) TYPE=MyISAM;


BTW sorry for little off-topic, but why there is no mailing list for developers? Where the heck is the unix nature in all those "Smilies" and "BBCode" ;-) ? I even can't attach a file in old, good way :-P.

Bye.
Back to top
silfreed
Site Admin


Joined: 19 Jan 2003
Posts: 394
Location: Shippensburg, PA, USA

PostPosted: Sun Jul 10, 2005 1:05 am    Post subject: Re: No more spikes after machine reboot Reply with quote

pjf wrote:
What would you say for such a patch?


Looks good; I'll wait for Brady to look it over.

pjf wrote:
BTW sorry for little off-topic, but why there is no mailing list for developers? Where the heck is the unix nature in all those "Smilies" and "BBCode" ;-) ? I even can't attach a file in old, good way :-P.


Well, I'd rather not go into all the reasons, but we do have a way to attach files - in the bug tracker. And the BBCode and smilies can be disabled per-post.

-Doug
Back to top
balleman
Site Admin


Joined: 20 Jan 2003
Posts: 282

PostPosted: Sun Jul 10, 2005 1:38 pm    Post subject: Reply with quote

I like it! I'll probably want to change it a bit so that Gauge's don't get set as unknown, but that's about it. I wouldn't expect it to be included in our next release (which should be *soon*), but hopefully the following one. I've started bug#419 to address this issue. Thanks for the patch!
Back to top
pjf
Beginner


Joined: 08 Jul 2005
Posts: 2

PostPosted: Sun Jul 10, 2005 1:47 pm    Post subject: Reply with quote

> I like it!

Thanks.

> I'll probably want to change it a bit so that Gauge's don't get set as unknown, but
> that's about it.

I thought about it too, but I was probably to lazy to do it :P.

> Thanks for the patch!

No problem, BTW thanks for Netmrg to you all!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    lists.netmrg.net Forum Index -> Development All times are GMT
Page 1 of 1

 



smartBlue Style © 2002 Smartor
Powered by phpBB © 2001, 2002 phpBB Group