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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
|
.\" $Id: mon.8 1.11 Sat, 18 Aug 2001 15:37:53 -0400 trockij $
.TH mon 8 "$Date: Sat, 18 Aug 2001 15:37:53 -0400 $" Linux "Parallel Service Monitoring Daemon"
.SH NAME
mon \- monitor services for availability, sending alarms upon failures.
.SH SYNOPSIS
.B mon
.RB [ \-dfhlMSv ]
.RB [ \-a
.IR dir ]
.RB [ \-A
.IR authfile ]
.RB [ \-b
.IR dir ]
.RB [ \-B
.IR dir ]
.RB [ \-c
.IR config ]
.RB [ \-D
.IR dir ]
.RB [ \-i
.IR secs ]
.RB [ \-k
.IR num ]
.RB [ \-l
.IR dir ]
.RB [ \-m
.IR num ]
.RB [ \-p
.IR num ]
.RB [ \-P
.IR pidfile ]
.RB [ \-r
.IR delay ]
.RB [ \-s
.IR dir ]
.SH DESCRIPTION
.B mon
is a general-purpose scheduler for monitoring service availability
and triggering alerts upon detecting failures.
.B mon
was designed to be open in the sense that it supports arbitrary
monitoring facilities and alert methods via a common interface, which
are easily implemented through programs (in C, Perl, shell, etc.),
SNMP traps, and special Mon (UDP packet) traps.
.SH OPTIONS
.TP
.BI \-a\ dir
Path to alert scripts. Default is
.IR /usr/local/lib/mon/alert.d:alert.d .
Multiple alert paths may be specified by separating them with
a colon. Non-absolute paths are taken to be relative to the
base directory
.RI ( /usr/lib/mon
by default).
.TP
.BI \-b\ dir
Base directory for mon. scriptdir, alertdir, and statedir
are all relative to this directory unless specified from /.
Default is
.IR /usr/lib/mon .
.TP
.BI \-B\ dir
Configuration file base directory. All config files are located here, including
mon.cf, monusers.cf, and auth.cf.
.TP
.BI \-A\ authfile
Authentication configuration file. By default this is
.IR /etc/mon/auth.cf " if the " /etc/mon
directory exists, or
.I /usr/lib/mon/auth.cf
otherwise.
.TP
.BI \-c\ file
Read configuration from
.IR file .
This defaults to
.IR /etc/mon/mon.cf " if the " /etc/mon
directory exists, otherwise to
.IR /etc/mon.cf .
.TP
.BI \-d
Enable debugging mode.
.TP
.BI \-D\ dir
Path to state directory. Default is the first of
.IR /var/state/mon ", " /var/lib/mon ", and " /usr/lib/mon/state.d
which exists.
.TP
.BI \-f
Fork and run as a daemon process. This is the
preferred way to run
.BR mon .
.TP
.BI \-h
Print help information.
.TP
.BI \-i\ secs
Sleep interval, in seconds. Defaults to 1. This shouldn't need to
be adjusted for any reason.
.TP
.BI \-k\ num
Set log history to a maximum of
.I num
entries. Defaults
to 100.
.TP
.BI \-l
Load state from the last saved state file. Currently the only
supported saved state is disabled watches, services, and hosts.
.TP
.BI \-L\ dir
Sets the log dir. See also
.B logdir
in the configuration file. The default is
.B /var/log/mon
if that directory exists, otherwise
.BR log.d
in the base directory.
.TP
.B \-M
Pre-process the configuration file with the
macro expansion package
.IR m4 .
.\"
.\"
.\"
.TP
.BI \-m\ num
Set the throttle for the maximum number of processes to
.IR num .
.TP
.BI \-p\ num
Make server listen on port
.IR num .
This defaults to 2583.
.TP
.B \-S
Start with the scheduler stopped.
.TP
.BI \-P\ pidfile
Store the server's pid in
.IR pidfile ,
the default is the first of
.IR /var/run/mon/mon.pid ,
.IR /var/run/mon.pid ,
and
.IR /etc/mon.pid
whose directory exists. An empty value tells
.B mon
not to use a pid file.
.TP
.BI \-r\ delay
Sets the number of seconds used to randomize the startup delay
before each service is scheduled. Refer to the global
.I randstart
variable in the configuration file.
.TP
.BI \-s\ dir
Path to monitor scripts. Default is
.IR /usr/local/lib/mon/mon.d:mon.d .
Multiple alert paths may be specified by separating them with
a colon. Non-absolute paths are taken to be relative to the
base directory
.RI ( /usr/lib/mon
by default).
.TP
.BI \-v
Print version information.
.SH DEFINITIONS
.TP
.BI monitor
A program which tests for a certain condition, returns either true or
false, and optionally produces output to be passed back to the scheduler.
Common monitors detect host reachability via ICMP echo messages, or
connection to TCP services.
.TP
.BI period
A period in time as interpreted by the Time::Period module.
.TP
.BI alert
A program which sends a message when invoked by the scheduler.
The scheduler calls upon an alert when it detects a failure from
a monitor.
An alert program accepts a set of command-line arguments from the
scheduler, in addition to data via standard input.
.TP
.BI hostgroup
A single host or list of hosts, specified as names or IP addresses.
.TP
.BI service
A collection of parameters used to deal with monitoring a particular
resource which is provided by a group. Services are usually modeled after
things such as an SMTP server, ICMP echo capability, server disk space
availability, or SNMP events.
.TP
.BI watch
A collection of services which apply to a particular group.
.SH OPERATION
When the
.B mon
scheduler starts, it reads a configuration file to determine the
services it needs to monitor. The configuration file defaults to
.IR /etc/mon.cf ,
and can be specified using the
.BI \-c
parameter. If the
.B -M
option is specified, then the configuration file is pre-processed
with
.IR m4 .
If the configuration file ends with .m4, the file is also processed by
m4 automatically.
The scheduler enters a loop which handles client connections,
monitor invocations, and failure alerts. Each service has a timer,
specified in the configuration file as the
.BI interval
variable, which tells the scheduler how frequently to invoke a
monitor process.
The scheduler may be temporarily stopped. While it is stopped, client
access still functions, but it just doesn't schedule things. This
is useful in conjunction while resetting the server, because you can do this:
save the hosts and services which are disabled, reset the server
with the scheduler stopped, re-disabled those hosts and services,
then start the scheduler. It also allows making atomic changes
across several client connections.
See the
.B moncmd
man page for more information.
.SH MONITOR\ PROGRAMS
Monitor processes are invoked with the arguments specified in the
configuration file, appended by the hosts from the applicable
host group. For example, if the watch group is "servers", which contain
the hostnames "smtp", "nntp", and "ns", and the monitor line reads
as follows,
.br
\fC
monitor fping.monitor -t 4000 -r 2
\fR
.br
then the executable "fping.monitor" will be executed with these
parameters:
.br
\fC
MONITOR_DIR/fping.monitor -t 4000 -r 2 smtp nntp ns
\fR
.br
MONITOR_DIR is actually a search path, by default
.I /usr/local/lib/mon/mon.d
then
.IR /usr/lib/mon/mon.d ,
but it can be overridden by the
.BI \-s
option or in the configuration file.
If all hosts in the hostgroup have been disabled,
then a warning is sent to syslog and the monitor is
not run. This behavior may be overridden with the
"allow_empty_group" option in the service definition.
If the final argument to the "monitor" line is ";;"
(it must be preceded by whitespace),
then the host list will not be appended to the parameter list.
In addition to environment variables defined by
the user in the service definition,
.B mon
passes certain variables to monitor process.
.TP
.B MON_LAST_SUMMARY
The first line of the output from the last time the
monitor exited.
.TP
.B MON_LAST_OUTPUT
The entire output of the monitor from the last time it
exited.
.TP
.B MON_LAST_FAILURE
The time(2) of the last failure for this service.
.TP
.B MON_FIRST_FAILURE
The time(2) of the first time this service failed.
.TP
.B MON_LAST_SUCCESS
The time(2) of the last time this service passed.
.TP
.B MON_DESCRIPTION
The description of this service, as defined in the
configuration file using the
.I description
tag.
.TP
.B MON_DEPEND_STATUS
The depend status, "o" if dependency failure, "1" otherwise.
.TP
.B MON_LOGDIR
The directory log files should be placed,
as indicated by the
.I logdir
global configuration variable.
.TP
.B MON_STATEDIR
The directory where state files should be kept,
as indicated by the
.I statedir
global configuration variable.
.P
"fping.monitor" should return an exit status of 0 if it
completed successfully (found no problems), or nonzero if a problem
was detected. The first line of output from the monitor
script has a special meaning: it
is used as a brief summary of the exact failure which was detected, and
is passed to the alert program. All remaining output is also passed
to the alert program, but it has no required interpretation.
If a monitor for a particular service is still
running, and the time comes for
.B mon
to run another monitor for that service, it will not
start another monitor. For example, if the
.I interval
is 10s, and the monitor does not finish running
within 10 seconds, then
.B mon
will wait until the first monitor exits before
running another one.
.SH ALERT DECISION LOGIC
Upon a non-zero or zero exit status, the associated alert or upalert
program (respectively) is started,
pending the following conditions: If an alert for a specific
service is disabled, do not send an alert.
If
.B dep_behavior
is set to
.IR "'a'" ,
and a parent dependency is failing, then suppress the alert.
If the alert has previously been acknowledged, do not send
the alert, unless it is an upalert.
If an alert is not within the specified period, record the failure
via syslog(3) and do not send an alert.
If the failure does not fall within a defined period, do not
send an alert.
No upalerts are sent without corresponding down alerts,
unless
.B no_comp_alerts
is defined in the period section.
If an alert was already sent within the last
.B alertevery
interval, do not send another alert,
.I unless
the summary output from the current monitor program differs from the last
monitor process. Otherwise, send an alert using each alert program
listed for that period. The
.B "observe_detail"
argument to
.B alertevery
affects this behavior by observing the changes in the detail part
of the output in addition to the summary line.
If a monitor has successive failures and the
summary output changes in each of them,
.B alertevery
will not suppress multiple consecutive alerts.
The reasoning is that if the summary output changes, then
a significant event occurred and the user should be alerted.
.SH ALERT\ PROGRAMS
Alert programs are found in the path supplied with the
.BI \-a
parameter, or in the
.I /usr/local/lib/mon/alert.d
and
.I /usr/lib/mon/alert.d
directories if not specified. They are invoked with the following command-line
parameters:
.TP
.BI \-s\ service
Service tag from the configuration file.
.TP
.BI \-g\ group
Host group name from the configuration file.
.TP
.BI \-h\ hosts
The expanded version of the host group, space delimited, but contained
in one shell "word".
.TP
.BI \-l\ alertevery
The number of seconds until the next alarm will be sent.
.TP
.BI \-O
This option is supplied to an alert only if the
alert is being generated as a result of an expected traap timing out
.TP
.BI \-t\ time
The time (in
.BR time (2)
format) of when this failure condition
was detected.
.TP
.BI \-T
This option is supplied to an alert only if the alert was triggered by a trap
.TP
.B \-u
This option is supplied to an alert only if it is being
called as an upalert.
.P
The remaining arguments are supplied from the trailing parameters in
the configuration file, after the "alert" service parameter.
As with monitor programs, alert programs are invoked with environment
variables defined by the user in the service definition, in addition
to the following which are explicitly set by the server:
.TP
.B MON_LAST_SUMMARY
The first line of the output from the last time the
monitor exited.
.TP
.B MON_LAST_OUTPUT
The entire output of the monitor from the last time it
exited.
.TP
.B MON_LAST_FAILURE
The time(2) of the last failure for this service.
.TP
.B MON_FIRST_FAILURE
The time(2) of the first time this service failed.
.TP
.B MON_LAST_SUCCESS
The time(2) of the last time this service passed.
.TP
.B MON_DESCRIPTION
The description of this service, as defined in the
configuration file using the
.I description
tag.
.TP
.B MON_GROUP
The watch group which triggered this alarm
.TP
.B MON_SERVICE
The service heading which generated this alert
.TP
.B MON_RETVAL
The exit value of the failed monitor program, or return value
as accepted from a trap.
.TP
.B MON_OPSTATUS
The operational status of the service.
.TP
.B MON_ALERTTYPE
Has one of the following values: "failure", "up", "startup",
"trap", or "traptimeout", and signifies the type of alert which
was triggered.
.TP
.B MON_TRAP_INTENDED
This is only set when an unknown mon trap is received and caught
by the default/defaut watch/service. This contains colon
separated entries of the trap's intended watch group and service name.
.TP
.B MON_LOGDIR
The directory log files should be placed,
as indicated by the
.I logdir
global configuration variable.
.TP
.B MON_STATEDIR
The directory where state files should be kept,
as indicated by the
.I statedir
global configuration variable.
.P
The first line from standard input must be used as a brief summary
of the problem, normally supplied as the subject line of an email, or
text sent to an alphanumeric pager. Interpretation of all subsequent
lines read from stdin is left up to the alerting program. The usual
parameters are a list of recipients to deliver the notification to.
The interpretation of the recipients is not specified, and is up
to the alert program.
.SH CONFIGURATION FILE
The configuration file consists of zero or more hostgroup definitions,
and one or more watch definitions. Each watch definition may have one
or more service definitions. A line beginning with optional
leading whitespace and a pound ("#") is
regarded as a comment, and is ignored.
Lines are parsed as they are read. Long lines may be continued by ending
them with a backslash ("\\"). If a line is continued, then the backslash,
the trailing whitespace after the backslash, and the leading whitespace
of the following line are removed. The end result is assembled into a
single line.
.SS "Global Variables"
The following variables may be set to override compiled-in
defaults. Command-line options will have a higher precedence than
these definitions.
.TP
.BI "alertdir = " dir
.I dir
is the full path to the alert scripts. This is the value set by
the
.B \-a
command-line parameter.
Multiple alert paths may be specified by separating them with
a colon. Non-absolute paths are taken to be relative to the
base directory
.RI ( /usr/lib/mon
by default).
When the configuration file is read, all alerts referenced from the
configuration will be looked up in each of these paths, and the full
path to the first instance of the alert found is stored in a hash. This
hash is only generated upon startup or after a "reset" command, so newly
added alert scripts will not be recognized until a "reset" is performed.
.TP
.BI "mondir = " dir
.I dir
is the full path to the monitor scripts. This value may also be
set by the
.B \-s
command-line parameter.
Multiple monitor paths may be specified by separating them with
a colon. Non-absolute paths are taken to be relative to the
base directory
.RI ( /usr/lib/mon
by default).
When the configuration file is read, all monitors referenced from the
configuration will be looked up in each of these paths, and the
full path to the first
instance of the monitor found is stored in a hash. This hash is only
generated upon startup or after a "reset" command, so newly added monitor
scripts will not be recognized until a "reset" is performed.
.TP
.BI "statedir = " dir
.I dir
is the full path to the state directory.
.B mon
uses this directory to save various state information.
.TP
.BI "logdir = " dir
.I dir
is the full path to the log directory.
.B mon
uses this directory to save various logs, including
the downtime log.
.TP
.BI "basedir = " dir
.I dir
is the full path for the state, script, and alert directory.
.TP
.BI "cfbasedir = " dir
.I dir
is the full path where all the config files can be found
(monusers.cf, auth.cf, etc.).
.TP
.BI "authfile = " file
.I file
is the full path to the authentication file.
.TP
.BI "authtype = " "type [type...]"
.I type
is the type of authentication to use. A space-separated list of
types may be specified, and they will be checked the order they are
listed. As soon as a successful authentication is performed, the user
is considered authenticated by mon for the duration of the session and
no more authentication checks are performed.
If
.I type
is
.BR getpwnam ,
then the standard Unix passwd file authentication method will be used
(calls getpwnam(3) on the user and compares the crypt(3)ed version
of the password with what it gets from getpwnam). This will not work
if shadow passwords are enabled on the system.
If
.I type
is
.BR userfile ,
then usernames and hashed passwords are read from
.IR userfile ,
which is defined via the
.B userfile
configuration variable.
If
.I type
is
.BR pam ,
then PAM (pluggable authentication modules) will be used for authentication.
The service specified by the
.B pamservice
global will be used. If no global is given, the PAM
.B passwd
service will be used.
.TP
.BI "userfile = " file
This file is used when
.B authtype
is set to
.IR userfile .
It consists of a sequence of lines of the format
.BR "'username : password'" .
.B password
is stored as the hash returned by the standard Unix
crypt(3) function.
.B NOTE:
the format of this file is compatible with the Apache file based
username/password file format. It is possible to use the
.I htpasswd
program supplied with Apache to manage the mon userfile.
Blank lines and lines beginning with # are ignored.
.TP
.BI "pamservice = " service
The PAM service used for authentication. This is applicable
only if "pam" is specified as a parameter to the
.B authtype
setting. If this global is not defined, it defaults
to
.BR "passwd" .
.TP
.BI "snmpport = " portnum
Set the SNMP port that the server binds to.
.TP
.BI "serverbind = " addr
.TP
.BI "trapbind = " addr
.B serverbind
and
.B trapbind
specify which address to bind the server and trap ports to, respectively.
If these are not defined, the default address is INADDR_ANY, which
allows connections on all interfaces. For security reasons,
it could be a good idea to bind only to the loopback interface.
.TP
.BI "snmp =" {yes|no}
Turn on/off SNMP support (currently unimplemented).
.TP
.BI "dtlogfile = " file
.I file
is a file which will be used to record the downtime log. Whenever
a service fails for some amount of time and then stop failing, this
event is written to the log. If this parameter is not set, no
logging is done. The format of the file is as follows (# is a
comment and may be ignored):
.BR "timenoticed group service firstfail downtime interval summary".
.B timenoticed
is the time(2) the service came back up.
.B "group service"
is the group and service which failed.
.B "firstfail"
is the time(2) when the service began to fail.
.B "downtime"
is the number of seconds the service failed.
.B "interval"
is the frequency (in seconds) that the service is polled.
.B "summary"
is the summary line from when the service was failing.
.TP
.BI "dtlogging = " yes/no
Turns downtime logging on or off. The default is off.
.TP
.BI "histlength = " num
.I num
is the the maximum number of events to be retained
in history list. The default is 100.
This value may also be set by the
.B \-k
command-line parameter.
.TP
.BI "historicfile = " file
If this variable is set, then alerts are logged to
.IR file ,
and upon startup, some (or all) of the past history is read
into memory.
.TP
.BI "historictime = " timeval
.I num
is the amount of the history file to read upon startup.
"Now" -
.I timeval
is read. See the explanation of
.I interval
in the "Service Definitions" section
for a description of
.IR timeval .
.TP
.BI "serverport = " port
.I port
is the TCP port number that the server should bind to. This value may also be
set by the
.B \-p
command-line parameter. Normally this port is looked up via getservbyname(3),
and it defaults to 2583.
.TP
.BI "trapport = " port
.I port
is the UDP port number that the trap server should bind to.
Normally this port is looked up via getservbyname(3),
and it defaults to 2583.
.TP
.BI "pidfile = " path
.I path
is the file the sever will store its pid in. This value may also be set
by the
.B \-P
command-line parameter.
.TP
.BI "maxprocs = " num
Throttles the number of concurrently forked processes to
.I num.
The intent is to provide a safety net for the unlikely situation
when the server tries to take on too many tasks at once. Note that this
situation has only been reported to happen when trying to use a garbled
configuration file! You don't want to use a garbled configuration
file now, do you?
.TP
.BI "cltimeout = " secs
Sets the client inactivity timeout to
.I secs.
This is meant to help thwart denial of service attacks or
recover from crashed clients.
.I secs
is interpreted as a "1h/1m/1s" string, where
"1m" = 60 seconds.
.TP
.BI "randstart = " interval
When the server starts, normally all services will not be scheduled
until the interval defined in the respective service section.
This can cause long delays before the first check of a service,
and possibly a high load on the server if multiple things are scheduled
at the same intervals.
This option is used to randomize the scheduling
of the first test for all services during the startup period, and
immediately after the
.I reset
command.
If
.I randstart
is defined, the scheduled run time of all services of all watch groups
will be a random number between zero and
.I randstart
seconds.
.TP
.BI "dep_recur_limit = " depth
Limit dependency recursion level to
.IR depth .
If dependency recursion (dependencies which depend on other dependencies)
tries to go beyond
.IR depth ,
then the recursion is aborted and a messages is logged to syslog.
The default limit is 10.
.TP
.BI "dep_behavior = " {a|m}
.B dep_behavior
controls whether the dependency expression
suppresses either the running of alerts or monitors
when a node in the dependency graph fails. Read more
about the behavior in the "Service Definitions" section
below.
This is a global setting which controls the default
settings for the service-specified variable.
.TP
.BI "syslog_facility = " facility
Specifies the syslog facility used for logging.
.B daemon
is the default.
.TP
.BI "startupalerts_on_reset = " {yes|no}
If set to "yes", startupalerts will be invoked when the
.B reset
client command is executed. The default is "no".
.SS "Hostgroup Entries"
Hostgroup entries begin with the keyword
.BR hostgroup ,
and are followed by a hostgroup tag and one or more hostnames
or IP addresses, separated by whitespace. The hostgroup tag must
be composed of alphanumeric
characters, a dash ("-"), a period ("."),
or an underscore ("_"). Non-blank lines following
the first hostgroup line are interpreted as more hostnames.
The hostgroup definition ends with a blank line. For example:
.RS
.nf
hostgroup servers nameserver smtpserver nntpserver
nfsserver httpserver smbserver
hostgroup router_group cisco7000 agsplus
.fi
.RE
.SS "Watch Group Entries"
Watch entries begin with a line that starts
with the keyword
.BR watch ,
followed by whitespace and a single word which
normally refers
to a pre-defined hostgroup. If the second word is not recognized
as a hostgroup tag, a new hostgroup is created whose tag is
that word, and that word is its only member.
Watch entries consist of one or more service definitions.
There is a special watch group entry called "default". If a
default watch group is defined with a "default" service entry,
then this definition will be used in handling unknown mon
traps.
.SS "Service Definitions"
.TP
.BI service " servicename"
A service definition begins with they keyword
.B service
followed by a word which is the tag for this service.
The components of a service are an interval, monitor, and
one or more time period definitions, as defined below.
If a service name of "default" is defined within a watch
group called "dafault" (see above), then the default/default
definition will be used for handling unknown mon traps.
.TP
.BI interval " timeval"
The keyword
.B interval
followed by a time value specifies the frequency that
a monitor script will be triggered.
Time values are defined as "30s", "5m", "1h", or "1d",
meaning 30 seconds, 5 minutes, 1 hour, or 1 day. The numeric portion
may be a fraction, such as "1.5h" or an hour and a half. This
format of a time specification will be referred to as
.IR timeval .
.TP
.BI failure_interval " timeval"
Adjusts the polling interval to
.I timeval
when the service check is failing. Resets the interval
to the original when the service succeeds.
.TP
.BI traptimeout " timeval"
This keyword takes the same time specification argument as
.BI interval ,
and makes the service expect a trap from an external source
at least that often, else a failure will be registered. This is
used for a heartbeat-style service.
.TP
.BI trapduration " timeval"
If a trap is received, the status of the service the trap was delivered
to will normally remain constant. If
.B trapduration
is specified, the status of the service will remain in a failure
state for the duration specified by
.IR timeval ,
and then it will be reset to "success".
.TP
.BI randskew " timeval"
Rather than schedule the monitor script to run at the start of each
interval, randomly adjust the interval specified by the
.B interval
parameter by plus-or-minus
.B "randskew".
The skew value is specified as the
.B interval
parameter: "30s", "5m", etc...
For example if
.B "interval"
is 1m, and
.B "randskew"
is "5s", then
.I mon
will schedule the monitor script some time between every
55 seconds and 65 seconds.
The intent is to help distribute the load on the server when
many services are scheduled at the same intervals.
.TP
.BI monitor " monitor-name [arg...]"
The keyword
.B monitor
followed by a script name and arguments
specifies the monitor to run when the timer
expires. Shell-like quoting conventions are
followed when specifying the arguments to send
to the monitor script.
The script is invoked from the directory
given with the
.B \-s
argument, and all following words are supplied
as arguments to the monitor program, followed by the
list of hosts in the group referred to by the current watch group.
If the monitor line ends with ";;" as a separate word,
the host groups are not appended to the argument list
when the program is invoked.
.TP
.B allow_empty_group
The
.B allow_empty_group
option will allow a monitor to be invoked even when the
hostgroup for that watch is empty because of
disabled hosts. The default behavior is not
to invoke the monitor when all hosts in a hostgroup
have been disabled.
.TP
.BI description " descriptiontext"
The text following
.B description
is queried by client programs, passed to alerts and monitors via an
environment variable. It should contain a brief description of the
service, suitable for inclusion in an email or on a web page.
.TP
.BI exclude_hosts " host [host...]"
Any hosts listed after
.B exclude_hosts
will be excluded from the service check.
.TP
.BI exclude_period " periodspec"
Do not run a scheduled monitor during the time
identified by
.IR periodspec .
.TP
.BI depend " dependexpression"
The
.B depend
keyword is used to specify a dependency expression, which
evaluates to either true of false, in the boolean sense.
Dependencies are actual Perl expressions, and must obey all syntactical
rules. The expressions are evaluated in their own package space so as
to not accidentally have some unwanted side-effect.
If a syntax error is found when evaluating the expression, it
is logged via syslog.
Before evaluation, the following substitutions on the expression occur:
phrases which look like "group:service" are substituted with the value
of the current operational status of that specified service. These
opstatus substitutions are computed recursively, so if service A
depends upon service B, and service B depends upon service C, then
service A depends upon service C. Successful operational statuses (which
evaluate to "1") are "STAT_OK", "STAT_COLDSTART", "STAT_WARMSTART", and
"STAT_UNKNOWN". The word "SELF" (in all caps) can be used for the group
(e.g. "SELF:service"), and is an abbreviation for the current watch group.
This feature can be used to control alerts for services which are
dependent on other services, e.g. an SMTP test which is dependent upon
the machine being ping-reachable.
.TP
.BI dep_behavior " {a|m}"
The evaluation of dependency graphs
can control the
suppression of either alert or monitor invocations.
.BR "Alert suppression" .
If this option is set to "a",
then the dependency expression
will be evaluated after the
monitor for the service exits or
after a trap is received.
An alert will only be sent
if the evaluation succeeds, meaning
that none of the nodes in the dependency
graph indicate failure.
.BR "Monitor suppression" .
If it is set to "m",
then the dependency expression will be evaulated
before the monitor for the service is about to run.
If the evaulation succeeds, then the monitor
will be run. Otherwise, the monitor will not
be run and the status of the service will remain
the same.
.SS "Period Definitions"
Periods are used to define the conditions which
should allow alerts
to be delivered.
.TP
.BI period " [label:] periodspec"
A period groups one or more alarms and variables
which control how often an alert happens when there
is a failure.
The
.B period
keyword has two forms. The first
takes an argument which is a
period specification from Patrick Ryan's
Time::Period Perl 5 module. Refer to
"perldoc Time::Period" for more information.
The second form requires a label followed by a period specification, as
defined above. The label is a tag consisting of an alphabetic character
or underscore followed by zero or more alphanumerics or underscores
and ending with a colon. This
form allows multiple periods with the same period definition. One use
is to have a period definition which has no
.B alertafter
or
.B alertevery
parameters for a particular time period, and another
for the same time period with a different
set of alerts that does contain those
parameters.
.TP
.BI alertevery " timeval [observe_detail]"
The
.B alertevery
keyword (within a
.B period
definition) takes the same type of argument as the
.B interval
variable, and limits the number of times an alert
is sent when the service continues to fail.
For example, if the interval is "1h", then only
the alerts in the period section will only
be triggered once every hour. If the
.B alertevery
keyword is
omitted in a period entry, an alert will be sent
out every time a failure is detected. By default,
if the summary output of two successive failures changes,
then the alertevery interval is overridden, and an alert
will be sent.
If the string
"observe_detail" is the last argument, then both the summary
and detail output lines will be considered when comparing the
output of successive failures. Please refer to the
.B "ALERT DECISION LOGIC"
section for a detailed explanation of how alerts are suppressed.
.TP
.BI alertafter " num"
.TP
.BI alertafter " num timeval"
.TP
.BI alertafter " timeval"
The
.B alertafter
keyword (within a
.B period
section) has three forms: only with the "num"
argument, or with the "num timeval" arguments,
or only with the "timeval" argument.
In the first form, an alert will only be invoked
after "num" consecutive failures.
In the second form,
the arguments are a positive integer followed by an interval,
as described by the
.B interval
variable above.
If these parameters are specified,
then the alerts for that period will only
be called after that many failures happen
within that interval. For example,
if
.B alertafter
is given the arguments "3\ 30m", then the alert will be called
if 3 failures happen within 30 minutes.
In the third form,
the argument is an interval,
as described by the
.B interval
variable above.
Alerts for that period
will only be called if the service has been
in a failure state for more than the length
of time desribed by the interval, regardless
of the number of failures noticed within that
interval.
.TP
.BI numalerts " num"
This variable tells the server to call no more than
.I num
alerts during a
failure. The alert counter is kept on a per-period basis,
and is reset upon each success.
.TP
.B "no_comp_alerts"
If this option is specified, then upalerts will be called whenever the
service state changes from failure to success, rather than only after
a corresponding "down" alert.
.TP
.BI alert " alert [arg...]"
A period may contain multiple alerts, which are triggered
upon failure of the service. An alert is specified with
the
.B alert
keyword, followed by an optional
.B exit
parameter, and arguments which are interpreted the same as
the
.B monitor
definition, but without the ";;" exception. The
.B exit
parameter takes the form of
.B "exit=x"
or
.B "exit=x-y"
and has the effect that the alert is only called if the
exit status of the monitor script falls within the range
of the
.B exit
parameter. If, for example, the alert line is
.I "alert exit=10-20 mail.alert mis"
then
.I mail-alert
will only be invoked with
.I mis
as its arguments if the monitor
program's exit value is between 10 and 20. This feature
allows you to trigger different alerts at different
severity levels (like when free disk space goes from 8% to 3%).
See the
.B "ALERT PROGRAMS"
section above for a list of the pramaeters mon will pass
automatically to alert programs.
.TP
.BI upalert " alert [arg...]"
An
.B upalert
is the compliment of an
.BR alert .
An upalert is called when a services makes the state transition from
failure to success, if a corresponding "down" alert
was previously sent. The
.B upalert
script is called supplying
the same parameters as the
.B alert
script, with the addition of the
.B \-u
parameter which is simply used to let
an alert script know that it is being called
as an upalert. Multiple upalerts may be
specified for each period definition.
Set the per-period
.B no_comp_alerts
option to
send an upalert regardless if whether or not
a "down" alert was sent.
.TP
.BI startupalert " alert [arg...]"
A
.B startupalert
is only called when the
.B mon
server starts execution.
.TP
.BI upalertafter " timeval"
The
.B upalertafter
parameter is specified as a string that
follows the syntax of the
.B interval
parameter ("30s", "1m", etc.), and
controls the triggering of an
.BR upalert .
If a service comes back up after
being down for a time greater than
or equal to the value of this option, an
.B upalert
will be called. Use this option to prevent
upalerts to be called because of "blips" (brief outages).
.SH "AUTHENTICATION CONFIGURATION FILE"
The file specified by the
.B authfile
variable in the configuration file (or
passed via the
.B "-A"
parameter) will be loaded upon startup.
This file defines restrictions upon which client
commands may be executed by which users. It is a
text file which consists of comments,
command definitions, and trap authentication parameters.
A comment line begins with optional
whitespace followed by pound sign. Blank lines are ignored.
The file is separated into a command section and a trap
section. Sections are specified by a single line containing
one of the following statements:
.RS
.nf
command section
.fi
.RE
or
.RS
.nf
trap section
.fi
.RE
Lines following one of the above statements apply to that section until
either the end of the file or another section begins.
A command definition consists of a command, followed by a colon,
followed by a comma-separated list of users who may execute the command.
The default is that no users may execute any commands unless they are
explicitly allowed in this configuration file. For clarity, a user can
be denied by prefixing the user name with "!". If the word "AUTH_ANY"
is used for a username, then any authenticated user will be allowed to
execute the command.
The trap section allows configuration of which users may send traps from
which hosts. The syntax is a source host (name or ip address), whitespace,
a username, whitespace, and a plaintext password for that user. If
the source host is "*", then allow traps from any host. If the username
is "*", then accept traps without regard for the username or password. If
no hosts or users are specified, then no traps will be accepted.
An example configuration file:
.RS
.nf
command section
list: all
reset: root,admin
loadstate: root
savestate: root
trap section
127.0.0.1 root r@@tp4sswrd
.fi
.RE
This means that all clients are able to perform the
.B list
command, "root" is able to perform "reset", "loadstate", "savestate",
and "admin" is able to execute the "reset"
command.
.SH CLIENT\-SERVER\ INTERFACE
The server listens on TCP port 2583, which may be overridden using
the
.BI \-p\ port
option. Commands are a single line each, terminated by a newline.
Currently the server is iterative, accepting a single client at
a time. This will change in future releases.
.SH CLIENT\ INTERFACE\ COMMANDS
See manual page for
.BR moncmd .
.SH MON\ TRAPPING
Mon has the facility to receive special "mon traps" from any local
or remote machine. Currently, the only available method for
sending mon traps are through the Mon::Client perl interface,
though the UDP packet format is defined well enough to permit
the writing of traps in other languages.
Traps are handled similarly to monitors: a trap sends
an operational status, summary line, and description
text, and mon generates an alert or
upalert as necessary.
Traps can be caught by any watch/service group set up in
the mon configuration file, however it is suggested that
you configure watch/service groups specifically for
the traps you expect to receive. When defining a special
watch/service group for traps, do not include a "monitor"
directive (as no monitor need be invoked). Since a monitor
is not being invoked, it is not necessary for the watch
definition to have a hostgroup which contains real host names.
Just make up a useful name, and mon will automatically create
the watch group for you.
Here is a simple config file example:
.RS
.nf
watch trap-service
service host1-disks
description TRAP: for host1 disk status
period wd {Sun-Sat}
alert mail.alert someone@your.org
upalert mail.alert -u someone@your.org
.fi
.RE
Since mon listens on a UDP port for any trap, a
default facility is available for handling traps to unknown
groups or services.
To enable this facility, you must include a "default" watch
group with a "default" service entry containing the specifics
of alarms. If a default/default watch group and service are
not configured, then unknown traps get logged via syslog, and
no alarm is sent.
.B NOTE:
The default/default facility is a single entity as far as
accounting and alarming go. Alarm programs which are not
aware of this fact may send confusing information when a
failure trap comes from one machine, followed by a
success (ok) trap from a different machine. See the alarm
environment variable
.B MON_TRAP_INTENDED
above for a possible way around this. It is intended that
default/default be used as a facility to catch unknown
traps, and should not be relied upon to catch all traps
in a production environment. If you are lazy and only want
to use default/default for catching all traps,
it would be best to disable
upalerts, and use the MON_TRAP_INTENDED environment
variable in alert scripts to make the alerts more
meaningful to you.
Here is an example default facility:
.RS
.nf
watch default
service default
description Default trap service
period wd {Sun-Sat}
alert mail.alert someone@your.org
upalert mail.alert -u someone@your.org
.fi
.RE
.SH EXAMPLES
The
.B mon
distribution comes with an
example configuration called
.IR example.cf .
Refer to that file for more information.
.SH SEE ALSO
.BR moncmd (1),
.BR Time::Period (3pm),
.BR Mon::Client (3pm)
.SH HISTORY
.B mon
was written because I couldn't find anything out
there that did just what I needed, and nothing was worth modifying
to add the features I wanted. It doesn't have a cool name, and
that bothers me because I couldn't think of one.
.SH BUGS
Report bugs to the email address below.
.SH AUTHOR
Jim Trocki <trockij@transmeta.com>
|