Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| addons:hobbitnotes [2017/12/05 02:09] – [bbnote_editor.cgi for 4.3] wikiadmin | addons:hobbitnotes [2017/12/05 05:54] (current) – [Xymon Notes Editor] wikiadmin | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| ^ Requirements | Perl, HTML:: | ^ Requirements | Perl, HTML:: | ||
| ^ Download | None | | ^ Download | None | | ||
| - | ^ Last Update | 2012-01-03 | | + | ^ Last Update | 2017-12-05 | |
| ===== Description ===== | ===== Description ===== | ||
| Line 89: | Line 89: | ||
| <!-- | <!-- | ||
| - | | + | |
| - | weekDayName = new Array (" | + | weekDayName = new Array (" |
| - | monthName = new Array (" | + | monthName = new Array (" |
| - | | + | |
| - | + | document.write(weekDayName[today.getDay()]+ ", " + monthName[today.getMonth()] + " " + today.getDate()+ " " + " " + today.getHours() + ":" | |
| - | | + | } |
| - | document.write(weekDayName[today.getDay()]+ ", " + monthName[today.getMonth()] + " " + today.getDate()+ " " + " " + today.getHours() + ":" | + | |
| - | } | + | |
| --> | --> | ||
| Line 103: | Line 101: | ||
| <style type=" | <style type=" | ||
| - | | + | |
| - | background-repeat: | + | background-repeat: |
| - | background-color: | + | background-color: |
| - | | + | |
| </ | </ | ||
| Line 117: | Line 115: | ||
| <!-- The favicon image --> | <!-- The favicon image --> | ||
| - | <link rel=" | + | <link rel=" |
| </ | </ | ||
| - | |||
| - | <BODY class="& | ||
| <BODY BGCOLOR="& | <BODY BGCOLOR="& | ||
| + | & | ||
| + | |||
| + | <TABLE SUMMARY=" | ||
| + | < | ||
| + | <TR> | ||
| + | <TD VALIGN=MIDDLE ALIGN=LEFT WIDTH=" | ||
| + | <FONT FACE=" | ||
| + | </TD> | ||
| + | <TD VALIGN=MIDDLE ALIGN=CENTER WIDTH=" | ||
| + | < | ||
| + | </TD> | ||
| + | <TD VALIGN=MIDDLE ALIGN=RIGHT WIDTH=" | ||
| + | < | ||
| + | </TD> | ||
| + | </TR> | ||
| + | <TR> | ||
| + | <TD COLSPAN=3> | ||
| + | </TR> | ||
| + | </ | ||
| + | <BR> | ||
| - | <TABLE SUMMARY=" | ||
| - | < | ||
| - | <TR> | ||
| - | <TD VALIGN=MIDDLE ALIGN=LEFT WIDTH=" | ||
| - | <FONT FACE=" | ||
| - | </TD> | ||
| - | <TD VALIGN=MIDDLE ALIGN=CENTER WIDTH=" | ||
| - | < | ||
| - | </TD> | ||
| - | <TD VALIGN=MIDDLE ALIGN=RIGHT WIDTH=" | ||
| - | < | ||
| - | </TD> | ||
| - | </TR> | ||
| - | <TR> | ||
| - | <TD COLSPAN=3> | ||
| - | </TR> | ||
| - | </ | ||
| - | <BR> | ||
| </ | </ | ||
| </ | </ | ||
| Line 180: | Line 178: | ||
| <hidden onHidden=" | <hidden onHidden=" | ||
| <code html> | <code html> | ||
| - | < | + | |
| - | <TABLE SUMMARY=" | + | |
| - | < | + | < |
| - | <TD> <HR WIDTH=" | + | <TD> <HR WIDTH=" |
| - | </ | + | </ |
| - | < | + | < |
| - | <TD ALIGN=RIGHT>< | + | <TD ALIGN=RIGHT>< |
| - | </ | + | </ |
| - | </ | + | </ |
| </ | </ | ||
| Line 459: | Line 457: | ||
| <code perl> | <code perl> | ||
| # | # | ||
| - | + | # | |
| ############################################# | ############################################# | ||
| # Name: bbnote_editor.cgi | # Name: bbnote_editor.cgi | ||
| Line 467: | Line 465: | ||
| # Version: 1.0 | # Version: 1.0 | ||
| # The text2html module can be downloaded from CPAN ############################################# | # The text2html module can be downloaded from CPAN ############################################# | ||
| - | + | ||
| use strict; | use strict; | ||
| use CGI ": | use CGI ": | ||
| use HTML:: | use HTML:: | ||
| - | |||
| # Your $XYMONHOME | # Your $XYMONHOME | ||
| - | my $xymon_home = "/home/xymon/server"; | + | my $xymon_home = "/usr/share/ |
| - | # hobbit config file | + | my $xymon_cmd |
| - | my $xymoncfg=" | + | # xymon config file |
| - | # The web path to gifs. | + | my $xymoncfg |
| - | my $xymon_gifs | + | |
| - | my $xymon_web | + | # The actual www notes dir on the server |
| - | + | my $xymon_notes | |
| - | # The actual www notes dir on the server | + | |
| - | my $xymon_notes | + | |
| # Not to be confused with the default notes dir. | # Not to be confused with the default notes dir. | ||
| - | my $xymon_notesdata | + | my $xymon_notesdata |
| my $xymon_header = " | my $xymon_header = " | ||
| my $xymon_footer = " | my $xymon_footer = " | ||
| + | |||
| #Standard hosts.cfg file | #Standard hosts.cfg file | ||
| - | my $xymon_hosts = " | + | my $xymon_hosts = " |
| - | my $xymon_showhosts | + | my $xymon_menu |
| - | + | ||
| # No changes needed below. | # No changes needed below. | ||
| - | my $version = "4.3.5"; | + | my $version = "4.3.28"; |
| my $color = " | my $color = " | ||
| my %hosts; | my %hosts; | ||
| Line 501: | Line 497: | ||
| my $note = param(" | my $note = param(" | ||
| my @lines; | my @lines; | ||
| - | + | ||
| - | # Set up the environment variables and dynamic variables from xymonserver.cfg | + | # Set up the environment variables and dynamic variables from xymonserver.cfg |
| - | foreach (`. $xymoncfg; set`) { | + | foreach (`$xymon_home/ |
| - | chomp; | + | chomp; |
| - | my ($var,$val) = / | + | next if $_ =~ / |
| - | $ENV{$var} | + | |
| + | $ENV{$var} = $val; | ||
| } | } | ||
| - | $ENV{' | ||
| - | |||
| sub print_notesdata { | sub print_notesdata { | ||
| - | | + | |
| - | while (< | + | while (< |
| - | print; | + | print; |
| - | } | + | } |
| - | close NOTESDATA; | + | close NOTESDATA; |
| } | } | ||
| - | + | ||
| sub write_notesdata { | sub write_notesdata { | ||
| - | | + | |
| - | print NOTESDATA $note; | + | print NOTESDATA $note; |
| - | close NOTESDATA; | + | close NOTESDATA; |
| } | } | ||
| - | + | ||
| sub make_note { | sub make_note { | ||
| - | | + | |
| - | my $note = " | + | my $note = " |
| - | + | ||
| - | open (NOTE, "> | + | open (NOTE, "> |
| - | select NOTE; | + | select NOTE; |
| - | & | + | & |
| - | & | + | & |
| - | & | + | & |
| - | select STDOUT; | + | select STDOUT; |
| - | close NOTE; | + | close NOTE; |
| - | + | ||
| } | } | ||
| - | + | ||
| sub save_note { | sub save_note { | ||
| - | | + | |
| - | & | + | & |
| - | & | + | & |
| - | print '< | + | print '< |
| - | & | + | & |
| } | } | ||
| - | + | ||
| sub edit_note { | sub edit_note { | ||
| - | | + | |
| - | my $t2h = HTML:: | + | my $t2h = HTML:: |
| - | blockcode | + | blockcode |
| - | lines => 1, | + | lines => 1, |
| - | tables | + | tables |
| - | bullets | + | bullets |
| - | numbers | + | numbers |
| - | urls => 1, | + | urls => 1, |
| - | email => 1, | + | email => 1, |
| - | bold => 1, | + | bold => 1, |
| - | underline | + | underline |
| - | }); | + | }); |
| - | $note = $t2h-> | + | $note = $t2h-> |
| - | #$note =~ s/ | + | #$note =~ s/ |
| - | + | } | |
| - | | + | |
| - | if ($cmd =~ /strip html/) { | + | |
| - | $note =~ s/< | + | $note =~ s/< |
| - | } | + | } |
| - | print << | + | |
| - | < | + | |
| - | < | + | < |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | <TR> | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| HTML | HTML | ||
| - | if ($note) { | + | |
| print $note; | print $note; | ||
| - | } elsif ($lines[0]) { | + | |
| print @lines; | print @lines; | ||
| - | } else { | + | |
| print '< | print '< | ||
| print << | print << | ||
| - | </ | + | |
| - | <input name=" | + | <input name=" |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| HTML | HTML | ||
| } | } | ||
| - | + | ||
| sub print_note { | sub print_note { | ||
| + | print << | ||
| + | < | ||
| + | <TABLE WIDTH=" | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | <TR> | ||
| + | <TD> | ||
| + | HTML | ||
| + | if ($lines[0]) { | ||
| + | print @lines; | ||
| print << | print << | ||
| - | < | + | |
| + | </ | ||
| + | < | ||
| + | <TD ALIGN=" | ||
| + | | ||
| + | <input type="hidden" | ||
| HTML | HTML | ||
| - | if ($lines[0]) { | + | } elsif ($cmd =~ /preview/) { |
| - | print @lines; | + | print << |
| - | | + | |
| - | </ | + | |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| HTML | HTML | ||
| - | | + | |
| - | print << | + | print << |
| - | $note</ | + | The are no notes for $host [$hosts{$host}]. |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| HTML | HTML | ||
| - | } else { | + | |
| - | print << | + | |
| - | The are no notes for $host [$hosts{$host}].</ | + | |
| - | HTML | + | |
| - | } | + | |
| print << | print << | ||
| - | <input type=" | + | |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| HTML | HTML | ||
| } | } | ||
| - | + | # | |
| sub print_error { | sub print_error { | ||
| - | | + | |
| - | print "< | + | print "< |
| } | } | ||
| - | + | ||
| sub get_note { | sub get_note { | ||
| - | | + | |
| - | open (NOTE, "< | + | open (NOTE, "< |
| - | while (my $note = < | + | while (my $note = < |
| - | push @lines, $note; | + | push @lines, $note; |
| - | } | + | |
| - | close NOTE; | + | |
| } | } | ||
| + | close NOTE; | ||
| + | } | ||
| } | } | ||
| - | + | ||
| - | sub print_menu{ | + | sub print_menu { |
| - | print '< | + | print '< |
| - | for my $host(sort keys %hosts) { | + | for my $host(sort keys %hosts) { |
| - | print << | + | print << |
| < | < | ||
| - | < | + | < |
| HTML | HTML | ||
| - | | + | |
| - | print '</ | + | print '</ |
| } | } | ||
| - | + | ||
| - | sub get_hosts{ | + | sub get_hosts { |
| - | open (HOSTS, " | + | open (HOSTS, " |
| - | while (< | + | while (< |
| - | | + | |
| - | $hosts{$2} = $1; | + | $hosts{$hostname} = $hostip; |
| - | } | + | } |
| - | } | + | close HOSTS; |
| - | | + | |
| } | } | ||
| - | + | ||
| sub print_header { | sub print_header { | ||
| - | | + | |
| - | print " | + | print " |
| - | open (HEAD, "< | + | open (HEAD, "< |
| - | while (< | + | while (< |
| - | | + | # It's a bit hard to edit with a refresh ;) |
| - | if (/META/i && / | + | if (/META/i && / |
| - | s/& | + | s/& |
| - | s/& | + | s/& |
| - | s/& | + | |
| - | s/& | + | s/& |
| - | s/& | + | |
| - | s/& | + | s/& |
| + | s/& | ||
| + | s/& | ||
| + | |||
| + | if (/& | ||
| + | s/& | ||
| + | open (MENU, "< | ||
| + | while (< | ||
| + | s/ | ||
| + | s/ | ||
| + | s/ | ||
| print; | print; | ||
| + | } | ||
| + | close MENU; | ||
| } | } | ||
| - | close HEAD; | + | |
| + | } | ||
| + | | ||
| } | } | ||
| - | + | ||
| - | sub print_footer{ | + | sub print_footer { |
| - | open (FOOT, "< | + | open (FOOT, "< |
| - | while (< | + | while (< |
| - | s/& | + | s/& |
| - | s/& | + | s/& |
| - | print; | + | print; |
| - | } | + | } |
| - | close FOOT; | + | close FOOT; |
| } | } | ||
| - | + | ||
| # Main | # Main | ||
| my ($oldbar) = $|; | my ($oldbar) = $|; | ||
| my $cfh = select (STDOUT); | my $cfh = select (STDOUT); | ||
| $| = 1; | $| = 1; | ||
| - | |||
| & | & | ||
| & | & | ||
| if ($cmd =~ / | if ($cmd =~ / | ||
| - | | + | |
| - | & | + | & |
| } elsif ($cmd eq ' | } elsif ($cmd eq ' | ||
| - | | + | |
| - | & | + | & |
| } elsif ($cmd eq ' | } elsif ($cmd eq ' | ||
| - | | + | |
| } elsif ($cmd eq ' | } elsif ($cmd eq ' | ||
| - | | + | |
| } elsif ($cmd eq ' | } elsif ($cmd eq ' | ||
| - | | + | |
| } else { | } else { | ||
| - | | + | |
| } | } | ||
| - | + | ||
| & | & | ||
| - | + | ||
| $| = $oldbar; | $| = $oldbar; | ||
| - | select ($cfh); | + | select ($cfh); |
| </ | </ | ||
| </ | </ | ||