You are not logged in.

#1 2016-05-29 09:15:34

sato
Member
From: France
Registered: 2016-05-29
Posts: 14

Show my web server on conky

Hi all,

I have two web server for my business, and i want to know if it's possible to show:

- Disk Space of my web server on conky
- And a ping solution (If the webserver responds to the ping: The server is UP, and if the server dont responds to the ping: The server have a problem.

I have a ssh access on both server.

I'm a beginner on conky, have u an idea for my project ?

Thx.

Offline

#2 2016-05-29 09:31:32

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Show my web server on conky

I am no expert on conky either, but I think it is possible to do that if you can connect to the servers without having to enter a password.

'Sector11' is our conky man.
I am sure he will be able to give you all  the details.

Offline

#3 2016-05-29 15:38:37

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Show my web server on conky

Well, I've never had a webserver so this is just brainstorming.

@sato

Can you cd to your server(s)?

If yes, then you can use ${if_existing} - conky says it's for files - but Linux says directories are files.

Here's an example.

On my partition mounted at /media/5 I have a file CRIBBAGE.TXT
sooooooooooo option 1 fails the test and options 2 & 3 pass as well as option 4 as I have my external disk plugged in:

The server is: ${if_existing /media/5/CRIBBAGE.txt}UP${else}DOWN${endif}
The server is: ${if_existing /media/5/CRIBBAGE.TXT}UP${else}DOWN${endif}
The server is: ${if_existing /media/5/}UP${else}DOWN${endif}

The 'disk' is: ${if_existing /media/sector11/disk/}${else}Not ${endif}Connected

2016_05_29_12_19_18_Scrot11.jpg

I unmount my ext HDD (same as option 1 where "CRIBBAGE.txt" doesn't exist) and see:
2016_05_29_12_19_44_Scrot11.jpg

If you can get that working we have a place to start.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#4 2016-05-29 15:55:12

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Show my web server on conky

UPDATE:  I have this ... triple line if not up/connected to "maintain" the same height conky uses.
2016_05_29_12_51_38_Scrot11.jpg2016_05_29_12_52_16_Scrot11.jpg

${alignc}${color7}Web Server: Disk${color}\
${if_existing /media/sector11/disk/}
${alignc}Size: ${fs_size /media/sector11/disk/}
Used: ${fs_used /media/sector11/disk/}${alignr}Free: ${fs_free /media/sector11/disk/}
${fs_bar /media/sector11/disk/}${else}
${color9}${alignc}Is
${alignc}Not
${alignc}UP${color}${endif}

Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#5 2016-05-29 16:17:00

sato
Member
From: France
Registered: 2016-05-29
Posts: 14

Re: Show my web server on conky

Ok,

Thx for this, but you mean if my webserver can CD, if i have understand, i mount my webserver in the same way to ma flash disk.

If i create a php file contain a script, conky can use this ?

Offline

#6 2016-05-29 17:03:55

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Show my web server on conky

Can you "cd" to your server and cd to it without having to enter a password as xaos50 mentioned.

The same way you would cd to any directory on your system?
- If yes, then you do not need another file you can use conky directly as shown just change the "cd /path/to/here/".

Not knowing what a php file is, I cannot answer that.  Sorry.

Hmmmmmmmm looking at the OP (Opening Post) I see: ssh
and so went searching: Why does `cd` command not work via SSH? which means I may be wrong about the whole thing.  sad


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#7 2016-05-29 17:07:30

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,641

Re: Show my web server on conky

Hello friends,
I have no idea...

But what is this?  hmm   conky webserver access log

Offline

#8 2016-05-29 20:34:14

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Show my web server on conky

^ A conky to read the logs of an nginx server.  Interesting.  Don't see any 'password' controls in there either.

The interesting part:

cat /srv/http/var/log/nginx/access.log


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#9 2016-05-29 22:47:21

Eraph
Member
From: /au/qld/bne
Registered: 2016-02-29
Posts: 282
Website

Re: Show my web server on conky

I don't know so much about the scripting side of things, but I'm going to throw some ideas into the soup and see if someone can brew them together. Let's say sato has a file on their server that they can target, is there a script that Conky could run to determine if it is responding or not? Check the response header for a 200 (OK) or otherwise.

A quick look suggests that curl might be able to do that.


Lenovo IdeaPad Yoga 13 | BunsenLabs Hydrogen (x64)
Intel Core i7-3537U | Intel HD4000 | 8GB DDR3 | 256GB SSD

Offline

#10 2016-05-30 01:25:31

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,552
Website

Re: Show my web server on conky

Another stone for the soup...

Have the server run a cron job at regular intervals to get the disk space (or any other system information you want) and put the results in a file, still on the server. This would have the disadvantage that the general public might be able to read the file too, unless you password-protect it, but it should then be quite easy for your local computer to ask the server for that file and display its contents with conky.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#11 2016-05-30 10:08:22

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Show my web server on conky

Alternative:
install package 'sshfs' and mount the server filesystem locally.
This would allow you to cd into any  directory on the server, and Sector11 can guide you through the rest.

Proviso: I don't have any server running for myself either. So can not test this myself.

Offline

#12 2016-05-30 12:10:06

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,737

Re: Show my web server on conky

Or a php script on server (disk.php), like

<?php
echo passthru('df -hT /var/www');
?>

or http://php.net/manual/en/function.disk-free-space.php
and then just wget that somehow onto conky (some sort of "execi wget url" I guess).

p.s. This seems to be working on conky side

${execi 60 curl http://172.17.6.17/disk.php}

p.s.2. One could also use .htaccess style of dir protection and curl.

Last edited by brontosaurusrex (2016-05-30 13:04:09)

Offline

#13 2016-05-30 12:55:32

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,008

Re: Show my web server on conky

Thoughts - since I'm not sure how web servers work

If the server is online and not mounted the code I gave above in conky will give a false 'fail'
If the server is not online but is mounted the code above will give a false 'positive'

The curl - wget ideas are excellent, have a script that checks the online status.
- if the server is up create an empty file on the local HDD ie: server1-up or server2-up
- if the server is down check for server1-up and if existing remove it.

That should do it.

@brontosaurusrex - what is the output of ${execi 60 curl http://172.17.6.17/disk.php} on your system?


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#14 2016-05-30 13:00:02

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,737

Re: Show my web server on conky

@Sector11

The output of that php script I posted, which is exactly(?) the same as output of "df -hT /var/www".
Just an example, one would probably want something prettier i imagine.

Last edited by brontosaurusrex (2016-05-30 13:02:24)

Offline

#15 2016-05-30 13:44:02

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Show my web server on conky

If you go the curl way, make sure to specify a sufficiently low --connect-time-out or curl may hang for a long time when the network is down or the server is overloaded - which I suppose will hang conky as well, waiting for the response.

Offline

#16 2016-05-30 13:52:35

sato
Member
From: France
Registered: 2016-05-29
Posts: 14

Re: Show my web server on conky

brontosaurusrex wrote:

Or a php script on server (disk.php), like

<?php
echo passthru('df -hT /var/www');
?>

or http://php.net/manual/en/function.disk-free-space.php
and then just wget that somehow onto conky (some sort of "execi wget url" I guess).

p.s. This seems to be working on conky side

${execi 60 curl http://172.17.6.17/disk.php}

p.s.2. One could also use .htaccess style of dir protection and curl.

This the result, not bad, i try on conky.

https://www.thomasmayet.fr/space.php

UPDATE:

Its seems to be not work, screen:

http://www.plixup.com/pics_core3/146461 … 1conky.png

My conky:

http://pastebin.com/Prhh8NvM

Last edited by sato (2016-05-30 13:59:53)

Offline

#17 2016-05-30 14:06:41

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,737

Re: Show my web server on conky

@sato: double dollar sign on line 155.

Offline

#18 2016-05-30 14:17:07

sato
Member
From: France
Registered: 2016-05-29
Posts: 14

Re: Show my web server on conky

brontosaurusrex wrote:

@sato: double dollar sign on line 155.

Thinks, but have an other problem, i think its due to my https:

http://www.plixup.com/pics_core3/146461 … conky2.png

Offline

#19 2016-05-30 14:19:45

nobody
The Great
Registered: 2015-08-10
Posts: 3,655

Re: Show my web server on conky

sato wrote:
brontosaurusrex wrote:

@sato: double dollar sign on line 155.

Thinks, but have an other problem, i think its due to my https:

http://www.plixup.com/pics_core3/146461 … conky2.png

Specify the -L switch to follow redirects.

Offline

#20 2016-05-30 14:22:27

sato
Member
From: France
Registered: 2016-05-29
Posts: 14

Re: Show my web server on conky

twoion wrote:
sato wrote:
brontosaurusrex wrote:

@sato: double dollar sign on line 155.

Thinks, but have an other problem, i think its due to my https:

http://www.plixup.com/pics_core3/146461 … conky2.png

Specify the -L switch to follow redirects.

Where i put this in the line ?

Offline

Board footer

Powered by FluxBB