forked from Cacti/plugin_servcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays.php
More file actions
1408 lines (1375 loc) · 59.9 KB
/
arrays.php
File metadata and controls
1408 lines (1375 loc) · 59.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
// for encrypt credentials
if (!defined('SERVCHECK_CIPHER')) {
define('SERVCHECK_CIPHER', 'aes-256-cbc');
}
// $user_agent can be of user's choice e.g. Linux or Windows based
$user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36';
$ca_info = $config['base_path'] . '/plugins/servcheck/cert/ca-bundle.crt';
$servcheck_tabs = [
'servcheck_test.php' => __('Tests', 'servcheck'),
'servcheck_ca.php' => __('CA certificates', 'servcheck'),
'servcheck_proxy.php' => __('Proxies', 'servcheck'),
'servcheck_restapi.php' => __('Rest API methods', 'servcheck'),
'servcheck_credential.php' => __('Credential', 'servcheck'),
'servcheck_curl_code.php' => __('Curl return codes', 'servcheck'),
];
$servcheck_states = [
'error' => __('Error', 'servcheck'),
'duration' => __('Long duration', 'servcheck'),
'warning' => __('Warning', 'servcheck'),
'failing' => __('Failing', 'servcheck'),
'ok' => __('Ok', 'servcheck'),
'disabled' => __('Disabled', 'servcheck')
];
$service_types = [
'web_http' => __('HTTP plaintext, default port 80', 'servcheck'),
'web_https' => __('HTTP encrypted (HTTPS), default port 443', 'servcheck'),
'mail_smtp' => __('SMTP plaintext, default port 25 (or 587 for submission)', 'servcheck'),
'mail_smtptls' => __('SMTP with STARTTLS, default port 25 (or 587 for submission)', 'servcheck'),
'mail_smtps' => __('SMTP encrypted (SMTPS), default port 465', 'servcheck'),
'mail_imap' => __('IMAP plaintext, default port 143', 'servcheck'),
'mail_imaptls' => __('IMAP with STARTTLS, default port 143', 'servcheck'),
'mail_imaps' => __('IMAP encrypted (IMAPS), default port 993', 'servcheck'),
'mail_pop3' => __('POP3 plaintext, default port 110', 'servcheck'),
'mail_pop3tls' => __('POP3 with STARTTLS, default port 110', 'servcheck'),
'mail_pop3s' => __('POP3 encrypted (POP3S), default port 995', 'servcheck'),
'dns_dns' => __('DNS plaintext, default port 53', 'servcheck'),
'dns_doh' => __('DNS over HTTPS, default port 443', 'servcheck'),
'ldap_ldap' => __('LDAP plaintext, default port 389', 'servcheck'),
'ldap_ldaps' => __('LDAP encrypted (LDAPS), default port 636', 'servcheck'),
'ftp_ftp' => __('FTP plaintext, default port 21', 'servcheck'),
'ftp_tftp' => __('TFTP protocol - download file, default port 69', 'servcheck'),
'ftp_scp' => __('SCP download file, default port 22', 'servcheck'),
'smb_smb' => __('SMB plaintext download file, default port 445', 'servcheck'),
'smb_smbs' => __('SMB encrypted (SMBS) download file, default port 445', 'servcheck'),
'mqtt_mqtt' => __('MQTT plaintext, default port 1883', 'servcheck'),
'rest_basic' => __('Rest API with Basic HTTP auth', 'servcheck'),
'rest_apikey' => __('Rest API with API key auth', 'servcheck'),
'rest_oauth2' => __('Rest API with OAuth2/Bearer token auth', 'servcheck'),
'rest_cookie' => __('Rest API with Cookie based auth', 'servcheck'),
'snmp_get' => __('SNMP get', 'servcheck'),
'snmp_walk' => __('SNMP walk', 'servcheck'),
'ssh_command' => __('SSH command on remote system', 'servcheck'),
'ssh_sftp' => __('SFTP protocol - directory listing, default port 22', 'servcheck'),
];
$service_types_ports = [
'web_http' => 80,
'web_https' => 443,
'mail_smtp' => 25,
'mail_smtptls' => 25,
'mail_smtps' => 465,
'mail_imap' => 143,
'mail_imaptls' => 143,
'mail_imaps' => 993,
'mail_pop3' => 110,
'mail_pop3tls' => 110,
'mail_pop3s' => 995,
'dns_dns' => 53,
'dns_doh' => 443,
'ldap_ldap' => 389,
'ldap_ldaps' => 636,
'ftp_ftp' => 21,
'ftp_scp' => 22,
'ftp_tftp' => 69,
'smb_smb' => 389,
'smb_smbs' => 636,
'mqtt_mqtt' => 1883,
'rest_basic' => 443,
'rest_apikey' => 443,
'rest_oauth2' => 443,
'rest_cookie' => 443,
'snmp_get' => 161,
'snmp_walk' => 161,
'ssh_command' => 22,
'ssh_sftp' => 22,
];
$credential_types = [
'userpass' => __('Username and password', 'servcheck'),
'basic' => __('Rest API - Basic HTTP auth', 'servcheck'),
'apikey' => __('Rest API - API key auth', 'servcheck'),
'oauth2' => __('Rest API - OAuth2/Bearer token auth', 'servcheck'),
'cookie' => __('Rest API - Cookie based auth', 'servcheck'),
'snmp' => __('SNMP v1 or v2', 'servcheck'),
'snmp3' => __('SNMP v3', 'servcheck'),
'sshkey' => __('SSH private key - Cacti 1.2.31+', 'servcheck'),
];
$graph_interval = [
1 => __('Last hour', 'servcheck'),
6 => __('Last 6 hours', 'servcheck'),
24 => __('Last day', 'servcheck'),
168 => __('Last week', 'servcheck'),
];
$text_result_search = [
'ok' => __('String found', 'servcheck'),
'not ok' => __('String not found', 'servcheck'),
'failed ok' => __('Failed string found', 'servcheck'),
'failed not ok' => __('Failed string not found', 'servcheck'),
'maint ok' => __('Maint string found', 'servcheck'),
'not yet' => __('Not tested yet', 'servcheck'),
'not tested' => __('Search not performed', 'servcheck')
];
$text_result = [
'ok' => __('OK', 'servcheck'),
'not yet' => __('Not tested yet', 'servcheck'),
'error' => __('Error/failed', 'servcheck'),
];
$snmp_security_levels = [
'noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'
];
$snmp_auth_protocols = [
'[None]' => __('[None]'),
'MD5' => __('MD5'),
'SHA' => __('SHA'),
'SHA224' => __('SHA-224'),
'SHA256' => __('SHA-256'),
'SHA392' => __('SHA-392'),
'SHA512' => __('SHA-512'),
];
$snmp_priv_protocols = [
'[None]' => __('[None]'),
'DES' => __('DES'),
'AES' => __('AES'),
'AES128' => __('AES-128'),
'AES192' => __('AES-192'),
'AES192C' => __('AES-192-C'),
'AES256' => __('AES-256'),
'AES256C' => __('AES-256-C')
];
$httperrors = [
0 => __('Unable to Connect', 'servcheck'),
100 => __('Continue', 'servcheck'),
101 => __('Switching Protocols', 'servcheck'),
200 => __('OK', 'servcheck'),
201 => __('Created', 'servcheck'),
202 => __('Accepted', 'servcheck'),
203 => __('Non-Authoritative Information', 'servcheck'),
204 => __('No Content', 'servcheck'),
205 => __('Reset Content', 'servcheck'),
206 => __('Partial Content', 'servcheck'),
300 => __('Multiple Choices', 'servcheck'),
301 => __('Moved Permanently', 'servcheck'),
302 => __('Found', 'servcheck'),
303 => __('See Other', 'servcheck'),
304 => __('Not Modified', 'servcheck'),
305 => __('Use Proxy', 'servcheck'),
306 => __('(Unused)', 'servcheck'),
307 => __('Temporary Redirect', 'servcheck'),
400 => __('Bad Request', 'servcheck'),
401 => __('Unauthorized', 'servcheck'),
402 => __('Payment Required', 'servcheck'),
403 => __('Forbidden', 'servcheck'),
404 => __('Not Found', 'servcheck'),
405 => __('Method Not Allowed', 'servcheck'),
406 => __('Not Acceptable', 'servcheck'),
407 => __('Proxy Authentication Required', 'servcheck'),
408 => __('Request Timeout', 'servcheck'),
409 => __('Conflict', 'servcheck'),
410 => __('Gone', 'servcheck'),
411 => __('Length Required', 'servcheck'),
412 => __('Precondition Failed', 'servcheck'),
413 => __('Request Entity Too Large', 'servcheck'),
414 => __('Request-URI Too Long', 'servcheck'),
415 => __('Unsupported Media Type', 'servcheck'),
416 => __('Requested Range Not Satisfiable', 'servcheck'),
417 => __('Expectation Failed', 'servcheck'),
500 => __('Internal Server Error', 'servcheck'),
501 => __('Not Implemented', 'servcheck'),
502 => __('Bad Gateway', 'servcheck'),
503 => __('Service Unavailable', 'servcheck'),
504 => __('Gateway Timeout', 'servcheck'),
505 => __('HTTP Version Not Supported', 'servcheck')
];
$servcheck_cycles = [
1 => __('%d Poller run', 1, 'servcheck'),
2 => __('%d Poller runs', 2, 'servcheck'),
3 => __('%d Poller runs', 3, 'servcheck'),
4 => __('%d Poller runs', 4, 'servcheck'),
5 => __('%d Poller runs', 5, 'servcheck'),
6 => __('%d Poller runs', 6, 'servcheck'),
7 => __('%d Poller runs', 7, 'servcheck'),
8 => __('%d Poller runs', 8, 'servcheck'),
9 => __('%d Poller runs', 9, 'servcheck'),
10 => __('%d Poller runs', 10, 'servcheck'),
];
$servcheck_seconds = [
3 => __('%d Seconds', 3, 'servcheck'),
4 => __('%d Seconds', 4, 'servcheck'),
5 => __('%d Seconds', 5, 'servcheck'),
6 => __('%d Seconds', 6, 'servcheck'),
7 => __('%d Seconds', 7, 'servcheck'),
8 => __('%d Seconds', 8, 'servcheck'),
9 => __('%d Seconds', 9, 'servcheck'),
10 => __('%d Seconds', 10, 'servcheck'),
];
$rest_api_apikey_option = [
'http' => __('Auth in HTTP headers', 'servcheck'),
'custom' => __('Custom HTTP header', 'servcheck'),
'post' => __('POST method, form-urlencoded', 'servcheck'),
'post_json' => __('POST method, JSON encoded', 'servcheck'),
];
$rest_api_cookie_option = [
'json' => __('JSON encoded', 'servcheck'),
'x-www-form-urlencoded' => __('Form urlencoded', 'servcheck'),
];
$servcheck_notify_formats = [
'html' => 'html',
'plain' => 'plain',
];
$accounts = db_fetch_assoc("SELECT id, username, email_address
FROM user_auth
WHERE email_address != ''");
if (!empty($accounts)) {
foreach ($accounts as $account) {
$servcheck_notify_accounts[$account['id']] = $account['username'] . ' - ' . $account['email_address'];
}
} else {
$servcheck_notify_accounts = [];
}
$servcheck_ca_fields = [
'name' => [
'method' => 'textbox',
'friendly_name' => __('Name'),
'description' => __('A Useful Name for this CA chain.'),
'value' => '|arg1:name|',
'max_length' => '100',
'size' => '100',
'default' => __('New CA')
],
'cert' => [
'friendly_name' => __('CA Chain', 'servcheck'),
'method' => 'textarea',
'textarea_rows' => 10,
'textarea_cols' => 100,
'description' => __('CA and intermediate certs, PEM encoded', 'servcheck'),
'value' => '|arg1:cert|'
],
'id' => [
'method' => 'hidden_zero',
'value' => '|arg1:id|'
]
];
$servcheck_proxy_fields = [
'name' => [
'method' => 'textbox',
'friendly_name' => __('Name'),
'description' => __('A Useful Name for this Proxy.'),
'value' => '|arg1:name|',
'max_length' => '40',
'size' => '40',
'default' => __('New Proxy')
],
'hostname' => [
'method' => 'textbox',
'friendly_name' => __('Hostname'),
'description' => __('The Proxy Hostname.'),
'value' => '|arg1:hostname|',
'max_length' => '64',
'size' => '40',
'default' => ''
],
'http_port' => [
'method' => 'textbox',
'friendly_name' => __('HTTP Port'),
'description' => __('The HTTP Proxy Port.'),
'value' => '|arg1:http_port|',
'max_length' => '5',
'size' => '5',
'default' => '80'
],
'https_port' => [
'method' => 'textbox',
'friendly_name' => __('HTTPS Port'),
'description' => __('The HTTPS Proxy Port.'),
'value' => '|arg1:https_port|',
'max_length' => '5',
'size' => '5',
'default' => '443'
],
'cred_id' => [
'friendly_name' => __('Credential', 'servcheck'),
'method' => 'drop_sql',
'default' => 0,
'description' => __('Select correct credential or left empty.', 'servcheck'),
'value' => '|arg1:cred_id|',
'sql' => "SELECT id, name FROM plugin_servcheck_credential WHERE type = 'userpass' ORDER BY name",
'none_value' => __('None', 'servcheck'),
],
'id' => [
'method' => 'hidden_zero',
'value' => '|arg1:id|'
]
];
$servcheck_test_fields = [
'general_spacer' => [
'method' => 'spacer',
'friendly_name' => __('General Settings', 'servcheck')
],
'name' => [
'method' => 'textbox',
'friendly_name' => __('Service Check Name', 'servcheck'),
'description' => __('The name that is displayed for this Service Check, and is included in any Alert notifications.', 'servcheck'),
'value' => '|arg1:name|',
'max_length' => '256',
],
'attempt' => [
'friendly_name' => __('How many attempts', 'servcheck'),
'method' => 'textbox',
'description' => __('Cacti attempts to run each test multiple times. The first successful attempt ends the testing and records the success. If none of the attempts are successful, the test is terminated and a failure is recorded. High number causes log test duration.', 'servcheck'),
'default' => '3',
'size' => '20',
'max_length' => '1',
'value' => '|arg1:attempt|',
],
'enabled' => [
'method' => 'checkbox',
'friendly_name' => __('Enable test', 'servcheck'),
'description' => __('Uncheck this box to disable this test from being checked.', 'servcheck'),
'value' => '|arg1:enabled|',
'default' => 'on',
],
'run_script' => [
'method' => 'checkbox',
'friendly_name' => __('Enable run script for this test', 'servcheck'),
'description' => __('If the global Command Execution function is enabled, you can set here whether the script should be run for this test or not.', 'servcheck'),
'value' => '|arg1:run_script|',
'default' => 'on',
],
'poller_id' => [
'friendly_name' => __('Poller', 'servcheck'),
'method' => 'drop_sql',
'default' => 1,
'description' => __('Poller on which the test will run', 'servcheck'),
'value' => '|arg1:poller_id|',
'sql' => 'SELECT id, name FROM poller ORDER BY id',
],
'type' => [
'friendly_name' => __('Type of service', 'servcheck'),
'method' => 'drop_array',
'on_change' => 'setTest()',
'array' => $service_types,
'default' => 'web_http',
'description' => __('What type of service?', 'servcheck'),
'value' => '|arg1:type|',
],
'hostname' => [
'method' => 'textbox',
'friendly_name' => __('IP Address or DNS name of server', 'servcheck'),
'description' => __('You can specify another port (example.com:5000) otherwise default will be used. For DOH (DNS over HTTPS) use here name of server (example 10.10.10.10, cloudflare-dns.com, ..)', 'servcheck'),
'value' => '|arg1:hostname|',
'max_length' => '100',
'size' => '30'
],
'ipaddress' => [
'method' => 'textbox',
'friendly_name' => __('Resolve DNS to Address'),
'description' => __('Enter an IP Address to force DNS name to resolve to. Leaving blank will use DNS Resolution instead.'),
'value' => '|arg1:ipaddress|',
'max_length' => '46',
'size' => '40',
'default' => ''
],
'service_spacer' => [
'method' => 'spacer',
'friendly_name' => __('Service settings', 'servcheck')
],
'cred_id' => [
'friendly_name' => __('Credential', 'servcheck'),
'method' => 'drop_sql',
'default' => 0,
'description' => __('Select correct credential', 'servcheck'),
'value' => '|arg1:cred_id|',
'sql' => 'SELECT id, name FROM plugin_servcheck_credential ORDER BY name',
'none_value' => __('None', 'servcheck'),
],
'snmp_oid' => [
'friendly_name' => __('SNMP OID', 'servcheck'),
'method' => 'textbox',
'description' => __('Insert SNMP OID', 'servcheck'),
'value' => '|arg1:snmp_oid|',
'max_length' => '255',
'size' => '50'
],
'ssh_command' => [
'friendly_name' => __('SSH command', 'servcheck'),
'method' => 'textbox',
'description' => __('Insert SSH command with full path, result of command will be returned', 'servcheck'),
'value' => '|arg1:ssh_command|',
'max_length' => '255',
'size' => '50'
],
'ca_id' => [
'friendly_name' => __('CA Chain', 'servcheck'),
'method' => 'drop_sql',
'none_value' => __('None', 'servcheck'),
'default' => '0',
'description' => __('Your own CA and intermediate certs', 'servcheck'),
'value' => '|arg1:ca_id|',
'sql' => 'SELECT id, name FROM plugin_servcheck_ca ORDER by name'
],
'ldapsearch' => [
'friendly_name' => __('LDAP Search', 'servcheck'),
'method' => 'textbox',
'description' => __('LDAP search filter, it could be ,OU=anygroup,DC=example,DC=com', 'servcheck'),
'value' => '|arg1:ldapsearch|',
'max_length' => '200',
'size' => '50'
],
'dns_query' => [
'method' => 'textbox',
'friendly_name' => __('DNS Name for Query', 'servcheck'),
'description' => __('DNS name for querying. For DOH (DNS over HTTPS) use /resolve?name=example.com or /dns-query?name=example.com&type=A. For plaintext DNS A and AAAA records will be returned', 'servcheck'),
'value' => '|arg1:dns_query|',
'max_length' => '40',
'size' => '30'
],
'path' => [
'method' => 'textbox',
'friendly_name' => __('Path Part of URL', 'servcheck'),
'description' => __('For web service insert at least "/" or something like "/any/path/".', 'servcheck'),
'value' => '|arg1:path|',
'max_length' => '140',
'size' => '30'
],
'requiresauth' => [
'method' => 'checkbox',
'friendly_name' => __('Requires Authentication', 'servcheck'),
'description' => __('Check this box if the site will normally return a 401 Error as it requires a username and password.', 'servcheck'),
'value' => '|arg1:requiresauth|',
'default' => '',
],
'proxy_id' => [
'method' => 'drop_sql',
'friendly_name' => __('Proxy Server', 'servcheck'),
'description' => __('If this connection text requires a proxy, select it here. Otherwise choose \'None\'.', 'servcheck'),
'value' => '|arg1:proxy_id|',
'none_value' => __('None', 'servcheck'),
'default' => '0',
'sql' => 'SELECT id, name FROM plugin_servcheck_proxy ORDER by name'
],
'checkcert' => [
'method' => 'checkbox',
'friendly_name' => __('Check Certificate', 'servcheck'),
'description' => __('If using SSL, check this box if you want to validate the certificate. Default on, turn off if you the site uses a self-signed certificate.', 'servcheck'),
'value' => '|arg1:checkcert|',
'default' => '',
],
'certexpirenotify' => [
'method' => 'checkbox',
'friendly_name' => __('Check and notify Certificate expiration', 'servcheck'),
'description' => __('If using SSL, check this box if you want to check the certificate expiration. You can set in settings how many days before expiration notify..', 'servcheck'),
'value' => '|arg1:certexpirenotify|',
'default' => '',
],
'timings_spacer' => [
'method' => 'spacer',
'friendly_name' => __('Parameters', 'servcheck')
],
'how_often' => [
'friendly_name' => __('How Often to Test', 'servcheck'),
'method' => 'drop_array',
'array' => $servcheck_cycles,
'default' => 1,
'description' => __('Test every xth poller run', 'servcheck'),
'value' => '|arg1:how_often|',
],
'downtrigger' => [
'friendly_name' => __('Trigger', 'servcheck'),
'method' => 'textbox',
'default' => 1,
'max_length' => '2',
'size' => '30',
'description' => __('How many times the service must be DOWN before an alert email is triggered.', 'servcheck'),
'value' => '|arg1:downtrigger|',
],
'duration_trigger' => [
'friendly_name' => __('Long duration alert', 'servcheck'),
'method' => 'textbox',
'default' => 0,
'max_length' => '5',
'size' => '30',
'description' => __('If the test time is greater than this value more times in a row, send a notification. Related to variable Duration count. The test inherits the maximum runtime from the settings. If a higher value is set here, the maximum runtime is this value + 2 seconds.', 'servcheck'),
'value' => '|arg1:duration_trigger|',
],
'duration_count' => [
'friendly_name' => __('Number of duration violations in a row', 'servcheck'),
'method' => 'textbox',
'default' => 3,
'max_length' => '2',
'size' => '30',
'description' => __('How many times the duration trigger must be exceeded in a row for a notification to be sent', 'servcheck'),
'value' => '|arg1:duration_count|',
],
'verifications_spacer' => [
'method' => 'spacer',
'friendly_name' => __('Verification Strings', 'servcheck')
],
'search' => [
'method' => 'textarea',
'friendly_name' => __('Response Search String', 'servcheck'),
'description' => __('This is the string to search for in the response for a live and working service.', 'servcheck'),
'value' => '|arg1:search|',
'textarea_rows' => '3',
'textarea_cols' => '80',
],
'search_maint' => [
'method' => 'textarea',
'friendly_name' => __('Response Search String - Maintenance', 'servcheck'),
'description' => __('This is the string to search for on the Maintenance . The Service Check will check for this string if the above string is not found. If found, it means that the service is under maintenance.', 'servcheck'),
'value' => '|arg1:search_maint|',
'textarea_rows' => '3',
'textarea_cols' => '80',
],
'search_failed' => [
'method' => 'textarea',
'friendly_name' => __('Response Search String - Failed', 'servcheck'),
'description' => __('This is the string to search for a known failure in the service response. The Service Check will only alert if this string is found, ignoring any timeout issues and the search strings above.', 'servcheck'),
'value' => '|arg1:search_failed|',
'textarea_rows' => '3',
'textarea_cols' => '80',
],
'notification_spacer' => [
'method' => 'spacer',
'friendly_name' => __('Notification Settings', 'servcheck')
],
'notify' => [
'method' => 'checkbox',
'friendly_name' => __('Email notification', 'servcheck'),
'description' => __('If enabled email notification about state, duration and search result will be send', 'servcheck'),
'value' => '|arg1:notify|',
'default' => 'on',
],
'notify_format' => [
'friendly_name' => __('Notify Format', 'servcheck'),
'method' => 'drop_array',
'description' => __('This is the format to use when sending the notification email', 'servcheck'),
'array' => $servcheck_notify_formats,
'value' => '|arg1:notify_format|',
],
'notify_list' => [
'friendly_name' => __('Notification List', 'servcheck'),
'method' => 'drop_sql',
'description' => __('Use this Notification List for those to be notified when this service goes down.', 'servcheck'),
'sql' => 'SELECT id, name FROM plugin_notification_lists ORDER BY name',
'value' => '|arg1:notify_list|',
'none_value' => __('None', 'servcheck')
],
'notify_accounts' => [
'friendly_name' => __('Notify Accounts', 'servcheck'),
'method' => 'drop_multi',
'description' => __('This is a listing of accounts that will be notified when this service goes down.', 'servcheck'),
'array' => $servcheck_notify_accounts,
'value' => '|arg1:notify_accounts|',
],
'notify_extra' => [
'friendly_name' => __('Extra Alert Emails', 'servcheck'),
'method' => 'textarea',
'textarea_rows' => 3,
'textarea_cols' => 50,
'description' => __('You may specify here extra Emails to receive alerts for this test (comma separated)', 'servcheck'),
'value' => '|arg1:notify_extra|',
],
'notes' => [
'friendly_name' => __('Notes', 'servcheck'),
'method' => 'textarea',
'textarea_rows' => 3,
'textarea_cols' => 50,
'description' => __('Notes sent in email', 'servcheck'),
'value' => '|arg1:notes|',
],
'external_id' => [
'friendly_name' => __('External ID', 'servcheck'),
'method' => 'textbox',
'description' => __('Enter an External ID for this test.', 'servcheck'),
'default' => '',
'size' => '20',
'max_length' => '20',
'value' => '|arg1:external_id|',
],
'id' => [
'method' => 'hidden_zero',
'value' => '|arg1:id|'
],
'help_spacer' => [
'method' => 'spacer',
'friendly_name' => __('Help', 'servcheck')
],
];
$servcheck_credential_fields = [
'general_spacer' => [
'method' => 'spacer',
'friendly_name' => __('General Settings', 'servcheck')
],
'name' => [
'method' => 'textbox',
'friendly_name' => __('Credential Name', 'servcheck'),
'description' => __('The name that is displayed for this Credential.', 'servcheck'),
'value' => '|arg1:name|',
'max_length' => '100',
],
'type' => [
'friendly_name' => __('Credential type', 'servcheck'),
'method' => 'drop_array',
'on_change' => 'setCredential()',
'array' => $credential_types,
'default' => 'userpass',
'description' => __('Select correct Credential type.', 'servcheck'),
'value' => '|arg1:type|',
],
'option_apikey' => [
'friendly_name' => __('Options', 'servcheck'),
'method' => 'drop_array',
'array' => $rest_api_apikey_option,
'default' => 'http',
'description' => __('Set according to your REST API server', 'servcheck'),
'value' => '|arg1:option_apikey|',
],
'option_cookie' => [
'friendly_name' => __('Options', 'servcheck'),
'method' => 'drop_array',
'array' => $rest_api_cookie_option,
'default' => 'http',
'description' => __('Set according to your REST API server', 'servcheck'),
'value' => '|arg1:option_cookie|',
],
'username' => [
'friendly_name' => __('Username', 'servcheck'),
'method' => 'textbox',
'description' => __('Username', 'servcheck'),
'value' => '|arg1:username|',
'max_length' => '100',
'size' => '30'
],
'password' => [
'friendly_name' => __('Password', 'servcheck'),
'method' => 'textbox',
'description' => __('For anonymous FTP insert email address', 'servcheck'),
'value' => '|arg1:password|',
'max_length' => '100',
'size' => '30'
],
'token_name' => [
'method' => 'textbox',
'friendly_name' => __('Token/API Key name', 'servcheck'),
'description' => __('Auth can use different token or API Key name. You can specify it here. You need know correct name, check your Rest API server documentation.<br/>
<i>OAuth2 -</i> Commonly used name is \'Bearer\'<br/>
<i>API Key -</i> commonly used name is \'apikey\'<br/> ', 'servcheck'),
'value' => '|arg1:token_name|',
'max_length' => '100',
],
'token_value' => [
'method' => 'textbox',
'friendly_name' => __('Token/API key value', 'servcheck'),
'description' => __('API key and OAuth2 have two flows - You can have key/token from server and insert it here or use auth flow with credentials.', 'servcheck'),
'value' => '|arg1:token_value|',
'max_length' => '200',
],
'login_url' => [
'method' => 'textbox',
'friendly_name' => __('Login URL', 'servcheck'),
'description' => __('URL which is used to log in or get the token.', 'servcheck'),
'value' => '|arg1:login_url|',
'max_length' => '200',
],
'data_url' => [
'method' => 'textbox',
'friendly_name' => __('Data URL', 'servcheck'),
'description' => __('URL to retrieve data. Insert with http:// or https://', 'servcheck'),
'value' => '|arg1:data_url|',
'max_length' => '200',
],
'community' => [
'friendly_name' => __('SNMP v1 or v2 community', 'servcheck'),
'method' => 'textbox',
'description' => __('SNMP community string for SNMP v1 or v2(c)', 'servcheck'),
'value' => '|arg1:community|',
'max_length' => '30',
'size' => '30'
],
'snmp_security_level' => [
'method' => 'drop_array',
'friendly_name' => __('SNMP Security Level'),
'description' => __('SNMP v3 Security Level to use when querying the device.'),
'on_change' => 'setCredential()',
'value' => '|arg1:snmp_security_level|',
'default' => read_config_option('snmp_security_level'),
'array' => $snmp_security_levels
],
'snmp_auth_protocol' => [
'method' => 'drop_array',
'friendly_name' => __('SNMP Auth Protocol (v3)'),
'description' => __('Choose the SNMPv3 Authorization Protocol.'),
'value' => '|arg1:snmp_auth_protocol|',
'default' => read_config_option('snmp_auth_protocol'),
'array' => $snmp_auth_protocols,
],
'snmp_username' => [
'method' => 'textbox',
'friendly_name' => __('SNMP Username (v3)'),
'description' => __('SNMP v3 username for this device.'),
'value' => '|arg1:snmp_username|',
'default' => read_config_option('snmp_username'),
'max_length' => '50',
'size' => '40'
],
'snmp_password' => [
'method' => 'textbox_password',
'friendly_name' => __('SNMP Password (v3)'),
'description' => __('SNMP v3 password for this device.'),
'value' => '|arg1:snmp_password|',
'default' => read_config_option('snmp_password'),
'max_length' => '50',
'size' => '40'
],
'snmp_priv_protocol' => [
'method' => 'drop_array',
'friendly_name' => __('SNMP Privacy Protocol (v3)'),
'description' => __('Choose the SNMPv3 Privacy Protocol.'),
'value' => '|arg1:snmp_priv_protocol|',
'default' => read_config_option('snmp_priv_protocol'),
'array' => $snmp_priv_protocols,
],
'snmp_priv_passphrase' => [
'method' => 'textbox_password',
'friendly_name' => __('SNMP Privacy Passphrase (v3)'),
'description' => __('Choose the SNMPv3 Privacy Passphrase.'),
'value' => '|arg1:snmp_priv_passphrase|',
'default' => read_config_option('snmp_priv_passphrase'),
'max_length' => '200',
'size' => '80'
],
'snmp_context' => [
'method' => 'textbox',
'friendly_name' => __('SNMP Context (v3)'),
'description' => __('Enter the SNMP Context to use for this device.'),
'value' => '|arg1:snmp_context|',
'default' => '',
'max_length' => '64',
'size' => '40'
],
'snmp_engine_id' => [
'method' => 'textbox',
'friendly_name' => __('SNMP Engine ID (v3)'),
'description' => __('Enter the SNMP v3 Engine Id or empty.'),
'value' => '|arg1:snmp_engine_id|',
'default' => '',
'max_length' => '64',
'size' => '40'
],
'ssh_username' => [
'friendly_name' => __('SSH user', 'servcheck'),
'method' => 'textbox',
'description' => __('Insert username here', 'servcheck'),
'value' => '|arg1:ssh_username|',
'max_length' => '40',
'size' => '20'
],
'sshkey' => [
'friendly_name' => __('SSH private key', 'servcheck'),
'method' => 'textarea',
'textarea_rows' => 10,
'textarea_cols' => 100,
'description' => __('SSH private key ', 'servcheck'),
'value' => '|arg1:sshkey|'
],
'sshkey_passphrase' => [
'friendly_name' => __('SSH private key passphrase', 'servcheck'),
'method' => 'textbox',
'description' => __('If your key is password protected, insert password here', 'servcheck'),
'value' => '|arg1:sshkey_passphrase|',
'max_length' => '60',
'size' => '30'
],
'oauth_client_id' => [
'friendly_name' => __('Client ID', 'servcheck'),
'method' => 'textbox',
'description' => __('Oauth Client ID', 'servcheck'),
'value' => '|arg1:oauth_client_id|',
'max_length' => '100',
'size' => '30'
],
'oauth_client_secret' => [
'friendly_name' => __('Client secret', 'servcheck'),
'method' => 'textbox',
'description' => __('OAuth Client secret', 'servcheck'),
'value' => '|arg1:oauth_client_secret|',
'max_length' => '100',
'size' => '30'
],
'token_name' => [
'friendly_name' => __('Token name', 'servcheck'),
'method' => 'textbox',
'description' => __('Token name', 'servcheck'),
'value' => '|arg1:token_name|',
'max_length' => '100',
'size' => '30'
],
'token_value' => [
'friendly_name' => __('Token value', 'servcheck'),
'method' => 'textbox',
'description' => __('Token value', 'servcheck'),
'value' => '|arg1:token_value|',
'max_length' => '100',
'size' => '30'
],
'id' => [
'method' => 'hidden_zero',
'value' => '|arg1:id|'
],
'help_spacer' => [
'method' => 'spacer',
'friendly_name' => __('Help', 'servcheck')
],
];
$servcheck_help_credential = [
'userpass' => __('<b>Can be used for a lot of service checks:</b><br/>\
<i>Http/https</i> - optional, when it is set, try HTTP basic auth<br/>\
<i>SMTP on port 587 - optional. Without a username/password, only the server response is tested. With a username and password, login is also performed<br/>\
<i>Imap, imaps, pop3, pop3s, ftp</i> - optional. For anonymous ftp, use username \"anonymous\" and email address as password<br/>\
<i>LDAP, smb, smbs</i> - required<br/>\
<i>MQTT</i> - optional<br/>\
<i>SCP, SSH command</i> - you can use this method or private key method', 'servcheck'),
'basic' => __('Rest API - Basic HTTP auth. Username and password are required', 'servcheck'),
'apikey' => __('Rest API - API key auth<br/>Auth is send in HTTP header, custom header or POST method. Credentials in URL is not supported.<br/>Insert API key name and value. Both values are required.\
For HTTP header the name <i>Bearer or apikey or \"\"</i> is usually used (Authorization: Bearer apivalue).\
For custom header <i>X-API-Key</i> is usually used (X-Api-Key: keyvalue).\
For POST <i>api_key</i> is usually used.', 'servcheck'),
'oauth2' => __('Rest API - OAuth2/Bearer token auth<br/>You can have key/token from server and insert it here or use auth flow with credentials. Username and password are send Json encoded.', 'servcheck'),
'cookie' => __('Rest API - Cookie based auth - both values are required. After login, cookie is returned', 'servcheck'),
'snmp' => __('SNMP v1 or v2 - required, insert community name here', 'servcheck'),
'snmp3' => __('SNMP v3 - The security level determines which parameters are required', 'servcheck'),
'sshkey' => __('SSH private key - Can be used for SCP or SSH command test. These test can use username/password too', 'servcheck'),
];
$servcheck_help_test = [
'web_http' => __('It only checks whether the web server is responding. If username/password credential is used, it will try Basic HTTP auth.', 'servcheck'),
'web_https' => __('The same as HTTP plaintext but adds the ability to test certificates.', 'servcheck'),
'mail_smtp' => __('It only checks whether the SMTP server is responding. No authentication. You will see server login banner and ehlo response.', 'servcheck'),
'mail_smtptls' => __('Unencrypted + STARTTL. It is also possible to test the validity of the certificate. Without username and password, \
you will see server login banner and ehlo response. With credential, login will be performed', 'servcheck'),
'mail_smtps' => __('Encrypted connection on default port 465. It is also possible to test the validity of the certificate. With username and password\
AUTH LOGIN will be tested.', 'servcheck'),
'mail_imap' => __('Unencrypted IMAP connection. Without credential, only connection will be tested. You will see only login banner. \
With credential login will be tested and try to read list of messages. You can use AUTHENTICATE PLAIN or AUTHENTICATE LOGIN method.', 'servcheck'),
'mail_imaptls' => __('The same as unencrypted IMAP but after login STARTTLS is used. It is also possible to test the validity of the certificate after STARTLS.', 'servcheck'),
'mail_imaps' => __('Encrypted IMAP, you can try login and test certificate and user login', 'servcheck'),
'mail_pop3' => __('Unencrypted POP3 connection. Without credential, only connection will be tested. You will see only login banner. \
With credential login will be tested and try to read list of messages', 'servcheck'),
'mail_pop3tls' => __('The same as unencrypted POP3 but after login STARTTLS is used. It is also possible to test the validity of the certificate after STARTLS.', 'servcheck'),
'mail_pop3s' => __('Encrypted POP3, you can try login and test certificate and user login.', 'servcheck'),
'dns_dns' => __('Try to resolve DNS record on specified DNS server', 'servcheck'),
'dns_doh' => __('Try DNS over HTTPS.', 'servcheck'),
'ldap_ldap' => __('All parameters are required. Perform unencrypted LDAP login and search', 'servcheck'),
'ldap_ldaps' => __('All parameters are required. Perform encrypted LDAP login and search', 'servcheck'),
'ftp_ftp' => __('Unencrypted FTP connection, login and try to download file specified in path (/path/to/file.txt). For anonymous connection use login *anonymous* and email address as password. The content \
of the file is returned.', 'servcheck'),
'ftp_tftp' => __('Try to download file specified in path (/path/to/file.txt) from TFTP server. The content of the file is returned.', 'servcheck'),
'ftp_scp' => __('Encrypted SCP connection, login and try to download file specified in path (/path/to/file.txt).', 'servcheck'),
'smb_smb' => __('Try SMB protocol, username and password are required. Try to login and download file.', 'servcheck'),
'smb_smbs' => __('Try SMB protocol, username and password are required. Try to login and download file.', 'servcheck'),
'mqtt_mqtt' => __('Connetct to MQTT server and listen for any message. You can specify topic in Path (bedroom/temp), blank for any topic. For this test is recommended increase \"Long duration alert\"', 'servcheck'),
'rest_basic' => __('REST API test with basic HTTP auth. Prepare credential first.', 'servcheck'),
'rest_apikey' => __('REST API test with API key auth. Prepare credential first.', 'servcheck'),
'rest_oauth2' => __('REST API test with Oauth2. Prepare credential first.', 'servcheck'),
'rest_cookie' => __('REST API test with cookie auth. Prepare credential first.', 'servcheck'),
'snmp_get' => __('Try SNMP get method. Output for specified OID is returned. Credential is required, you have to prepare SNMP v.1,2 or v3 credential first.', 'servcheck'),
'snmp_walk' => __('Try SNMP walk method. Output for specified OID is returned. Credential is required, you have to prepare SNMP v.1,2 or v3 credential first.', 'servcheck'),
'ssh_command' => __('Use ssh and connect to remote host. After login run specified command and return output. Username and password or private key is possible.', 'srvcheck'),
'ssh_sftp' => __('SFTP protocol on port 22, username and password and path are required. Try to do directory listing of path.', 'servcheck'),
];
$curl_error = [
0 => [
'title' => 'CURLE_OK',
'description' => __('All fine. Proceed as usual.', 'servcheck')
],
1 => [
'title' => 'CURLE_UNSUPPORTED_PROTOCOL',
'description' => __('The URL you passed to libcurl used a protocol that this libcurl does not support. The support might be a compile-time option that you did not use, it can be a misspelled protocol string or just a protocol libcurl has no code for.', 'servcheck')
],
2 => [
'title' => 'CURLE_FAILED_INIT',
'description' => __('Early initialization code failed. This is likely to be an internal error or problem, or a resource problem where something fundamental could not get done at init time.', 'servcheck')
],
3 => [
'title' => 'CURLE_URL_MALFORMAT',
'description' => __('The URL was not properly formatted.', 'servcheck')
],
4 => [
'title' => 'CURLE_NOT_BUILT_IN',
'description' => __('A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. This means that a feature or option was not enabled or explicitly disabled when libcurl was built and in order to get it to function you have to get a rebuilt libcurl.', 'servcheck')
],
5 => [
'title' => 'CURLE_COULDNT_RESOLVE_PROXY',
'description' => __('Could not resolve proxy. The given proxy host could not be resolved.', 'servcheck')
],
6 => [
'title' => 'CURLE_COULDNT_RESOLVE_HOST',
'description' => __('Could not resolve host. The given remote host was not resolved.', 'servcheck')
],
7 => [
'title' => 'CURLE_COULDNT_CONNECT',
'description' => __('Failed to connect() to host or proxy.', 'servcheck')
],
8 => [
'title' => 'CURLE_WEIRD_SERVER_REPLY',
'description' => __('The server sent data libcurl could not parse. This error code was known as CURLE_FTP_WEIRD_SERVER_REPLY before 7.51.0.', 'servcheck')
],
9 => [
'title' => 'CURLE_REMOTE_ACCESS_DENIED',
'description' => __('We were denied access to the resource given in the URL. For FTP, this occurs while trying to change to the remote directory.', 'servcheck')
],
10 => [
'title' => 'CURLE_FTP_ACCEPT_FAILED',
'description' => __('While waiting for the server to connect back when an active FTP session is used, an error code was sent over the control connection or similar.', 'servcheck')
],
11 => [
'title' => 'CURLE_FTP_WEIRD_PASS_REPLY',
'description' => __('After having sent the FTP password to the server, libcurl expects a proper reply. This error code indicates that an unexpected code was returned.', 'servcheck')
],
12 => [
'title' => 'CURLE_FTP_ACCEPT_TIMEOUT',
'description' => __('During an active FTP session while waiting for the server to connect, the CURLOPT_ACCEPTTIMEOUT_MS (or the internal default) timeout expired.', 'servcheck')
],
13 => [
'title' => 'CURLE_FTP_WEIRD_PASV_REPLY',
'description' => __('Libcurl failed to get a sensible result back from the server as a response to either a PASV or a EPSV command. The server is flawed.', 'servcheck')
],
14 => [
'title' => 'CURLE_FTP_WEIRD_227_FORMAT',
'description' => __('FTP servers return a 227-line as a response to a PASV command. If libcurl fails to parse that line, this return code is passed back.', 'servcheck')
],
15 => [
'title' => 'CURLE_FTP_CANT_GET_HOST',
'description' => __('An internal failure to lookup the host used for the new connection.', 'servcheck')
],
16 => [
'title' => 'CURLE_HTTP2',
'description' => __('A problem was detected in the HTTP2 framing layer. This is somewhat generic and can be one out of several problems, see the error buffer for details.', 'servcheck')
],