Page 1 of 1

Network Switch/Router Wizard - Select the port naming scheme

Posted: Wed Oct 08, 2014 3:30 pm
by questrad
Hello All,

Based on our experience of using Network Switch/Router Wizard I would suggest one small additional option in Monitoring Options -> Monitor Using:

So, if it possible, please add option also to have information for ifDescr field from Cisco devices.
Right now you using: ifIndex and ifAlias

ifIndex = Currently used for "Port's Number" - suggestion to change "Port's Index"
ifAlias = Currently used for "Port's Name" - suggestion to change "Port's Alias"
ifDescr = Can be used for "Port's Description"

And also, I suggest to using "_" instead of space and any others special characters in Service description, for example:

"Port 900 Bandwidth" -> "Port_900_Bandwidth"
"UPLINK TO SW2P05-OOB01 L2 Trunk Bandwidth" -> "UPLINK_TO_SW2P05_OOB01_L2_Trunk_Bandwidth"
"GigabitEthernet0/8 Bandwidth" -> "GigabitEthernet0_8_Bandwidth"

I will provide changes that I have made in the script already to support my request.



Thanks

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Wed Oct 08, 2014 3:58 pm
by abrist
I will open an internal feature request to include ifDescr in the wizard output list.
questrad wrote: And also, I suggest to using "_" instead of space and any others special characters in Service description, for example:
This could cause issues with currently configured check when a user runs the wizard an additional time to add more ports. Also, the intent of the description is to mirror the alias as much as possible. Is there a use case for this desired change?

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Wed Oct 08, 2014 6:10 pm
by questrad
So, changes:

Code: Select all

Line 289:
+                <option value="descr" '.is_selected($portnames, "descr").'>'.gettext("Port's Description").'</option>

Line 576-579:
change:            $badchars = explode(" ", "- ` ~ ! $ % ^ & * | ' \" < > ? , ( ) = / \\ { } [ ] ;");
change:            $port_number = str_replace($badchars, "_", $port_number);
change:            $port_description = str_replace($badchars, "_", $port_description);
change:            $port_long_desc = str_replace($badchars, "_", $port_long_desc);

Line 586-588:
+						if($portnames=="descr") {
+							$port_name=$port_description; //changed to long description -MG
+						}

Line 935-936:
change:                                    $badchars = explode(" ", "- ` ~ ! $ % ^ & * | ' \" < > ? , ( ) = / \\ { } [ ] ;");
change:                                    $portname=str_replace($badchars, "_", $portname);

Line 968:
change:                                        "service_description" => $portname . "_Bandwidth",

Line 984:
change:                                            "service_description" => $portname . "_Status",

Line 1001:
change:                                            "service_description" => $portname . "_Status",
This is all changes that I have made in:

/usr/local/nagiosxi/html/includes/configwizards/switch/switch.inc.php

Version:
2.1.3 - 08/29/2014

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Thu Oct 09, 2014 12:44 pm
by lmiltchev
Thanks for the submitted changes! Our developers will be looking into this.

Is there a use case for this desired change?

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Thu Oct 09, 2014 12:49 pm
by lmiltchev
Update: Andy just told me that the changes have been already added to a feature request.

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Thu Oct 09, 2014 1:43 pm
by questrad
Yes, there was request from Network team to have port description in Service name.

Also, for "_" we have get some issue with importing then exporting nagios config file that have spaces.

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Thu Oct 09, 2014 1:50 pm
by lmiltchev
Fair enough. Thanks, questrad!

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Fri Jan 09, 2015 7:42 am
by questrad
Hello All,

I have made last changes in this wizard to get out in service "Config Name" and "Description" the value from ifDescr, in service "Display name" the value from ifAlias.
Also, I have made changes in xi_email notification adding --notificationrecipients="$NOTIFICATIONRECIPIENTS$" --servicedisplayname="$SERVICEDISPLAYNAME$" --hostdisplayname="$HOSTDISPLAYNAME$":

Code: Select all

