summaryrefslogtreecommitdiffstats
path: root/plugins/urlize.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-09-15 12:59:37 +0200
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-09-15 12:59:37 +0200
commit802e46f8ea36c344f112d7e1dd8d64d17a4cc939 (patch)
treecabf480269113686430053d66df3dadcd4d137a7 /plugins/urlize.c
parenta3cf9041af810770daf5d9b83f1906fa9bb0dd11 (diff)
downloadmonitoring-plugins-802e46f8ea36c344f112d7e1dd8d64d17a4cc939.tar.gz
Run clang-format again
Diffstat (limited to 'plugins/urlize.c')
-rw-r--r--plugins/urlize.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/plugins/urlize.c b/plugins/urlize.c
index 1aa4e425..a8590fae 100644
--- a/plugins/urlize.c
+++ b/plugins/urlize.c
@@ -53,8 +53,10 @@ int main(int argc, char **argv) {
53 53
54 int c; 54 int c;
55 int option = 0; 55 int option = 0;
56 static struct option longopts[] = { 56 static struct option longopts[] = {{"help", no_argument, 0, 'h'},
57 {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"url", required_argument, 0, 'u'}, {0, 0, 0, 0}}; 57 {"version", no_argument, 0, 'V'},
58 {"url", required_argument, 0, 'u'},
59 {0, 0, 0, 0}};
58 60
59 setlocale(LC_ALL, ""); 61 setlocale(LC_ALL, "");
60 bindtextdomain(PACKAGE, LOCALEDIR); 62 bindtextdomain(PACKAGE, LOCALEDIR);
@@ -69,8 +71,9 @@ int main(int argc, char **argv) {
69 while (1) { 71 while (1) {
70 c = getopt_long(argc, argv, "+hVu:", longopts, &option); 72 c = getopt_long(argc, argv, "+hVu:", longopts, &option);
71 73
72 if (c == -1 || c == EOF) 74 if (c == -1 || c == EOF) {
73 break; 75 break;
76 }
74 77
75 switch (c) { 78 switch (c) {
76 case 'h': /* help */ 79 case 'h': /* help */
@@ -90,8 +93,9 @@ int main(int argc, char **argv) {
90 } 93 }
91 } 94 }
92 95
93 if (url == NULL) 96 if (url == NULL) {
94 url = strdup(argv[optind++]); 97 url = strdup(argv[optind++]);
98 }
95 99
96 cmd = strdup(argv[optind++]); 100 cmd = strdup(argv[optind++]);
97 for (c = optind; c < argc; c++) { 101 for (c = optind; c < argc; c++) {
@@ -118,27 +122,32 @@ int main(int argc, char **argv) {
118 strcat(tstr, buf); 122 strcat(tstr, buf);
119 } 123 }
120 124
121 if (!found) 125 if (!found) {
122 die(STATE_UNKNOWN, _("%s UNKNOWN - No data received from host\nCMD: %s</A>\n"), argv[0], cmd); 126 die(STATE_UNKNOWN, _("%s UNKNOWN - No data received from host\nCMD: %s</A>\n"), argv[0],
127 cmd);
128 }
123 129
124 /* chop the newline character */ 130 /* chop the newline character */
125 if ((nstr = strchr(tstr, NEWLINE_CHARACTER)) != NULL) 131 if ((nstr = strchr(tstr, NEWLINE_CHARACTER)) != NULL) {
126 *nstr = '\0'; 132 *nstr = '\0';
133 }
127 134
128 /* tokenize the string for Perfdata if there is some */ 135 /* tokenize the string for Perfdata if there is some */
129 nstr = strtok(tstr, PERF_CHARACTER); 136 nstr = strtok(tstr, PERF_CHARACTER);
130 printf("%s", nstr); 137 printf("%s", nstr);
131 printf("</A>"); 138 printf("</A>");
132 nstr = strtok(NULL, PERF_CHARACTER); 139 nstr = strtok(NULL, PERF_CHARACTER);
133 if (nstr != NULL) 140 if (nstr != NULL) {
134 printf(" | %s", nstr); 141 printf(" | %s", nstr);
142 }
135 143
136 /* close the pipe */ 144 /* close the pipe */
137 result = spclose(child_process); 145 result = spclose(child_process);
138 146
139 /* WARNING if output found on stderr */ 147 /* WARNING if output found on stderr */
140 if (fgets(buf, MAX_INPUT_BUFFER - 1, child_stderr)) 148 if (fgets(buf, MAX_INPUT_BUFFER - 1, child_stderr)) {
141 result = max_state(result, STATE_WARNING); 149 result = max_state(result, STATE_WARNING);
150 }
142 151
143 /* close stderr */ 152 /* close stderr */
144 (void)fclose(child_stderr); 153 (void)fclose(child_stderr);
@@ -153,8 +162,10 @@ void print_help(void) {
153 printf(COPYRIGHT, copyright, email); 162 printf(COPYRIGHT, copyright, email);
154 163
155 printf("%s\n", _("This plugin wraps the text output of another command (plugin) in HTML <A>")); 164 printf("%s\n", _("This plugin wraps the text output of another command (plugin) in HTML <A>"));
156 printf("%s\n", _("tags, thus displaying the child plugin's output as a clickable link in compatible")); 165 printf("%s\n",
157 printf("%s\n", _("monitoring status screen. This plugin returns the status of the invoked plugin.")); 166 _("tags, thus displaying the child plugin's output as a clickable link in compatible"));
167 printf("%s\n",
168 _("monitoring status screen. This plugin returns the status of the invoked plugin."));
158 169
159 printf("\n\n"); 170 printf("\n\n");
160 171
@@ -164,7 +175,8 @@ void print_help(void) {
164 175
165 printf("\n"); 176 printf("\n");
166 printf("%s\n", _("Examples:")); 177 printf("%s\n", _("Examples:"));
167 printf("%s\n", _("Pay close attention to quoting to ensure that the shell passes the expected")); 178 printf("%s\n",
179 _("Pay close attention to quoting to ensure that the shell passes the expected"));
168 printf("%s\n\n", _("data to the plugin. For example, in:")); 180 printf("%s\n\n", _("data to the plugin. For example, in:"));
169 printf(" %s\n\n", _("urlize http://example.com/ check_http -H example.com -r 'two words'")); 181 printf(" %s\n\n", _("urlize http://example.com/ check_http -H example.com -r 'two words'"));
170 printf(" %s\n", _("the shell will remove the single quotes and urlize will see:")); 182 printf(" %s\n", _("the shell will remove the single quotes and urlize will see:"));