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
|
Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.65
diff -r1.65 check_tcp.c
166a167,176
> else if (strstr (argv[0], "check_clamd")) {
> progname = strdup ("check_clamd");
> SERVICE = strdup ("CLAMD");
> SEND = strdup ("PING");
> EXPECT = strdup ("PONG");
> QUIT = NULL;
> PROTOCOL = IPPROTO_TCP;
> PORT = 3310;
> }
>
380,381c390,397
<
< 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
488c504
< if (is_host (optarg) == FALSE)
---
> if (optarg[0]!= '/' && is_host (optarg) == FALSE)
763c779
< 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.24
diff -r1.24 netutils.c
166a167
>
172a174
> if (host_name[0] != '/') {
212a215,239
> }
> 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.12
diff -r1.12 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\
|