Bitcoin Forum

Bitcoin => Mining software (miners) => Topic started by: p4xil on June 01, 2013, 01:22:44 PM



Title: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on June 01, 2013, 01:22:44 PM
SIMPLE CGMINER REMOTE MONITORING SCRIPT NOW WITH ALERTS

http://shrani.si/f/3G/SM/4rjKnUUC/stats.png

I made this script so I can check status for my rigs from anywhere not just my local computer.
I know there is ANUBIS but it is too heavy for me. I just needed a simple status script.

You will need:
- Webserver / webhosting with PHP (with socket support enabled)
- Crontab access for Alerts
- Postfix or Sendmail for sending Email Alerts
- Miners using Cgminer

1. CONFIGURING CGMINER

Enable API support with adding this to the cgminer.conf:
Code:
"api-port" : "4001",
"api-listen" : true,
"api-allow" : "YOUR_WEBSERVER_IP",

or cgminer command line:
Code:
--api-port 4001 --api-listen --api-allow "YOUR_WEBSERVER_IP"

Change YOUR_WEBSERVER_IP to your webserver REMOTE IP.
With --api-allow only webserver remote IP has the read only access to the cgminer API. This has to be set for security reasons.
Each rig needs its own api-port! Ports numbers can be ANYTHING you want as long the are not already taken. For example you can set port 4001 for Rig #1, 4002 for Rig #2, 4003 for Rig #3, etc.

2. OPEN PORTS ON ROUTER / FIREWALL

http://shrani.si/f/O/oV/2k4zAbGE/rutr.png

If you have a router or a firewall you will need to open ports you have chosen for your rigs. In my example you will need to open ports 4001, 4002, 4003.
To do this you will have to know your rigs local IPs and set the port forwarding on router to these IPs.
You get the rig's local IP number with:

on windows open command prompt and run:
Code:
ipconfig

Look at "IPv4 Address" of your network adapter.
http://shrani.si/f/k/IK/4LbbVJKs/cmd.png

on linux run command:
Code:
ifconfig

Look at "inet addr:"  of your network adapter.
http://shrani.si/f/2N/ji/h3kUH9d/cmd2.png

3. SETUP MONITORING PHP SCRIPTS

Download files from here:
https://github.com/Paxxil/cgminer_remote_monitoring

Open functions.inc.php in your text editor.
Follow the instructions inside and add your miner rigs settings there.
After you made the changes, FTP to your webserver, navigate to your public www directory, create subdirectory "monitoring" and upload the files to it.

If you set everything right you should get the monitoring stats when you navigate to http://your_webserver_ip/monitoring/ (or if you have a domain http://wwww.your_domain.com/monitoring/)

4. CONFIGURING ALERTS
Open functions.php.inc in your text editor.
Edit the settings (email, alert configs) in the # SETUP ALERTS # Section.

Next you will have to make the file email.lock writable by the script.
In linux you do it with command:
Code:
chmod 666 email.lock

Now open crontab editor:
Code:
crontab -e

And put ABSULUTE path to the monitoring_cron.php script
Code:
*/2 * * * *     php /path/to/your/monitoring_cron.php >/dev/null 2>&1
This will execute monitoring_cron.php every 2 minutes.
If you want to check the server less frequently change */2 * * * * part.
Some examples:
Code:
* * * * *   => every minute
*/5 * * * * => every 5 minutes
0 * * * *   => every hour
0 0 * * *   => once a day at midnight server time

Save the file and shut down one cgminer to test the script. If you receive the email then everything works.

If you can not get it to work just PM me and I will help you.

If you like it please support it with donating:
LTC : LdQ1UHiRy24Tvmm8NHbhAdHL3Qf3JqrUbG
BTC : 1EA8UrpifP9hi7LZHjJphCJQ6Hh45mb5pP

Good Luck!
--p4xil

EDIT
2014-01-02 : v2.1.1 Fixed some bugs
2013-12-29 : v2.1 Added ASC and PGA support
2013-06-13 : Fixed some bugs
2013-06-04 : v2.0 Added Email Alerts



Title: Re: Simple Cgminer Remote Monitoring Script
Post by: 3ham3 on June 02, 2013, 04:55:32 AM
Getting an error from the index file, fails to operate at all.


Title: Re: Simple Cgminer Remote Monitoring Script
Post by: 01BTC10 on June 02, 2013, 05:38:49 AM
File is suspicious.

Quote
SHA256:   33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598
File name:   monitoring.rar.exe
Detection ratio:    4 / 47
Analysis date:    2013-06-02 05:38:24 UTC ( 0 minut ago )
https://www.virustotal.com/cs/file/33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598/analysis/1370151504/


Title: Re: Simple Cgminer Remote Monitoring Script
Post by: p4xil on June 02, 2013, 07:54:32 AM
Getting an error from the index file, fails to operate at all. You Sir, are you trying to steal my coins?

