Page 1 of 2

Station Status question

Posted: Wed 16 Jul 2014 5:22 pm
by aznetcowboy
The normal station status readings are:
Component Status
Age h:m:s Latest update time as of 07/16/2014 10:13am

Cumulus realtime Current 0:00:05 07/16/2014 10:12am

Cumulus FTP Current 0:02:50 07/16/2014 10:10am

Cumulus weather data Current 0:03:02 07/16/2014 10:10am
Is there a way to add another update status readings to it? An example is my Fire Weather Index (FWI Calc) status.

Re: Station Status question

Posted: Thu 17 Jul 2014 1:55 pm
by saratogaWX
Easy to add. See the code in comments inside wxstatus.php

Code: Select all

<?php
############################################################################
#
# Add your custom checks below using the commented examples
#
# the do_check function has four arguments:
#   do_check($text,$target,$maxtime,$checktype);
#
# where:
#   $text is the text to display on the page.. always a good idea to run it
#        through langtransstr($text) for multilanguage support
#   $target is the item to be checked .. type of item is determined by $checktype
#
#     $target = relative file location/name if $checktype = 'file'
#     $target = unix timestamp (like from time() ) if $checktyp = 'application'
#
#   $maxtime is number of SECONDS expected between updates .. always allow a cushion
#        (extra time) to allow for delays in updates via FTP
#
#   $checktype defaults to 'file' type, use 'application' for timestamp checking from
#         applications.
#
#
############################################################################

/*
// example check for 'file' update time
        $tDir = './';
		if(file_exists($tDir.'somefile.ext')) {
           do_check(langtransstr("Some File"),$tDir.'somefile.ext',10*60+15,'file');
		
        }
	
// example check for 'application' update time (this WXSIM check is already in wxstatus.php)

		if(isset($SITE['WXSIM']) and file_exists('plaintext.txt')) {
	       $doPrint = false;
		   include_once($SITE['WXSIMscript']);
		   print "<!-- wdate='$wdate' -->\n";
		   $lastWXSIM = strtotime($wdate);
		   // note: '6*60*60 + 2*60' is 6:02:00 hms
           do_check(langtransstr("WXSIM forecast"),$lastWXSIM,6*60*60 + 2*60,'application');
		
        }

*/	
############################################################################
# start of custom checks (put your custom checks below)		



# end of custom checks
############################################################################
?>

Re: Station Status question

Posted: Fri 18 Jul 2014 7:09 pm
by aznetcowboy
Me thinks I am missing the obvious. I am getting nothing. What I am looking for is the find out when/if the file "fwiweb.xml" was uploaded to the root of my domain. I made some guesses as to what the code should have been, but I am no where near close to getting this correct. :cry:

As of right now, the result I am getting is:
Fire Weather Index Data NOT Current 390479:53:22 > 6:00:00

The code I have is:
$tDir = './';
if(file_exists($tDir.'fwiweb.xml')) {
do_check(langtransstr("Fire Weather Index Data"),$tDir.'fwiweb.xml',6*60*60,'fwiweb.xml');
}
The file timestamp is 3:021:02. The time calculation (6*60*60) is confusing. I assume it is where the > 6:00:00 is coming from. I am at least getting something right now, but not what is correct.

Re: Station Status question

Posted: Sat 19 Jul 2014 12:08 am
by beteljuice

Code: Select all

        6*60*60 // 6 HOURS

/* I assume you want 6 minutes (and a 'buffer') 6*60+15
    multiplication takes precedence so same as (6*60) +15
*/


Re: Station Status question

Posted: Sat 19 Jul 2014 2:28 am
by aznetcowboy
beteljuice wrote:

Code: Select all

        6*60*60 // 6 HOURS

/* I assume you want 6 minutes (and a 'buffer') 6*60+15
    multiplication takes precedence so same as (6*60) +15
*/

I have modified the timing so that the file gets uploaded every 30 minutes, need it or not. The status code is now:
$tDir = './';
if(file_exists($tDir.'fwiweb.xml')) {
do_check(langtransstr("Fire Weather Index Data"),$tDir.'fwiweb.xml',30*60+15,'fwiweb.xml');
}

The results are: Fire Weather Index Data NOT Current 390482:19:36 > 0:30:15


