mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 17:59:20 -04:00
Hawk is a web based utility for monitoring and comparing hosts on your
network with what is in DNS. Hosts that are answering pings but are not in DNS may be unauthorized, and addresses in DNS which are not answering may be able to be reclaimed. Hawk monitors all hosts on the networks you specify and lets you view them via a web page. Hawk consists of a backend written in Perl that monitors hosts by ICMP pings and writes the status to a mysql database. The frontend is in PHP and lets you select which network to view, and how to view it. This version has several enhancements to the original; including cleaner Perl code, a user-definable string to designate unused addresses that are in DNS, testing that the forward and reverse hostnames match, and the daemon forks one process pre subnet. WWW: http://sourceforge.net/projects/iphawk/
This commit is contained in:
parent
1938e3e48f
commit
6aaa224ddf
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=290513
12 changed files with 581 additions and 0 deletions
|
@ -81,6 +81,7 @@
|
|||
SUBDIR += grepip
|
||||
SUBDIR += gsnmp
|
||||
SUBDIR += hastmon
|
||||
SUBDIR += hawk
|
||||
SUBDIR += horde-nic
|
||||
SUBDIR += icinga
|
||||
SUBDIR += icmpmonitor
|
||||
|
|
71
net-mgmt/hawk/Makefile
Normal file
71
net-mgmt/hawk/Makefile
Normal file
|
@ -0,0 +1,71 @@
|
|||
# New ports collection makefile for: hawk
|
||||
# Date created: 06 February 2012
|
||||
# Whom: Doug Barton <dougb@FreeBSD.org>
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= hawk
|
||||
PORTVERSION= 0.6
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net-mgmt
|
||||
MASTER_SITES= SF/iphawk/iphawk/Hawk%20${PORTVERSION}/
|
||||
|
||||
MAINTAINER= dougb@FreeBSD.org
|
||||
COMMENT= Track uptime and DNS status for machines on your networks
|
||||
|
||||
RUN_DEPENDS= ${SITE_PERL}/Net/Netmask.pm:${PORTSDIR}/net-mgmt/p5-Net-Netmask \
|
||||
${SITE_PERL}/Net/Ping/External.pm:${PORTSDIR}/net/p5-Net-Ping-External \
|
||||
${SITE_PERL}/${PERL_ARCH}/DBI.pm:${PORTSDIR}/databases/p5-DBI \
|
||||
${SITE_PERL}/${PERL_ARCH}/DBD/mysql.pm:${PORTSDIR}/databases/p5-DBD-mysql
|
||||
|
||||
USE_PERL5= yes
|
||||
USE_MYSQL= server
|
||||
USE_PHP= mysql
|
||||
WANT_PHP_MOD= yes
|
||||
|
||||
USE_RC_SUBR= hawk
|
||||
|
||||
SUB_LIST= PERL=${PERL}
|
||||
PLIST_SUB+= WWWDIR_REL="${WWWDIR_REL}"
|
||||
|
||||
post-patch:
|
||||
@${SED} -e 's#%%PREFIX%%#${PREFIX}#' \
|
||||
${WRKSRC}/daemon/hawk > ${WRKSRC}/daemon/hawk.sed
|
||||
@${MV} ${WRKSRC}/daemon/hawk.sed ${WRKSRC}/daemon/hawk
|
||||
@${SED} -e 's#hawk.conf.inc#${PREFIX}/etc/hawk/php.conf#' \
|
||||
${WRKSRC}/php/hawk.php > ${WRKSRC}/php/hawk.php.sed
|
||||
@${MV} ${WRKSRC}/php/hawk.php.sed ${WRKSRC}/php/hawk.php
|
||||
|
||||
do-build:
|
||||
# Empty target, nothing to build
|
||||
|
||||
do-install:
|
||||
${MKDIR} ${PREFIX}/etc/hawk
|
||||
${INSTALL_DATA} ${WRKSRC}/daemon/hawk.conf ${PREFIX}/etc/hawk/daemon.conf.sample
|
||||
${INSTALL_SCRIPT} ${WRKSRC}/daemon/hawk ${PREFIX}/sbin
|
||||
${MKDIR} ${WWWDIR}/images
|
||||
(for f in ${WRKSRC}/php/images/* ${FILESDIR}/favicon.ico; do \
|
||||
${INSTALL_DATA} $$f ${WWWDIR}/images; \
|
||||
done)
|
||||
${INSTALL_DATA} ${WRKSRC}/php/hawk.php ${WWWDIR}
|
||||
${INSTALL_DATA} ${WRKSRC}/php/hawk.css ${WWWDIR}
|
||||
${INSTALL_DATA} ${WRKSRC}/php/hawk.conf.inc \
|
||||
${PREFIX}/etc/hawk/php.conf.sample
|
||||
.if !defined(NOPORTDOCS)
|
||||
@${MKDIR} ${DOCSDIR}
|
||||
${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}
|
||||
${INSTALL_DATA} ${FILESDIR}/create_hawk_db.sql ${DOCSDIR}
|
||||
${INSTALL_DATA} ${FILESDIR}/create_hawk_user.sql ${DOCSDIR}
|
||||
.endif
|
||||
|
||||
PKGMESSAGE= ${WRKDIR}/pkg-message
|
||||
|
||||
post-install:
|
||||
@${ECHO} '******************************************************************************' > ${PKGMESSAGE}
|
||||
@${ECHO} '*** See ${PREFIX}/share/doc/hawk/create_hawk* for instructions on ***' >> ${PKGMESSAGE}
|
||||
@${ECHO} '*** creating the database and user that the PHP code expects. ***' >> ${PKGMESSAGE}
|
||||
@${ECHO} '******************************************************************************' >> ${PKGMESSAGE}
|
||||
|
||||
@${CAT} ${PKGMESSAGE}
|
||||
|
||||
.include <bsd.port.mk>
|
2
net-mgmt/hawk/distinfo
Normal file
2
net-mgmt/hawk/distinfo
Normal file
|
@ -0,0 +1,2 @@
|
|||
SHA256 (hawk-0.6.tar.gz) = edd9b9bf1eb869aaa9995500dacf58ac153b923ed488f03e9eaf89380d4ab137
|
||||
SIZE (hawk-0.6.tar.gz) = 23507
|
14
net-mgmt/hawk/files/create_hawk_db.sql
Normal file
14
net-mgmt/hawk/files/create_hawk_db.sql
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Feed this file to mysql, e.g.,
|
||||
# mysql -u root -p -v < create_hawk_db.sql
|
||||
|
||||
create database hawk;
|
||||
use hawk;
|
||||
CREATE TABLE `ip` (
|
||||
`ip` char(46) NOT NULL DEFAULT '0',
|
||||
`hostname` char(255) DEFAULT NULL,
|
||||
`lastping` int(10) DEFAULT NULL,
|
||||
`for_rev_match` tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`ip`),
|
||||
UNIQUE KEY `ip` (`ip`),
|
||||
KEY `ip_2` (`ip`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Table for last ping time of hosts';
|
8
net-mgmt/hawk/files/create_hawk_user.sql
Normal file
8
net-mgmt/hawk/files/create_hawk_user.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Feed this file to mysql, e.g.,
|
||||
# mysql -u root -p -v < create_hawk_user.sql
|
||||
|
||||
grant select,insert,update,delete
|
||||
on hawk.*
|
||||
to hawk@localhost
|
||||
identified by 'YOUR_PASSWORD_HERE';
|
||||
flush privileges;
|
BIN
net-mgmt/hawk/files/favicon.ico
Normal file
BIN
net-mgmt/hawk/files/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
41
net-mgmt/hawk/files/hawk.in
Normal file
41
net-mgmt/hawk/files/hawk.in
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
#
|
||||
# PROVIDE: hawk
|
||||
# REQUIRE: LOGIN mysql
|
||||
# KEYWORD: shutdown
|
||||
#
|
||||
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
||||
# to enable this service:
|
||||
#
|
||||
# hawk_enable (bool): Set to NO by default.
|
||||
# Set it to YES to enable hawk.
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name=hawk
|
||||
rcvar=hawk_enable
|
||||
|
||||
load_rc_config hawk
|
||||
|
||||
: ${hawk_enable:="NO"}
|
||||
|
||||
command=%%PREFIX%%/sbin/hawk
|
||||
command_interpreter=%%PERL%%
|
||||
command_args='&'
|
||||
|
||||
find_pidfile()
|
||||
{
|
||||
if type get_pidfile_from_conf >/dev/null 2>&1 &&
|
||||
get_pidfile_from_conf pidfile %%PREFIX%%/etc/hawk/daemon.conf; then
|
||||
pidfile="$_pidfile_from_conf"
|
||||
else
|
||||
pidfile='/var/run/hawk.pid'
|
||||
fi
|
||||
}
|
||||
|
||||
start_precmd=find_pidfile
|
||||
stop_precmd=find_pidfile
|
||||
|
||||
run_rc_command "$1"
|
217
net-mgmt/hawk/files/patch-daemon__hawk
Normal file
217
net-mgmt/hawk/files/patch-daemon__hawk
Normal file
|
@ -0,0 +1,217 @@
|
|||
--- daemon/hawk.orig 2002-01-12 01:10:52.000000000 +0000
|
||||
+++ daemon/hawk 2012-02-05 12:31:38.000000000 +0000
|
||||
@@ -1,8 +1,9 @@
|
||||
-#!/usr/bin/perl
|
||||
+#!%%PREFIX%%/bin/perl -w
|
||||
|
||||
# hawk version 0.60
|
||||
# Greg Heim <gregheim@mindspring.com>
|
||||
|
||||
+use strict;
|
||||
|
||||
use Socket;
|
||||
use Net::Netmask;
|
||||
@@ -10,12 +11,14 @@
|
||||
use File::Basename;
|
||||
use DBI;
|
||||
|
||||
+# Variables defined in the config file
|
||||
+our (@networks, @gateways, $frequency, $pingtimeout, $debuglevel, $logfile,
|
||||
+ $dbuser, $dbpass, $dbhost, $dbname, $pidfile);
|
||||
|
||||
############################################################################
|
||||
# create pid file and process config file
|
||||
############################################################################
|
||||
-$configfile = dirname($0) . "/hawk.conf";
|
||||
-readConfigs($configfile);
|
||||
+readConfigs("%%PREFIX%%/etc/hawk/daemon.conf");
|
||||
|
||||
createPidFile($pidfile);
|
||||
|
||||
@@ -34,13 +37,24 @@
|
||||
# main loop
|
||||
##########################################################################
|
||||
LOOP: while () {
|
||||
+ my ($block, @children, $netblock, $gateway, @ips, $ip, $pingtime, $hostname);
|
||||
|
||||
- $loopstarttime = time();
|
||||
+ my $loopstarttime = time();
|
||||
|
||||
|
||||
BLOCK: foreach $block (@networks) {
|
||||
+
|
||||
+ my $pid = fork();
|
||||
+ if ($pid) {
|
||||
+ # parent
|
||||
+ push (@children, $pid);
|
||||
+ } elsif ($pid == 0) {
|
||||
+ # child
|
||||
+
|
||||
$netblock = new Net::Netmask ($block);
|
||||
|
||||
+ logMsg (2, "Forked a child process for $netblock");
|
||||
+
|
||||
# check here that gateway is up
|
||||
if (@gateways) {
|
||||
foreach $gateway (@gateways) {
|
||||
@@ -51,7 +65,7 @@
|
||||
|
||||
if (!ping($gateway, $pingtimeout)) {
|
||||
logMsg (1, "No response from gateway $gateway, skipping network $block");
|
||||
- next BLOCK;
|
||||
+ exit (0);
|
||||
}
|
||||
else {
|
||||
logMsg (1, "Gateway $gateway responded. $block ok so far.");
|
||||
@@ -90,15 +104,37 @@
|
||||
$hostname = gethostbyaddr (inet_aton($ip), AF_INET);
|
||||
$hostname = "" unless $hostname;
|
||||
|
||||
+ my $for_rev_match='0';
|
||||
+ if ($hostname) {
|
||||
+ my $packed_host_ip = gethostbyname("$hostname");
|
||||
+ if (defined $packed_host_ip) {
|
||||
+ if (inet_ntoa($packed_host_ip) =~ /^$ip$/) {
|
||||
+ $for_rev_match='1';
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
# check if it's already in the database
|
||||
# if pingtime is zero, that field isn't updated
|
||||
if (ipExists($ip)) {
|
||||
- updateRecord($ip, $hostname, $pingtime);
|
||||
+ updateRecord($ip, $hostname, $pingtime, $for_rev_match);
|
||||
}
|
||||
else {
|
||||
- insertRecord($ip, $hostname, $pingtime);
|
||||
+ insertRecord($ip, $hostname, $pingtime, $for_rev_match);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ logMsg (2, "Child process for $netblock exiting");
|
||||
+ exit (0);
|
||||
+
|
||||
+ } else {
|
||||
+ die "Couldn't fork: $!\n";
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ foreach (@children) {
|
||||
+ waitpid($_, 0);
|
||||
}
|
||||
|
||||
# sleep until it's time for another run
|
||||
@@ -121,8 +157,9 @@
|
||||
##########################################################################
|
||||
sub ipExists {
|
||||
|
||||
- ($ip) = @_;
|
||||
+ my ($ip) = @_;
|
||||
my $qip; # ip from query
|
||||
+ my ($dbh, %attr, $sth);
|
||||
|
||||
logMsg (2, "Checking database for $ip");
|
||||
|
||||
@@ -148,12 +185,13 @@
|
||||
##########################################################################
|
||||
sub insertRecord{
|
||||
|
||||
- ($ip, $hostname, $pingtime) = @_;
|
||||
+ my ($ip, $hostname, $pingtime, $for_rev_match) = @_;
|
||||
+ my ($dbh, %attr, $sth);
|
||||
|
||||
- logMsg (2, "Inserting record: IP: $ip, Hostname: $hostname, Pingtime: $pingtime");
|
||||
+ logMsg (2, "Inserting record: IP: $ip, Hostname: $hostname, Pingtime: $pingtime, Match: $for_rev_match");
|
||||
|
||||
$dbh = DBI->connect('dbi:mysql:' . $dbname . ';host='. $dbhost, $dbuser, $dbpass, \%attr) or die "Couldn't connect to database: " . DBI->errstr;
|
||||
- $sth = $dbh -> prepare("insert into hawk.ip (ip, hostname, lastping) values ('$ip', '$hostname', '$pingtime')");
|
||||
+ $sth = $dbh -> prepare("insert into hawk.ip (ip, hostname, lastping, for_rev_match) values ('$ip', '$hostname', '$pingtime', '$for_rev_match')");
|
||||
$sth -> execute or logMsg (0, "Couldn't update record!" . DBI -> errstr);
|
||||
|
||||
}
|
||||
@@ -164,15 +202,16 @@
|
||||
##########################################################################
|
||||
sub updateRecord{
|
||||
|
||||
- ($ip, $hostname, $pingtime) = @_;
|
||||
+ my ($ip, $hostname, $pingtime, $for_rev_match) = @_;
|
||||
+ my ($query, $dbh, %attr, $sth);
|
||||
|
||||
- logMsg (2, "Updating record: IP: $ip, Hostname: $hostname, Pingtime: $pingtime");
|
||||
+ logMsg (2, "Updating record: IP: $ip, Hostname: $hostname, Pingtime: $pingtime, Match: $for_rev_match");
|
||||
|
||||
if ($pingtime) {
|
||||
- $query = "update hawk.ip set hostname = '$hostname', lastping = '$pingtime' where ip = '$ip'";
|
||||
+ $query = "update hawk.ip set hostname = '$hostname', lastping = '$pingtime', for_rev_match = '$for_rev_match' where ip = '$ip'";
|
||||
}
|
||||
else {
|
||||
- $query = "update hawk.ip set hostname = '$hostname' where ip = '$ip'";
|
||||
+ $query = "update hawk.ip set hostname = '$hostname', for_rev_match = '$for_rev_match' where ip = '$ip'";
|
||||
}
|
||||
|
||||
$dbh = DBI->connect('dbi:mysql:' . $dbname . ';host='. $dbhost, $dbuser, $dbpass, \%attr) or die "Couldn't connect to database: " . DBI->errstr;
|
||||
@@ -188,14 +227,15 @@
|
||||
sub ping {
|
||||
|
||||
my ($ip, $timeout) = @_;
|
||||
+ my ($p, $return);
|
||||
|
||||
logMsg(2, "Pinging $ip");
|
||||
|
||||
- $p = Net::Ping->new(icmp);
|
||||
+ $p = Net::Ping->new('icmp');
|
||||
$return = $p->ping($ip, $timeout);
|
||||
$p->close;
|
||||
|
||||
- logMsg(2, "Ping returned $return");
|
||||
+ logMsg(2, "Ping $ip returned $return");
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -208,7 +248,7 @@
|
||||
|
||||
sub createPidFile {
|
||||
|
||||
- ($pidfile) = @_;
|
||||
+ my ($pidfile) = @_;
|
||||
|
||||
logMsg (2, "Creating pid file $pidfile");
|
||||
|
||||
@@ -219,7 +259,7 @@
|
||||
|
||||
# found pid file. signalling existing process
|
||||
logMsg (1, "Pid file $pidfile exists. Attempting to signal existing process.");
|
||||
- $kstatus = kill 0, $pid;
|
||||
+ my $kstatus = kill 0, $pid;
|
||||
|
||||
# see if we killed anything
|
||||
if ($kstatus) {
|
||||
@@ -305,9 +345,8 @@
|
||||
|
||||
sub readConfigs {
|
||||
|
||||
- ($file) = @_;
|
||||
+ my ($file) = @_;
|
||||
|
||||
- logMsg(1, "Reading config file");
|
||||
do $file;
|
||||
|
||||
}
|
||||
@@ -317,12 +356,12 @@
|
||||
##########################################################################
|
||||
# write debug messages
|
||||
##########################################################################
|
||||
-sub logMsg () {
|
||||
+sub logMsg {
|
||||
|
||||
- ($level, $message) = @_;
|
||||
+ my ($level, $message) = @_;
|
||||
if ($debuglevel >= $level) {
|
||||
|
||||
- $time = localtime(time);
|
||||
+ my $time = localtime(time);
|
||||
open LOGFILE, ">> $logfile" || die "Couldn't open logfile: $!\n";
|
||||
print LOGFILE "$time: $message\n";
|
||||
close LOGFILE;
|
26
net-mgmt/hawk/files/patch-php__hawk.conf.inc
Normal file
26
net-mgmt/hawk/files/patch-php__hawk.conf.inc
Normal file
|
@ -0,0 +1,26 @@
|
|||
--- php/hawk.conf.inc.orig 2002-01-11 17:12:30.000000000 -0800
|
||||
+++ php/hawk.conf.inc 2012-02-05 03:13:12.000000000 -0800
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
-# database info, should match what's in hawk.conf
|
||||
+# database info, should match what's in daemon.conf
|
||||
$dbuser = "";
|
||||
$dbpass = "";
|
||||
$dbhost = "mysql";
|
||||
@@ -12,7 +12,14 @@
|
||||
$yellowzone = 60 * 60 * 24;
|
||||
$redzone = 60 * 60 * 24 * 7;
|
||||
|
||||
-# networks, should match what's in hawk.conf
|
||||
+# optional hostname substring to equate to an empty hostname
|
||||
+#$purple_string = "unused.";
|
||||
+
|
||||
+# comment this out or set to 0 to not display if the forward
|
||||
+# and reverse hostnames match
|
||||
+$for_rev_check_default = 1;
|
||||
+
|
||||
+# networks, should match what's in daemon.conf
|
||||
#$networks = array (
|
||||
# "Main Network" => "192.168.64.0/22",
|
||||
# "Training Lab" => "192.168.62.0/24",
|
165
net-mgmt/hawk/files/patch-php__hawk.php
Normal file
165
net-mgmt/hawk/files/patch-php__hawk.php
Normal file
|
@ -0,0 +1,165 @@
|
|||
--- php/hawk.php.orig 2001-11-08 21:58:52.000000000 +0000
|
||||
+++ php/hawk.php 2012-02-05 12:09:21.000000000 +0000
|
||||
@@ -10,6 +10,7 @@
|
||||
# map these variables
|
||||
$sortby=$HTTP_POST_VARS["sortby"];
|
||||
$network=$HTTP_POST_VARS["network"];
|
||||
+ $for_rev_check=$HTTP_POST_VARS["for_rev_check"];
|
||||
$showeverydamnthing=$HTTP_POST_VARS["showeverydamnthing"];
|
||||
|
||||
$sortoptions = array (
|
||||
@@ -38,6 +39,18 @@
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
+ print "<br>";
|
||||
+
|
||||
+ if ($for_rev_check || ($for_rev_check_default && !$network)) {
|
||||
+ $checked = "checked";
|
||||
+ }
|
||||
+ else {
|
||||
+ $checked = "";
|
||||
+ }
|
||||
+ checkbox("for_rev_check", $checked);
|
||||
+ print " <font size=-1>Indicate if the forward and reverse hostnames match.</font>";
|
||||
+ print "<br>";
|
||||
+
|
||||
if ($showeverydamnthing) {
|
||||
$checked = "checked";
|
||||
}
|
||||
@@ -51,7 +64,6 @@
|
||||
print "</form>";
|
||||
|
||||
# href("#key", "Key");
|
||||
- print "<br>";
|
||||
|
||||
# show everything until network selection is implemented
|
||||
if ($network) {
|
||||
@@ -70,7 +82,7 @@
|
||||
#####################################################
|
||||
function shownet ($network) {
|
||||
|
||||
- global $dbuser, $dbpass, $dbhost, $dbname, $redzone, $yellowzone, $sortby, $showeverydamnthing;
|
||||
+ global $dbuser, $dbpass, $dbhost, $dbname, $redzone, $yellowzone, $sortby, $for_rev_check, $showeverydamnthing, $purple_string;
|
||||
if (!$link=@mysql_connect($dbhost, $dbuser, $dbpass)) {
|
||||
$errormsg = mysql_error();
|
||||
print urlencode($errormsg);
|
||||
@@ -87,10 +99,10 @@
|
||||
|
||||
# select them all for now
|
||||
if ($sortby == ip) {
|
||||
- $query = "select ip, hostname, lastping from hawk.ip order by inet_aton(ip)";
|
||||
+ $query = "select ip, hostname, lastping, for_rev_match from hawk.ip order by inet_aton(ip)";
|
||||
}
|
||||
else {
|
||||
- $query = "select ip, hostname, lastping from hawk.ip order by '$sortby'";
|
||||
+ $query = "select ip, hostname, lastping, for_rev_match from hawk.ip order by '$sortby'";
|
||||
}
|
||||
|
||||
if (!$result = @mysql_query($query)) {
|
||||
@@ -110,7 +122,7 @@
|
||||
extract ($record);
|
||||
|
||||
# only show blank ping/hostname records if $showeverydamnthing is set
|
||||
- if ($hostname == "" && $lastping == 0 && !$showeverydamnthing) continue 1;
|
||||
+ if ((!$hostname || strstr($hostname, $purple_string)) && !$lastping && !$showeverydamnthing) continue 1;
|
||||
|
||||
if (!testip($network, $ip)) continue 1;
|
||||
|
||||
@@ -126,24 +138,28 @@
|
||||
print "<tr>";
|
||||
|
||||
# no hostname, no ping response
|
||||
- if (!$hostname && !$lastping) {
|
||||
- print "<td>";img("images/purplesphere.png");print "</td>";
|
||||
+ if ((!$hostname || strstr($hostname, $purple_string)) && !$lastping) {
|
||||
+ print "<td>";img("images/purplesphere.png", 20, 20, "purple");print "</td>";
|
||||
}
|
||||
# ping response, but no hostname
|
||||
elseif ($lastping > (time() - $redzone) && !$hostname) {
|
||||
- print "<td>";img("images/bluesphere.png");print "</td>";
|
||||
+ print "<td>";img("images/bluesphere.png", 20, 20, "blue");print "</td>";
|
||||
+ }
|
||||
+ # forward and reverse hostnames do not match
|
||||
+ elseif ($for_rev_check && !$for_rev_match) {
|
||||
+ print "<td>";img("images/questionsphere.png", 20, 20, "question");print "</td>";
|
||||
}
|
||||
# ping response in "red zone"
|
||||
elseif ((time() - $redzone) > $lastping) {
|
||||
- print "<td>";img("images/redsphere.png");print "</td>";
|
||||
+ print "<td>";img("images/redsphere.png", 20, 20, "red");print "</td>";
|
||||
}
|
||||
# ping response in "yellow zone"
|
||||
elseif ((time() - $yellowzone) > $lastping) {
|
||||
- print "<td>";img("images/yellowsphere.png");print "</td>";
|
||||
+ print "<td>";img("images/yellowsphere.png", 20, 20, "yellow");print "</td>";
|
||||
}
|
||||
# recent ping response, hostname ok
|
||||
else {
|
||||
- print "<td>";img("images/greensphere.png");print "</td>";
|
||||
+ print "<td>";img("images/greensphere.png", 20, 20, "green");print "</td>";
|
||||
}
|
||||
print "<td>$ip</td>";
|
||||
print "<td>$hostname </td>";
|
||||
@@ -160,28 +176,34 @@
|
||||
#####################################################
|
||||
function showkey () {
|
||||
|
||||
- global $yellowzone, $redzone;
|
||||
+ global $for_rev_check, $yellowzone, $redzone;
|
||||
|
||||
print "<table>\n";
|
||||
|
||||
print "<tr><td>Key: </td><td>";
|
||||
- img("images/greensphere.png", 10, 10);
|
||||
+ img("images/greensphere.png", 10, 10, "green");
|
||||
print " Host in DNS. Recent ping response.<td></tr>";
|
||||
|
||||
+ if ($for_rev_check) {
|
||||
+ print "<tr><td></td><td>";
|
||||
+ img("images/questionsphere.png", 10, 10, "question");
|
||||
+ print " Host in DNS. Forward and reverse hostnames do not match.</td></tr>\n";
|
||||
+ }
|
||||
+
|
||||
print "<tr><td></td><td>";
|
||||
- img("images/yellowsphere.png", 10, 10);
|
||||
+ img("images/yellowsphere.png", 10, 10, "yellow");
|
||||
print " Host in DNS. No ping response for over $yellowzone seconds.</td></tr>\n";
|
||||
|
||||
print "<tr><td></td><td>";
|
||||
- img("images/redsphere.png", 10, 10);
|
||||
+ img("images/redsphere.png", 10, 10, "red");
|
||||
print " Host in DNS. No ping response for over $redzone seconds.</td></tr>\n";
|
||||
|
||||
print "<tr><td></td><td>";
|
||||
- img("images/purplesphere.png", 10, 10);
|
||||
+ img("images/purplesphere.png", 10, 10, "purple");
|
||||
print " Host not in DNS. No ping response.</td></tr>\n";
|
||||
|
||||
print "<tr><td></td><td>";
|
||||
- img("images/bluesphere.png", 10, 10);
|
||||
+ img("images/bluesphere.png", 10, 10, "blue");
|
||||
print " Host not in DNS. Recent ping response.</td></tr>\n";
|
||||
|
||||
print "</table>";
|
||||
@@ -196,6 +218,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="hawk.css" title="Hawk Style Sheet">
|
||||
+ <link rel="icon" type="image/vnd.microsoft.icon" href="images/favicon.ico">
|
||||
+ <link rel="shortcut icon" href="images/favicon.ico" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -244,9 +268,9 @@
|
||||
|
||||
}
|
||||
|
||||
- function img ($image, $height="", $width="") {
|
||||
+ function img ($image, $height="", $width="", $text="") {
|
||||
|
||||
- print "<img src=$image height=$height width=$width>";
|
||||
+ print "<img src=$image height=$height width=$width title=$text alt=$text>";
|
||||
|
||||
}
|
||||
|
16
net-mgmt/hawk/pkg-descr
Normal file
16
net-mgmt/hawk/pkg-descr
Normal file
|
@ -0,0 +1,16 @@
|
|||
Hawk is a web based utility for monitoring and comparing hosts on your
|
||||
network with what is in DNS. Hosts that are answering pings but are not
|
||||
in DNS may be unauthorized, and addresses in DNS which are not answering
|
||||
may be able to be reclaimed. Hawk monitors all hosts on the networks
|
||||
you specify and lets you view them via a web page.
|
||||
|
||||
Hawk consists of a backend written in Perl that monitors hosts by ICMP
|
||||
pings and writes the status to a mysql database. The frontend is in
|
||||
PHP and lets you select which network to view, and how to view it.
|
||||
|
||||
This version has several enhancements to the original; including cleaner
|
||||
Perl code, a user-definable string to designate unused addresses that
|
||||
are in DNS, testing that the forward and reverse hostnames match, and
|
||||
the daemon forks one process pre subnet.
|
||||
|
||||
WWW: http://sourceforge.net/projects/iphawk/
|
20
net-mgmt/hawk/pkg-plist
Normal file
20
net-mgmt/hawk/pkg-plist
Normal file
|
@ -0,0 +1,20 @@
|
|||
etc/hawk/daemon.conf.sample
|
||||
etc/hawk/php.conf.sample
|
||||
sbin/hawk
|
||||
%%WWWDIR_REL%%/images/bluesphere.png
|
||||
%%WWWDIR_REL%%/images/favicon.ico
|
||||
%%WWWDIR_REL%%/images/greensphere.png
|
||||
%%WWWDIR_REL%%/images/hawk.jpg
|
||||
%%WWWDIR_REL%%/images/purplesphere.png
|
||||
%%WWWDIR_REL%%/images/questionsphere.png
|
||||
%%WWWDIR_REL%%/images/redsphere.png
|
||||
%%WWWDIR_REL%%/images/yellowsphere.png
|
||||
%%WWWDIR_REL%%/hawk.php
|
||||
%%WWWDIR_REL%%/hawk.css
|
||||
%%PORTDOCS%%%%DOCSDIR%%/README
|
||||
%%PORTDOCS%%%%DOCSDIR%%/create_hawk_db.sql
|
||||
%%PORTDOCS%%%%DOCSDIR%%/create_hawk_user.sql
|
||||
%%PORTDOCS%%@dirrm %%DOCSDIR%%
|
||||
@dirrmtry %D/etc/hawk
|
||||
@dirrm %%WWWDIR_REL%%/images
|
||||
@dirrm %%WWWDIR_REL%%
|
Loading…
Add table
Reference in a new issue