Follow the tutorial and you should get it working.
I posted project to github now so you can check the files.

post it on github.  Your link is asking me to download exe which I'd never do without seeing the source code.

Looks nice.

I'd like to try it.  Post your script on github.

I posted project to github now.


File is suspicious.

Quote
SHA256:   33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598
File name:   monitoring.rar.exe
Detection ratio:    4 / 47
Analysis date:    2013-06-02 05:38:24 UTC ( 0 minut ago )
https://www.virustotal.com/cs/file/33bfc4e9478de38255b307ae725dd5a7a940d3a2bb47bf9028f57a5493e55598/analysis/1370151504/

I don't know where did you find EXE, but well it is on github now so do not worry about it anymore.


Title: Re: Simple Cgminer Remote Monitoring Script
Post by: Jazkal on June 02, 2013, 05:21:39 PM
Any chance this can be modified to use the default port of 4028 for all miners?


Title: Re: Simple Cgminer Remote Monitoring Script
Post by: p4xil on June 02, 2013, 06:13:06 PM
you can change port to default in port section, but it won't work if you set same port for all miners.


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on June 04, 2013, 09:17:21 AM
I have added EMAIL ALERTS support.


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: af_newbie on June 04, 2013, 07:20:52 PM
I have added EMAIL ALERTS support.

The emails will be sent out by whatever mail server you configure in php.ini, right?
Have you tried this on Windows under IIS?


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on June 04, 2013, 07:28:46 PM
I have added EMAIL ALERTS support.

The emails will be sent out by whatever mail server you configure in php.ini, right?
Have you tried this on Windows under IIS?

yes... you need postfix or sendmail installed on the server where webserver is.
I haven't tried with IIS.... but I am sure it can be done.


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: christov84 on June 08, 2013, 08:21:40 AM
Nice work


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: servicelabs on June 16, 2013, 09:30:41 AM
monitoring_cron.php on line 48
postdrop: warning: unable to look up public/pickup: No such file or directory


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: servicelabs on June 16, 2013, 10:08:54 AM
I have done according to your guide, Thanks!
http://www.service-labs.com/miner_monitoring/


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: PSL on July 06, 2013, 12:35:53 AM
This patch adds these features to monitoring script 2.0:

- fix temperature when card is hot (cosmetic).
- display correct active pool (bug)
- display user (new)

Code:
$ git diff -p
diff --git a/index.php b/index.php
index 7587ad7..b5c8145 100644
--- a/index.php
+++ b/index.php
@@ -148,12 +148,13 @@ for ($i=0; $i<$nr_rigs; $i++)
 <?php
 