xi_service_notification_handler	= /usr/bin/php /usr/local/nagiosxi/scripts/qt_handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --datetime="$LONGDATETIME$" --notificationrecipients="$NOTIFICATIONRECIPIENTS$" --servicedisplayname="$SERVICEDISPLAYNAME$" --hostdisplayname="$HOSTDISPLAYNAME$"
Changed the Service Alert Message:

Code: Select all

***** Nagios NonProd Alert *****

Notification Type: %type%     State: %servicestate%

Host: %host% (%hostaddress% --- %hostdisplayname%)
Service: %service%
(%servicedisplayname%)

Info: %serviceoutput%

Date/Time: %datetime%
Nagios URL: %xiserverurl%
Alert sent to: %notificationrecipients%
And here is diff:

Code: Select all

--- switch.inc.php.orig 2014-10-09 09:07:22.000000000 -0400
+++ switch.inc.php      2015-01-09 07:26:36.632362346 -0500
@@ -2,7 +2,7 @@
 // SWITCH CONFIG WIZARD
 //
 // Copyright (c) 2008-2014 Nagios Enterprises, LLC.  All rights reserved.
-//
+//
 // $Id: switch.inc.php 1388 2014-08-29 16:33:04Z jomann $
 //
 // TODOS:
@@ -30,6 +30,7 @@
     register_configwizard($name, $args);
 }

+
 /**
  *
  * Generates the instructions to be passed to the command line to generate an MRTG configuration.
@@ -41,7 +42,7 @@
  *
  * @return $cmd String - String to be executed
  */
