What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

SSH script with pfsense for temperature monitor

Votes:

0

Hello,

I have tried to monitor the pfsense's temperature throguh SNMP but it seems that pfsense doesn't send any information about it. So I have made a script that works on console. I have put it in

/var/prtg/scripts/

the name of script is cputemp and it is the below :

#!/bin/sh
sysctl -n dev.cpu.0.temperature |tr -d C

so when I type ./cputemp on console I get the cpu tempereature like this

45.0

Then, in PRTG devices I add ssh script sensor, I set pfsense's credentials, they are right because I see incoming ssh session in pfsense's log but in the next page at "Sensor Settings->Sctipt" I get the following message:

Warning, no access to tty, (Bad file descriptor).

And I am stuck and don't know what to do, probably it is a stupid problem, don't know.

pfsense prtg script ssh temperature

Created on Sep 28, 2017 8:45:57 AM

Last change on Sep 28, 2017 3:57:53 PM by  Felix Saure [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

I fixed it! I figured out why it was not working, the ssh user must have root rights, and not only admin rights.

Created on Sep 28, 2017 6:52:05 PM



7 Replies

Votes:

0

Hi Bitter,

Could you please forward the script as well as the output after activating the "Write Results to Disk Option" in the settings of the sensor. Thanks!

Best regards, Felix

Created on Sep 28, 2017 4:01:45 PM by  Felix Saure [Paessler Support]



Votes:

0

Hi, thanks for reply. I have 3 different file of output, the big one is the following:

Data['CheckFlavor'].asString := '';
Data['DoNotCheckShell'].asString := '';
Data['UsedSha2'].asString := '1';
Data['blockedsens'].asString := '';
Data['canlinux'].asString := '0';
Data['channel'].asString := 'Value';
Data['channelinfos'].asString := '{"1":{"Unit":"oukTimeResponse","CustomUnit":"","ValueLookupName":"","LimitMode":"0","LimitMinError":"","LimitMinWarning":"","LimitMaxError":"","LimitMaxWarning":""}}';
Data['channelnames'].asString := 'Execution Time'#$D#$A + 
'1'#$D#$A + 
'';
Data['command'].asString := '/var/prtg/scripts/Warning: no access to tty (Bad file descriptor). ';
Data['deviceid'].asString := '2041';
Data['elevation'].asString := '0';
Data['elevationkind'].asString := '';
Data['elevationname'].asString := '';
Data['elevationpass'].asString := '';
Data['fastcount'].asString := '0';
Data['host'].asString := '192.168.178.2';
Data['hostv6'].asString := '';
Data['inerror'].asString := '1';
Data['ipversion'].asString := '0';
Data['isexesensor'].asString := '0';
Data['lastmsg'].asString := '#O132 Warning: no access to tty (Bad file descriptor). Thus no job control in this shell. ';
Data['lastuptime'].asString := '0';
Data['monitorchange'].asString := '0';
Data['mutexname'].asString := '';
Data['notonpod'].asString := '0';
Data['password'].asString := '***';
Data['port'].asString := '22';
Data['privatekey'].asString := '***';
Data['reboot'].asString := '43005.7228721412';
Data['reqmsginterval'].asString := '60';
Data['resultfile'].asString := 'Result of Sensor 2095.txt';
Data['scriptfile'].asString := 'Warning: no access to tty (Bad file descriptor).';
Data['scriptparams'].asString := '';
Data['sensorid'].asString := '2095';
Data['shelltimeout'].asString := '10';
Data['simulate'].asString := '0';
Data['ssh_linuxshell'].asString := '$SHELL = /bin/tcsh
13302  -  Ss   0:00.01 -tcsh (tcsh)

';
Data['sshencoding'].asString := '1';
Data['sshversion_devicegroup'].asString := '2';
Data['sshversion_sensor'].asString := '0';
Data['timeout'].asString := '60';
Data['tlsexplicit_default'].asString := '';
Data['tlsexplicit_ftp'].asString := '';
Data['tlsexplicit_imap'].asString := '';
Data['tlsexplicit_pop3'].asString := '';
Data['tlsexplicit_port'].asString := '';
Data['tlsexplicit_smtp'].asString := '';
Data['unit'].asString := '#';
Data['uptimecount'].asString := '0';
Data['usednstime'].asString := '0';
Data['user'].asString := 'prtg';
Data['valuetype'].asString := '1';
Data['writeresult'].asString := '1';

Created on Sep 28, 2017 5:30:21 PM

Last change on Jan 15, 2018 9:58:42 AM by  Felix Saure [Paessler Support]



Votes:

0

I have read that the output of the script must be returncode:value:message

so I have edited my script as following echo 0:`sysctl -n dev.cpu.0.temperature | tr -d C`:Grad that returns: 0:45.0:Grad

But the error message is always the same.

Created on Sep 28, 2017 6:24:14 PM



Accepted Answer

Votes:

0

I fixed it! I figured out why it was not working, the ssh user must have root rights, and not only admin rights.

Created on Sep 28, 2017 6:52:05 PM



Votes:

0

Hey bitter,

Thanks for sharing your solution! I'm sure that this will help other customers in the future! Have a good day!

Best, Felix

Created on Sep 28, 2017 7:14:43 PM by  Felix Saure [Paessler Support]



Votes:

0

How did you assign the rights? I'm getting the same error. I think its something to do with the shell presented when logging in to pfsense.

Created on Jan 14, 2018 3:13:32 PM



Votes:

0

Hi Matt,

Did you already try using the root user to see if it works then?

Best regards, Felix

Created on Jan 15, 2018 10:01:00 AM by  Felix Saure [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.