Win32::Daemon::Simple vs. SVCANY.EXE

2004-04-18 Thread Jim Lancaster
I've written a script to read the Windows event logs and write the
results to a MySQL database.  I'm currently using Win32::Daemon::Simple
to run it as a service, polling the logs every 15 minutes.  However, I'm
wondering if this is the best method to use.  It would appear to be
simpler to put my polling code in a continuous loop with a sleep()
command at the end and install the compiled app as a service using
SVCANY.EXE from the Windows Resource Kit.  What are the relative
advantages/disadvantages of the two methods?

Also, I intend to develop similar scripts to poll other logs (syslog,
Apache) on Linux.  I think it would be easier to create (and maintain)
the scripts if the basic code was platform independent.  I've seen
mention of using Proc::Background.  How would this fit in with what I am
trying to do?

Thanks,

Jim

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Octetstr to hex conversion

2003-09-02 Thread Jim Lancaster
Well, upon further review, the answer requires less work than I thought.
Here is the detail for the two Linux NICs:

NIC =eth0
MAC =000102EAEC0F
OctetStr = 0x000102eaec0f 

NIC =eth1
MAC =00B0D0254A27
OctetStr = 0x00b0d0254a27 

I was looking at the OctetStr for one, and matching it with the MAC
address of the other. sheepish g.  I thought some sort of conversion
needed to take place, but as you can see the only thing I need to deal
with is the leading Ox.  Except for those 2 characters, the octetstr
IS the mac address.

Whoa boy.  Monday fell on a Tuesday this week.

Jim



-Original Message-
From: Peter Eisengrein [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 29, 2003 9:06 AM
To: Jim Lancaster; [EMAIL PROTECTED]
Subject: RE: Octetstr to hex conversion


Is this what you mean? 
my $hex = unpack(h*,pack(b*,$octetstr)); 


-Original Message- 
From: Jim Lancaster [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 28, 2003 11:30 AM 
To: [EMAIL PROTECTED] 
Subject: Octetstr to hex conversion 


I'm polling a Linux server with Net-SNMP and getting back an octetstr 
value for the mac address of the nic.  I saw a reference to using unpack

to convert it in an old posting, but no specifics.  How is this done? 
What kind of mask do I use? 


Jim Lancaster 
MBD Network Services, LLC 
___ 
Perl-Win32-Users mailing list 
[EMAIL PROTECTED] 
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: WMI wierdness.

2003-08-29 Thread Jim Lancaster
Here is the offending sub:

sub os_info {

# From the WMI documentation. These are the possible values for
#  OSProductSuite:
my %os_product_suite = (
1 = Small Business,
2 = Enterprise,
4 = BackOffice,
8 = Communication Server,
16 = Terminal Server,
32 = Small Business (Restricted),
64 = Embedded NT,
128 = Data Center
   );

my %os_info;
foreach my $os (in($WMI-InstancesOf(Win32_OperatingSystem))) {
$os_info{'Caption'}= $os-{'Caption'};
$os_info{'FreePhysicalMemory'} =
$os-{'FreePhysicalMemory'};
 
   # I'm not sure how/where this is calculated, but it doesn't
appear to jibe with
#  the data in Win32_PageFileUsage.
$os_info{'FreeSpaceInPagingFiles'} =
$os-{'FreeSpaceInPagingFiles'};

$os_info{'InstallDate'} = substr($os-{'InstallDate'},4,2)./.
 
substr($os-{'InstallDate'},6,2)./.
substr($os-{'InstallDate'},0,4);
if ($os-{'NumberOfLicensedUsers'}) {
$os_info{'NumberOfLicensedUsers'} =
$os-{'NumberOfLicensedUsers'};
} else {
$os_info{'NumberOfLicensedUsers'} = unknown;
}
$os_info{'NumberOfUsers'}  = $os-{'NumberOfUsers'};
if ($os-{'Organization'}) {
$os_info{'Organization'}   = $os-{'Organization'};
} else {
$os_info{'RegisteredUser'} = unknown;
}
if ($os-{'RegisteredUser'}) {
$os_info{'RegisteredUser'} = $os-{'RegisteredUser'};
} else {
$os_info{'Organization'}   = unknown;
}
$os_info{'SerialNumber'}   = $os-{'SerialNumber'};

# 'ServicePackMajorVersion' is a feature that was introduced
#   with W2K.  Use it if applicable; for earler versions use
'CSDVersion'.
if ($os-{'Version'} le 5.0) {
$os_info{'ServicePack'} = $os-{'CSDVersion'};
} else {
$os_info{'ServicePack'} = Service Pack .
 
$os-{'ServicePackMajorVersion'}...
 
$os-{'ServicePackMinorVersion'};
}

$os_info{'Version'}= $os-{'Version'};

# Calculate system uptime
my $byear= substr($os-{'LastBootUpTime'},0,4);
my $bmonth   = substr($os-{'LastBootUpTime'},4,2);
my $bday = substr($os-{'LastBootUpTime'},6,2);
my $bhour= substr($os-{'LastBootUpTime'},8,2);
my $bmin = substr($os-{'LastBootUpTime'},10,2);
my $bsec = substr($os-{'LastBootUpTime'},12,2);
my $cyear= substr($os-{'LocalDateTime'},0,4);
my $cmonth   = substr($os-{'LocalDateTime'},4,2);
my $cday = substr($os-{'LocalDateTime'},6,2);
my $chour= substr($os-{'LocalDateTime'},8,2);
my $cmin = substr($os-{'LocalDateTime'},10,2);
my $csec = substr($os-{'LocalDateTime'},12,2);
my ($dday,$dhour,$dmin,$dsec) =
Delta_DHMS($byear,$bmonth,$bday,$bhour,$bmin,$bsec,
 
$cyear,$cmonth,$cday,$chour,$cmin,$csec);
$os_info{'SystemUptime'} = $dday days, $dhour hrs, $dmin mins,
$dsec secs;

# For testing purposes only.
#dref(0,\%os_info);
#exit;
}

return (%os_info);

}


-Original Message-
From: Carl Jolley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 28, 2003 4:15 PM
To: Jim Lancaster
Cc: [EMAIL PROTECTED]
Subject: Re: WMI wierdness.


On Thu, 28 Aug 2003, Jim Lancaster wrote:

 Background:
 I'm running perl v5.6.1 build 635 and Win32-OLE 0.1403 on a WinXP Pro 
 workstation. I've written a number of scripts to query WMI for 
 configuration (system, cpu, memory, disk, nic, etc.) information.  
 They
 *had* been working fine until I went through them and cleaned up my
old
 code. (I know, if it ain't broke...g).  All I did was replace the
use
 of Win32-PerfLib with a new sub to calculate system uptime using WMI,
 and replace my clunky html subs with CGI.  The bulk of the WMI code I
 left alone.

 Symptoms:
 I can run my script from a command prompt against a single server and 
 it works fine. If I queue up several servers in an external cfg file, 
 some of the servers generate error messages indicating my script is 
 trying to process an uninitialized hash value. The errors usually 
 refer to the same couple of lines of code where I'm concatenating 
 something, or dividing one number by another to get a percentage 
 value.

 Wierdness:
 If I change the order of servers in the cfg file, the errors happen on

 different servers.  It never happens on all of the servers.  The 
 position in the list doesn't appear to have any effect.  And if there 
 is only one server in the list, no matter which, one, I almost never 
 see the error.

 Even more wierdness:
 I inserted some debugging code in my script to print out the suspect 
 hash values to the screen and they are there, properly initialized, 
 but the very