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.


Article Comments

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


Sep, 2017 - Permalink

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';

Sep, 2017 - Permalink

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.


Sep, 2017 - Permalink

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


Sep, 2017 - Permalink

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


Sep, 2017 - Permalink

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.


Jan, 2018 - Permalink

Hi Matt,

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

Best regards, Felix


Jan, 2018 - Permalink