1 /* $Id: config.h,v 1.232 2014/07/09 16:32:35 jared Exp $ */ 2 3 #include "defines.h" 4 5 /* change define -> undef if sysmond cores for you */ 6 #define QSORT_WAY 7 #include <signal.h> 8 #include <stdio.h> 9 #include <ctype.h> 10 #include <stdlib.h> 11 #include <time.h> 12 #include <netdb.h> 13 #include <string.h> 14 #include <pwd.h> 15 #include <limits.h> 16 #if (defined(__svr4__) || defined(unixware)) /* slo-laris */ 17 #include <sys/filio.h> 18 #endif 19 #include <sys/types.h> 20 #include <sys/socket.h> 21 #include <sys/ioctl.h> 22 #include <sys/time.h> 23 #include <sys/resource.h> 24 #include <sys/stat.h> 25 #include <sys/param.h> 26 #ifdef _AIX32 27 #include <fcntl.h> 28 #else /* _AIX32 */ 29 #include <sys/fcntl.h> 30 #endif /* _AIX32 */ 31 #include <errno.h> 32 #include <unistd.h> 33 #ifdef HAVE_PATHS_H 34 #include <paths.h> 35 #endif 36 #include <netinet/in.h> 37 #include <netinet/in_systm.h> 38 #include <netinet/ip.h> 39 #include <netinet/ip_icmp.h> 40 41 #ifdef HAVE_NETINET_ICMP6_H 42 #define HAVE_IPv6 43 #include <netinet/icmp6.h> 44 #endif /* ENABLE_IPV6 */ 45 46 #include <arpa/inet.h> 47 #include <syslog.h> 48 #include <stdarg.h> 49 #include <sys/utsname.h> 50 #include <sys/wait.h> 51 #include <strings.h> 52 53 #ifdef HAVE_LIBWRAP 54 #ifdef HAVE_TCPD_H 55 #include <tcpd.h> 56 #define ALLOWSEVERITY LOG_INFO; 57 #define DENYSEVERITY LOG_NOTICE; 58 #define DAEMONNAME "sysmond\0" 59 #endif /* HAVE_TCPD_H */ 60 #endif /* HAVE_LIBWRAP */ 61 62 #ifdef HAVE_LIBPTHREAD 63 #include <pthread.h> 64 #endif /* HAVE_LIBPTHREAD */ 65 66 #ifdef HAVE_LIBNCURSES 67 #define NICEINTERFACE /* define for ncurses interface in client */ 68 #endif /* HAVE_LIBNCURSES */ 69 70 #ifdef HAVE_LIBCURSES 71 #define NICEINTERFACE /* define for ncurses interface in client */ 72 #endif /* HAVE_LIBNCURSES */ 73 74 #ifdef NICEINTERFACE 75 #ifdef sgi 76 #include "/usr/local/include/ncurses.h" 77 #else 78 #include <curses.h> 79 #endif /* sgi */ 80 #endif /* NICEINTERFACE */ 81 82 #ifdef HAVE_NET_SNMP_VERSION_H 83 #define ENABLE_SNMP 84 #endif /* HAVE_NET_SNMP_VERSION_H */ 85 86 #ifdef HAVE_UCD_SNMP_VERSION_H 87 #define ENABLE_SNMP 88 #endif /* HAVE_UCD_SNMP_VERSION_H */ 89 90 91 #define SYSM_VERS "v0.93" 92 #ifdef _PATH_VARRUN 93 #define PIDFILE _PATH_VARRUN "sysmond.pid" 94 #else 95 #define PIDFILE "/etc/sysmond.pid" 96 #endif 97 #define PMESG "%H (%I) %w is %u %d\0" 98 #define SUBJECT "%h is %u\0" 99 #define UPCOLOR "77ff77" /* green */ 100 #define RECENTCOLOR "ffff00" /* yellow */ 101 #define DOWNCOLOR "ff5500" /* sumthin */ 102 103 #define SYSMON_PORTNUM 1345 104 #define MAX_ARGS 100 105 #define MAX_STRLEN 32768 106 107 /* the following should be read from /etc/services */ 108 109 /* SSH Remote Login Protocol */ 110 #define SSH_PORTNUM 22 111 112 /* Per rfc */ 113 #define SMTP_PORTNUM 25 114 115 /* per assigned ports */ 116 #define SNMP_PORTNUM 161 117 #define SNMP_TRAP_PORTNUM 162 118 #define SNMP_SYSTEM_SYSUPTIME ".1.3.6.1.2.1.1.3.0" 119 120 /* per rfc */ 121 #define HTTP_PORTNUM 80 122 123 /* per rfc */ 124 #define IMAP_PORTNUM 143 125 126 /* per rfc */ 127 #define NNTP_PORTNUM 119 128 129 /* per rfc? */ 130 #define POP2_PORTNUM 109 131 132 /* per rfc? */ 133 #define POP3_PORTNUM 110 134 135 /* */ 136 #define DNS_PORTNUM 53 137 138 /* Radius */ 139 #define RADIUS_PORTNUM 1645 140 141 /* SSL Http */ 142 #define HTTPS_PORTNUM 443 143 144 /* Bootp */ 145 #define BOOTP_CLIENT 68 146 #define BOOTP_SERVER 67 147 148 #ifdef HAVE_IPv6 149 #ifndef ICMPV6_ECHO_REQUEST 150 #define ICMPV6_ECHO_REQUEST 128 151 #endif /* ICMPV6_ECHO_REQUEST */ 152 #ifndef ICMPV6_ECHO_REPLY 153 #define ICMPV6_ECHO_REPLY 129 154 #endif /* ICMPV6_ECHO_REPLY */ 155 #endif /* HAVE_IPv6 */ 156 157 #ifndef bool 158 #define bool char 159 #endif 160 161 #ifndef MAX 162 #define MAX(a,b) (((a)>(b))?(a):(b)) 163 #endif /* MAX */ 164 165 #define ICMP_PACKET_SIZE 64 /* packet size */ 166 #define ICMP_HOLD_PACKETS 1500 /* number of packets in the air */ 167 #define ICMP_HOLD_LEN 5 /* 5 seconds worth of packets */ 168 #define ICMP_HOLD_QUEUE (ICMP_PACKET_SIZE*ICMP_HOLD_PACKETS*ICMP_HOLD_LEN) 169 170 #define ICMP_PHDR_LEN sizeof(struct timeval) 171 172 173 #ifndef FALSE 174 #define FALSE 0 175 #endif 176 #ifndef TRUE 177 #define TRUE 1 178 #endif 179 180 /* Check Types */ 181 #define SYSM_TYPE_TCP 1 /* TCP Checks */ 182 #define SYSM_TYPE_UDP 2 /* UDP Checks */ 183 #define SYSM_TYPE_PING 3 /* Ping */ 184 #define SYSM_TYPE_SNMP 4 /* Snmp based checks */ 185 #define SYSM_TYPE_NNTP 5 /* nntp checks */ 186 #define SYSM_TYPE_SMTP 6 /* smtp checks */ 187 #define SYSM_TYPE_IMAP 7 /* imap check */ 188 #define SYSM_TYPE_POP3 8 /* pop3 check */ 189 #define SYSM_TYPE_X500 9 /* umichX500 check */ 190 #define SYSM_TYPE_POP2 10 /* pop2 check */ 191 #define SYSM_TYPE_BOOTP 11 /* bootp check */ 192 #define SYSM_TYPE_DNS 12 /* check dns server */ 193 #define SYSM_TYPE_WWW 13 /* www content check */ 194 #define SYSM_TYPE_RADIUS 14 /* radius server check */ 195 #define SYSM_TYPE_HTTPS 15 /* https content check */ 196 #define SYSM_TYPE_SYSM 16 /* check another sysmond */ 197 #define SYSM_TYPE_SSHD 17 /* sshd check */ 198 #define SYSM_TYPE_IRCD 18 /* ircd check - connect, send quit */ 199 #define SYSM_TYPE_PING_LATENCY 19 /* latency - stick timeval in packet */ 200 #define SYSM_TYPE_PINGv6 20 /* IPv6 PING */ 201 #define SYSM_TYPE_UDP_RTT 21 /* udp rtt packet timeval coolness */ 202 203 /* Return Values */ 204 #define SYSM_ERR -2 205 #define SYSM_OK 0 206 #define SYSM_CONNREF 1 207 #define SYSM_NETUNRCH 2 208 #define SYSM_HOSTDOWN 3 209 #define SYSM_TIMEDOUT 4 210 #define SYSM_NODNS 5 211 #define SYSM_UNPINGABLE 6 212 #define SYSM_THROTTLED 7 213 #define SYSM_NOAUTH 8 214 #define SYSM_NORESP 9 215 #define SYSM_INPROG 10 216 #define SYSM_BAD_AUTH 11 217 #define SYSM_BAD_RESP 12 218 #define X500_WEDGED 13 219 #define SYSM_KILLED 14 /* killed locally */ 220 #define SYSM_HOSTUNRCH 15 221 #define SYSM_RTT_HIGH 16 222 #define SYSM_SNMP_REBOOT 17 223 #define SYSM_SNMP_HIGH 18 224 #define SYSM_SNMP_LOW 19 225 #define SYSM_SNMP_OOR 20 226 #define SYSM_SNMP_NOTEXACT 21 227 #define SYSM_SNMP_HIGHRATE 22 228 229 /* SNMP subTYPES */ 230 231 #define SYSM_SNMP_TYPE_REBOOT 1 /* if system.sysUpTime.0 goes down */ 232 #define SYSM_SNMP_TYPE_HIGH 2 233 #define SYSM_SNMP_TYPE_LOW 3 234 #define SYSM_SNMP_TYPE_RANGE 4 235 #define SYSM_SNMP_TYPE_EXACT 5 236 #define SYSM_SNMP_TYPE_COMPARE 6 /* compare two oid values if eq */ 237 #define SYSM_SNMP_TYPE_RATE 7 /* have a rate in val/sec, if avg 238 exceeds, gen alert */ 239 240 /* when to contact */ 241 #define SYSM_CONTACT_DOWN 1 242 #define SYSM_CONTACT_UP 2 243 244 struct hostinfo { 245 unsigned char *hostname; /* name of system to check */ 246 unsigned int type; /* 1 = tcp, 2 = udp, 3 = ping, 4 = snmp, 5 = nntp 247 6 = smtp, 7 = imap, 8 = pop3 9 = umichX500 10 = pop2 248 11 = bootp 12 = dns 13 = www-content, 14 = radius, 249 15 = https, 16 = sysmon, 17 = ssh, 18=ircd, 250 19= latency, 20 = ping6, 21 = rtt */ 251 unsigned int port; /* only relevant for tcp/udp */ 252 unsigned char *message; /* message to print for outages */ 253 unsigned char *contact; /* e-mail contact for this */ 254 unsigned char *snmp_community; /* snmp community */ 255 unsigned char *snmp_oid; /* OID to query - can be numerical 256 or textual*/ 257 unsigned char *snmp_oid_sec; /* used in snmp compare two values chk */ 258 unsigned char *snmp_up_msg; /* message for snmp up */ 259 unsigned char *snmp_down_msg; /* pmesg for snmp down */ 260 unsigned char *pmesg; /* custom per-object pmesg */ 261 unsigned int snmp_test_type; /* 1 = sysUpTime.0/reboot, 262 2 = high threshold (ie: alert if it goes above that value) 263 3 = low threshold (ie: alert if it goes below that value) 264 4 = range threshold (ie: specify a high+low and alert if 265 it is out of range 266 5 = exact threshold (ie: alert if it is != our value) */ 267 unsigned long snmp_low, snmp_high, snmp_exact; 268 unsigned long snmp_rate; /* rate/sec */ 269 bool snmp_octets; /* is rate in octets? true/false */ 270 unsigned long system_uptime; /* system.sysUpTime.0 or last snmp value */ 271 time_t last_snmp_resptime; 272 unsigned char *dns_query; /* name to do dns query of */ 273 bool dns_aa; /* require AA response */ 274 bool dns_recursion; /* perform recursive query */ 275 unsigned int lastcheck; /* lastchecked status 0 = ok, 1 = conn ref 276 2 = ENETUNREACH, 3 = EHOSTDOWN||EHOSTUNREACH, 277 4 = ETIMEDOUT, 5 = no dns entry, 6 = unpingable, 278 7 = Throttled, 8 = no auth, 9 = no response 279 10 = connection in progress, 11 = bad auth 280 12 = bad remote response, 13 = x500 error */ 281 unsigned char *username; /* for pop3, imap, etc */ 282 unsigned char *password; /* for pop3, imap, etc */ 283 unsigned char *hdr; 284 unsigned char *hdrval; 285 unsigned char *secret; /* used for RADIUS */ 286 unsigned char *lastmsgid; /* Message ID */ 287 unsigned char *unique_id; /* Unique id created by loadconfig 288 never to change even if we catch sighup, and be 289 unique enough between sysmon respawns */ 290 unsigned char *url; /* url for www */ 291 unsigned char *url_text; /* text to find within url */ 292 unsigned char *command; /* command to run on failure */ 293 unsigned char *group; /* group of object */ 294 unsigned char *notes; /* user attached notes for object */ 295 unsigned long totalchecked; /* total times checked */ 296 unsigned long totaldown; /* total times checked as down */ 297 unsigned long downct; /* number of times counted as down.. */ 298 unsigned long upct; /* number of times counted as down.. */ 299 unsigned long max_down; /* max times down before we contact someone */ 300 301 unsigned long queuetime; /* per-object check-interval in seconds */ 302 time_t next_queuetime; /* next time object should be queued */ 303 304 unsigned int send_pings; /* number of pings to send to host */ 305 unsigned int min_pings; /* min number of pings to require for 306 host to be up */ 307 308 bool reverse; /* if true then {if down, follow siblings}, else 309 behave as we do otherwise */ 310 bool contacted; /* true if mailed contact -- false if not */ 311 bool acked; /* true if someone has acked the alert */ 312 time_t lastcontacted; /* last time we "contacted" someone */ 313 314 int contact_when; /* page someone when it comes up */ 315 316 bool queued; /* 0 if not, 1 if in queue */ 317 bool warnlog; /* 0 if already done warnlog, 1 if not */ 318 bool trace; /* 1 if object should be have debugging enabled for it */ 319 320 time_t lchecktime; /* time last checked */ 321 time_t check_start; /* time of start of check */ 322 time_t deathtime; /* time of death ;-) */ 323 time_t last_up; /* time it last came back */ 324 325 } ; 326 327 328 /* New structures for monitoring */ 329 330 struct nei_list { 331 unsigned char *nei_name; 332 struct graph_elements *g_element; 333 struct nei_list *next; 334 }; 335 336 struct graph_elements { 337 unsigned char *unique_name; 338 struct hostinfo *data; 339 unsigned short int num_dep; 340 unsigned char **dep_txt_name; 341 unsigned short int tot_nei; 342 struct graph_elements **neighbors; 343 bool visit; 344 }; 345 346 struct all_elements_list { 347 struct graph_elements *value; 348 struct all_elements_list *next; 349 }; 350 351 352 /* for lib.c:parse() */ 353 struct parsed { 354 int count; 355 unsigned char **data; 356 } ; 357 358 /* 359 * perhaps we should move the filedes used in monitordata-> 360 * into here to aide in select() 361 */ 362 struct monitorent { 363 struct hostinfo *checkent; 364 unsigned char *unique_name; 365 struct monitorent *next; 366 struct timeval queueat; /* time we got queued at */ 367 struct timeval lastserv; /* time we got last serviced */ 368 int filedes; /* filedes used in check */ 369 int fd_state; /* 1 = fd waiting for rd, otherwise wr */ 370 short int started; /* is the check actually started yet */ 371 short int retval; /* set to the return val, or -1 if check not 372 done yet */ 373 void *monitordata; /* should be free'ed when retval is set */ 374 }; 375 376 /* client status */ 377 struct clientstatus { 378 time_t lastactivity; 379 short int filedes; 380 unsigned char *un; /* username */ 381 unsigned char *ip; 382 int authlvl; 383 int clientver; 384 bool outage_log; 385 bool xml; 386 struct clientstatus *next; 387 }; 388 389 /* my version of struct hostent -- used in dnscache.c */ 390 struct my_hostent { 391 unsigned char *h_name; /* Official name of host */ 392 int h_addrtype_v4; /* Host address type. */ 393 int h_length_v4; /* Length of address. */ 394 unsigned char *my_h_addr_v4; /* List of v4 addresses from dns */ 395 int h_addrtype_v6; 396 int h_length_v6; 397 unsigned char *my_h_addr_v6; /* List of v6 addresses from dns*/ 398 }; 399 400 401 /* the actual dns cache list */ 402 struct dnscache { 403 unsigned char *hostname; 404 struct my_hostent *hp; 405 time_t lastquery; 406 struct dnscache *next; 407 }; 408 409 #ifdef USE_BOOTP 410 /* we should use this someday */ 411 struct bootp_pkt { 412 unsigned char bp_op; /* packet opcode type */ 413 unsigned char bp_htype; /* hardware addr type */ 414 unsigned char bp_hlen; /* hardware addr length */ 415 unsigned char bp_hops; /* gateway hops */ 416 unsigned long bp_xid; /* transaction ID */ 417 unsigned short bp_secs; /* seconds since boot began */ 418 unsigned short bp_unused; 419 struct in_addr bp_ciaddr; /* client IP address */ 420 struct in_addr bp_yiaddr; /* 'your' IP address */ 421 struct in_addr bp_siaddr; /* server IP address */ 422 struct in_addr bp_giaddr; /* gateway IP address */ 423 unsigned char bp_chaddr[16]; /* client hardware address */ 424 unsigned char bp_sname[64]; /* server host name */ 425 unsigned char bp_file[128]; /* boot file name */ 426 unsigned char bp_vend[64]; /* vendor-specific area */ 427 }; 428 429 430 #define BOOTP_REQUEST 1 431 #define BOOTP_REPLY 2 432 #endif /* USE_BOOTP */ 433 434 /* Maximum times to try if you get a connection refused */ 435 #define MAX_TRIES 7 436 /* Minimum ping responses required to declare host up */ 437 #define MIN_PING_RESP 1 438 439 /* ****************************************** * 440 * NO USER SERVICABLE PARTS BEYOND THIS POINT * 441 * ****************************************** */ 442 443 #define HEARTBEAT_HOST "204.42.254.5" 444 #define HEARTBEAT_PORT 1345 445 446 /* xml tags */ 447 #define XML_OBJECT "Object" 448 #define XML_SYSMON_STATUS "SysmonStatus" 449 #define XML_OBJECT_STATUS "ObjectStatus" 450 #define XML_HOSTNAME "HostName" 451 #define XML_OBJECT_TYPE "ObjectType" 452 #define XML_OBJECT_PORT "ObjectPort" 453 #define XML_OBJECT_MESSAGE "ObjectMessage" 454 #define XML_OBJECT_CONTACT "ObjectContact" 455 #define XML_SNMP_COMMUNITY "ObjectSNMPCommunity" 456 #define XML_SNMP_OID "ObjectSNMPoid" 457 #define XML_SNMP_TYPE "ObjectSNMPType" 458 #define XML_SNMP_LOW "ObjectSNMPLowThresh" 459 #define XML_SNMP_HIGH "ObjectSNMPHighThresh" 460 #define XML_SNMP_EXACT "ObjectSNMPExactThresh" 461 #define XML_SNMP_SysUpTime "ObjectSNMPObjectSysUpTime" 462 #define XML_SNMP_RATE "ObjectSNMPRate" 463 #define XML_SNMP_OCTETS "ObjectSNMPOctets" 464 #define XML_SNMP_LASTRESP "ObjectSNMPLastResponseTime" 465 #define XML_OBJECT_STATE "ObjectLastcheckState" 466 #define XML_AUTH_USER "ObjectAuthUsername" 467 #define XML_AUTH_PASSWD "ObjectAuthPassword" 468 #define XML_HEADER "ObjectHeader" 469 #define XML_HEADER_VAL "ObjectHeaderValue" 470 #define XML_RADIUS_SECRET "ObjectRadiusSecret" 471 #define XML_MESSAGE_ID "ObjectMessageID" 472 #define XML_UNIQUE_ID "ObjectUniqueID" 473 #define XML_OBJECT_GROUP "ObjectGroup" 474 #define XML_OBJECT_NOTES "ObjectNotes" 475 #define XML_OBJ_URL "ObjectURL" 476 #define XML_OBJ_URL_TEXT "ObjectURLText" 477 #define XML_OBJ_EXEC "ObjectExecCmd" 478 #define XML_TOT_CHECKED "ObjectTotalChecked" 479 #define XML_TOT_DOWN "ObjectTotalDown" 480 #define XML_DOWN_CT "ObjectDownCt" 481 #define XML_UP_CT "ObjectUpCt" 482 #define XML_MAX_DOWN "ObjectMaxDown" 483 #define XML_QUEUE_INT "ObjectQueueInterval" 484 #define XML_SEND_PING "ObjectSendPings" 485 #define XML_MIN_PING "ObjectMinPings" 486 #define XML_OBJ_REVERSED "ObjectReversed" 487 #define XML_OBJ_CONTACTED "ObjectContacted" 488 #define XML_OBJ_CONTACTEDAT "ObjectContactedAt" 489 #define XML_CONTACT_UP "ObjectContactOnUp" 490 #define XML_QUEUED "ObjectQueued" 491 #define XML_LASTCHECK "ObjectLastChecked" 492 #define XML_CHECK_START "ObjectCheckStarted" 493 #define XML_OUTAGE_TIME "ObjectOutageTime" 494 #define XML_LAST_TIME_UP "ObjectLastTimeUp" 495 496 497 /* misc defines for any/all external functions */ 498 extern char *myname; /* my called name when I startup */ 499 extern char *statefile; 500 extern bool mallocdebug; 501 extern bool stop_daemon; 502 extern char *errorsto; 503 extern char *authkey; 504 extern char *path_savestate; 505 extern char *replyto; 506 extern char *downcolor, *upcolor, *recentcolor; 507 extern char *statusfilename; 508 extern char *cssfilename; 509 extern bool quiet; 510 extern time_t boottime; /* does a time() when program starts */ 511 extern bool debug; 512 extern int dnsexpire; 513 extern bool donotify; 514 extern time_t dnslog_last_log; 515 extern int dnslog; 516 extern int facility; 517 extern char *log_file; 518 extern int globtimeout, globtimeoutlen; 519 extern char *globhdr, *globhdrval; 520 extern bool gotsighup; 521 extern bool heartbeat; 522 extern int html; 523 extern unsigned short disable_icmp; 524 extern int glob_icmp_fd; /* icmp.c + syswatch.c */ 525 extern int glob_icmpv6_fd; /* pingv6.c */ 526 extern int snmp_trap_fd; /* loadconfig.c + snmp.c + syswatch.c */ 527 extern bool paused; /* syswatch.c + srvclient.c + textfile.c */ 528 extern int inactivetime; 529 extern int numfailures; 530 extern int numqueued; /* num of elements in the queue */ 531 extern unsigned long queuetime; 532 extern int pageinterval; 533 extern bool showupalso; 534 extern bool not_started_yet; 535 extern struct clientstatus *clienthead; 536 extern struct monitorent *queuehead; 537 extern struct dnscache *dnshead; 538 extern struct all_elements_list *currenthead; 539 extern struct hostinfo *first; 540 extern struct protoent *icmpproto; 541 extern unsigned char *ident_hash; 542 extern char *pmesg; 543 extern char *subject; 544 extern char *sender; 545 extern int maxqueued; 546 extern int cieling_max_queued; 547 extern bool ckconfigonly; 548 extern bool badconfig; 549 extern struct graph_elements *configed_root; 550 extern struct all_elements_list *parser_head; 551 extern bool do_syslog; 552 extern int yylex( void ); 553 extern FILE *yyin, *yyout; 554 555 #ifdef HAVE_LIBPTHREAD 556 extern pthread_mutex_t Sysmon_Giant; 557 #endif /* HAVE_LIBPTHREAD */ 558 559 /* parser.l externs */ 560 extern char *parser_name; 561 extern char *parser_pmesg; 562 extern char *parser_ip; 563 extern char *parser_root; 564 extern int line_no; 565 extern char *parser_type; 566 extern int parser_i_type; 567 extern char *parser_port; 568 extern int parser_i_port; 569 extern char *parser_numfailures; 570 extern int parser_i_numfailures; 571 extern char *parser_desc; 572 extern char *parser_group; 573 extern char *parser_spawn; 574 extern char *parser_contact; 575 extern char *parser_child; 576 extern bool parser_reverse; 577 extern char *parser_sender; 578 extern char *parser_subject; 579 extern char *parser_upcolor; 580 extern char *parser_downcolor; 581 extern char *parser_recentcolor; 582 extern char *parser_replyto; 583 extern char *parser_errorsto; 584 extern char *parser_header; 585 extern char *parser_authkey; 586 extern char *parser_savestate; 587 extern char *parser_statusfile; 588 extern char *parser_cssfile; 589 extern char *parser_pidfile; 590 extern char *parser_logging; 591 extern int parser_logging_fac; 592 extern int parser_statusfile_type; 593 extern char *parser_dateformat; 594 extern struct nei_list *parser_dep; 595 extern struct nei_list *parser_dep_tmp; 596 extern char *parser_page; 597 extern char *parser_also; 598 extern char *parser_secret; 599 extern bool parser_catch_snmptrap; 600 extern char *parser_username; 601 extern char *parser_password; 602 extern char *parser_url; 603 extern char *parser_urltext; 604 extern char *parser_include; 605 extern int parser_i_queuetime; 606 extern char *parser_queuetime; 607 extern int parser_i_dnsexpire; 608 extern char *parser_dnsexpire; 609 extern int parser_i_dnslog; 610 extern char *parser_dnslog; 611 extern int parser_i_pageinterval; 612 extern char *parser_pageinterval; 613 extern int parser_i_maxqueued; 614 extern char *parser_maxqueued; 615 extern int parser_showupalso; /* */ 616 extern int parser_nologconnects; 617 extern int parser_nosubject; 618 extern int parser_html_refresh; 619 extern char *current_parsing_filename; 620 /* parser.l functions */ 621 void use_logging_now(); 622 623 /* new routine names */ 624 625 626 extern bool nologconnects; 627 628 /* in sysmon.c */ 629 void start_check_sysmon(struct monitorent *, time_t); 630 void service_check_sysmon(struct monitorent *, time_t); 631 void stop_check_sysmon(struct monitorent *); 632 633 void start_test_dns(struct monitorent *); 634 void service_test_dns(struct monitorent *); 635 636 void start_test_bootp(struct monitorent *); 637 void service_test_bootp(struct monitorent *); 638 void start_test_www(struct monitorent *, time_t); 639 void service_test_www(struct monitorent *, time_t); 640 void start_test_https(struct monitorent *); 641 void service_test_https(struct monitorent *); 642 643 /* parser.l */ 644 void initalize_parser(); 645 void free_struct_nei_list(struct nei_list *); 646 647 /* icmp.c */ 648 void setup_icmp_fd(); 649 void handle_icmp_responses(); 650 void start_test_ping(struct monitorent *); 651 void service_test_ping(struct monitorent *, struct timeval *); 652 unsigned short int generate_ident(); 653 unsigned short in_cksum(); 654 655 656 /* pingv6.c */ 657 void handle_pingv6_responses(); 658 void setup_icmpv6_fd(); 659 660 /* imap.c */ 661 void start_test_imap(struct monitorent *, time_t); 662 void service_test_imap(struct monitorent *, time_t); 663 664 /* nntp.c */ 665 void start_test_nntp(struct monitorent *, time_t); 666 void service_test_nntp(struct monitorent *, time_t); 667 668 /* pop3.c */ 669 void start_test_pop3(struct monitorent *, time_t); 670 void service_test_pop3(struct monitorent *, time_t); 671 672 void start_test_radius(struct monitorent *, time_t); 673 void service_test_radius(struct monitorent *, time_t); 674 675 void start_test_smtp(struct monitorent *, time_t); 676 void service_test_smtp(struct monitorent *, time_t); 677 void start_test_tcp(struct monitorent *, time_t); 678 void service_test_tcp(struct monitorent *, time_t); 679 void start_test_udp(struct monitorent *, time_t); 680 void service_test_udp(struct monitorent *, time_t); 681 void start_test_x500(struct monitorent *, time_t); 682 void service_test_x500(struct monitorent *); 683 684 void start_test_sshd(struct monitorent *, time_t); 685 void service_test_sshd(struct monitorent *here, time_t); 686 687 void stop_test_tcp(struct monitorent *); 688 void stop_test_udp(struct monitorent *); 689 void stop_test_ping(struct monitorent *); 690 void stop_test_snmp(struct monitorent *); 691 void process_snmp_trap(int); 692 void stop_test_nntp(struct monitorent *); 693 void stop_test_smtp(struct monitorent *); 694 void stop_test_imap(struct monitorent *); 695 void stop_test_pop3(struct monitorent *); 696 void stop_test_x500(struct monitorent *); 697 void stop_test_pop2(struct monitorent *); 698 void stop_test_bootp(struct monitorent *); 699 void stop_test_dns(struct monitorent *); 700 void stop_test_www(struct monitorent *); 701 void stop_test_radius(struct monitorent *); 702 void stop_test_https(struct monitorent *); 703 void stop_test_sysm(struct monitorent *); 704 void stop_test_sshd(struct monitorent *); 705 706 707 /* if v6 was detected, we should define the testing functions 708 * to prevent compiler warnings 709 */ 710 #ifdef HAVE_IPv6 711 void start_test_pingv6(struct monitorent *); 712 void service_test_pingv6(struct monitorent *); 713 void stop_test_pingv6(struct monitorent *); 714 #endif /* HAVE_IPv6 */ 715 716 int is_open(int); 717 void set_defaults(); 718 void free_tree(struct all_elements_list *); 719 void stop_it(); 720 void service_this(struct monitorent *, struct timeval *, time_t); 721 void print_queue(int ); 722 void reload_config(); 723 struct all_elements_list *sync_after_sighup(struct all_elements_list *, char *); 724 float mydifftime(struct timeval, struct timeval); 725 void blocktillready(int, int); 726 void expire_dns(time_t ); 727 728 /* in lib.c: */ 729 int str_cnt(const char *, const char); 730 char *snmp_type_to_name(int); 731 char randchar(); 732 void gen_rand_ascii(char *, int); 733 int check_runtime(struct timeval, struct timeval, char *, int); /* Logs funcs that suck time */ 734 int errno_to_error(int); 735 void print_err (int, const char *, ...); 736 void ABORT(); 737 738 int um_x500_monitor(char *, int); 739 void do_tree_periodic(); 740 int tcp_open_sock(int); 741 int nextfd(); 742 int udp_open_sock(); 743 int init_tcp_socket(int); 744 int init_udp_socket(int); 745 int icmp_open_sock(int); 746 747 /* dnscache.c */ 748 struct my_hostent *my_gethostbyname(unsigned char *, int); 749 char *get_ip(struct my_hostent *); 750 char *get_hostname(struct my_hostent *); 751 void warn_dnscache_lameness(); 752 753 void client_poll(); 754 int test_udp(char*, int); 755 int test_tcp(char*, int); 756 757 /* talktcp.c */ 758 int sendline(int , char *); 759 760 void hard_copy(struct hostinfo *old, struct hostinfo *new); 761 void dump_to_file(char *, int, time_t ); 762 void add_line(FILE *, struct hostinfo, int, time_t); 763 int data_waiting_read(int, int); 764 void dump_to_file_walk_this_way(FILE *, struct graph_elements*, int, time_t); 765 void timeout_clients(); 766 void dead_client_cleanup(); 767 int ping(struct hostinfo *); 768 char *str_difftime(time_t, time_t); 769 char *str_difftime_sec(time_t, time_t); 770 void page_someone(struct hostinfo*, int, time_t); 771 struct hostinfo *parseline(int *, int*, char*, FILE*); 772 int test_pop3(char*,char*,char*); 773 int check_http(char*,char*, char*); 774 char *yes_no(int); 775 int getline_tcp(int , char *); 776 void set_nonblock(int); 777 int can_write(int, int); 778 /* loadconfig.c */ 779 void do_set(unsigned char *, unsigned char *); 780 unsigned char *do_set_replace(unsigned char *); 781 unsigned char *gen_unique_id(); 782 struct all_elements_list *loadconfig(char *); 783 struct graph_elements *find_object_by_name(char *); 784 void update_globs_from_parser(); 785 void clear_visited(); 786 int parse(char *, struct parsed *); 787 void free_parsed(struct parsed *); 788 int match_facility(char *); 789 790 int open_host(char*, int, int*, int); 791 int open_sock(); 792 char *errtostr(int); 793 char *type_to_name(int); 794 char *timedata(time_t); 795 void syslogmsg(char *, time_t); 796 void send_heartbeat(char *); 797 798 /* auth dns check */ 799 int gethost(char *,struct sockaddr_in *); 800 int check_authdns(char *,char *); 801 int chk_ns(char *, char *,int,int ,int , int ,int ); 802 803 /* dns.c */ 804 void start_check_dns(struct monitorent *); 805 void service_check_dns(struct monitorent *); 806 void stop_check_dns(struct monitorent *); 807 808 /* snmp.c */ 809 void service_test_snmp(struct monitorent *); 810 void start_test_snmp(struct monitorent *); 811 812 /* radius check */ 813 void start_check_radius(struct monitorent *, time_t); 814 void service_check_radius(struct monitorent *, time_t); 815 void stop_check_radius(struct monitorent *); 816 void md5_calc (unsigned char *, unsigned char *, unsigned int); 817 818 /* srvclient.c */ 819 void send_object_xml(int, FILE*, struct graph_elements *); 820 void client_send_statechange(char *, int , int); 821 822 /* in lib.c */ 823 void *MALLOC(size_t, char *); 824 void *STRDUP(char *, char *); 825 void FREE(void *); 826 short int name_to_type(char *); 827 short int name_to_snmp_type(char *); 828 void quicksort(char *, size_t, size_t, int (*) ()); 829 /* end lib.c */ 830 831 #if (defined(HAVE_LIBNCURSES) || defined(HAVE_LIBCURSES)) 832 void pretty_print_down(struct hostinfo*); 833 void update_screen(); 834 void setup_screen(); 835 #endif 836 837 #if (defined(linux)) /* || defined(unixware)) */ 838 #define ICMPHDR icmphdr 839 #define ICMP_TYPE type 840 #define ICMP_CHECKSUM checksum 841 #define ICMP_CODE code 842 #define IPHDR iphdr 843 #define IHL ihl 844 #define ICMP_SEQ un.echo.sequence 845 #define ICMP_ECHO_ID un.echo.id 846 #ifndef RLIMIT_OFILE 847 #define RLIMIT_OFILE RLIMIT_NOFILE 848 #endif 849 #endif 850 851 #if (defined(unixware) || defined(__APPLE_CC__)) 852 #define RLIMIT_OFILE RLIMIT_NOFILE 853 #define ICMPHDR icmp 854 #define ICMP_CHECKSUM icmp_cksum 855 #define ICMP_TYPE icmp_type 856 #define ICMP_CODE icmp_code 857 #define IPHDR ip 858 #define IHL ip_hl 859 #define ICMP_SEQ icmp_seq 860 #define ICMP_ECHO_ID icmp_id 861 #endif 862 863 864 #if (defined(__NetBSD__) || defined(__FreeBSD) || defined(sgi)|| \ 865 defined(FreeBSD) || defined(__FreeBSD__) || defined(__bsdi__) || \ 866 defined(__OpenBSD__)) 867 868 #if (defined(sgi) || defined(__NetBSD__) || defined(__OpenBSD__)) 869 #define RLIMIT_OFILE RLIMIT_NOFILE 870 #endif 871 #define ICMPHDR icmp 872 #define ICMP_CHECKSUM icmp_cksum 873 #define ICMP_TYPE icmp_type 874 #define ICMP_CODE icmp_code 875 #define IPHDR ip 876 #define IHL ip_hl 877 #define ICMP_SEQ icmp_seq 878 #define ICMP_ECHO_ID icmp_id 879 #endif 880 881 #if (defined(sun) && defined(unix)) /* sunos, solaris, should work for most all */ 882 #define ICMPHDR icmp 883 #define ICMP_CHECKSUM icmp_cksum 884 #define ICMP_TYPE icmp_type 885 #define ICMP_CODE icmp_code 886 #define IPHDR ip 887 #define IHL ip_hl 888 #define ICMP_SEQ icmp_seq 889 #define ICMP_ECHO_ID icmp_id 890 #endif 891 892 /* 893 * this came from an OSF/1 machine 894 */ 895 #if (defined(__osf__) && defined(__alpha__)) 896 #define ICMPHDR icmp 897 #define ICMP_CHECKSUM icmp_cksum 898 #define ICMP_TYPE icmp_type 899 #define ICMP_CODE icmp_code 900 #define IPHDR ip 901 #define IHL ip_vhl 902 #define ICMP_SEQ icmp_seq 903 #define ICMP_ECHO_ID icmp_id 904 #define RLIMIT_OFILE RLIMIT_NOFILE 905 906 #endif 907 908 #ifdef _AIX /* AIX */ 909 #define ICMPHDR icmp 910 #define ICMP_CHECKSUM icmp_cksum 911 #define ICMP_TYPE icmp_type 912 #define ICMP_CODE icmp_code 913 #define IPHDR ip 914 #define IHL ip_vhl 915 #define ICMP_SEQ icmp_seq 916 #define ICMP_ECHO_ID icmp_id 917 918 #endif 919 920 921 #ifndef hpux 922 #ifdef _HPUX_SOURCE 923 #define hpux 924 #endif /* _HPUX_SOURCE */ 925 #endif /* hpux */ 926 927 #ifdef hpux 928 #define ICMPHDR icmp 929 #define ICMP_CHECKSUM icmp_cksum 930 #define ICMP_TYPE icmp_type 931 #define ICMP_CODE icmp_code 932 #define IPHDR ip 933 #define IHL ip_hl 934 #define ICMP_SEQ icmp_seq 935 #define ICMP_ECHO_ID icmp_id 936 #define RLIMIT_OFILE RLIMIT_NOFILE 937 #endif 938 939