The last update to the fwi file was 20 minutes ago. BTW, what is the "390482:19:36:\" and the "> 0:30:15"?

Re: Station Status question

Posted: Sat 19 Jul 2014 3:00 am
by saratogaWX
Looking at the view-source of your wxstatus.php page shows
<h1>Weather Station Status</h1>
<p> <br/><br/>
Station system up for <b>16 hours 14 minutes</b><br/>
Station system free memory <b>2289/4094 MB (free/total)</b><br/>
This website uses <b>Cumulus
(1.9.4-b1096)</b> for weather conditions reporting.<br/>
It was last started <b>1 hour 56 minutes</b>.<br/></p>

<table width="620" border="0" cellspacing="6" cellpadding="3" style="border-collapse:collapse">
<tr>
<th style="width: 40%" scope="col">Component</th>
<th style="width: 15%" scope="col" align="center">Status</th>
<th style="width: 10%" scope="col" align="right">Age<br />h:m:s</th>
<th style="width: 35%" scope="col" align="right">Latest update time as of<br/> 07/18/2014 7:53pm</th>
</tr>

<!-- include-wxstatus.php - V1.05 - 06-Mar-2013 -->
<!-- ./realtime.txt age = 6 secs. 0:00:06 -->
<tr>
<td>Cumulus realtime</td>
<td align="center"><span style="color: green"><b>Current</b></span></td>
<td align="right">0:00:06</td>
<td align="right">07/18/2014 7:53pm </td>
</tr>
<!-- CUtags.php age = 217 secs. 0:03:37 -->
<tr>
<td>Cumulus FTP</td>
<td align="center"><span style="color: green"><b>Current</b></span></td>
<td align="right">0:03:37</td>
<td align="right">07/18/2014 7:50pm </td>
</tr>
<!-- CUtags.php internal update date time='7/18/2014 19:50' fixed='2014-07-18 19:50' -->
<!-- age = 229 secs. 0:03:49 -->
<tr>
<td>Cumulus weather data</td>
<td align="center"><span style="color: green"><b>Current</b></span></td>
<td align="right">0:03:49</td>
<td align="right">07/18/2014 7:50pm </td>
</tr>
<!-- GR3='/home/elghek00/domains/elgheko.us/public_html/GR3/KDMA_cr_0.jpg' -->
<!-- end include-wxstatus.php -->
<!-- age = 1405738429 secs. 390482:53:49 -->

<tr>
<td>Fire Weather Index Data</td>
<td align="center"><span style="color: red"><b>NOT Current</b></span></td>
<td align="right">390482:53:49</td>
<td align="right"> > 0:30:15 <br/><b></b></td>
</tr>

</table>
so the display is not 'Fire Weather Index Data' but the GRLevel3 Radar image data check, and
/GR3/KDMA_cr_0.jpg doesn't exist on your site.

Zip and attach your wxstatus.php page (or rename it to .txt and attach it here). I think your code shown in the above post is in a extended PHP comment (and is therefore not executed).

Best regards,
Ken

Re: Station Status question

Posted: Sat 19 Jul 2014 3:08 am
by beteljuice
It should be in the form of - Age h:m:s Latest update time as of 07/16/2014 10:13am

but there is definately something odd going on.

What is the time/datestamp of your ./fwicalc.xml file ?

Re: Station Status question

Posted: Sat 19 Jul 2014 3:18 am
by aznetcowboy
Ken,

Here it (wxstatus.zip) is as requested.

Tom

Re: Station Status question

Posted: Sat 19 Jul 2014 3:21 am
by aznetcowboy
beteljuice wrote:I should[/] be in the form of - Age h:m:s Latest update time as of 07/16/2014 10:13am

but there is definately something odd going on.

What is the time/datestamp of your ./fwicalc.xml file ?

The current timestamp is 08:04:18 and my current time is 08:20:00. Hmmmm, this doesn't happen to operate on a 24 HR clock does it?

Re: Station Status question

Posted: Sat 19 Jul 2014 3:25 am
by saratogaWX
That timestamp of 1405738429 is essentially 'now'.

I just looked at wxstatus you posted, and your mod IS in the correct place.

If you're not running GRLevel3 radar, please change your Settings.php code

Code: Select all

