1
+ <?php
2
+ // MASS ACKNOWLEDGE COMPONENT
3
+ //
4
+ // Copyright (c) 2010 Nagios Enterprises, LLC. All rights reserved.
5
+ //
6
+ // $Id: profile.inc.php 115 2010-08-16 16:15:26Z mguthrie $
7
+
8
+ //include the helper file
9
+ require_once (dirname (__FILE__ ).'/../componenthelper.inc.php ' );
10
+
11
+ // respect the name
12
+ $ profile_component_name ="profile " ;
13
+
14
+ // run the initialization function
15
+ profile_component_init ();
16
+
17
+ ////////////////////////////////////////////////////////////////////////
18
+ // COMPONENT INIT FUNCTIONS
19
+ ////////////////////////////////////////////////////////////////////////
20
+
21
+ function profile_component_init (){
22
+ global $ profile_component_name ;
23
+
24
+ //boolean to check for latest version
25
+ $ versionok =profile_component_checkversion ();
26
+
27
+ //component description
28
+ $ desc =gettext ("This component creates a system profile menu in the Admin panel
29
+ which can be used for troubleshooting purposes. " );
30
+
31
+ if (!$ versionok )
32
+ $ desc ="<b> " .gettext ("Error: This component requires Nagios XI 20011R1.1 or later. " )."</b> " ;
33
+
34
+ //all components require a few arguments to be initialized correctly.
35
+ $ args =array (
36
+
37
+ // need a name
38
+ COMPONENT_NAME => $ profile_component_name ,
39
+ COMPONENT_VERSION => '1.1 ' ,
40
+ COMPONENT_DATE => '8/28/2012 ' ,
41
+
42
+ // informative information
43
+ COMPONENT_AUTHOR => "Nagios Enterprises, LLC " ,
44
+ COMPONENT_DESCRIPTION => $ desc ,
45
+ COMPONENT_TITLE => "System Profile " ,
46
+
47
+ );
48
+
49
+ //register this component with XI
50
+ register_component ($ profile_component_name ,$ args );
51
+
52
+ // register the addmenu function
53
+ if ($ versionok )
54
+ register_callback (CALLBACK_MENUS_INITIALIZED ,'profile_component_addmenu ' );
55
+ }
56
+
57
+
58
+
59
+
60
+ ///////////////////////////////////////////////////////////////////////////////////////////
61
+ // MISC FUNCTIONS
62
+ ///////////////////////////////////////////////////////////////////////////////////////////
63
+
64
+ function profile_component_checkversion (){
65
+
66
+ if (!function_exists ('get_product_release ' ))
67
+ return false ;
68
+ //requires greater than 2011R1
69
+ if (get_product_release ()<201 )
70
+ return false ;
71
+
72
+ return true ;
73
+ }
74
+
75
+ function profile_component_addmenu ($ arg =null ){
76
+ global $ profile_component_name ;
77
+ //retrieve the URL for this component
78
+ $ urlbase =get_component_url_base ($ profile_component_name );
79
+ //figure out where I'm going on the menu
80
+ $ mi =find_menu_item (MENU_ADMIN ,"menu-admin-managesystemconfig " ,"id " );
81
+ if ($ mi ==null ) //bail if I didn't find the above menu item
82
+ return ;
83
+
84
+ $ order =grab_array_var ($ mi ,"order " ,"" ); //extract this variable from the $mi array
85
+ if ($ order =="" )
86
+ return ;
87
+
88
+ $ neworder =$ order +0.1 ; //determine my menu order
89
+
90
+ //add this to the main home menu
91
+ add_menu_item (MENU_ADMIN ,array (
92
+ "type " => "link " ,
93
+ "title " => "System Profile " ,
94
+ "id " => "menu-admin-profile " ,
95
+ "order " => $ neworder ,
96
+ "opts " => array (
97
+ //this is the page the menu will actually point to.
98
+ //all of my actual component workings will happen on this script
99
+ "href " => $ urlbase ."/profile.php " ,
100
+ )
101
+ ));
102
+
103
+ }
104
+
105
+
106
+ ?>
0 commit comments