Debian Codegraph @

contrib/ovmrtg/ovupdate

raw
1 #!/usr/local/bin/perl5
2 # -*- mode: Perl -*-
3 ##################################################################
4 # This file controls the creation of all the MRTG config files from OV
5 ##################################################################
6 # Created by Laurie Gellatly <[email protected]>
7 # See newrtrov.txt for a description of what is performed
8 #################################################################
9 #
10 # Distributed under the GNU copyleft
11 #
12 # $Id: ovupdate,v 1.1.1.1 2002/02/26 10:16:36 oetiker Exp $
13 #
14 use Socket;
15 use strict;
16 use ovmrtg;
17 use vars '$DEBUG';
18 my $DEBUG = 0;
19 my $rundir = "/opt/mrtg/run";
20 my $cronfile = "mrtgc";
21 my $dnsfile = "ovmrtgc.csv";
22
23
24 my($sysncfg,$cnt);
25 my(@sysipnms,@sysips,@mrtgc,@sysnms);
26
27 sub main {
28
29 chdir $rundir;
30 $cnt = 0;
31 open (MRTGC,"<".$cronfile);
32 while(<MRTGC>){
33 chomp;
34 if (/mrtg (.*)\.cfg/){
35 $mrtgc[@mrtgc] = $1;
36 }
37 }
38 close (MRTGC);
39 @mrtgc = sort(@mrtgc);
40 for($cnt=0;$cnt<@mrtgc;++$cnt){
41 $sysncfg=$mrtgc[$cnt].".cfg";
42 open (MRTGC,"<".$sysncfg);
43 while(<MRTGC>){
44 if (/^Target/){
45 if (/^Target.*ovcvtfile ([0-9\.]*)/){
46 $sysips[@sysips] = $1;
47 last;
48 }
49 if (/^Target.*\@([0-9\.]*)/){
50 $sysips[@sysips] = $1;
51 last;
52 }
53 }
54 }
55 close (MRTGC);
56 }
57 @sysipnms=ovsysnms @sysips;
58
59 open (DNSFILE,">".$dnsfile);
60 for ($cnt = 0; $cnt < @sysipnms ; $cnt++){
61 # $sysipnms[$cnt] =~ s/ /,/;
62 print DNSFILE "$sysipnms[$cnt]\n";
63 }
64 close (DNSFILE);
65 }
66 main;
67 exit(0);
68