$SITE['GR3radar']    = 'KDMA';    // set to lower-case full name of NEXRAD radar site
$SITE['GR3DIR']        = '/GR3';     // set to directory for GRLevel3 images (or '.' for root directory
$SITE['GR3type']    = 'cr';        // radar image type 'cr','br','cr248','br1' etc.
$SITE['GR3img']        = 'jpg';    // GR3 image type 'jpg' or 'png'
$SITE['GR3cnt']        = 10;        // number of images in series 10=(_0 ... _9 in name of file)
$SITE['GR3width']    = 512;        // width of GR3 images
$SITE['GR3height']  = 512;        // height of GR3 images
$SITE['showradarstatus'] = true; // set to false to suppress 'active' message by radar-status.php
to

Code: Select all

/*
$SITE['GR3radar']    = 'KDMA';    // set to lower-case full name of NEXRAD radar site
$SITE['GR3DIR']        = '/GR3';     // set to directory for GRLevel3 images (or '.' for root directory
$SITE['GR3type']    = 'cr';        // radar image type 'cr','br','cr248','br1' etc.
$SITE['GR3img']        = 'jpg';    // GR3 image type 'jpg' or 'png'
$SITE['GR3cnt']        = 10;        // number of images in series 10=(_0 ... _9 in name of file)
$SITE['GR3width']    = 512;        // width of GR3 images
$SITE['GR3height']  = 512;        // height of GR3 images
$SITE['showradarstatus'] = true; // set to false to suppress 'active' message by radar-status.php
*/
so the check for GR3 data (which is failing) should stop interfering with the display.

Then change your code from

Code: Select all

$tDir = './';
if(file_exists($tDir.'fwiweb.xml')) {
do_check(langtransstr("Fire Weather Index Data"),$tDir.'fwiweb.xml',30*60+15,'fwiweb.xml');
}
to

Code: Select all

$tDir = './';
if(file_exists($tDir.'fwiweb.xml')) {
do_check(langtransstr("Fire Weather Index Data"),$tDir.'fwiweb.xml',30*60+15,'file');
}
The last argument must be either 'file' or 'application' as values.. it doesn't understand the 'fwiweb.xml' 4th argument literal string.



Best regards,
Ken

Re: Station Status question

Posted: Sat 19 Jul 2014 3:55 am
by aznetcowboy
saratogaWX wrote: <SNIP>

Then change your code from

Code: Select all

$tDir = './';
if(file_exists($tDir.'fwiweb.xml')) {
do_check(langtransstr("Fire Weather Index Data"),$tDir.'fwiweb.xml',30*60+15,'fwiweb.xml');
}
to

Code: Select all

$tDir = './';
if(file_exists($tDir.'fwiweb.xml')) {
do_check(langtransstr("Fire Weather Index Data"),$tDir.'fwiweb.xml',30*60+15,'file');
}
The last argument must be either 'file' or 'application' as values.. it doesn't understand the 'fwiweb.xml' 4th argument literal string.


Best regards,
Ken
Thank you Ken! I was wondering what that "file" meant. I blew that one, big time. Over the years I programmed in CA-Clipper and HTML, not PHP. :bash:

What has the GR3 got to do with it? That is one thing I've never been able to get working and I guess I forgot all about it over time. :groan:


Tom

Re: Station Status question

Posted: Sun 14 Jan 2018 12:56 am
by dazza1223
can i uses on my site cumulus mx or i need to use it with the template wxstatus.php???

Re: Station Status question

Posted: Sun 14 Jan 2018 11:28 pm
by saratogaWX
The wxstatus.php (and include-wxstatus.php) do rely on having the Saratoga template installed for other parts that are used (Settings.php, Settings-weather.php, common.php).

The 'guts' of the page are handled in include-wxstatus.php -- you could replace all the $SITE['...'] variable calls with the appropriate data concerning your site, and use the basic code. A bit of a programming exercise, but doable, nonetheless.

Re: Station Status question

Posted: Sun 14 Jan 2018 11:32 pm
by dazza1223
well im not very good with php and i dont think u got the time to help me to set something like this up

Re: Station Status question

Posted: Sun 14 Jan 2018 11:49 pm
by saratogaWX
Generally, with PHP, you learn by doing. Having someone do it for you is not learning. This is a hobby.. enjoy it by learning :)