gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-users] strange - currently only few satellites


From: hans mayer
Subject: Re: [gpsd-users] strange - currently only few satellites
Date: Sun, 10 Apr 2016 21:22:35 +0200
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Thunderbird/24.1.1


Dear David,

This is actually a nice idea to feed MRTG with satellites numbers.
MRTG is running all 5 minutes typically. So it would be nice to have
an average number of satellites of the last 5 minutes instead of
just the value when MRTG is executed.

I setup several MRTG's in the past but always reading the values
with SNMP. No idea how to read data in a different way.

This simple script below would just print out the number of
available satellites at moment when it's started.


gpspipe -r | egrep --line-buffered  'GPGSA' | head -1 | gawk  '-F,' '
{
 CNT=0 ;
 if ( $1 ~  /GPGSA/ ) {
   for (i = 1; i <= NF; i++) {
     if ( $i != "" ) {
       CNT++ ;
     } ;
   } ;
   print ( CNT - 6 ) ;
 } ;
}'



Kind regards
Hans

--



Am 09.04.2016 09:58, schrieb David J Taylor:
Dear David,

you can download the source from github:
https://github.com/hans-mayer/sat_usage
if there are any questions tell me.

// hans
==================================

Hans,

Many thanks for that that, most helpful!  What I actually need is a
script (or whatever) which returns the number of satellites being used
by gpsd for a fix and I'll use this as input to MRTG (likely via the
SNMP pass mechanism).  Although I am completely unfamiliar with Linux
shell commands, I've been able to simplify your script down to:

________________________________________
gpspipe -r | egrep --line-buffered  'GPGSA' | stdbuf -o0 gawk  '-F,' '
{
  CNT=0 ;
  if ( $1 ~  /GPGSA/ ) {
    for (i = 1; i <= NF; i++) {
      if ( $i != "" ) {
        # print ( $i ) ;
        CNT++ ;
      } ;
    } ;
    print ( CNT ) ;
  } ;
}'
________________________________________

which is near to what I need, with two exceptions:

1 - The script runs continuously.  What I need is just to get the
current number of satellites and exit.  Run once, not every second.
Something like a "break" after printing the count.  My Linux knowledge
isn't up to knowing how to do this!

2 - What I would like is also the number of satellites gpsd is actually
using for a fix.  Comparing the script result with "cgps -s" for
example, the value returned by the script is the total number of
satellites in the right-hand cgps column, whereas I would also like the
number of satellites with "Y" against them - satellites being used.
Perhaps this is more complex. though?

BTW: gawk isn't in the default Raspberry Pi Wheezy distribution, but
easily obtained with apt-get.

Thanks,
David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]