Author

Topic: Simple Cgminer Remote Monitoring Script - now with email alerts (Read 31861 times)

sr. member
Activity: 329
Merit: 251
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
full member
Activity: 141
Merit: 100
Hello

Where I can put user and passw?

Dyndns option?
full member
Activity: 207
Merit: 112
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.

full member
Activity: 136
Merit: 100
I prefer multiminer. It is better
newbie
Activity: 58
Merit: 0
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?
newbie
Activity: 19
Merit: 0
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. Smiley 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. Smiley
sr. member
Activity: 269
Merit: 250
Thank you for the script.  I've been using it for a few months. 

Just sent you some LTC.
PSL
member
Activity: 166
Merit: 10
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++)
                                                echo $dev['Fan Percent']?>%
                                                
                                                        -                                                       $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++)
                                                        ?>
                                               
                                                echo $dev['Status'] == 'Alive' '$dev['Status'] . ''$dev['Status'] . '?>
-                                               echo $dev['Temperature'] > ALERT_TEMP 'round($dev['Temperature']) . '°Cround($dev['Temperature']) . '°C' ?>
-                                               echo $dev['Fan Percent']?>%
+                                               echo isset ($dev['Temperature']) ? ($dev['Temperature'] > ALERT_TEMP 'round($dev['Temperature']) . '°Cround($dev['Temperature']) . '°C') : '-' ?>
+                                               echo isset ($dev['Fan Percent']) ? $dev['Fan Percent'] . '%' '-' ?>
                                               
PSL
member
Activity: 166
Merit: 10
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]
newbie
Activity: 45
Merit: 0
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?
hero member
Activity: 956
Merit: 1001
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. 
newbie
Activity: 45
Merit: 0
i already read it, cgminer configured fine, but it doesn't work
hero member
Activity: 956
Merit: 1001
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 Sad Any suggestions?

See "1. CONFIGURING CGMINER" in first post by OP
newbie
Activity: 45
Merit: 0
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 Sad Any suggestions?
full member
Activity: 214
Merit: 100
I think you are on the wrong forum topic. This topic is about Simple Cgminer Script and not Anubis.
Anubis topic is here: https://bitcointalksearch.org/topic/anubis-a-cgminer-web-frontend-57342
full member
Activity: 214
Merit: 100
this is not the script problem but problem with your setup (cPanel or any other module) not able to connect to SQL database.
newbie
Activity: 42
Merit: 0
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)
newbie
Activity: 57
Merit: 0
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?
newbie
Activity: 15
Merit: 0
Love this monitor. Thanks for making it!  Smiley
sr. member
Activity: 350
Merit: 250
Co-Owner Of DCMCo-Op Mining Farm at 3.5 th/s
full member
Activity: 214
Merit: 100
v2.1.1 Fixed some bugs
full member
Activity: 214
Merit: 100
v2.1 Added ASC and PGA support
sr. member
Activity: 350
Merit: 250
Co-Owner Of DCMCo-Op Mining Farm at 3.5 th/s
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
full member
Activity: 127
Merit: 100
only GPU support ? and Icarus boards ?
PSL
member
Activity: 166
Merit: 10
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))
full member
Activity: 155
Merit: 100
I really can not get this to work....

http://tomsmining.yzi.me/test
full member
Activity: 214
Merit: 100
Yes probably.
You should save the files using UTF8 without BOM encoding.
member
Activity: 60
Merit: 10
For some reason the degrees symbol wasn't registering right for me so I swapped it out with ° but was most likely due to my editor Smiley
full member
Activity: 214
Merit: 100
Thanks!
I've commited the changes.
PSL
member
Activity: 166
Merit: 10
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++)
  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 'Pool ' $pool['POOL'] . ' - ' $pool['URL'] . ''
;
-                       break;
+                        
$pool_priority $pool['Priority'];
+                       
$pool_active 'Pool ' $pool['POOL'] . ' - ' $pool['URL'] . ', user - ' $pool['User'] . '';
                }
        }
        
?>
@@ -187,7 +188,7 @@ for ($i=0; $i<$nr_rigs; $i++)
                                        
                                                echo $gpu['GPU'?>
                                                echo $gpu['Status'] == 'Alive' '$gpu['Status'] . ''$gpu['Status'] . '?>

-                                               echo $gpu['Temperature'] > ALERT_TEMP 'round($gpu['Temperature']) . '°Cround($gpu['Temperature']) ?>°C
+                                               echo $gpu['Temperature'] > ALERT_TEMP 'round($gpu['Temperature']) . '°Cround($gpu['Temperature']) . '°C' ?>
                                                echo $gpu['Fan Percent']?>%
                                                
                                                        
legendary
Activity: 1064
Merit: 1001
itkylin.com
legendary
Activity: 1064
Merit: 1001
itkylin.com
monitoring_cron.php on line 48
postdrop: warning: unable to look up public/pickup: No such file or directory
newbie
Activity: 16
Merit: 0
full member
Activity: 214
Merit: 100
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.
legendary
Activity: 2688
Merit: 1468
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?
full member
Activity: 214
Merit: 100
I have added EMAIL ALERTS support.
full member
Activity: 214
Merit: 100
you can change port to default in port section, but it won't work if you set same port for all miners.
sr. member
Activity: 319
Merit: 250
Any chance this can be modified to use the default port of 4028 for all miners?
full member
Activity: 214
Merit: 100
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.
vip
Activity: 756
Merit: 503
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/
legendary
Activity: 2688
Merit: 1468
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.
full member
Activity: 137
Merit: 100
Getting an error from the index file, fails to operate at all.
full member
Activity: 214
Merit: 100
SIMPLE CGMINER REMOTE MONITORING SCRIPT NOW WITH ALERTS



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



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.


on linux run command:
Code:
ifconfig

Look at "inet addr:"  of your network adapter.


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

Jump to: