Online / Offline Status Notification System via push



  • I’m gonna do status notification system today for mono / pfsense. I don’t really want to do it full system release yet. But here is what I think to release to public. It will work as a service that is intended for large networks.

    Mono or pfSense = NAS

    1. NAS connects to our server
    2. Server authenticates the NAS
    3. Server updates NAS and shows as it is online and operational
    4. Server Publish status on the web (either public or private access)
    5. If Geo info provided server builds network map to show functionality
    6. Server builds on demand RSS

    Part one is mod for NAS everything else is a server side. Because everything else is a server side I rather run my server available for public and provide free service for everyone.

    Please tell me your opinion on this. Do you think I should build this project? I have most of the script already I just need to know if community really wants it or should I keep it private? Also will it be integrated in actually releases of mono and pfSense.



  • How does this really differ from FreeNAS?



  • I need some clarification here - Do you mean NAS like NAS in Network Attached Storage?

    Regards
    Daniel S. Haischt



  • Beside my understanding issue why you associate the acronym NAS with m0n0wall or pfSense, I would like to suggest to at least publish the sources of your server. That way people would be able to install the server at their side if necessary.

    Regards
    Daniel S. Haischt



  • NAS = Network Access Server aka Router (I used it so that i dont have ro feferre to both pfSense and Mono at the time)

    So it has nothing to do with network attached storage.

    As to the source dodes for the server, yes I might think of releasing them but i have 2 problems w. that: a) Setup Complexity (Althoughr yes I can do installer) b) Security: This functionality is a part of our propriatary system, so if I release everything some ppl can get full functionality of our propriatary system



  • NAS is somehow confusing. You should try to find a yet unused name imo.



  • ok renaming it to Router how is that?



  • I just placed my script on the pfSense Dev image and when I was trying to execute it (bash script i got errors)

    a) No bash ?
    b) no DIR commands?

    I've chaked the bin rirectory and ddint find the command there, so i will try to add them.  But the question is, if i add them therewill they will be included in compiled image?

    also i will neeed those commands:

    1. case
      2)grep
      3)cut
      4)awk
      5)wget


  • replace bash shell with tcsh or sh shell
    replace youre wget commands with fetch commands
    all the other commands are all ready in embedded 1.01

    dir is called ls on bsd systems



  • Ok, so now I know what is a dofference in BSD and Linux.

    "…all the other commands are all ready in embedded 1.01 " I didnt find any dev image for 1.01 so i used 1.0 but i did that long upgrade that it oferred, didnt really the the thing adding the commands but O look again today



  • Ok skript works now… one thing to get more reliable picture i wnat to check which interface assigned to LAN and WAN, I assome there is a file somwhere that says LAN=eth0 WAN=eth1
    If I can get the interface names i can extract the IP values ... sure I can get them from config file, but i rather get the aluef directly from the OS (besides i have no idea how to make bach script to read XML)



  • you may might be able to utilize some code from interfaces>assign or status>interfaces. Both these screens show information on which nic is assigned to which uinterfacename.



  • do you refer to PHP pages?



  • Yes.



  • I'm there now, still cant find the file weher intergface assigments are stored… unles its webguiconfig.in



  • $g['varrun_path'] . "/lan.conf.dirty";

    Is that config I need? what tha value of g[varrun_path]?



  • /etc/inc/globals.inc



  • actually I was fullish and miss the part in the main confog file that is cleraly saying LAN=eth1 etc in the XML file, just as usual…. so now im looking on how to read XML w/ bash script... aperantly i have no idea how to do that...



  • Erm, I dont think there is a EASY way to do this.  Good luck!



  • Good, so at the end you wont tell me that my script is too easy :-P



  • Technically you could call php from your bash script and echo out the values after parsing but this is going to be SLLLOOOW.



  • well besides slow it will eat extra ~15% of CPU, for wrap that is not an option. And in combination to the fact that the script does HTTP request to the external server I definettly dont want to call PHP XML parser… in my case I will have to call it min 2 times and the  3rd will be external HTTP request.

    Well lets see what i end up with. Im sure linux/bsd shuld have ability to read xml files.



  • lets take a look at it from a difrent side and use the pfsense rules file and get there the lan and wan from

    
     #!/bin/sh
    lan=`awk '/lan = "\{ /{ print $0 }' /tmp/rules.debug | sed -e 's/lan = "{ //' | sed -e 's/ }"//'`
    wan=`awk '/wan = "\{ /{ print $0 }' /tmp/rules.debug | sed -e 's/wan = "{ //' | sed -e 's/ }"//'`
    echo "lan interface=" $lan
    echo "wan interface=" $wan
    
    


  • nice that screept does work.. i was doing almost the same w/ xml just now… but as I see in that example it uses temp dir? is that dor will be included in future releases? is that dir exist in mono, and finally what rules does it refering to? firewall rules? what if NAT is disabled?
    Tnx



  • i have made that script on a running pfsense embedded 1.01 soekris
    /tmp/rules.debug is the running firewall config of pfsense
    mono will have it to i think
    nat on or off will not chance the lan of wan interface on the firewall



  • ok if that folder is permament and present on both mono and pfSense I will use it …
    Less hedeach reading XML file for me..

    Tnx



  • Ok,  operational script partd is done! Now time to build user enterface. PHP time :-) well almowst php + DNS, I hate my DNS…



  • Ok, good part of Webinterface is done now.
    One problem, I was trying to use fetch instead of wget (as sudgested earlier) but a) I cant make it to work b) it doesnt work as spider

    So, is it posible to install WGET to the system and include it in the distribution?



  • What doesn't work with fetch?



  • everithing, I tryed all posible syntax and never got it to work …

    Can you give me a sample code on using fatch to open lets say http://example.com and do not download any info?



  • What do you mean "do not download any info?"

    Do you mean quiet?



  • Spider mode = no downloads
    quite mode = no output

    Technicaly i need them both



  • Quiet and no downloads?  Sorry but I dont follow you.  The point of fetch and wget is to download/fetch a page.



  • who cares about original point :-P
    i used wget yo open the remote webpage and transfer variables to remote server via HTTP POST -this is called -spider in wget

    wger –spider -q "http://ecample.com?cmd=Hello2%World"

    This will send Hello World to remote webserver. and at the same time will not download or save anything. Well some times i can run as spider but not in quite mode so i can see if the requested page returns me an error. This technique is used by google and paypal





  • Ok good seams to work :-) Tnx
    Now I have to join the GUI with the script and set DNS and i'm done on the client side  ;D



  • I jaws was trying to use my GUI to modify crontabfile but no luck… i went to actual file and found out this message:

    DO NOT EDIT THIS FILE - edit the master and reinstall.

    (/tmp/crontab.lfJ3UAOksN installed on Thu Nov  9 04:03:50 2006)

    (Cron version – $FreeBSD: src/usr.sbin/cron/crontab/crontab.c,v 1.22 2004/09/14 19:01:19 dds Exp $)

    */60 * * * * sh /usr/local/StatusNotifier/server_status.sh >/dev/null 2>&1

    The cron that is there is the one that i installed but I want to let my GUI to be able to edit cron job, but as file says I cant edit it?  :o as i would normally do under linux. So how can I edit cron file with out reinstalling it? I dont think I can reinstalll it via script, one way or another its alternating and saving  the file content.

    Well maybe i missing something? Any ideas?



  • Edit /etc/crontab

    killall -HUP cron



  • ok Clinent Side is 98% Done, Server side is 30% Done



  • I still have no idea what your working on but good luck. ;)

    One bit about that fetch command… Do check the shell return code.  fetch will fail if a problem occurred.

    I apologize if you are already doing so.


Log in to reply