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
|
Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.61
diff -r1.61 check_tcp.c
99c99
< int use_ssl = FALSE;
---
> int use_ssl = FALSE;
170a171,180
> else if (strstr (argv[0], "check_clamd")) {
> progname = strdup ("check_clamd");
> SERVICE = strdup ("CLAMD");
> SEND = strdup ("PING");
> EXPECT = strdup ("PONG");
> QUIT = NULL;
> PROTOCOL = TCP_PROTOCOL;
> PORT = 3310;
> }
>
378,379c388,395
<
< printf
---
> if(server_address[0]=='/')
> printf
> (_("%s %s%s - %.3f second response on socket %s"),
> SERVICE,
> state_text (result),
> (was_refused) ? " (refused)" : "",
> elapsed_time, server_address);
> else printf
486c502
< if (is_host (optarg) == FALSE)
---
> if (optarg[0]!= '/' && is_host (optarg) == FALSE)
761c777
< printf (_("This plugin tests %s connections with the specified host.\n\n"),
---
> printf (_("This plugin tests %s connections with the specified host or unix socket.\n\n"),
Index: netutils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.c,v
retrieving revision 1.22
diff -r1.22 netutils.c
221a222
>
227a229
> if (host_name[0] != '/') {
267a270,294
> }
> else{ // unix socket
> struct sockaddr_un su;
> if (strlen(host_name) >= sizeof(su.sun_path)) {
> printf("Hostname too long for unix domain socket: %s\n",
> host_name);
> return STATE_UNKNOWN;
> }
> memset(&su, 0, sizeof su);
> su.sun_family = AF_UNIX;
> strncpy(su.sun_path, host_name, sizeof su.sun_path);
> *sd = socket(PF_UNIX, SOCK_STREAM, 0);
> if ( sd < 0) {
> printf ("Socket creation failed\n");
> return STATE_UNKNOWN;
> }
> result=connect(*sd, (struct sockaddr *)&su, sizeof su);
> if (result == -1) {
> printf ("Connect to socket failed\n");
> close(*sd);
> return STATE_UNKNOWN;
> }
>
> }
>
Index: netutils.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.h,v
retrieving revision 1.10
diff -r1.10 netutils.h
37a38
> #include <sys/un.h>
Index: utils.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.h,v
retrieving revision 1.22
diff -r1.22 utils.h
139c139
< Host name or IP Address\n\
---
> Host name or IP Address or unix socket (starting with \"/\")\n\
|