Author Topic: NWS Alerts  (Read 1042 times)

0 Members and 1 Guest are viewing this topic.

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
NWS Alerts
« on: February 24, 2025, 08:55:30 AM »
Greetings all,

Well looks like my alerts are not updating, last update was Thursday the 20th at 5:37 pm.
https://www.lakehuronweather.org/wxadvisory.php
I did not change anything so not sure why.
Now there are alerts that have expired but not being updated.
Any input is welcomed.
Thanks
CW3699

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9689
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Alerts
« Reply #1 on: February 24, 2025, 11:00:37 AM »
It is very strange.  It looks like the fetches are happening, but in the end, the nws-alerts.php script shows
Quote
NO cache files updated

I noticed that your nws-alerts.php is maybe modded or downlevel.  I suggest you rename your nws-alerts.php and upload a fresh copy from
https://saratoga-weather.org/wxtemplates/USA/nws-alerts.php?sce=view

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
Re: NWS Alerts
« Reply #2 on: February 24, 2025, 11:53:25 AM »
I did get your latest version and still same issue with cache.
The only mod is the first line entry that ICDSoft requires in php file for cron jobs.
Had been running smoothly until this.  Strange.
CW3699

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
Re: NWS Alerts
« Reply #3 on: February 24, 2025, 12:01:58 PM »
This is the error that show at the end when I run the cron from my CP.

Quote
Warning: fopen(./cache/nws-notes.txt): Failed to open stream: No such file or directory in /home/lakehuronweather/www/www/nws-alerts.php on line 825

Fatal error: Uncaught TypeError: fputs(): Argument #1 ($stream) must be of type resource, bool given in /home/lakehuronweather/www/www/nws-alerts.php:826
Stack trace:
#0 /home/lakehuronweather/www/www/nws-alerts.php(826): fputs(false, 'Script characte...')
#1 {main}
  thrown in /home/lakehuronweather/www/www/nws-alerts.php on line 826

Edit: Yea forgot to add this  ](*,).  The text file referenced is in the cache directory so that baffeles me.  I did try replacing the existing txt with a newly creatd on but no change.




« Last Edit: February 24, 2025, 05:30:55 PM by Otis »
CW3699

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9689
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Alerts
« Reply #4 on: February 25, 2025, 02:53:54 PM »
What is the exact cron command you're using for the cron job to run nws-alerts.php?

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
Re: NWS Alerts
« Reply #5 on: February 25, 2025, 04:06:51 PM »
Ken, first thanks for helping.
Second, glad you are back.

Now, I have gone ahead and disabled the cron job and limited the zones to 2.  Only way I could clear the stale alert.
However alerts have not updated since before noon.

As for the cron job:  attached is a screen shot of the cron command that was being used.  Also attached is a shot of the entire results after running (your updated) the latest version of the alerts file.

As noted previously, the files and directories that are being identified as missing are there.

Also, ICDSoft requires a line added to the first line of php scripts for cron jobs.  We had fixed this before.

Thanks again Ken, any help is greatly appreciated.

 [ You are not allowed to view attachments ]

CW3699

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9689
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Alerts
« Reply #6 on: February 25, 2025, 04:45:05 PM »
So, how about trying a different command set for the cron.  You won't need the #!/usr/bin/php-cgi with this:

Quote
cd /home/lakehuronweather/www/www;/usr/local/php81/bin/php -q nws-alerts.php 2>&1 >nws-status.txt

This does two things:
1) changes the default directory to your document root
2) runs the nws-alerts using your current PHP command (quietly) and sends output to nws-status.txt file

Let me know if that works..

If so, a similar construct would be used for your River fetch too.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
Re: NWS Alerts
« Reply #7 on: February 25, 2025, 04:55:13 PM »
Sorry Ken it does not run suing this command.
CW3699

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9689
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Alerts
« Reply #8 on: February 25, 2025, 05:54:12 PM »
Try deleting on the site ./cache/nws-alertsMainData.php and run nws-alerts.php?mu=1 to reload the cache.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
Re: NWS Alerts
« Reply #9 on: February 25, 2025, 06:20:39 PM »
Tried that and still no change.

Right now I would be happy to just have alerts working without the cron.  Most interested in two locations so only 4 zones but still can't get that to work.  Very frustrating at times.

So, can you help me straighten out alerts for 4 zones please?

Oh yea, in the cache there are 2 files one named nws-alertsMainData.php and the other is nws-alertsMainData2.php.
Not sure if this is important.

Edit: Okay then, I got the alerts working without the cron, just getting data for 4 zones.  So far seems to be working.
For now onto the next puzzle  ](*,)

Ken, thanks for your time.  You do an awful lot for all of us here, appreciate it.



« Last Edit: February 25, 2025, 08:06:42 PM by Otis »
CW3699

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
Re: NWS Alerts
« Reply #10 on: March 08, 2025, 07:05:55 AM »
Ken, I wanted to follow-up on this issue.

As noted I had stopped the cron job and just used 2 zones for updating.  During our (your) trouble shooting of the issue I got the following message from my host company (ICDSOFT).

Quote
Dear Customer,

Our server monitoring systems indicated excessive outgoing requests to a single IP address (23.41.168.15:https://api.weather.gov) by your website for lakehuronweather.org.

We checked the hosting Control Panel > Site Statistics and noticed that the site was bombarde by hits from web bots. To reduce the excessive requests, we blocked these bots from accessing the website by using the following directives in the ~/www/www/.htaccess file:

I don’t know if this had anything to do with my issue of the alerts/cron job.  So, just yesterday I tried using a cron job again to check several zones for alerts and all seems to be working.

Anyway, no conclusive answers but wanted to follow-up.  Thanks again Ken for all your assistance.
CW3699

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9689
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS Alerts
« Reply #11 on: March 08, 2025, 03:29:57 PM »
Yes, NOT using cron for nws-alerts means a possible fetch from api.weather.gov for data when the cache expires.  If your site is getting crawled by bots, they may cause multiple fetches/attempts since it happens when a page is loaded.

I currently have the following in my main site .htaccess to prohibit the most egregious bots from access:

Quote
SetEnvIfNoCase Referer "^qq829" TOBLOCK=1
SetEnvIfNoCase Referer "^cnzz" TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*80legs.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Ezooms.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Ahrefs.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*package.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*scalaj.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*MJ12bot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*semrush.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Knowledge.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Gigabot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*PetalBot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*BLEXBot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*DataForSeo.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Barkrowler.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*python-requests.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*hypefactors.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Baispider.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*serpstatbot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*marginalia.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*semantic-visions.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*curl.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*claudebot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*SeekportBot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Baidu.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*meta-externalagent.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*Bytespider.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*amazonbot.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*SiteLockSpider.* TOBLOCK=1
SetEnvIfNoCase ^User-Agent$ .*GPTBot.* TOBLOCK=1

<FilesMatch "(.*)">
Order Allow,Deny
Allow from all
Deny from env=TOBLOCK
# deny from nnn.nnn.nnn.nnn entries.
</FilesMatch>

That gives them a 403-Forbidden return and no script is run.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Otis

  • (aka Paul)
  • Forecaster
  • *****
  • Posts: 791
    • Lake Huron Weather
Re: NWS Alerts
« Reply #12 on: March 08, 2025, 04:10:41 PM »
Thanks Ken, will give it a try.
CW3699

 

anything