Proposed patch to allow checknow via the web interface
Matt.A.Cleveland at healthnet.com
Matt.A.Cleveland at healthnet.com
Mon May 9 11:18:16 EDT 2005
I see that attachments don't make it through the list server, so here is
the text of the patches.
First for the file cgi
--- src/cgi Wed Apr 20 17:55:32 2005
+++ src/cgi.mod Mon Apr 25 14:32:32 2005
@@ -54,6 +54,7 @@
flushcache => [\&web_flushcache, 1 ],
about => [\&web_about, 1 ],
dispconf => [\&web_getconf, 1 ],
+ checknow => [\&web_checknow, 1 ],
annotate => [\&web_annotate, 1 ],
rmannotate => [\&web_annotate, 1 ],
override => [\&web_override, 1 ],
@@ -570,6 +571,41 @@
print "</PRE>\n";
$me->endpage();
}
+
+sub web_checknow {
+ my $me = shift;
+ my( $obj, $r, $k, $v );
+
+ $obj = decode( $me->{q}->param('object') );
+ return unless $me->check_acl_func($obj, 'checknow', 1);
+ $r = $argusd->command_raw( func => 'checknow',
+ object => encode($obj),
+ );
+ return $me->error( "unable to connect to server" ) unless $r;
+ return $me->error( "Unable to access <I>$obj</I><BR>$r" ) unless
$r->{resultcode} = 200;
+ $r = $argusd->command( func => 'about',
+ object => encode($obj),
+ );
+ return $me->error( "unable to connect to server" ) unless $r;
+ return $me->error( "Unable to access <I>$obj</I><BR>$r" ) unless
$r->{resultcode} = 200;
+
+ $me->startpage( "Checknow: $obj" );
+ print "<p>Check ok<br/>\n";
+ print "<a href=\"?object=", encode($obj),
";func=about\">debug</a><br/>\n";
+ print "<a href=\"?object=", encode($obj), ";func=page\">back to
object</a><br/>\n";
+ foreach $k (sort keys %$r){
+ if ($k eq 'test::currvalue' || $k eq 'status'){
+ $v = $r->{$k};
+ $v =~ s/~x([01234567].)/chr(hex($1))/ge;
+ $v =~ s/&/\&\;/g;
+ $v =~ s/</\<\;/g;
+ $v =~ s/>/\>\;/g;
+ print "<pre>$k = $v</pre><br/>\n";
+ }
+ }
+ print "</p>";
+ $me->endpage();
+}
sub web_flushcache {
my $me = shift
Next for the file MonEl.pm
--- src/MonEl.pm Wed Apr 20 17:55:27 2005
+++ /usr/local/argus/lib/MonEl.pm Mon Apr 25 14:29:16 2005
@@ -170,6 +170,12 @@
attrs => ['config', 'inherit', 'bool'],
default => 'no',
},
+ web_checknow => {
+ descr => 'should checknow function be displayed on the web page -
default is no for groups and yes for services',
+ attrs => ['config', 'inherit', 'bool'],
+ # default varies by object, Services=>yes, Group=>no
+ versn => '3.4',
+ },
# Change the gravitational constant of the universe!
# -- Q, Star Trek TNG
gravity => {
@@ -553,6 +559,12 @@
versn => '3.1',
html => 'acl',
},
+ acl_checknow => {
+ descr => 'extended mode access control list - execute check now
function',
+ attrs => ['config', 'acl'],
+ versn => '3.4',
+ html => 'acl',
+ },
acl_flush => {
descr => 'extended mode access control list - flush page access',
attrs => ['config', 'acl'],
@@ -954,7 +966,7 @@
# the specified simple set
#
# user, staff, root =>
-# page, about, getconf, flush, override, annotate, logfile, ntfylist,
ntfyack, ntfyackall, ntfydetail
+# page, about, getconf, checknow, flush, override, annotate, logfile,
ntfylist, ntfyack, ntfyackall, ntfydetail
sub init_acls {
my $me = shift;
@@ -965,6 +977,7 @@
$me->{acl_about} =
$me->{acl_getconf} =
+ $me->{acl_checknow} =
$me->{acl_flush} =
$me->{acl_ntfyackall} = $me->{acl_root};
Next for Service.pm
--- src/Service.pm Wed Apr 20 17:55:29 2005
+++ /usr/local/argus/lib/Service.pm Mon Apr 25 13:24:35 2005
@@ -303,6 +303,7 @@
unless( $me->{notify}{sendnotify2} ){
$me->{notify}{sendnotify} = 0;
}
+ $me->{web_checknow} = 1 unless defined $me->{web_checknow};
$cf->warning( "test frequency is less than retrydelay" )
if $me->{srvc}{retrydelay} && $me->{srvc}{frequency} <
$me->{srvc}{retrydelay};
Last for Web.pm
--- src/Service.pm Wed Apr 20 17:55:29 2005
+++ /usr/local/argus/lib/Service.pm Mon Apr 25 13:24:35 2005
@@ -303,6 +303,7 @@
unless( $me->{notify}{sendnotify2} ){
$me->{notify}{sendnotify} = 0;
}
+ $me->{web_checknow} = 1 unless defined $me->{web_checknow};
$cf->warning( "test frequency is less than retrydelay" )
if $me->{srvc}{retrydelay} && $me->{srvc}{frequency} <
$me->{srvc}{retrydelay};
Matt Cleveland
Sr. Web Developer
HealthNet Inc.
916.935.1248
matt.cleveland at healthnet.com
Matt.A.Cleveland at he
althnet.com To: arguslist at tcp4me.com
Sent by: cc:
arguslist-bounces at t Subject: Proposed patch to allow checknow via the web interface
cp4me.com
05/09/2005 07:33 AM
Please respond to
Discussion about
Argus
I have been configuring Argus in our environment here for a couple of
weeks, and I'm really pleased with it. I like the new checknow function in
3.4, but I would like to have it exposed via the web pages and I have done
a bit of coding to expose it. Here is a set of patch files for my changes.
These patches are against the code in version 3.4 RC-20050419. Can this be
added to the source, and can we have a new RC build with this in it?
(See attached file: Web.pm.patch)(See attached file: MonEl.pm.patch)(See
attached file: Service.pm.patch)(See attached file: cgi.patch)
Matt Cleveland
Sr. Web Developer
HealthNet Inc.
916.935.1248
matt.cleveland at healthnet.com
This message,together with any attachments, is
intended only for the use of the individual or entity
to which it is addressed. It may contain information
that is confidential and prohibited from disclosure.
If you are not the intended recipient, you are hereby
notified that any dissemination or copying of this
message or any attachment is strictly prohibited. If
you have received this message in error, please notify
the original sender immediately by telephone or by
return e-mail and delete this message, along with any
attachments, from your computer. Thank you.
More information about the Arguslist
mailing list