Handle hostnames with upper-case letters
[webmin.git] / status / squid-monitor.pl
1 # squid-monitor.pl
2 # Monitor the squid server on this host
3
4 # Check the PID file to see if squid is running
5 sub get_squid_status
6 {
7 return { 'up' => -1 } if (!&foreign_check($_[1]));
8 &foreign_require($_[1], "squid-lib.pl");
9 return { 'up' => -1 } if (!&foreign_check($_[1]));
10 local %sconfig = &foreign_config($_[1]);
11 return { 'up' => -1 } if (!-r $sconfig{'squid_conf'});
12 local $conf = &foreign_call($_[1], "get_config");
13 local $str = &foreign_call($_[1], "find_config", "pid_filename", $conf);
14 local $file;
15 if ($str) {
16         $file = $str->{'values'}->[0];
17         }
18 else {
19         $file = $sconfig{'pid_file'};
20         }
21 if (open(PID, $file) && <PID> =~ /(\d+)/ && kill(0, $1)) {
22         close(PID);
23         local @st = stat($file);
24         return { 'up' => 1,
25                  'desc' => &text('up_since', scalar(localtime($st[9]))) };
26         }
27 else {
28         return { 'up' => 0 };
29         }
30 }
31
32 sub parse_squid_dialog
33 {
34 &depends_check($_[0], "squid");
35 }
36
37 1;
38