Cover V06, I09
Article
Listing 1
Listing 2
Listing 3
Listing 4

sep97.tar


Listing 1: Perl script to produce a GIF file from a xmd data file

SNMPtoweb.pl (line numbers are shown here for reference only)

1   #!/usr/local/bin/perl5
2   ####################################################################
3   # @(#) SNMPtoweb.pl
4   # script to print an HP Openview map then convert that to a ppm
5   # graphic image and finally convert to a gif file for web viewing
6   # Steven Brown / Network Systems Integrator /  Paranet
7   ####################################################################
8   Open open(LOGFILE,">>/opt/paranet/src/scripts/logfile") || die "Cannot create log file";
9   ########################
10  # Transpose xnmpgrah to a xwd file
11  # Collecting SNMPinpkts, cpu utilization, disk utilization
12  ########################
13
14  `/opt/OV/bin/xnmgraph -mib ".1.3.6.1.2.25.1.10::1::::::" -displayWidth "7d" -printOnly -printCommand "cat > /opt/paranet/src/scripts/SNMPin.xwd" server 2 >>/opt/paranet/src/scripts/logfile`;
15  `/opt/OV/bin/xnmgraph -mib ".1.3.6.1.4.1.110.5.4.2.10::0::::::" -displayWidth "7d" -printOnly -printCommand "cat > /opt/paranet/src/scripts/cpu.xwd" server 2>>/opt/paranet/src/scripts/logfile`;
16  `/opt/OV/bin/xnmgraph -mib "Disk%util::::::::" -displayWidth "7d" -print Only -printCommand "cat > /opt/paranet/src/scripts/disk.xwd" server 2>>/opt/paranet /src/scripts/logfile`;
17  `/opt/OV/bin/xnmgraph -mib "EA_negFreeSwap::::::::" -displayWidth "7d" - printOnly -printCommand "cat > /opt/paranet/src/scripts/swap.xwd" server 2>>/opt /paranet/src/scripts/logfile`;
18
19  ########################
20  # Convert xwd files to pnm formatted file
21  #
22  ########################
23  `/usr/local/bin/xwdtopnm  < /opt/paranet/src/scripts/SNMPin.xwd 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/SNMPin.pnm`;
24  `/usr/local/bin/xwdtopnm  < /opt/paranet/src/scripts/cpu.xwd 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/cpu.pnm`;
25  `/usr/local/bin/xwdtopnm  < /opt/paranet/src/scripts/disk.xwd 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/disk.pnm`;
26  `/usr/local/bin/xwdtopnm  < /opt/paranet/src/scripts/swap.xwd 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/swap.pnm`;
27
28
29  ########################
30  # Make a miniature version of the file(s)
31  #
32  ########################
33  `/usr/local/bin/pnmscale -xscale 0.3 -yscale 0.2 < /opt/paranet/src/scripts/SNMPin.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/SNMPin_icon.pnm`;
34  `/usr/local/bin/pnmscale -xscale 0.3 -yscale 0.2 < /opt/paranet/src/scripts/cpu.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/cpu_icon.pnm`;
35  `/usr/local/bin/pnmscale -xscale 0.3 -yscale 0.2 < /opt/paranet/src/scripts/disk.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/disk_icon.pnm`;
36  `/usr/local/bin/pnmscale -xscale 0.3 -yscale 0.2 < /opt/paranet/src/scripts/swap.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/swap_icon.pnm`;
37
38  ########################
39  # Make the pnm files brighter
40  #
41  ########################
42  `/usr/local/bin/pnmgamma  35 < /opt/paranet/src/scripts/SNMPin_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/t_SNMPin_icon.pnm`;
43  `/usr/local/bin/pnmgamma  35 < /opt/paranet/src/scripts/cpu_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/t_cpu_icon.pnm`;
44  `/usr/local/bin/pnmgamma  35 < /opt/paranet/src/scripts/disk_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/t_disk_icon.pnm`;
45  `/usr/local/bin/pnmgamma  35 < /opt/paranet/src/scripts/swap_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/t_swap_icon.pnm`;
46  ########################
47  # Check for colors in icon file(s)
48  #
49  ########################
50  `/usr/local/bin/ppmquant 256 < /opt/paranet/src/scripts/t_SNMPin_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/tmp_SNMPin_icon.pnm`;
51  `/usr/local/bin/ppmquant 256 < /opt/paranet/src/scripts/t_cpu_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/tmp_cpu_icon.pnm`;
52  `/usr/local/bin/ppmquant 256 < /opt/paranet/src/scripts/t_disk_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/tmp_disk_icon.pnm`;
53  `/usr/local/bin/ppmquant 256 < /opt/paranet/src/scripts/t_swap_icon.pnm 2>>/opt/paranet/src/scripts/logfile> /opt/paranet/src/scripts/tmp_swap_icon.pnm`;
54
55  ########################
56  # Convert pnm files to gif files
57  #
58  ########################
59  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts/SNMPin.pnm 2>>/opt/paranet/src/scripts/logfile> SNMPin.gif`;
60  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts /tmp_SNMPin_icon.pnm 2>>/opt/paranet/src/scripts/logfile> SNMPin_icon.gif`;
61  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts/cpu.pnm 2>>/opt/paranet/src/scripts/logfile> cpu.gif`;
62  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts/tmp_cpu_icon.pnm 2>>/opt/paranet/src/scripts/logfile> cpu_icon.gif`;
63  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts/disk.pnm 2>>/opt/paranet/src/scripts/logfile> disk.gif`;
64  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts/tmp_disk_icon.pnm 2>>/opt/paranet/src/scripts/logfile> disk_icon.gif`;
65  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts/swap.pnm 2>>/opt/paranet/src/scripts/logfile> swap.gif`;
66  `/usr/local/bin/ppmtogif < /opt/paranet/src/scripts/tmp_swap_icon.pnm 2>>/opt/paranet/src/scripts/logfile> swap_icon.gif`;
67
68  ########################
70  # Change ownership and move gif images to proper directories
71  ########################
72  `chown http *.gif`;
73  `chgrp http *.gif`;
74
75  `mv SNMPin_icon.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
76  `mv cpu_icon.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
77  `mv disk_icon.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
78  `mv swap_icon.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
79  `mv SNMPin.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
80  `mv cpu.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
81  `mv disk.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
82  `mv swap.gif /opt/hppd/etc/httpd/www/SNMPgifs 2>>/opt/paranet/src/scripts/logfile`;
83
84  ########################
85  # Remove xwd file(s)
86  ########################
87  `rm /opt/paranet/src/scripts/t*`;
88  `rm /opt/paranet/src/scripts/SNMPin*`;
89  `rm /opt/paranet/src/scripts/cpu.*`;
90  `rm /opt/paranet/src/scripts/cpu_icon.*`;
91  `rm /opt/paranet/src/scripts/disk.*`;
92  `rm /opt/paranet/src/scripts/swap.*`;
93  `rm /opt/paranet/src/scripts/swap_icon.*`;

# End of File