for ($i=0$i<$nr_rigs$i++)
 {
+        
$pool_priority 999;
        foreach (
$r[$i]['pools'] as $pool)
        {
-               if (
$pool['Stratum Active'] == 'true')
+               if ((
$pool['Status'] == 'Alive') and ($pool['Priority'] < $pool_priority))
                {
-                       
$pool_active '<span style="font-weight:normal">Pool ' $pool['POOL'] . ' - ' $pool['URL'] . '</span>';
-                       break;
+                        
$pool_priority $pool['Priority'];
+                       
$pool_active '<span style="font-weight:normal">Pool ' $pool['POOL'] . ' - ' $pool['URL'] . ', user - ' $pool['User'] . '</span>';
                }
        }
        
?>

@@ -187,7 +188,7 @@ for ($i=0; $i<$nr_rigs; $i++)
                                        <tr>
                                                <td style="text-align:center"><?php echo $gpu['GPU'?></td>
                                                <td style="text-align:center"><?php echo $gpu['Status'] == 'Alive' '<span class="ok">' $gpu['Status'] . '</span>' '<span class="error">' $gpu['Status'] . '</span>' ?></td>
-                                               <td style="text-align:center"><?php echo $gpu['Temperature'] > ALERT_TEMP '<span class="error">' round($gpu['Temperature']) . '°C</span>' round($gpu['Temperature']) ?>°C</td>
+                                               <td style="text-align:center"><?php echo $gpu['Temperature'] > ALERT_TEMP '<span class="error">' round($gpu['Temperature']) . '°C</span>' round($gpu['Temperature']) . '°C' ?></td>
                                                <td style="text-align:center"><?php echo $gpu['Fan Percent']?>%</td>
                                                <td style="text-align:center">
                                                        <?php


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on July 17, 2013, 07:22:09 AM
Thanks!
I've commited the changes.


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: grobbes on July 18, 2013, 02:17:57 PM
For some reason the degrees symbol wasn't registering right for me so I swapped it out with &deg; but was most likely due to my editor :)


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on July 18, 2013, 02:32:08 PM
Yes probably.
You should save the files using UTF8 without BOM encoding.


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: tuckertz1992 on July 22, 2013, 07:01:42 PM
I really can not get this to work....

http://tomsmining.yzi.me/test


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: PSL on July 26, 2013, 10:25:29 AM
I post a patch, that address an issue that wrong pool and user is displayed for miner that is offline:

Code:
$ git diff -p
diff --git a/index.php b/index.php
index 4ca2063..b4a031f 100644
--- a/index.php
+++ b/index.php
@@ -149,6 +149,7 @@ for ($i=0; $i<$nr_rigs; $i++)
 for ($i=0; $i<$nr_rigs; $i++)
 {
        $pool_priority = 999;
+       $pool_active = '';
        foreach ($r[$i]['pools'] as $pool)
        {
                if (($pool['Status'] == 'Alive') && ($pool['Priority'] < $pool_priority))


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: forum2005 on August 13, 2013, 05:10:13 PM
only GPU support ? and Icarus boards ?


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: gjpminingco on September 18, 2013, 02:49:15 AM
I am getting this Error

under the USB section

Warning: Division by zero in /home/a1628273/public_html/index.php on line 181

0 Alive 54°C 100% 0.00 | 0.00 0 0 0 0% 2013-09-17 22:36:28 Alive 0°C % 335.61 | 335.03 1 1 2 100% 2013-09-17 22:46:11


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on December 29, 2013, 09:48:19 AM
v2.1 Added ASC and PGA support


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on January 02, 2014, 01:53:40 PM
v2.1.1 Fixed some bugs


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: gjpminingco on January 02, 2014, 03:00:48 PM
Thanks


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: eleazar on January 03, 2014, 07:58:18 PM
Love this monitor. Thanks for making it!  :)


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: Gorets on January 07, 2014, 10:44:51 AM
Hi!
I set Email alert on my GPUfarm, but on every farm i have AMD APU, integrater chip userd for control/work, and i not mine on it, so i get error in email:
PROBLEM: Farm1 - G1 (0.00 MH/s) Home - G1 (0.00 MH/s) Office - G1 (0.00 MH/s) Work - G1 (0.00 MH/s) Farm2 - G1 (0.00 MH/s)
How i can fix it?


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: sikboy on January 20, 2014, 08:02:42 AM
any help to setup this at my domain through cPanel?

getting this error


FATAL: Cannot use Anubis_db ! SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on January 20, 2014, 08:38:30 AM
this is not the script problem but problem with your setup (cPanel or any other module) not able to connect to SQL database.


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: p4xil on January 20, 2014, 09:11:35 AM
I think you are on the wrong forum topic. This topic is about Simple Cgminer Script and not Anubis.
Anubis topic is here: https://bitcointalk.org/index.php?topic=57342.0


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: taxik on February 07, 2014, 08:53:02 PM
Hello,

i have cgminer 3.7.0 and this doesn't work for me. I have port open (i checked it via http://www.yougetsignal.com/tools/open-ports/)
and its open (4028). It says miner is offline :( Any suggestions?


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: abracadabra on February 07, 2014, 08:58:51 PM
Hello,

i have cgminer 3.7.0 and this doesn't work for me. I have port open (i checked it via http://www.yougetsignal.com/tools/open-ports/)
and its open (4028). It says miner is offline :( Any suggestions?

See "1. CONFIGURING CGMINER" in first post by OP


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: taxik on February 07, 2014, 09:06:40 PM
i already read it, cgminer configured fine, but it doesn't work


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: abracadabra on February 07, 2014, 09:57:53 PM
i already read it, cgminer configured fine, but it doesn't work

use the java API app that comes with cgminer to determine if cgminer is not setup correctly or if your port is not forwarded properly. 


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: taxik on February 07, 2014, 10:19:17 PM
Sorry, i don't know how to use java API with cgminer. I am noob

btw.: as i said port is forwared, so firewall is not blocking traffic, but where is problem?

//looks, my web hosting have denied UDP ports. Maybe, that's problem?


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: PSL on February 08, 2014, 11:09:11 AM
Sorry, i don't know how to use java API with cgminer. I am noob

Code:
cgminer$ ls -l API.class; java API coin localhost 4028
-rw-r--r-- 1 peon peon 3431 2013-05-27 16:56 API.class
Attempting to send 'coin' to 127.0.0.1:4028
Answer='STATUS=S,When=1391857634,Code=78,Msg=BFGMiner coin,Description=bfgminer 3.10.0|COIN,Hash Method=scrypt,Current Block Time=1391857600,Current Block Hash=fb246a37af09cb9c2cac0593375fd94752b81e72c591274b39870b1dc049b16d,LP=true,Network Difficulty=158.43854530|'
[STATUS] =>
(
   [STATUS] => S
   [When] => 1391857634
   [Code] => 78
   [Msg] => BFGMiner coin
   [Description] => bfgminer 3.10.0
)
[COIN] =>
(
   [0] => COIN
   [Hash Method] => scrypt
   [Current Block Time] => 1391857600
   [Current Block Hash] => fb246a37af09cb9c2cac0593375fd94752b81e72c591274b39870b1dc049b16d
   [LP] => true
   [Network Difficulty] => 158.43854530
)
[/code]


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: PSL on February 08, 2014, 11:54:10 AM
A patch to support miner that report 'MHS 20s'...
Code:
# git diff -p index.php
diff --git a/index.php b/index.php
index 2935bc7..4890627 100644
--- a/index.php
+++ b/index.php
@@ -217,7 +217,7 @@ for ($i=0; $i<$nr_rigs; $i++)
                                                <td style="text-align:center"><?php echo $dev['Fan Percent']?>%</td>
                                                <td style="text-align:center">
                                                        <?php
-                                                       $stats_second = isset ($dev['MHS 5s']) ? $dev['MHS 5s'] : (isset ($dev['MHS 2s']) ? $dev['MHS 2s'] : 0);
+                                                       
$stats_second = isset ($dev['MHS 20s']) ? $dev['MHS 20s'] : (isset ($dev['MHS 5s']) ? $dev['MHS 5s'] : (isset ($dev['MHS 2s']) ? $dev['MHS 2s'] : 0));
                                                        
$stats_second_string $r[$i]['coin']['COIN']['Hash Method'] == 'scrypt' $stats_second 1000 ' | ' $dev['MHS av'] * 1000 $stats_second ' | ' $dev['MHS av'];
                                                        
$stats_ratio 0;
                                                        if (
$dev['MHS av'] > 0)

A patch to address that several small USB devices don't have FAN and temperature sensor.
Code:
# git diff -p index.php
diff --git a/index.php b/index.php
index 2935bc7..5ca0d67 100644
--- a/index.php
+++ b/index.php
@@ -213,11 +213,11 @@ for ($i=0; $i<$nr_rigs; $i++)
                                                        ?>
                                                </td>
                                                <td style="text-align:center"><?php echo $dev['Status'] == 'Alive' '<span class="ok">' $dev['Status'] . '</span>' '<span class="error">' $dev['Status'] . '</span>' ?></td>
-                                               <td style="text-align:center"><?php echo $dev['Temperature'] > ALERT_TEMP '<span class="error">' round($dev['Temperature']) . '°C</span>' round($dev['Temperature']) . '°C' ?></td>
-                                               <td style="text-align:center"><?php echo $dev['Fan Percent']?>%</td>
+                                               <td style="text-align:center"><?php echo isset ($dev['Temperature']) ? ($dev['Temperature'] > ALERT_TEMP '<span class="error">' round($dev['Temperature']) . '°C</span>' round($dev['Temperature']) . '°C') : '-' ?></td>
+                                               <td style="text-align:center"><?php echo isset ($dev['Fan Percent']) ? $dev['Fan Percent'] . '%' '-' ?></td>
                                                <td style="text-align:center">


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: jdape on February 17, 2014, 04:12:44 AM
Thank you for the script.  I've been using it for a few months. 

Just sent you some LTC.


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: shawnp0wers on March 14, 2014, 02:27:53 PM
Hey Paxxil,

Just wanted to say thank you. I heavily, heavily modified your script, and quite honestly learned more about PHP along the way than I every thought I'd know. :) I'd offer up some of the changes, but I'm a total hack and wouldn't begin to know how to properly contribute.

That said, one of the things I've done is to create a static html page with cURL every couple minutes, and point my browser to it. The load time is instant, and I haven't found a downside yet.

So thank you again for a great script, and a great lesson, even if the latter wasn't your intent. :)


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: sapstar on March 17, 2014, 02:12:07 PM
Hi Paxxil, Thanks very much for creating the monitoring script. I just started using it today. It would be helpful if you can add the WU values for each GPU. Would it be possible to make to add this?


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: tanil on March 21, 2014, 09:20:41 PM
I prefer multiminer. It is better


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: 9600 on June 20, 2014, 05:42:46 AM
Anyone know why I might be getting 0MH in the summary portion of the index page? I'm getting API data from Antminer S1s and I know the API is shoddy at best with these, but I'm curious because the detailed hashrate is still present.

https://i.imgur.com/Lljknmq.png


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: dusca on January 17, 2016, 02:15:14 PM
Hello

Where I can put user and passw?

Dyndns option?


Title: Re: Simple Cgminer Remote Monitoring Script - now with email alerts
Post by: wedgy2k on February 14, 2016, 03:28:27 PM
I appreciate this is old but I'd like to say thanks
Works a treat with Sgminer - gives me the minimumn info I want to see on my smartphone

Cheers