Page 1 of 1

Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Sun Apr 11, 2010 1:25 am
by Box293
At stage 4 in the configuration wizard you can specify how often to check the services, see screenshot:
Monitoring Settings.jpg
In my home made configuration wizard, is there a way to specify what default values are populated in these fields?


For example, I have some auditing checks that I only want performed three times a day (say every 28800 minutes).

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Sun Apr 11, 2010 5:16 pm
by mmestnik
If you are asking should I assume it's not part of the HTML generated by php?
Monday.

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Mon Apr 12, 2010 12:35 pm
by admin
You are adventurous! We haven't documented the config wizard API officially yet, so its great to see that you're delving in on your own.

The mods you suggested aren't possible YET. However, we know this would be really useful, so we'll extend the config wizard API to allow your own custom wizards to initialize the default values that are displayed here. It might take a few weeks to get this in and tested, but we'll definitely get it incorporated. :-)

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Mon Apr 12, 2010 12:56 pm
by mmestnik

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Tue Apr 13, 2010 5:10 am
by Box293
Thanks for the info, there is no rush to get this feature added as I'm sure there are many more important things on your list at this point in time. :mrgreen:

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Thu Apr 22, 2010 1:16 am
by TSCAdmin
I've just built my own Linux server monitoring wizard (the one provided uses NRPE, and I'd rather use SNMP and different variety of checks, such as bonded network interfaces, fibre cards, etc) ... this part was the only thing I was having difficulty with. Glad to hear this is being worked on :D

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Sat Apr 24, 2010 11:00 am
by Box293
I've noticed in the 2009R1.2 development snapshot you've made mention of this API change.

How do we make use of this new functionality when creating our own config wizards?

Cheers

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Mon Apr 26, 2010 11:28 am
by mmestnik
Ethan made the API change and he is going to a Con this week and has another Con coming up, so it will be a few weeks to get this out.

This feature doesn't seam critical enough to effect development of Wizards for 1.2, the API likely works just like the rest of the API and you might even be able to write a prototype of the code. What you are missing just now is the Nouns and Verbs, you should have a good feel for what the rest would look like. When I asked Ethan didn't give me any hints as to how to use this API, this is his last day in the office prior to going over seas.

I'd also like to add that although it's prudent to have a 1.2 branch for your projects I'd feel unpleasant about there being users potentially using anything like that in production. Please make sure any Wizards you release or publish have a 1.1H compatible back-port, as I'd hate for users to upgrade prematurely so they could make use of your applications.

Thank you!! :D

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Mon Apr 26, 2010 12:31 pm
by admin
Okay, here's some code snippets that go in the same callback function you use to output HTML, etc in wizards. Hopefully this will give you enough to try it out on your own. :-)

Code: Select all


		case CONFIGWIZARD_MODE_GETSTAGE3OPTS:
		
			// pass any monitoring variables you want to override...
			$outargs[CONFIGWIZARD_OVERRIDE_OPTIONS]=array(
				"check_interval" => 9,
				"retry_interval" => 10,
				"max_check_attempts" => 11,
				);
		
			break;
		
		case CONFIGWIZARD_MODE_GETSTAGE4OPTS:
		
			// pass any notification variables you want to override...
			$outargs[CONFIGWIZARD_OVERRIDE_OPTIONS]=array(
				"notification_interval" => 12,
				"first_notification_delay" => 13,
				"notification_options" => "none", // "delayed", "immediate", or "none"
				"notification_targets" => array(
					"myself" => "on",
					"contacts" => "",
					"contactgroups" => "on",
					),
				"contact_id" => array( // pre-selected contacts
					311 => "on",
					177 => "on"
					),
				"contactgroup_id" => array( // pre-selected contact groups
					146 => "on"
					),
				);
		
			break;
		
		// THE FOLLOWING MODES ARE POST-CONFIGURATION CALLBACKS
		// THEY CAN BE USED TO DO CONFIGURATION TASKS, ETC AFTER A NEW CONFIGURATION HAS BEEN SUBMITTED
			
		case CONFIGWIZARD_MODE_COMMITERROR:
			echo "COMMITERROR!\n";
			break;
			
		case CONFIGWIZARD_MODE_COMMITCONFIGERROR:
			echo "COMMITCONFIGERROR!\n";
			break;

		case CONFIGWIZARD_MODE_COMMITPERMSERROR:
			echo "COMMITPERMSERROR!\n";
			break;
			
		case CONFIGWIZARD_MODE_COMMITOK:
		
			//echo "COMMITOK!\n";
			//echo "INARGS:\n";
			//print_r($inargs);
			
			$services_serial=grab_array_var($inargs,"services_serial");
			$services=unserialize(base64_decode($services_serial));
			
			//echo "SERVICES:\n";
			//print_r($services);

			// initialize each 'SNMP Traps' service with an OK state
			$servicename="SNMP Traps";
			$hosts=grab_array_var($services,"host");
			foreach($hosts as $hostname => $hoststate){
				echo "HOST/SVC => $hostname,SNMP Traps\n";
				$output="";
				$raw_command="PROCESS_SERVICE_CHECK_RESULT;".$hostname.";".$servicename.";0;Waiting for trap...\n";
				submit_direct_nagioscore_command($raw_command,$output);
				}
			
			break;

Re: Home made Configuraiton Wizards - Stage 4 populating fields

Posted: Mon Apr 26, 2010 6:33 pm
by Box293
Thanks for taking time to get this information to us.