-function switch_configwizard_get_cfgmaker_cmd($snmpopts, $address, $port, $snmpversion = "1", $defaultspeed = "100000000")
+function switch_configwizard_get_cfgmaker_cmd($snmpopts, $address, $port, $snmpversion = "1", $defaultspeed = "1073741824")
 {
     $cmd = "/usr/bin/cfgmaker ";
     $args[] = "--show-op-down";
@@ -100,33 +101,42 @@

     switch ($mode) {

+
         case CONFIGWIZARD_MODE_GETSTAGE1HTML:
             $address = grab_array_var($inargs, "address", "");
             $address_port = grab_array_var($inargs, "port", 161);
-            $snmpversion = grab_array_var($inargs, "snmpversion", "2c");
+            $snmpversion = grab_array_var($inargs, "snmpversion", "3");
             $snmpopts_serial = grab_array_var($inargs, "snmpopts_serial", "");
             if (!empty($snmpopts_serial)) {
                 $snmpopts = unserialize(base64_decode($snmpopts_serial));
             } else {
                 // Set the defaults if nothing is set yet
                 $snmpopts_default = array(
-                    "snmpcommunity" => "public",
-                    "v3_security_level" => "",
-                    "v3_username" => "",
-                    "v3_auth_password" => "",
+                    "snmpcommunity" => "XXXXXX",
+                    "v3_security_level" => "authNoPriv",
+                    "v3_username" => "USERNAME",
+                    "v3_auth_password" => "XXXXXXXX",
                     "v3_priv_password" => "",
-                    "v3_auth_proto" => "MD5",
+                    "v3_auth_proto" => "SHA",
                     "v3_priv_proto" => "DES"
+
+                    //"snmpcommunity" => "XXXXXX",
+                    //"v3_security_level" => "authNoPriv",
+                    //"v3_username" => "",
+                    //"v3_auth_password" => "",
+                    //"v3_priv_password" => "",
+                    //"v3_auth_proto" => "SHA",
+                    //"v3_priv_proto" => "DES"
                 );
                 $snmpopts = grab_array_var($inargs, "snmpopts", $snmpopts_default);
             }
-            $portnames = grab_array_var($inargs, "portnames", "number");
+            $portnames = grab_array_var($inargs, "portnames", "descr");
             $scaninterfaces = grab_array_var($inargs, "scaninterfaces", "on");
-            $default_port_speed = grab_array_var($inargs, "default_port_speed", 100000000);
-            $warn_speed_in_percent = grab_array_var($inargs, "warn_speed_in_percent", 50);
-            $warn_speed_out_percent = grab_array_var($inargs, "warn_speed_out_percent", 50);
-            $crit_speed_in_percent = grab_array_var($inargs, "crit_speed_in_percent", 80);
-            $crit_speed_out_percent = grab_array_var($inargs, "crit_speed_out_percent", 80);
+            $default_port_speed = grab_array_var($inargs, "default_port_speed", 1073741824);
+            $warn_speed_in_percent = grab_array_var($inargs, "warn_speed_in_percent", 70);
+            $warn_speed_out_percent = grab_array_var($inargs, "warn_speed_out_percent", 70);
+            $crit_speed_in_percent = grab_array_var($inargs, "crit_speed_in_percent", 90);
+            $crit_speed_out_percent = grab_array_var($inargs, "crit_speed_out_percent", 90);
             if (!switch_configwizard_checkversion()) {
                 $output = "<br/><strong>" . gettext("Error: This wizard requires Nagios XI 2014 or later.") . "</strong>";
             } else {
@@ -162,7 +172,16 @@
                 <input type="text" size="40" name="address" id="address" value="' . htmlentities($address) . '" class="textfield" /><br class="nobr" />
                 ' . gettext("The IP address of the network device you'd like to monitor") . '.<br class="nobr" />
             </td>
-        </tr>
+
+    <td>
+    <label>' . gettext('Host Name:') . '</label><br class="nobr" />
+    </td>
+    <td>
+<input type="text" size="20" name="hostname" id="hostname" value="' . htmlentities($hostname) . '" class="textfield" /><br class="nobr" />
+    ' . gettext('The name you\'d like to have associated with this switch or router.') . '
+    </td>
+    </tr>
+
         <tr>
             <td valign="top">
                 <label>'.gettext("Port").':</label>
@@ -216,7 +235,7 @@
                     <br class="nobr" />
                 </td>
             </tr>
-
+
             <tr>
                 <td valign="top">
                     <label>' . gettext("Username") . ':</label><br class="nobr" />
@@ -284,6 +303,7 @@
             <select name="portnames">
                 <option value="number" ' . is_selected($portnames, "number") . '>' . gettext("Port's Number") . '</option>
                 <option value="name" ' . is_selected($portnames, "name") . '>' . gettext("Port's Name") . '</option>
+                <option value="descr" '.is_selected($portnames, "descr").'>'.gettext("Port's Description").'</option>
             </select>
         </td>
     </tr>
@@ -351,13 +371,25 @@
         case CONFIGWIZARD_MODE_VALIDATESTAGE1DATA:

             // Get variables that were passed to us
-            $address = grab_array_var($inargs, "address", "");
+            $address1 = grab_array_var($inargs, "address", "");
+            print "Addr1:" . $address1;
+            //$data = "foo:*:1023:1000::/home/foo:/bin/sh";
+            list($address, $hostname) = explode(":", $address1);
+            print "Addr:" . $address;
+            print "Host:" . $hostname;
+//            htmlentities($address) = $address;
+//            $address = grab_array_var($inargs, "address", "");
+
+            if(empty($hostname)) {
+                    $hostname = grab_array_var($inargs, "hostname", "");
+            }
+
             $address_port = grab_array_var($inargs, "port", 161);
             $snmpopts = grab_array_var($inargs, "snmpopts", array());
             $scaninterfaces = grab_array_var($inargs, "scaninterfaces");
             $snmpversion = grab_array_var($inargs, "snmpversion", "2c");
             $default_port_speed = grab_array_var($inargs, "default_port_speed", 100000000);
-            $errors = 0;
+                        $errors = 0;
             $errmsg = array();

             // Do error checking
@@ -398,9 +430,22 @@

         case CONFIGWIZARD_MODE_GETSTAGE2HTML:

+
+            // Get variables that were passed to us
             // Get variables that were passed to us
-            $address = grab_array_var($inargs, "address");
+            $address1 = grab_array_var($inargs, "address", "");
+            //$data = "foo:*:1023:1000::/home/foo:/bin/sh";
+            list($address, $hostname) = explode(":", $address1);
+//            htmlentities($address) = $address;
+//            $address = grab_array_var($inargs, "address", "");
+
+            if(empty($hostname)) {
+                    $hostname = grab_array_var($inargs, "hostname", "");
+            }
+
+//            $address = grab_array_var($inargs, "address");
             $address_port = grab_array_var($inargs, "port", 161);
+//            $hostname = grab_array_var($inargs, "hostname", "");
             $snmpopts_serial = grab_array_var($inargs, "snmpopts_serial", "");
             if (!empty($snmpopts_serial)) {
                 $snmpopts = unserialize(base64_decode($snmpopts_serial));
@@ -419,6 +464,7 @@
             }
             $vendor = grab_array_var($inargs, "vendor", "");
             $portnames = grab_array_var($inargs, "portnames");
+                        $portdisplaynames = grab_array_var($inargs, "portnames");
             $scaninterfaces = grab_array_var($inargs, "scaninterfaces");
             $snmpversion = grab_array_var($inargs, "snmpversion", "2c");
             $default_port_speed = grab_array_var($inargs, "default_port_speed", 100000000);
@@ -426,15 +472,18 @@
             $warn_speed_out_percent = grab_array_var($inargs, "warn_speed_out_percent", 50);
             $crit_speed_in_percent = grab_array_var($inargs, "crit_speed_in_percent", 80);
             $crit_speed_out_percent = grab_array_var($inargs, "crit_speed_out_percent", 80);
-            $hostname = @gethostbyaddr($address);
+            if(empty($hostname)){
+                $hostname = @gethostbyaddr($address);
+            }

             $output = '
-
+
         <input type="hidden" name="snmpversion" value="' . htmlentities($snmpversion) . '" />
         <input type="hidden" name="address" value="' . htmlentities($address) . '" />
         <input type="hidden" name="vendor" value="' . htmlentities($vendor) . '" />
         <input type="hidden" name="snmpopts_serial" value="' . $snmpopts_serial . '" />
         <input type="hidden" name="portnames" value="' . htmlentities($portnames) . '" />
+                <input type="hidden" name="portdisplaynames" value="' . htmlentities($portdisplaynames) . '" />
         <input type="hidden" name="scaninterfaces" value="' . htmlentities($scaninterfaces) . '" />
         <input type="hidden" name="warn_speed_in_percent" value="' . htmlentities($warn_speed_in_percent) . '" />
         <input type="hidden" name="crit_speed_in_percent" value="' . htmlentities($crit_speed_in_percent) . '" />
@@ -442,7 +491,7 @@
         <input type="hidden" name="crit_speed_out_percent" value="' . htmlentities($crit_speed_out_percent) . '" />

     <div class="sectionTitle">' . gettext('Switch Details') . '</div>
-
+
     <table>

     <tr>
@@ -467,14 +516,14 @@
     </table>

     <div class="sectionTitle">' . gettext('Services') . '</div>
-
+
     <p>' . gettext('Specify which services you\'d like to monitor for the switch or router.') . '</p>
-
+
     <table>

     <tr>
     <td valign="top">
-    <input type="checkbox" class="checkbox" id="ping" name="services[ping]" checked>
+    <input type="checkbox" class="checkbox" id="ping" name="services[ping]" >
     </td>
     <td>
     <b>' . gettext('Ping') . '</b><br>
@@ -498,50 +547,50 @@
                 $ports = switch_configwizard_read_walk_file($outfile, $address);

                 $output .= '
-
+
                 <div class="sectionTitle">' . gettext('Bandwidth and Port Status') . '</div>
-
+
                 <script type="text/javascript">
-                //check all ports
+                //check all ports
                 var allChecked=false;
                 function switchCheckAll()
                 {
-                    $(".portbox:checkbox").each(function() {
-                      this.checked = "checked";
+                    $(".portbox:checkbox").each(function() {
+                      this.checked = "checked";
                     });
-                }
+                }
                 function switchUncheckAll()
                 {
-                    $(".portbox:checkbox").each(function() {
-                      this.checked = "";
+                    $(".portbox:checkbox").each(function() {
+                      this.checked = "";
                     });
                 }
                 function bandwidthCheckAll()
                 {
-                    $(".bandwidthbox:checkbox").each(function() {
-                      this.checked = "checked";
+                    $(".bandwidthbox:checkbox").each(function() {
+                      this.checked = "checked";
                     });
-                }
+                }
                 function bandwidthUncheckAll()
                 {
-                    $(".bandwidthbox:checkbox").each(function() {
-                      this.checked = "";
+                    $(".bandwidthbox:checkbox").each(function() {
+                      this.checked = "";
                     });
                 }
                 function statusCheckAll()
                 {
-                    $(".statusbox:checkbox").each(function() {
-                      this.checked = "checked";
+                    $(".statusbox:checkbox").each(function() {
+                      this.checked = "checked";
                     });
-                }
+                }
                 function statusUncheckAll()
                 {
-                    $(".statusbox:checkbox").each(function() {
-                      this.checked = "";
+                    $(".statusbox:checkbox").each(function() {
+                      this.checked = "";
                     });
                 }
                 </script>
-
+
                 ';

                 if (count($ports) > 0) {
@@ -561,6 +610,7 @@

                         $port_bytes = grab_array_var($parr, "max_bytes", 0);

+
                         // We'll use either description or number as the name later
                         $port_description = grab_array_var($parr, "port_description", $port_num);
                         $port_number = grab_array_var($parr, "port_number", $port_num);
@@ -568,15 +618,18 @@

                         // Remome illegal chars in portnames -SW
                         // `~!$%^&*|'"<>?,()=\
-                        $badchars = explode(" ", "` ~ ! $ % ^ & * | ' \" < > ? , ( ) = \\ { } [ ]");
-                        $port_number = str_replace($badchars, " ", $port_number);
-                        $port_description = str_replace($badchars, " ", $port_description);
-                        $port_long_desc = str_replace($badchars, " ", $port_long_desc);
+                        $badchars = explode(" ", "- ` ~ ! $ % ^ & * | ' \" < > ? , ( ) = / \\ { } [ ] ;");
+                                                $port_number = str_replace($badchars, "_", $port_number);
+                                                $port_description = str_replace($badchars, "_", $port_description);
+                        $port_long_desc = str_replace($badchars, "_", $port_long_desc);

                         // Default to using port number for service name
                         $port_name = "Port " . $port_number;
                         if ($portnames == "name") {
-                            $port_name = $port_long_desc; //changed to long description -MG
+                            $port_name = $port_long_desc; //changed to long description -MG
+                        }
+                        if($portnames=="descr") {
+                            $port_name=$port_description; //changed to long description -MG
                         }

                         $x++;
@@ -604,13 +657,14 @@
                         ' . gettext('Port ') . $port_num . '<br />' .
                             encode_form_val($port_description)
                             . '</td>
-
+
                         <td>
                         ' . $max_speed . '
                         </td>

                         <td>
                         <input type="text" size="20" name="serviceargs[portname][' . $port_num . ']" value="' . $port_name . '">
+                                                <input type="hidden" name="serviceargs[portdisplayname][' . $port_num . ']"  value="' . $port_long_desc . '" />
                         </td>

                         <td>
@@ -636,7 +690,7 @@
                         <td>
                         <input type="text" size="2" name="serviceargs[bandwidth_warning_output_value][' . $port_num . ']" value="' . number_format($warn_out_speed) . '">
                         </td>
-
+
                         <td>
                         <label>' . gettext('Critical') . ':</label>
                         </td>
@@ -656,8 +710,8 @@
                         </td>
                         </tr>
                         </table>
-
-
+
+
                         </td>
                         <td>
                         <input type="checkbox" class="checkbox statusbox" id="portstatus_' . $port_num . '" name="serviceargs[portstatus][' . $port_num . ']" checked>
@@ -706,8 +760,21 @@
         case CONFIGWIZARD_MODE_VALIDATESTAGE2DATA:

             // get variables that were passed to us
-            $hostname = grab_array_var($inargs, "hostname");
-            $address = grab_array_var($inargs, "address");
+//            $hostname = grab_array_var($inargs, "hostname");
+//            $address = grab_array_var($inargs, "address");
+                    $address1 = grab_array_var($inargs, "address", "");
+            print "Addr1:" . $address1;
+            //$data = "foo:*:1023:1000::/home/foo:/bin/sh";
+            list($address, $hostname) = explode(":", $address1);
+            print "Addr:" . $address;
+            print "Host:" . $hostname;
+//            htmlentities($address) = $address;
+//            $address = grab_array_var($inargs, "address", "");
+
+            if(empty($hostname)) {
+                    $hostname = grab_array_var($inargs, "hostname", "");
+            }
+
             $portnames = grab_array_var($inargs, "portnames");
             $snmpopts_serial = grab_array_var($inargs, "snmpopts_serial", "");
             if (!empty($snmpopts_serial)) {
@@ -752,10 +819,25 @@
         case CONFIGWIZARD_MODE_GETSTAGE3HTML:

             // get variables that were passed to us
-            $address = grab_array_var($inargs, "address");
-            $hostname = grab_array_var($inargs, "hostname");
+//            $address = grab_array_var($inargs, "address");
+//            $hostname = grab_array_var($inargs, "hostname");
+                    $address1 = grab_array_var($inargs, "address", "");
+            print "Addr1(Stage3):" . $address1;
+            //$data = "foo:*:1023:1000::/home/foo:/bin/sh";
+            list($address, $hostname) = explode(":", $address1);
+            print "Addr:" . $address;
+            print "Host:" . $hostname;
+//            htmlentities($address) = $address;
+//            $address = grab_array_var($inargs, "address", "");
+
+            if(empty($hostname)) {
+                    $hostname = grab_array_var($inargs, "hostname", "");
+            }
+
             $vendor = grab_array_var($inargs, "vendor");
             $portnames = grab_array_var($inargs, "portnames");
+                        $portdisplaynames = grab_array_var($inargs, "portdisplaynames");
+                        print "DisplayName:" . $portdisplaynames;
             $snmpopts_serial = grab_array_var($inargs, "snmpopts_serial", "");
             if ($snmpopts_serial != "") {
                 $snmpopts = unserialize(base64_decode($snmpopts_serial));
@@ -789,7 +871,7 @@
             echo "REQUEST:<BR>";
             global $request;
             print_r($request);
-
+
             echo "SERVICES:<BR>";
             print_r($services);
             echo "SERVICEARGS:<BR>";
@@ -798,13 +880,14 @@


             $output = '
-
+
         <input type="hidden" name="address" value="' . htmlentities($address) . '" />
         <input type="hidden" name="hostname" value="' . htmlentities($hostname) . '" />
         <input type="hidden" name="snmpopts_serial" value="' . $snmpopts_serial . '" />
         <input type="hidden" name="snmpversion" value="' . htmlentities($snmpversion) . '" />
         <input type="hidden" name="vendor" value="' . htmlentities($vendor) . '" />
         <input type="hidden" name="portnames" value="' . htmlentities($portnames) . '" />
+                <input type="hidden" name="portdisplaynames" value="' . htmlentities($portdisplaynames) . '" />
         <input type="hidden" name="scaninterfaces" value="' . htmlentities($scaninterfaces) . '" />
         <input type="hidden" name="warn_speed_in_percent" value="' . htmlentities($warn_speed_in_percent) . '" />
         <input type="hidden" name="crit_speed_in_percent" value="' . htmlentities($crit_speed_in_percent) . '" />
@@ -812,28 +895,42 @@
         <input type="hidden" name="crit_speed_out_percent" value="' . htmlentities($crit_speed_out_percent) . '" />
         <input type="hidden" name="services_serial" value="' . $services_serial . '" />
         <input type="hidden" name="serviceargs_serial" value="' . $serviceargs_serial . '" />
-
+
         <!-- SERVICES=' . serialize($services) . '<BR>
         SERVICEARGS=' . serialize($serviceargs) . '<BR> -->
-
+
             ';
             break;

         case CONFIGWIZARD_MODE_VALIDATESTAGE3DATA:

+
             break;

         case CONFIGWIZARD_MODE_GETFINALSTAGEHTML:

             $output = '
-
+
             ';
             break;

         case CONFIGWIZARD_MODE_GETOBJECTS:

-            $hostname = grab_array_var($inargs, "hostname", "");
-            $address = grab_array_var($inargs, "address", "");
+//            $hostname = grab_array_var($inargs, "hostname", "");
+//            $address = grab_array_var($inargs, "address", "");
+            $address1 = grab_array_var($inargs, "address", "");
+            print "Addr1(GETOBJECTS):" . $address1;
+            //$data = "foo:*:1023:1000::/home/foo:/bin/sh";
+            list($address, $hostname) = explode(":", $address1);
+//            print "Addr:" . $address;
+//            print "Host:" . $hostname;
+//            htmlentities($address) = $address;
+//            $address = grab_array_var($inargs, "address", "");
+
+            if(empty($hostname)) {
+                    $hostname = grab_array_var($inargs, "hostname", "");
+            }
+
             $snmpopts_serial = grab_array_var($inargs, "snmpopts_serial", "");
             if ($snmpopts_serial != "") {
                 $snmpopts = unserialize(base64_decode($snmpopts_serial));
@@ -887,12 +984,15 @@
             if (!host_exists($hostname)) {
                 $objs[] = array(
                     "type" => OBJECTTYPE_HOST,
-                    "use" => "xiwizard_switch_host",
+                    "use" => "qt_xiwizard_networkdevice_host",
                     "host_name" => $hostname,
                     "address" => $hostaddress,
                     "icon_image" => "switch.png",
                     "statusmap_image" => "switch.png",
                     "_xiwizard" => $wizard_name,
+                                        "contacts" => 0,
+                                        "notification_period" => 0,
+                                        "check_period" => 0,
                 );
             }

@@ -910,8 +1010,11 @@
                             "type" => OBJECTTYPE_SERVICE,
                             "host_name" => $hostname,
                             "service_description" => "Ping",
-                            "use" => "xiwizard_switch_ping_service",
+                            "use" => "qt_xiwizard_netwrok_ping_service",
                             "_xiwizard" => $wizard_name,
+                                                        "contacts" => 0,
+                                                        "notification_period" => 0,
+                                                        "check_period" => 0,
                         );
                         break;

@@ -921,11 +1024,20 @@
                             //echo "HAVE PORT $portnum<BR>\n";

                             $portname = gettext("Port ") . $portnum;
+                                                        //$portdescription = gettext("Port ") . $portnum;
                             if (array_key_exists("portname", $serviceargs)) {
                                 if (array_key_exists($portnum, $serviceargs["portname"])) {
                                     $portname = $serviceargs["portname"][$portnum];
-                                    $badchars = explode(" ", "` ~ ! $ % ^ & * | ' \" < > ? , ( ) = \\ { } [ ]");
-                                    $portname = str_replace($badchars, " ", $portname);
+                                                                        $badchars = explode(" ", "- ` ~ ! $ % ^ & * | ' \" < > ? , ( ) = / \\ { } [ ] ;");
+                                    $portname=str_replace($badchars, "_", $portname);
+                                                                        //$portdescription = $portname;
+                                }
+                            }
+                                                        if (array_key_exists("portdisplayname", $serviceargs)) {
+                                if (array_key_exists($portnum, $serviceargs["portdisplayname"])) {
+                                    $portdescription = $serviceargs["portdisplayname"][$portnum];
+                                                                        $badchars = explode(" ", "- ` ~ ! $ % ^ & * | ' \" < > ? , ( ) = / \\ { } [ ] ;");
+                                    $portdescription=str_replace($badchars, "_", $portdescription);
                                 }
                             }

@@ -957,10 +1069,14 @@
                                     $objs[] = array(
                                         "type" => OBJECTTYPE_SERVICE,
                                         "host_name" => $hostname,
-                                        "service_description" => $portname . " Bandwidth",
-                                        "use" => "xiwizard_switch_port_bandwidth_service",
+                                        "service_description" => $portname . "_Bandwidth",
+                                        "use" => "qt_xiwizard_network_service",
                                         "check_command" => "check_xi_service_mrtgtraf!" . $hostaddress . "_" . $portnum . ".rrd!" . $warn_pair . "!" . $crit_pair . "!" . $label,
                                         "_xiwizard" => $wizard_name,
+                                                                                "contacts" => 0,
+                                                                                "notification_period" => 0,
+                                                                                "check_period" => 0,
+                                                                                "display_name" => $portdescription,
                                     );
                                 }
                             }
@@ -973,10 +1089,15 @@
                                         $objs[] = array(
                                             "type" => OBJECTTYPE_SERVICE,
                                             "host_name" => $hostname,
-                                            "service_description" => $portname . " Status",
-                                            "use" => "xiwizard_switch_port_status_service",
-                                            "check_command" => "check_xi_service_ifoperstatus!" . $snmpopts['snmpcommunity'] . "!" . $portnum . "!-v " . (int)$snmpversion,
+                                            "service_description" => $portname . "_Status",
+                                            "use" => "qt_xiwizard_network_service",
+                                            //"check_command" => "check_xi_service_ifoperstatus!" . $snmpopts['snmpcommunity'] . "!" . $portnum . "!-v " . (int)$snmpversion,
+                                                                                        "check_command" => "qt_check_xi_service_ifoperstatus_v2!{$portnum}",
                                             "_xiwizard" => $wizard_name,
+                                                                                        "contacts" => 0,
+                                                                                        "notification_period" => 0,
+                                                                                        "check_period" => 0,
+                                                                                        "display_name" => $portdescription,
                                         );
                                     } else {

@@ -990,10 +1111,15 @@
                                         $objs[] = array(
                                             "type" => OBJECTTYPE_SERVICE,
                                             "host_name" => $hostname,
-                                            "service_description" => $portname . " Status",
-                                            "use" => "xiwizard_switch_port_status_service",
-                                            "check_command" => "check_xi_service_ifoperstatusnag!{$portnum}!-v{$snmpversion} -u {$snmpopts['v3_username']} -A {$snmpopts['v3_auth_password']} {$priv_password_and_proto} -a {$snmpopts["v3_auth_proto"]} -l {$snmpopts['v3_security_level']}",
+                                            "service_description" => $portname . "_Status",
+                                            "use" => "qt_xiwizard_network_service",
+                                            //"check_command" => "check_xi_service_ifoperstatusnag!{$portnum}!-v{$snmpversion} -u {$snmpopts['v3_username']} -A {$snmpopts['v3_auth_password']} {$priv_password_and_proto} -a {$snmpopts["v3_auth_proto"]} -l {$snmpopts['v3_security_level']}",
+                                            "check_command" => "qt_check_xi_service_ifoperstatusnag_v3!{$portnum}!",
                                             "_xiwizard" => $wizard_name,
+                                                                                        "contacts" => 0,
+                                                                                        "notification_period" => 0,
+                                                                                        "check_period" => 0,
+                                                                                        "display_name" => $portdescription,
                                         );
                                     }
                                 }
@@ -1112,6 +1238,7 @@
                 $long_descrip = trim(str_replace("</td>", NULL, $long_descrip));
                 // save the description
                 if ($long_descrip != '') $output[$port_number]["port_long_description"] = $long_descrip;
+                                //print_r($long_descrip);

             }

@@ -1178,7 +1305,7 @@

     fclose($fo);

-    // immediately tell mrtg to generate data from the new walk file
+    // immediately tell mrtg to generate data from the new walk file
     // if we didn't do this, nagios might send alerts about missing rrd files!
     $cmd = "mrtg {$f} &";
     exec($cmd);
@@ -1267,6 +1394,7 @@
             break;
     }

+
 }

 /**
@@ -1317,3 +1445,4 @@
     }
 }
 ?>
+

Re: Network Switch/Router Wizard - Select the port naming sc

Posted: Fri Jan 09, 2015 12:11 pm
by sreinhardt
Awesome, I'll note it in the FR!