1 | 1 | simandl | package HotSaNICmod::common; |
2 | | | |
3 | | | sub version { |
4 | | | ($VERSION = '$Revision: 1.4 $') =~ s/.*(\d+\.\d+).*/$1/; |
5 | | | return "common.pm $VERSION"; |
6 | | | } |
7 | | | |
8 | | | sub configure { |
9 | | | my %MODCONF=HotSaNICparser::get_moduleconfig(".",(NTPCOMMAND=>"var",HOST=>"array")); |
10 | | | |
11 | | | if (!@{$MODCONF{HOST}}) { @{$MODCONF{HOST}}=("localhost,local system"); } |
12 | | | if ($MODCONF{NTPCOMMAND} eq "") { |
13 | | | my @list=HotSaNICparser::locate_files("bin/ntpdc"); |
14 | | | if (! @list) { @list=HotSaNICparser::locate_files("bin/xntpdc"); } |
15 | | | $MODCONF{NTPCOMMAND}=pop @list; |
16 | | | } |
17 | | | |
18 | | | return %MODCONF; |
19 | | | } |
20 | | | |
21 | | | sub get_names { |
22 | | | my $entry=shift || ","; |
23 | | | my $item=shift || ""; |
24 | | | my $community=""; |
25 | | | |
26 | | | my %DESCR=(""=>"","stratum"=>"stratum","distance"=>"root distance","dispersion"=>"root dispersion","frequency"=>"frequency error","stability"=>"stability"); |
27 | | | |
28 | | | my ($host,$description)=split /,/,$entry; |
29 | | | if ($host eq "") { |
30 | | | $dbname="time"; |
31 | | | $file=$item; |
32 | | | $name=$item; |
33 | | | $description=$DESCR{$item}; |
34 | | | } |
35 | | | else { |
36 | | | ($dbname=$host) =~ s/:/_/g; |
37 | | | ($file="$host-$item") =~ s/[.:]/_/g; |
38 | | | $name="$host-$item"; |
39 | | | $description="$DESCR{$item} on $host"; |
40 | | | } |
41 | | | return ($host,$community,$item,$dbname,$name,$file,$description); |
42 | | | } |
43 | | | 1; |
44 | | | |