2222 +-------------------------------------------------------------------------+
2323*/
2424
25- /* let PHP run just as long as it has to */
25+ // let PHP run just as long as it has to
2626ini_set ('max_execution_time ' , '0 ' );
2727
2828error_reporting (E_ALL );
29- $ dir = dirname ( __FILE__ ) ;
29+ $ dir = __DIR__ ;
3030chdir ($ dir );
3131
3232if (strpos ($ dir , 'plugins ' ) !== false ) {
3737
3838include_once ($ config ['base_path ' ] . '/plugins/thold/thold_functions.php ' );
3939
40- /* set the defaults */
40+ // set the defaults
4141$ force = false ;
4242$ debug = false ;
4343$ gtemplate = 0 ;
4444$ ttemplate = 0 ;
4545$ hids = '' ;
4646$ gids = '' ;
4747
48- /* process calling arguments */
48+ // process calling arguments
4949$ parms = $ _SERVER ['argv ' ];
5050array_shift ($ parms );
5151
5252if (sizeof ($ parms )) {
53- foreach ($ parms as $ parameter ) {
53+ foreach ($ parms as $ parameter ) {
5454 if (strpos ($ parameter , '= ' )) {
55- list ( $ arg , $ value) = explode ('= ' , $ parameter );
55+ [ $ arg , $ value] = explode ('= ' , $ parameter );
5656 } else {
57- $ arg = $ parameter ;
57+ $ arg = $ parameter ;
5858 $ value = '' ;
5959 }
6060
7272 case '--debug ' :
7373 case '-d ' :
7474 $ debug = true ;
75+
7576 break ;
7677 case '--force ' :
7778 case '-f ' :
7879 $ force = true ;
80+
7981 break ;
8082 case '--graph-template ' :
8183 case '-gt ' :
8284 $ gtemplate = $ value ;
85+
8386 break ;
8487 case '--thold-template ' :
8588 case '-tt ' :
8689 $ ttemplate = $ value ;
90+
8791 break ;
8892 case '--graph-ids ' :
8993 case '-ids ' :
9094 $ gids = $ value ;
95+
9196 break ;
9297 case '--host-ids ' :
9398 $ hids = $ value ;
99+
94100 break ;
95101 case '--version ' :
96102 case '-V ' :
110116 }
111117}
112118
113- /* validate device ids */
119+ // validate device ids
114120if (strlen ($ hids )) {
115121 $ hids = explode (' ' , $ hids );
116- foreach ($ hids as $ id ) {
122+
123+ foreach ($ hids as $ id ) {
117124 if (!is_numeric ($ id )) {
118125 print 'ERROR: The Device ID \'' . $ id . '\' is NOT numeric. All Device IDs must be numeric. ' . PHP_EOL . PHP_EOL ;
119126 display_help ();
122129 }
123130}
124131
125- /* validate values */
132+ // validate values
126133if (!is_numeric ($ ttemplate )) {
127134 print 'ERROR: The Thold Template must be numeric. ' . PHP_EOL . PHP_EOL ;
128135 display_help ();
129136 exit (-1 );
130137}
131138
132- /* validate values */
139+ // validate values
133140if (!is_numeric ($ gtemplate )) {
134141 print 'ERROR: The Graph Template must be numeric. ' . PHP_EOL . PHP_EOL ;
135142 display_help ();
136143 exit (-1 );
137144}
138145
139- /* validate graph ids */
146+ // validate graph ids
140147if (strlen ($ gids )) {
141148 $ gids = explode (' ' , $ gids );
142- foreach ($ gids as $ id ) {
149+
150+ foreach ($ gids as $ id ) {
143151 if (!is_numeric ($ id )) {
144152 print 'ERROR: The Graph ID \'' . $ id . '\' is NOT numeric. All Graph IDs must be numeric. ' . PHP_EOL . PHP_EOL ;
145153 display_help ();
148156 }
149157}
150158
151- /* perform some checks */
159+ // perform some checks
152160if ($ ttemplate == 0 && $ gtemplate == 0 && $ hids == '' && $ gids == '' ) {
153161 print 'ERROR: You must choose either --auto-create or a combination of Devices, Graphs, ' . PHP_EOL ;
154162 print 'a Graph Template of Threshold Template. ' . PHP_EOL . PHP_EOL ;
@@ -174,6 +182,7 @@ function thold_cli_autocreate($hids = '', $gids = '', $gtemplate = 0, $ttemplate
174182
175183function display_version () {
176184 global $ config ;
185+
177186 if (!function_exists ('plugin_thold_version ' )) {
178187 include_once ($ config ['base_path ' ] . '/plugins/thold/setup.php ' );
179188 }
@@ -182,9 +191,8 @@ function display_version() {
182191 print 'Threshold Command Line Interface, Version ' . $ info ['version ' ] . ', ' . COPYRIGHT_YEARS . PHP_EOL ;
183192}
184193
185-
186- /* display_help - displays the usage of the function */
187- function display_help () {
194+ // display_help - displays the usage of the function
195+ function display_help () {
188196 display_version ();
189197
190198 print PHP_EOL ;
@@ -206,4 +214,3 @@ function display_help () {
206214 print '--thold-template=N - The Threshold Template to use for creating Thresholds ' . PHP_EOL ;
207215 print '--graph-ids= \'N1 N2 ... \' - The Threshold Template to use for creating Thresholds ' . PHP_EOL . PHP_EOL ;
208216}
209-
0 commit comments